import{c as ae,b as Ne,e as fn,o as J,F as vt,f as pt,t as nt,a as se,g as yt,L as Wi,h as it,d as Tt,C as Yr,K as qo,w as er,B as K0,n as no,r as Si,j as Rm,v as J0,E as ex,A as tx,i as nx}from"./vue.esm-bundler-ClpepJn5.js";import{c as ix,a as ri,m as oi}from"./vuex.esm-bundler-BR9taj6_.js";import{_ as lt}from"./lodash-qUBZfgSu.js";import"./axios-DfDhhHc2.js";import{a as vi}from"./axios-DpTMJf8O.js";import{T as Wt}from"./index-DS-NXSZL.js";import{g as uf}from"./getRandomInt-Fh-OFTG8.js";import{_ as mt}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{L as sx}from"./LoadingIndicator-D1oZcZI1.js";import{L as rx,A as ox}from"./Attachment-OWVPjher.js";import{_ as ca}from"./core-BrMIa0al.js";import{b as ax}from"./baseUrl-NH_W-SvB.js";import{t as lx}from"./tippy.esm-C-c050lq.js";import{T as cx}from"./tooltips-C9HTwLqv.js";import{b as Pm,t as hx}from"./trackAdClicks-DavCVIir.js";import{v as Lm}from"./viewportDimensions-Ducgdxtn.js";import{v as Dm}from"./validationErrors-CWG8CjTK.js";import{o as ux}from"./optional-C8cdIxsm.js";import"./_commonjsHelpers-BosuxZz1.js";import"./popper-CvwSYPO-.js";const Im=()=>({quiz:{adZoneId:!1,list:[]},result:{adZoneId:!1,list:[]}}),dx=Im(),fx={resetAds(n){lt.assign(n,Im())},adZoneId(n,e){lt.has(n,e.area)&&(n[e.area].adZoneId=e.id)},ads(n,e){if(lt.has(n,e.area)){let t;lt.has(e.ads,"list")?t=e.ads.list:t=[e.ads.item],n[e.area].list=t}}},px={hasQuizAd:n=>!!n.quiz.list.length},mx={fetchQuizAds({commit:n,getters:e},t){vi.get(e.quizModeAdUrl).then(i=>{n("adZoneId",{id:i.data.id,area:"quiz"}),n("ads",{ads:i.data,area:"quiz"})})},fetchResultAds({commit:n,getters:e}){vi.get(e.quizResultAdsUrl).then(t=>{n("adZoneId",{id:t.data.id,area:"result"}),n("ads",{ads:t.data,area:"result"})})}},_x={state:dx,mutations:fx,getters:px,actions:mx},gx={origin:"",foxTest:!1,url:!1,isLoading:!1,slug:"",exhibition:null,exhibitionInfoQuestions:{companyId:null,questions:[]},userGroupHash:"",userGroupName:null,error:{},notices:[]},vx={loading(n){n.isLoading=!0},clearLoading(n){n.isLoading=!1},error(n,e){n.error={data:e.data,status:e.status,statusText:e.statusText}},clearError(n){n.error={}},origin(n,e){n.origin=e},foxTest(n,e){n.foxTest=e},url(n,e){n.url=e},slug(n,e){n.slug=e},exhibition(n,e){n.exhibition=e},exhibitionInfoQuestions(n,e){n.exhibitionInfoQuestions=e},userGroupHash(n,e){n.userGroupHash=e},userGroupName(n,e){n.userGroupName=e},notices(n,e){n.notices=lt.unionBy(e,n.notices,"name")}},xx={routePrefix:n=>n.origin.length?`${n.origin}.`:"",quizDataUrl:(n,e)=>{let t;return e.isExhibitionQuiz?t=Wt("playmit.json.portal.exhibition-quiz.data",[n.exhibition.slug,n.slug]):n.origin==="fox"?t=Wt("fox.json.portal.quiz.data",[n.slug,n.userGroupHash]):t=Wt("playmit.json.portal.quiz.data",n.slug),t},questionViewingUrl:(n,e)=>t=>e.isExhibitionQuiz?Wt("playmit.portal.quiz-mode.exhibition.viewing",[n.exhibition.slug,t]):Wt(`${e.routePrefix}portal.quiz-mode.viewing`,t),questionAnswerUrl:(n,e)=>t=>e.isExhibitionQuiz?Wt("playmit.portal.quiz-mode.exhibition.answered",[n.exhibition.slug,t]):Wt(`${e.routePrefix}portal.quiz-mode.answered`,t),quizResultUrl:(n,e)=>t=>e.isExhibitionQuiz?Wt("playmit.json.portal.exhibition-quiz.result",[n.exhibition.slug,t]):Wt(`${e.routePrefix}json.portal.quiz.result`,t),quizAbortUrl:(n,e)=>t=>e.isExhibitionQuiz?Wt("playmit.portal.quiz-mode.exhibition.abort",[n.exhibition.slug,t]):Wt(`${e.routePrefix}portal.quiz-mode.abort`,t),rankingUrl:(n,e)=>Wt(`${e.routePrefix}json.portal.quiz.result.user-ranking`),furtherLinksUrl:(n,e)=>Wt(`${e.routePrefix}json.portal.quiz.result.further-links`),quizModeAdUrl:(n,e)=>e.isExhibitionQuiz?Wt("playmit.json.portal.exhibition-quiz.ad",[n.exhibition.slug,n.slug]):Wt(`${e.routePrefix}json.portal.quiz.ad`,n.slug),quizResultAdsUrl:(n,e)=>Wt(`${e.routePrefix}json.portal.quiz.result.ad-zone`),shouldTrack:n=>n.origin==="playmit",isPlaymitQuiz:n=>n.origin==="playmit",isExhibitionQuiz:n=>n.origin==="playmit"&&n.exhibition!==null,isFoxQuiz:n=>n.origin==="fox",isFoxTest:n=>n.foxTest},Mx={resetQuiz({state:n,commit:e,getters:t,dispatch:i}){e("resetGameRound"),e("resetResult"),i("loadGameRound",{reset:!0}),t.isPlaymitQuiz&&(e("resetAds"),i("fetchQuizAds",n.slug))}},Ex={state:gx,mutations:vx,getters:xx,actions:Mx},yx=({url:n,payload:e,successCb:t,errorCb:i},s)=>{vi.post(n,e).then(r=>{t(r)}).catch(r=>{i(r)}).then(()=>{s.callback()})},df=new class{constructor(n){this.queue=[],this.handler=n}append(n){this.queue.push(n),this.queue.length===1&&this.run()}run(){this.handler(this.queue[0],this)}callback(){this.queue.shift(),this.queue.length>0&&this.run()}}(yx),wh={buildWrongQuestions:(n,e)=>{const t=[];return Object.keys(e).forEach(i=>{t.push({question:n.question(i),answers:e[i]})}),t},buildArrayWithAnsweredQuestions:n=>{const e=[];return n.forEach(t=>{t.status==="answered"&&e.push(t.hash)}),e},getQuestionsToCheck:n=>{if(!n.length||!window.recaptchaKey)return[];if(n.length<=2){const s=[];return n.forEach(r=>{s.push(r.hash)}),s}const e=Math.floor(n.length/2),t=n[uf(0,e-1)],i=n[uf(e,n.length-1)];return[t.hash,i.hash]}},Um=()=>({hash:null,answeredQuestions:[],answersResponded:[],user:null,guest:!1,quizzes:[],currentQuizIndex:0,viewingsResponded:[],questionsToCheck:[],questionsChecked:[],points:{possible:0,exceptions:[],earned:0}}),Sx=Um(),bx={resetGameRound(n){lt.assign(n,Um())},setHash(n,e){n.hash=e},setAnsweredQuestions(n,e){n.answeredQuestions=e},addAnsweredQuestion(n,e){n.answeredQuestions.push(e)},setViewingsResponded(n,e=[]){e.length&&(n.viewingsResponded=lt.union(n.viewingsResponded,e))},addViewingResponded(n,e){lt.find(n.viewingsResponded,i=>e===i)||n.viewingsResponded.push(e)},setAnswersResponded(n,e=[]){e.length&&(n.answersResponded=e)},addAnswerResponded(n,e){lt.find(n.answersResponded,i=>e===i)||n.answersResponded.push(e)},user(n,e){n.user=e},guest(n,e){n.guest=e},points(n,e){n.points=e},quizzes(n,e){n.quizzes=e},nextQuiz(n){n.currentQuizIndex=n.currentQuizIndex<n.quizzes.length-1?n.currentQuizIndex+1:n.currentQuizIndex},questionsToCheck(n,e){n.questionsToCheck=e},addQuestionChecked(n,e){n.questionsChecked.push(e)}},wx={currentQuiz:n=>n.quizzes.length?n.quizzes[n.currentQuizIndex]:{},isCharacteristicQuiz:(n,e)=>e.currentQuiz.type==="eigenschaften",questions:n=>{const e=[];return n.quizzes.forEach(t=>{e.push(t.questions)}),lt.flatten(e)},questionsNumber:(n,e)=>e.questions.length,question:(n,e)=>t=>e.questionsNumber?e.questions[t]:{},currentQuestion:(n,e)=>e.question(n.answeredQuestions.length),currentQuestionShouldBeChecked:(n,e)=>e.currentQuestion?lt.findIndex(n.questionsToCheck,i=>i===e.currentQuestion.hash)>-1:!1,allQuestionsChecked:n=>n.questionsToCheck.length===n.questionsChecked.length,isLastQuestion:(n,e)=>e.questionsNumber-e.answeredQuestionsNumber===1,isLastQuestionInCurrentQuiz:(n,e)=>e.currentQuestion&&!lt.isEmpty(e.currentQuiz)?lt.findIndex(e.currentQuiz.questions,{hash:e.currentQuestion.hash})===e.currentQuiz.questions.length-1:!1,answeredQuestionsNumber:n=>n.answeredQuestions.length,currentQuestionNumber:(n,e)=>e.answeredQuestionsNumber<e.questionsNumber?e.answeredQuestionsNumber+1:e.answeredQuestionsNumber,unansweredQuestions:(n,e)=>lt.filter(e.questions,t=>!lt.find(n.answeredQuestions,i=>t.hash===i)),unansweredQuestionsNumber:(n,e)=>e.unansweredQuestions.length,allViewingsResponded:(n,e)=>n.viewingsResponded.length===e.questionsNumber,allAnswersResponded:(n,e)=>n.answersResponded.length===e.questionsNumber,allViewingsAndAnswersResponded:(n,e)=>e.allViewingsResponded&&e.allAnswersResponded,questionsFilteredFromRemember:(n,e)=>lt.filter(e.questions,t=>t.type!=="remember"),rememberQuestionsSeen:(n,e)=>{if(!e.questions.length)return 0;let t=0;for(let i=0;i<e.currentQuestionNumber;i+=1)e.questions[i].type==="remember"&&(t+=1);return t}},Tx={loadGameRound({state:n,commit:e,getters:t,dispatch:i},{reset:s}){e("loading"),vi.post(t.quizDataUrl).then(r=>{e("setHash",r.data.hash),e("user",r.data.user),e("guest",r.data.guest),e("quizzes",r.data.quizzes);const o=wh.buildArrayWithAnsweredQuestions(t.questions);e("setAnsweredQuestions",o),e("setViewingsResponded",o),e("setAnswersResponded",o),e("questionsToCheck",wh.getQuestionsToCheck(t.unansweredQuestions)),e("notices",r.data.notices),e("points",r.data.points),e("clearError"),i("prepopulateIntrosSeen"),s===!0&&i("handleIntroSeen",n.currentQuizIndex)}).catch(r=>{e("error",r.response)}).then(()=>{e("clearLoading")})},submitViewing({commit:n,getters:e},{hash:t}){const i={url:e.questionViewingUrl(t),payload:{},successCb:s=>{n("addViewingResponded",t)},errorCb:s=>{n("error",s.response)}};df.append(i)},submitAnswer({commit:n,getters:e,dispatch:t},i={}){const{isLastQuestionInCurrentQuiz:s,isLastQuestion:r}=e;r?n("loading"):s&&n("nextQuiz");const o={url:e.questionAnswerUrl(i.questionHash),payload:i,successCb:a=>{n("addAnswerResponded",i.questionHash),r&&t("waitForLastCheckAndFetchResult")},errorCb:a=>{n("error",a.response)}};df.append(o),n("addAnsweredQuestion",i.questionHash)},executeRecaptcha({state:n,commit:e},{hash:t,action:i}){window.recaptchaKey&&grecaptcha.execute(window.recaptchaKey,{action:i}).then(s=>{vi.post(Wt("playmit.portal.recaptcha.verify-for-gameround"),{token:s,hash:n.hash}).then(r=>{e("addQuestionChecked",t)})})},waitForLastCheckAndFetchResult({state:n,getters:e,dispatch:t}){if(e.allQuestionsChecked)t("fetchResult",{hash:n.hash});else{const i=setInterval(()=>{e.allQuestionsChecked&&(t("fetchResult",{hash:n.hash}),clearInterval(i))},100)}}},Ax={state:Sx,mutations:bx,getters:wx,actions:Tx},Ca=window.localStorage,gc={storeIntroSeen:(n,e,t)=>{if(!n||!e||!t)return;let i=Ca.getItem(n);i?i=JSON.parse(i):i={},i[e]=t,Ca.setItem(n,JSON.stringify(i))},getIntrosSeen:(n,e)=>{if(n&&e){let t=Ca.getItem(n);return t&&(t=JSON.parse(t),t[e])?t[e]:null}return null},clear:n=>{n&&Ca.removeItem(n)}},Cx={introsSeen:[]},Rx={setIntrosSeen(n,e){n.introsSeen=e},addIntroSeen(n,e){n.introsSeen.indexOf(e)===-1&&n.introsSeen.push(e)},removeIntroSeen(n,e){const t=n.introsSeen.indexOf(e);t>-1&&n.introsSeen.splice(t,1)}},Px={introSeen:n=>e=>n.introsSeen.indexOf(e)>-1,currentQuizIntro:(n,e,t,i)=>i.currentQuiz.intro,currentQuizIntroSeen:(n,e,t)=>e.introSeen(t.gameRound.currentQuizIndex)},Lx={prepopulateIntrosSeen({commit:n,rootState:e}){const t=gc.getIntrosSeen(e.gameRound.user,e.gameRound.hash);t?n("setIntrosSeen",t):gc.clear(e.gameRound.user)},handleIntroSeen({state:n,commit:e,rootState:t},i){e("addIntroSeen",i),gc.storeIntroSeen(t.gameRound.user,t.gameRound.hash,n.introsSeen)}},Dx={state:Cx,mutations:Rx,getters:Px,actions:Lx},Nm=()=>({hasResult:!1,answersStatus:{},currentWrongQuestionNumber:0,points:{possible:0,requiredCorrectAnswers:0,exceptions:[],earned:0},furtherLinks:[],ranking:{},username:"",wrongQuestions:[]}),Ix=Nm(),Ux={resetResult(n){lt.assign(n,Nm())},setHasResult(n,e){n.hasResult=e},answersStatus(n,e){n.answersStatus=e.answersStatus},resultPoints(n,e){n.points=e.points},username(n,e){n.username=e.username},setWrongQuestions(n,e){n.wrongQuestions=e},setCurrentWrongQuestionNumber(n,e=!1){n.currentWrongQuestionNumber=e===!1?n.currentWrongQuestionNumber+1:e},ranking(n,e){n.ranking=e},furtherLinks(n,e){n.furtherLinks=e}},Nx={wrongQuestionsNumber:n=>n.wrongQuestions.length,currentWrongQuestion:(n,e)=>e.wrongQuestionsNumber?n.wrongQuestions[n.currentWrongQuestionNumber]:{},isFirstWrongQuestion:n=>n.currentWrongQuestionNumber===0,isLastWrongQuestion:(n,e)=>n.currentWrongQuestionNumber===e.wrongQuestionsNumber-1},Fx={fetchResult({commit:n,getters:e,dispatch:t},{hash:i}){vi.post(e.quizResultUrl(i)).then(s=>{t("handleResult",s.data)}).catch(s=>{n("error",s.response)})},handleResult({commit:n,getters:e},t){t.foxTest===!0?window.location.href=Wt(`${e.routePrefix}portal.home`):(n("setHasResult",!0),n("answersStatus",t),n("resultPoints",t),n("username",t),n("setWrongQuestions",wh.buildWrongQuestions(e,t.wrongQuestions)),n("notices",t.notices),n("clearLoading"),e.isExhibitionQuiz&&t.exhibitionInfoQuestions&&n("exhibitionInfoQuestions",t.exhibitionInfoQuestions))},fetchRanking({commit:n,getters:e}){vi.get(e.rankingUrl).then(t=>{n("ranking",t.data)})},fetchFurtherLinks({commit:n,getters:e}){vi.get(e.furtherLinksUrl).then(t=>{n("furtherLinks",t.data)})}},Ox={state:Ix,mutations:Ux,getters:Nx,actions:Fx},zx={ads:_x,base:Ex,gameRound:Ax,intros:Dx,result:Ox},kx=ix({modules:zx}),Bx={name:"EmbedVideo",props:{url:{type:String,required:!0},ratio:{type:String,default:"16/9",validator:n=>["16/9","4/3"].indexOf(n.toLowerCase())!==1}},computed:{ratioClass(){return{"container--16-9":this.ratio==="16/9","container--4-3":this.ratio==="4/3"}}},methods:{isVimeo(){return this.url.indexOf("vimeo")>-1},isYoutube(){return this.url.indexOf("youtu")>-1}}},Hx=["src"],Vx=["src"];function Gx(n,e,t,i,s,r){return J(),ae("div",{class:fn(["container",r.ratioClass])},[r.isVimeo()?(J(),ae("iframe",{key:0,class:"video video--vimeo",src:t.url,frameborder:"0",allow:"autoplay; fullscreen; picture-in-picture",allowfullscreen:""},null,8,Hx)):Ne("",!0),r.isYoutube()?(J(),ae("iframe",{key:1,class:"video video--youtube",src:t.url,frameborder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowfullscreen:""},null,8,Vx)):Ne("",!0)],2)}const Wx=mt(Bx,[["render",Gx],["__scopeId","data-v-d6b92834"]]),$x={name:"AvailableGuestRounds",props:{notice:{type:Object,required:!0}},computed:{availableGuestRoundsNumber(){return this.notice.value}}},qx={class:"c-alert c-alert--error"};function Xx(n,e,t,i,s,r){return J(),ae("div",qx,[r.availableGuestRoundsNumber?(J(),ae(vt,{key:0},[pt(" Du kannst noch "+nt(r.availableGuestRoundsNumber)+" Quiz-Runden als Gast spielen! ",1)],64)):(J(),ae(vt,{key:1},[e[0]||(e[0]=pt(" Du kannst keine weiteren Quiz-Runden mehr als Gast spielen. ")),e[1]||(e[1]=se("a",{style:{"text-decoration":"underline"},href:"/registrieren"},"Lege ein kostenloses Konto an",-1)),e[2]||(e[2]=pt(", um weiter zu spielen und tolle Preise zu gewinnen! "))],64))])}const Yx=mt($x,[["render",Xx]]),Qx={name:"NoticeHandler",props:{notice:{type:Object,required:!0}},components:{"available-guest-rounds":Yx},computed:{noticeComponent(){const n=lt.kebabCase(this.notice.name);return lt.has(this.$options.components,n)?n:!1}}};function jx(n,e,t,i,s,r){return r.noticeComponent?(J(),yt(Wi(r.noticeComponent),{key:0,notice:t.notice},null,8,["notice"])):Ne("",!0)}const Zx=mt(Qx,[["render",jx]]),Kx={name:"Default"},Jx={class:"c-error"};function eM(n,e,t,i,s,r){return J(),ae("div",Jx,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Leider gab es einen Fehler! ",-1)]))}const Fm=mt(Kx,[["render",eM]]),tM={name:"Http",computed:{message(){let n;switch(this.$store.state.base.error.status){case 403:n="Du bist nicht berechtigt dieses Quiz zu spielen. Versuche ein anderes!";break;default:n="Leider gab es einen Fehler. Starte ein neues Quiz!";break}return n}}},nM={class:"c-error"},iM={class:"c-error__message"};function sM(n,e,t,i,s,r){return J(),ae("div",nM,[se("div",iM,nt(r.message),1),e[0]||(e[0]=se("a",{class:"c-error__action c-button c-button--with-border",href:"/quiz-modus/abbrechen"},"Quiz wählen",-1))])}const rM=mt(tM,[["render",sM]]),oM={name:"GuestRoundLimit",data(){return{redirectUrl:"/quiz-modus/exception-guest-round-limit"}},created(){location.href=this.$store.state.base.url+this.redirectUrl},render(){return""}},aM={name:"QuizLimitDaily"},lM={class:"c-error"};function cM(n,e,t,i,s,r){return J(),ae("div",lM,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Du hast dieses Quiz heute schon zu oft gespielt. Versuche es morgen wieder! ",-1)]))}const hM=mt(aM,[["render",cM]]),uM={name:"QuizLimitMonthly"},dM={class:"c-error"};function fM(n,e,t,i,s,r){return J(),ae("div",dM,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Du hast dieses Quiz in diesem Monat bereits zu oft gespielt. Probiere doch ein Anderes! ",-1)]))}const pM=mt(uM,[["render",fM]]),mM={name:"QuizLimitTotal",created(){this.$store.state.base.foxTest&&(location.href=this.$store.state.base.url)}},_M={key:0,class:"c-error"};function gM(n,e,t,i,s,r){return n.$store.state.base.foxTest?Ne("",!0):(J(),ae("div",_M,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Du hast dieses Quiz bereits zu oft gespielt. Probiere doch ein Anderes! ",-1)])))}const vM=mt(mM,[["render",gM]]),xM={name:"UnauthorizedUser",data(){return{redirectUrl:"/email/bestaetigen"}},created(){location.href=this.$store.state.base.url+this.redirectUrl},render(){return""}},MM={name:"UnknownHashException"},EM={class:"c-error"};function yM(n,e,t,i,s,r){return J(),ae("div",EM,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Ups, beim Speichern ist ein Fehler aufgetreten. Lade die Seite bitte neu. ",-1)]))}const SM=mt(MM,[["render",yM]]),bM={name:"GameRoundInvalidException"},wM={class:"c-error"};function TM(n,e,t,i,s,r){return J(),ae("div",wM,e[0]||(e[0]=[se("div",{class:"c-error__message"}," Du hast versucht etwas an einer Spielrunde zu ändern, die bereits abgeschlossen ist. Starte einfach eine neue Runde! ",-1)]))}const AM=mt(bM,[["render",TM]]),CM={name:"FoxTestInactive",created(){location.href=this.$store.state.base.error.data.redirect},render(){return""}},RM={name:"ErrorHandler",components:{default:Fm,http:rM,"guest-round-limit":oM,"quiz-limit-daily":hM,"quiz-limit-monthly":pM,"quiz-limit-total":vM,"unauthorized-user":xM,"unknown-hash":SM,"game-round-invalid":AM,"fox-test-inactive":CM},computed:{exception(){if(this.$store){let n=this.$store.state.base.error.data.exception;return n.substr(n.lastIndexOf("\\")+1)}return""},errorComponent(){let n=this.exception.replace("Exception",""),e=lt.kebabCase(n)+"";return lt.has(this.$options.components,e)?e:"default"}}};function PM(n,e,t,i,s,r){return J(),yt(Wi(r.errorComponent))}const LM=mt(RM,[["render",PM]]),DM={name:"Quiz",props:{origin:{type:String,default:"playmit",validator:n=>typeof n>"u"?!0:n==="playmit"||n==="fox"},foxTest:{type:Boolean,default:!1},slug:{type:String,required:!0},exhibition:{type:Object,default:null},userGroupHash:{type:String,default:null},userGroupName:{type:String,default:null},ad:{type:[Object,Array],default:null},baseUrl:{type:String,default:!1}},computed:{...ri(["currentQuizIntro","currentQuizIntroSeen","isExhibitionQuiz"]),isLoading(){return this.$store.state.base.isLoading},showIntro(){return this.currentQuizIntro&&!this.currentQuizIntroSeen},hasResult(){return this.$store.state.result.hasResult},hasError(){return!ca.isEmpty(this.$store.state.base.error)},error(){return ca.isString(this.$store.state.base.error)?this.$store.state.base.error:""},quizTypeComponent(){let n=this.isLoading?"standard":this.$store.getters.currentQuiz.type.toLowerCase();return n=="firma"||n=="berufsvideo"||n=="eigenschaften"?"quiz-type-standard":`quiz-type-${n}`},quizType(){return this.$store.getters.currentQuiz.type.toLowerCase()},quizResultComponent(){return this.isExhibitionQuiz?"quiz-result-playmit-exhibition":`quiz-result-${this.origin}`},mainCssClasses(){const n=`l-quiz l-quiz--${this.origin}`,e=this.isLoading?"l-quiz--is-loading":"";return`${n} ${e}`}},created(){this.$store.commit("origin",this.origin),this.$store.commit("foxTest",this.foxTest),this.$store.commit("slug",this.slug),this.$store.commit("exhibition",this.exhibition),this.$store.commit("userGroupHash",this.userGroupHash),this.$store.commit("userGroupName",this.userGroupName),this.$store.commit("url",this.baseUrl),this.$store.dispatch("loadGameRound",{reset:!1}),this.ad&&(this.$store.commit("adZoneId",{id:this.ad.id,area:"quiz"}),this.$store.commit("ads",{ads:this.ad,area:"quiz"}))}};function IM(n,e,t,i,s,r){const o=it("error"),a=it("loading-indicator"),l=it("quiz-intro");return J(),ae("div",{class:fn(r.mainCssClasses)},[r.hasError?(J(),yt(o,{key:0})):(J(),ae(vt,{key:1},[r.hasResult?(J(),yt(Wi(r.quizResultComponent),{key:1})):(J(),ae(vt,{key:0},[r.isLoading?(J(),yt(a,{key:0})):r.showIntro?(J(),yt(l,{key:1,quizType:r.quizType},null,8,["quizType"])):(J(),yt(Wi(r.quizTypeComponent),{key:2}))],64))],64))],2)}const UM=mt(DM,[["render",IM]]),NM={computed:{currentUrlPath(){const n=document.head.querySelector('meta[name="current-url"]');return n?n.content:""}}},FM={methods:{trackPageView(n=null){window.matomoEnabled&&(n&&_paq.push(["setDocumentTitle",n]),_paq.push(["trackPageView"]))}}},OM={methods:{trackAdImpression(n){n&&window.matomoEnabled&&_paq.push(["trackContentImpression",`ad_zone_${n.id}`,`company_${n.item.companyId}`,this.currentUrlPath])}}},zM={name:"QuizTypeStandard",components:{"default-error-message":Fm},mixins:[NM,FM,OM],computed:{...oi({userGroupName:n=>n.base.userGroupName}),...ri(["currentQuiz","shouldTrack","isPlaymitQuiz","isFoxQuiz"]),quizName(){return this.currentQuiz.name},currentQuestion(){return this.$store.getters.currentQuestion},questionType(){return"question-"+this.currentQuestion.type},hasError(){return!lt.isEmpty(this.$store.state.base.error)},currentQuestionNumber(){return this.$store.getters.currentQuestionNumber},ad(){return this.$store.getters.hasQuizAd?{id:this.$store.state.ads.quiz.adZoneId,item:this.$store.state.ads.quiz.list[0]}:null}},watch:{currentQuestionNumber(n,e){this.fireTracking()}},mounted(){this.addBodyClasses(),this.$nextTick(()=>{this.fireTracking()})},unmounted(){this.removeBodyClasses()},methods:{fireTracking(){this.shouldTrack&&(this.trackPageView(`${this.currentUrlPath}/${this.currentQuestionNumber}`),this.trackAdImpression(this.ad))},addBodyClasses(){this.bodyElem=document.querySelector(".l-body"),this.bodyElem&&this.bodyElem.classList.add("l-body--quiz-mode-playing")},removeBodyClasses(){this.bodyElem&&this.bodyElem.classList.remove("l-body--quiz-mode-playing")}}},kM={class:"l-quiz-type-standard"},BM={class:"l-quiz-type-standard__content"},HM={class:"l-quiz-type-standard__stage"},VM={class:"l-quiz-type-standard__stage-content"},GM={class:"l-quiz-type-standard__quiz-name"},WM={key:0,class:"l-quiz-type-standard__ad-container"},$M={class:"c-promo-single"},qM={key:0,class:"c-promo-single__powered"},XM=["href"],YM=["src"],QM=["src"],jM={key:0,class:"l-quiz-type-standard__progress-bar"};function ZM(n,e,t,i,s,r){const o=it("quiz-header"),a=it("quiz-textual-progress"),l=it("default-error-message"),c=it("quiz-progress-bar");return J(),ae("div",kM,[Tt(o),se("section",BM,[se("div",HM,[se("div",VM,[r.currentQuestion?(J(),ae(vt,{key:0},[se("div",GM,[n.isFoxQuiz&&n.userGroupName?(J(),ae(vt,{key:0},[pt(nt(n.userGroupName)+" / ",1)],64)):Ne("",!0),pt(" "+nt(r.quizName),1)]),r.hasError?Ne("",!0):(J(),yt(a,{key:0,class:"l-quiz-type-standard__textual-progress"})),(J(),yt(Wi(r.questionType),{question:r.currentQuestion,key:r.currentQuestion.hash},null,8,["question"]))],64)):(J(),yt(l,{key:1}))])]),r.ad?(J(),ae("div",WM,[se("div",$M,[n.isPlaymitQuiz?(J(),ae("span",qM,"Unterstützt von")):Ne("",!0),r.ad.item.url?(J(),ae("a",{key:1,href:r.ad.item.url,target:"_blank"},[se("img",{class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,YM)],8,XM)):(J(),ae("img",{key:2,class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,QM))])])):Ne("",!0)]),r.hasError?Ne("",!0):(J(),ae("div",jM,[Tt(c)]))])}const KM=mt(zM,[["render",ZM]]);/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT */const gd="169",JM=0,ff=1,eE=2,Om=1,tE=2,Ni=3,xs=0,Sn=1,Oi=2,ds=0,Qr=1,pf=2,mf=3,_f=4,nE=5,Xs=100,iE=101,sE=102,rE=103,oE=104,aE=200,lE=201,cE=202,hE=203,Th=204,Ah=205,uE=206,dE=207,fE=208,pE=209,mE=210,_E=211,gE=212,vE=213,xE=214,Ch=0,Rh=1,Ph=2,io=3,Lh=4,Dh=5,Ih=6,Uh=7,zm=0,ME=1,EE=2,fs=0,yE=1,SE=2,bE=3,wE=4,TE=5,AE=6,CE=7,km=300,so=301,ro=302,Nh=303,Fh=304,ec=306,Oh=1e3,Zs=1001,zh=1002,Bn=1003,RE=1004,Ra=1005,kn=1006,vc=1007,us=1008,$i=1009,Bm=1010,Hm=1011,ha=1012,vd=1013,tr=1014,zi=1015,ga=1016,xd=1017,Md=1018,oo=1020,Vm=35902,Gm=1021,Wm=1022,ti=1023,$m=1024,qm=1025,jr=1026,ao=1027,Xm=1028,Ed=1029,Ym=1030,yd=1031,Sd=1033,El=33776,yl=33777,Sl=33778,bl=33779,kh=35840,Bh=35841,Hh=35842,Vh=35843,Gh=36196,Wh=37492,$h=37496,qh=37808,Xh=37809,Yh=37810,Qh=37811,jh=37812,Zh=37813,Kh=37814,Jh=37815,eu=37816,tu=37817,nu=37818,iu=37819,su=37820,ru=37821,wl=36492,ou=36494,au=36495,Qm=36283,lu=36284,cu=36285,hu=36286,PE=3200,LE=3201,DE=0,IE=1,cs="",di="srgb",Yi="srgb-linear",bd="display-p3",tc="display-p3-linear",kl="linear",It="srgb",Bl="rec709",Hl="p3",lr=7680,gf=519,UE=512,NE=513,FE=514,jm=515,OE=516,zE=517,kE=518,BE=519,vf=35044,xf="300 es",ki=2e3,Vl=2001;let go=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}};const an=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Mf=1234567;const Xo=Math.PI/180,ua=180/Math.PI;function vo(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(an[n&255]+an[n>>8&255]+an[n>>16&255]+an[n>>24&255]+"-"+an[e&255]+an[e>>8&255]+"-"+an[e>>16&15|64]+an[e>>24&255]+"-"+an[t&63|128]+an[t>>8&255]+"-"+an[t>>16&255]+an[t>>24&255]+an[i&255]+an[i>>8&255]+an[i>>16&255]+an[i>>24&255]).toLowerCase()}function vn(n,e,t){return Math.max(e,Math.min(t,n))}function wd(n,e){return(n%e+e)%e}function HE(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function VE(n,e,t){return n!==e?(t-n)/(e-n):0}function Yo(n,e,t){return(1-t)*n+t*e}function GE(n,e,t,i){return Yo(n,e,1-Math.exp(-t*i))}function WE(n,e=1){return e-Math.abs(wd(n,e*2)-e)}function $E(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function qE(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function XE(n,e){return n+Math.floor(Math.random()*(e-n+1))}function YE(n,e){return n+Math.random()*(e-n)}function QE(n){return n*(.5-Math.random())}function jE(n){n!==void 0&&(Mf=n);let e=Mf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ZE(n){return n*Xo}function KE(n){return n*ua}function JE(n){return(n&n-1)===0&&n!==0}function ey(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function ty(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function ny(n,e,t,i,s){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+i)/2),h=o((e+i)/2),f=r((e-i)/2),p=o((e-i)/2),m=r((i-e)/2),g=o((i-e)/2);switch(s){case"XYX":n.set(a*h,l*f,l*p,a*c);break;case"YZY":n.set(l*p,a*h,l*f,a*c);break;case"ZXZ":n.set(l*f,l*p,a*h,a*c);break;case"XZX":n.set(a*h,l*g,l*m,a*c);break;case"YXY":n.set(l*m,a*h,l*g,a*c);break;case"ZYZ":n.set(l*g,l*m,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Fr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function pn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const Ut={DEG2RAD:Xo,RAD2DEG:ua,generateUUID:vo,clamp:vn,euclideanModulo:wd,mapLinear:HE,inverseLerp:VE,lerp:Yo,damp:GE,pingpong:WE,smoothstep:$E,smootherstep:qE,randInt:XE,randFloat:YE,randFloatSpread:QE,seededRandom:jE,degToRad:ZE,radToDeg:KE,isPowerOfTwo:JE,ceilPowerOfTwo:ey,floorPowerOfTwo:ty,setQuaternionFromProperEuler:ny,normalize:pn,denormalize:Fr};let Dt=class Zm{constructor(e=0,t=0){Zm.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(vn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*s+e.x,this.y=r*s+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},gt=class Km{constructor(e,t,i,s,r,o,a,l,c){Km.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c)}set(e,t,i,s,r,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=i,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],h=i[4],f=i[7],p=i[2],m=i[5],g=i[8],x=s[0],d=s[3],u=s[6],w=s[1],M=s[4],E=s[7],N=s[2],A=s[5],T=s[8];return r[0]=o*x+a*w+l*N,r[3]=o*d+a*M+l*A,r[6]=o*u+a*E+l*T,r[1]=c*x+h*w+f*N,r[4]=c*d+h*M+f*A,r[7]=c*u+h*E+f*T,r[2]=p*x+m*w+g*N,r[5]=p*d+m*M+g*A,r[8]=p*u+m*E+g*T,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-i*r*h+i*a*l+s*r*c-s*o*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,p=a*l-h*r,m=c*r-o*l,g=t*f+i*p+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=f*x,e[1]=(s*c-h*i)*x,e[2]=(a*i-s*o)*x,e[3]=p*x,e[4]=(h*t-s*l)*x,e[5]=(s*r-a*t)*x,e[6]=m*x,e[7]=(i*l-c*t)*x,e[8]=(o*t-i*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(xc.makeScale(e,t)),this}rotate(e){return this.premultiply(xc.makeRotation(-e)),this}translate(e,t){return this.premultiply(xc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const xc=new gt;function Jm(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Gl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function iy(){const n=Gl("canvas");return n.style.display="block",n}const Ef={};function Tl(n){n in Ef||(Ef[n]=!0,console.warn(n))}function sy(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}function ry(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function oy(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const yf=new gt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Sf=new gt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Po={[Yi]:{transfer:kl,primaries:Bl,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[di]:{transfer:It,primaries:Bl,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[tc]:{transfer:kl,primaries:Hl,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(Sf),fromReference:n=>n.applyMatrix3(yf)},[bd]:{transfer:It,primaries:Hl,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(Sf),fromReference:n=>n.applyMatrix3(yf).convertLinearToSRGB()}},ay=new Set([Yi,tc]),St={enabled:!0,_workingColorSpace:Yi,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!ay.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=Po[e].toReference,s=Po[t].fromReference;return s(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Po[n].primaries},getTransfer:function(n){return n===cs?kl:Po[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(Po[e].luminanceCoefficients)}};function Zr(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Mc(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let cr,ly=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{cr===void 0&&(cr=Gl("canvas")),cr.width=e.width,cr.height=e.height;const i=cr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=cr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Gl("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=Zr(r[o]/255)*255;return i.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Zr(t[i]/255)*255):t[i]=Zr(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},cy=0,e_=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cy++}),this.uuid=vo(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Ec(s[o].image)):r.push(Ec(s[o]))}else r=Ec(s);i.url=r}return t||(e.images[this.uuid]=i),i}};function Ec(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?ly.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let hy=0,ai=class Al extends go{constructor(e=Al.DEFAULT_IMAGE,t=Al.DEFAULT_MAPPING,i=Zs,s=Zs,r=kn,o=us,a=ti,l=$i,c=Al.DEFAULT_ANISOTROPY,h=cs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hy++}),this.uuid=vo(),this.name="",this.source=new e_(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Dt(0,0),this.repeat=new Dt(1,1),this.center=new Dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==km)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Oh:e.x=e.x-Math.floor(e.x);break;case Zs:e.x=e.x<0?0:1;break;case zh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Oh:e.y=e.y-Math.floor(e.y);break;case Zs:e.y=e.y<0?0:1;break;case zh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};ai.DEFAULT_IMAGE=null;ai.DEFAULT_MAPPING=km;ai.DEFAULT_ANISOTROPY=1;let $t=class t_{constructor(e=0,t=0,i=0,s=1){t_.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*s+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],h=l[4],f=l[8],p=l[1],m=l[5],g=l[9],x=l[2],d=l[6],u=l[10];if(Math.abs(h-p)<.01&&Math.abs(f-x)<.01&&Math.abs(g-d)<.01){if(Math.abs(h+p)<.1&&Math.abs(f+x)<.1&&Math.abs(g+d)<.1&&Math.abs(c+m+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const M=(c+1)/2,E=(m+1)/2,N=(u+1)/2,A=(h+p)/4,T=(f+x)/4,I=(g+d)/4;return M>E&&M>N?M<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(M),s=A/i,r=T/i):E>N?E<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(E),i=A/s,r=I/s):N<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(N),i=T/r,s=I/r),this.set(i,s,r,t),this}let w=Math.sqrt((d-g)*(d-g)+(f-x)*(f-x)+(p-h)*(p-h));return Math.abs(w)<.001&&(w=1),this.x=(d-g)/w,this.y=(f-x)/w,this.z=(p-h)/w,this.w=Math.acos((c+m+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}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}},uy=class extends go{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new $t(0,0,e,t),this.scissorTest=!1,this.viewport=new $t(0,0,e,t);const s={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:kn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const r=new ai(s,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);r.flipY=!1,r.generateMipmaps=i.generateMipmaps,r.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,s=e.textures.length;i<s;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new e_(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ms=class extends uy{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},n_=class extends ai{constructor(e=null,t=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=Bn,this.minFilter=Bn,this.wrapR=Zs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},dy=class extends ai{constructor(e=null,t=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=Bn,this.minFilter=Bn,this.wrapR=Zs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},xo=class{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,o,a){let l=i[s+0],c=i[s+1],h=i[s+2],f=i[s+3];const p=r[o+0],m=r[o+1],g=r[o+2],x=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(a===1){e[t+0]=p,e[t+1]=m,e[t+2]=g,e[t+3]=x;return}if(f!==x||l!==p||c!==m||h!==g){let d=1-a;const u=l*p+c*m+h*g+f*x,w=u>=0?1:-1,M=1-u*u;if(M>Number.EPSILON){const N=Math.sqrt(M),A=Math.atan2(N,u*w);d=Math.sin(d*A)/N,a=Math.sin(a*A)/N}const E=a*w;if(l=l*d+p*E,c=c*d+m*E,h=h*d+g*E,f=f*d+x*E,d===1-a){const N=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=N,c*=N,h*=N,f*=N}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,s,r,o){const a=i[s],l=i[s+1],c=i[s+2],h=i[s+3],f=r[o],p=r[o+1],m=r[o+2],g=r[o+3];return e[t]=a*g+h*f+l*m-c*p,e[t+1]=l*g+h*p+c*f-a*m,e[t+2]=c*g+h*m+a*p-l*f,e[t+3]=h*g-a*f-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),h=a(s/2),f=a(r/2),p=l(i/2),m=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=p*h*f+c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f-p*m*g;break;case"YXZ":this._x=p*h*f+c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f+p*m*g;break;case"ZXY":this._x=p*h*f-c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f-p*m*g;break;case"ZYX":this._x=p*h*f-c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f+p*m*g;break;case"YZX":this._x=p*h*f+c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f-p*m*g;break;case"XZY":this._x=p*h*f-c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f+p*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],f=t[10],p=i+a+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(h-l)*m,this._y=(r-c)*m,this._z=(o-s)*m}else if(i>a&&i>f){const m=2*Math.sqrt(1+i-a-f);this._w=(h-l)/m,this._x=.25*m,this._y=(s+o)/m,this._z=(r+c)/m}else if(a>f){const m=2*Math.sqrt(1+a-i-f);this._w=(r-c)/m,this._x=(s+o)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+f-i-a);this._w=(o-s)/m,this._x=(r+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(vn(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-i*c,this._z=r*h+o*c+i*l-s*a,this._w=o*h-i*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,s=this._y,r=this._z,o=this._w;let a=o*e._w+i*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=s,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-t;return this._w=m*o+t*this._w,this._x=m*i+t*this._x,this._y=m*s+t*this._y,this._z=m*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=o*f+this._w*p,this._x=i*f+this._x*p,this._y=s*f+this._y*p,this._z=r*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ce=class i_{constructor(e=0,t=0,i=0){i_.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(bf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*i),h=2*(a*t-r*s),f=2*(r*i-o*t);return this.x=t+l*c+o*f-a*h,this.y=i+l*h+a*c-r*f,this.z=s+l*f+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-i*l,this.z=i*a-s*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yc.copy(this).projectOnVector(e),this.sub(yc)}reflect(e){return this.sub(yc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(vn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const yc=new ce,bf=new xo;let Mo=class{constructor(e=new ce(1/0,1/0,1/0),t=new ce(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Xn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Xn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Xn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Xn):Xn.fromBufferAttribute(r,o),Xn.applyMatrix4(e.matrixWorld),this.expandByPoint(Xn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Pa.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Pa.copy(i.boundingBox)),Pa.applyMatrix4(e.matrixWorld),this.union(Pa)}const s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Xn),Xn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lo),La.subVectors(this.max,Lo),hr.subVectors(e.a,Lo),ur.subVectors(e.b,Lo),dr.subVectors(e.c,Lo),ji.subVectors(ur,hr),Zi.subVectors(dr,ur),Ds.subVectors(hr,dr);let t=[0,-ji.z,ji.y,0,-Zi.z,Zi.y,0,-Ds.z,Ds.y,ji.z,0,-ji.x,Zi.z,0,-Zi.x,Ds.z,0,-Ds.x,-ji.y,ji.x,0,-Zi.y,Zi.x,0,-Ds.y,Ds.x,0];return!Sc(t,hr,ur,dr,La)||(t=[1,0,0,0,1,0,0,0,1],!Sc(t,hr,ur,dr,La))?!1:(Da.crossVectors(ji,Zi),t=[Da.x,Da.y,Da.z],Sc(t,hr,ur,dr,La))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};const wi=[new ce,new ce,new ce,new ce,new ce,new ce,new ce,new ce],Xn=new ce,Pa=new Mo,hr=new ce,ur=new ce,dr=new ce,ji=new ce,Zi=new ce,Ds=new ce,Lo=new ce,La=new ce,Da=new ce,Is=new ce;function Sc(n,e,t,i,s){for(let r=0,o=n.length-3;r<=o;r+=3){Is.fromArray(n,r);const a=s.x*Math.abs(Is.x)+s.y*Math.abs(Is.y)+s.z*Math.abs(Is.z),l=e.dot(Is),c=t.dot(Is),h=i.dot(Is);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const fy=new Mo,Do=new ce,bc=new ce;let Td=class{constructor(e=new ce,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):fy.setFromPoints(e).getCenter(i);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Do.subVectors(e,this.center);const t=Do.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(Do,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(bc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Do.copy(e.center).add(bc)),this.expandByPoint(Do.copy(e.center).sub(bc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};const Ti=new ce,wc=new ce,Ia=new ce,Ki=new ce,Tc=new ce,Ua=new ce,Ac=new ce;let s_=class{constructor(e=new ce,t=new ce(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ti)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ti.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ti.copy(this.origin).addScaledVector(this.direction,t),Ti.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){wc.copy(e).add(t).multiplyScalar(.5),Ia.copy(t).sub(e).normalize(),Ki.copy(this.origin).sub(wc);const r=e.distanceTo(t)*.5,o=-this.direction.dot(Ia),a=Ki.dot(this.direction),l=-Ki.dot(Ia),c=Ki.lengthSq(),h=Math.abs(1-o*o);let f,p,m,g;if(h>0)if(f=o*l-a,p=o*a-l,g=r*h,f>=0)if(p>=-g)if(p<=g){const x=1/h;f*=x,p*=x,m=f*(f+o*p+2*a)+p*(o*f+p+2*l)+c}else p=r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p=-r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p<=-g?(f=Math.max(0,-(-o*r+a)),p=f>0?-r:Math.min(Math.max(-r,-l),r),m=-f*f+p*(p+2*l)+c):p<=g?(f=0,p=Math.min(Math.max(-r,-l),r),m=p*(p+2*l)+c):(f=Math.max(0,-(o*r+a)),p=f>0?r:Math.min(Math.max(-r,-l),r),m=-f*f+p*(p+2*l)+c);else p=o>0?-r:r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),s&&s.copy(wc).addScaledVector(Ia,p),m}intersectSphere(e,t){Ti.subVectors(e.center,this.origin);const i=Ti.dot(this.direction),s=Ti.dot(Ti)-i*i,r=e.radius*e.radius;if(s>r)return null;const o=Math.sqrt(r-s),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,s=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,s=(e.min.x-p.x)*c),h>=0?(r=(e.min.y-p.y)*h,o=(e.max.y-p.y)*h):(r=(e.max.y-p.y)*h,o=(e.min.y-p.y)*h),i>o||r>s||((r>i||isNaN(i))&&(i=r),(o<s||isNaN(s))&&(s=o),f>=0?(a=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(a=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),i>l||a>s)||((a>i||i!==i)&&(i=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,Ti)!==null}intersectTriangle(e,t,i,s,r){Tc.subVectors(t,e),Ua.subVectors(i,e),Ac.crossVectors(Tc,Ua);let o=this.direction.dot(Ac),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ki.subVectors(this.origin,e);const l=a*this.direction.dot(Ua.crossVectors(Ki,Ua));if(l<0)return null;const c=a*this.direction.dot(Tc.cross(Ki));if(c<0||l+c>o)return null;const h=-a*Ki.dot(Ac);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},qt=class uu{constructor(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d){uu.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d)}set(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d){const u=this.elements;return u[0]=e,u[4]=t,u[8]=i,u[12]=s,u[1]=r,u[5]=o,u[9]=a,u[13]=l,u[2]=c,u[6]=h,u[10]=f,u[14]=p,u[3]=m,u[7]=g,u[11]=x,u[15]=d,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new uu().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,s=1/fr.setFromMatrixColumn(e,0).length(),r=1/fr.setFromMatrixColumn(e,1).length(),o=1/fr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),f=Math.sin(r);if(e.order==="XYZ"){const p=o*h,m=o*f,g=a*h,x=a*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=m+g*c,t[5]=p-x*c,t[9]=-a*l,t[2]=x-p*c,t[6]=g+m*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*h,m=l*f,g=c*h,x=c*f;t[0]=p+x*a,t[4]=g*a-m,t[8]=o*c,t[1]=o*f,t[5]=o*h,t[9]=-a,t[2]=m*a-g,t[6]=x+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*h,m=l*f,g=c*h,x=c*f;t[0]=p-x*a,t[4]=-o*f,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*h,t[9]=x-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*h,m=o*f,g=a*h,x=a*f;t[0]=l*h,t[4]=g*c-m,t[8]=p*c+x,t[1]=l*f,t[5]=x*c+p,t[9]=m*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=x-p*f,t[8]=g*f+m,t[1]=f,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=m*f+g,t[10]=p-x*f}else if(e.order==="XZY"){const p=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=p*f+x,t[5]=o*h,t[9]=m*f-g,t[2]=g*f-m,t[6]=a*h,t[10]=x*f+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(py,e,my)}lookAt(e,t,i){const s=this.elements;return An.subVectors(e,t),An.lengthSq()===0&&(An.z=1),An.normalize(),Ji.crossVectors(i,An),Ji.lengthSq()===0&&(Math.abs(i.z)===1?An.x+=1e-4:An.z+=1e-4,An.normalize(),Ji.crossVectors(i,An)),Ji.normalize(),Na.crossVectors(An,Ji),s[0]=Ji.x,s[4]=Na.x,s[8]=An.x,s[1]=Ji.y,s[5]=Na.y,s[9]=An.y,s[2]=Ji.z,s[6]=Na.z,s[10]=An.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],h=i[1],f=i[5],p=i[9],m=i[13],g=i[2],x=i[6],d=i[10],u=i[14],w=i[3],M=i[7],E=i[11],N=i[15],A=s[0],T=s[4],I=s[8],C=s[12],_=s[1],b=s[5],W=s[9],z=s[13],G=s[2],K=s[6],H=s[10],ie=s[14],B=s[3],ue=s[7],me=s[11],Me=s[15];return r[0]=o*A+a*_+l*G+c*B,r[4]=o*T+a*b+l*K+c*ue,r[8]=o*I+a*W+l*H+c*me,r[12]=o*C+a*z+l*ie+c*Me,r[1]=h*A+f*_+p*G+m*B,r[5]=h*T+f*b+p*K+m*ue,r[9]=h*I+f*W+p*H+m*me,r[13]=h*C+f*z+p*ie+m*Me,r[2]=g*A+x*_+d*G+u*B,r[6]=g*T+x*b+d*K+u*ue,r[10]=g*I+x*W+d*H+u*me,r[14]=g*C+x*z+d*ie+u*Me,r[3]=w*A+M*_+E*G+N*B,r[7]=w*T+M*b+E*K+N*ue,r[11]=w*I+M*W+E*H+N*me,r[15]=w*C+M*z+E*ie+N*Me,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],f=e[6],p=e[10],m=e[14],g=e[3],x=e[7],d=e[11],u=e[15];return g*(+r*l*f-s*c*f-r*a*p+i*c*p+s*a*m-i*l*m)+x*(+t*l*m-t*c*p+r*o*p-s*o*m+s*c*h-r*l*h)+d*(+t*c*f-t*a*m-r*o*f+i*o*m+r*a*h-i*c*h)+u*(-s*a*h-t*l*f+t*a*p+s*o*f-i*o*p+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=e[9],p=e[10],m=e[11],g=e[12],x=e[13],d=e[14],u=e[15],w=f*d*c-x*p*c+x*l*m-a*d*m-f*l*u+a*p*u,M=g*p*c-h*d*c-g*l*m+o*d*m+h*l*u-o*p*u,E=h*x*c-g*f*c+g*a*m-o*x*m-h*a*u+o*f*u,N=g*f*l-h*x*l-g*a*p+o*x*p+h*a*d-o*f*d,A=t*w+i*M+s*E+r*N;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/A;return e[0]=w*T,e[1]=(x*p*r-f*d*r-x*s*m+i*d*m+f*s*u-i*p*u)*T,e[2]=(a*d*r-x*l*r+x*s*c-i*d*c-a*s*u+i*l*u)*T,e[3]=(f*l*r-a*p*r-f*s*c+i*p*c+a*s*m-i*l*m)*T,e[4]=M*T,e[5]=(h*d*r-g*p*r+g*s*m-t*d*m-h*s*u+t*p*u)*T,e[6]=(g*l*r-o*d*r-g*s*c+t*d*c+o*s*u-t*l*u)*T,e[7]=(o*p*r-h*l*r+h*s*c-t*p*c-o*s*m+t*l*m)*T,e[8]=E*T,e[9]=(g*f*r-h*x*r-g*i*m+t*x*m+h*i*u-t*f*u)*T,e[10]=(o*x*r-g*a*r+g*i*c-t*x*c-o*i*u+t*a*u)*T,e[11]=(h*a*r-o*f*r-h*i*c+t*f*c+o*i*m-t*a*m)*T,e[12]=N*T,e[13]=(h*x*s-g*f*s+g*i*p-t*x*p-h*i*d+t*f*d)*T,e[14]=(g*a*s-o*x*s-g*i*l+t*x*l+o*i*d-t*a*d)*T,e[15]=(o*f*s-h*a*s+h*i*l-t*f*l-o*i*p+t*a*p)*T,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+i,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+i,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,o){return this.set(1,i,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,f=a+a,p=r*c,m=r*h,g=r*f,x=o*h,d=o*f,u=a*f,w=l*c,M=l*h,E=l*f,N=i.x,A=i.y,T=i.z;return s[0]=(1-(x+u))*N,s[1]=(m+E)*N,s[2]=(g-M)*N,s[3]=0,s[4]=(m-E)*A,s[5]=(1-(p+u))*A,s[6]=(d+w)*A,s[7]=0,s[8]=(g+M)*T,s[9]=(d-w)*T,s[10]=(1-(p+x))*T,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;let r=fr.set(s[0],s[1],s[2]).length();const o=fr.set(s[4],s[5],s[6]).length(),a=fr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],Yn.copy(this);const c=1/r,h=1/o,f=1/a;return Yn.elements[0]*=c,Yn.elements[1]*=c,Yn.elements[2]*=c,Yn.elements[4]*=h,Yn.elements[5]*=h,Yn.elements[6]*=h,Yn.elements[8]*=f,Yn.elements[9]*=f,Yn.elements[10]*=f,t.setFromRotationMatrix(Yn),i.x=r,i.y=o,i.z=a,this}makePerspective(e,t,i,s,r,o,a=ki){const l=this.elements,c=2*r/(t-e),h=2*r/(i-s),f=(t+e)/(t-e),p=(i+s)/(i-s);let m,g;if(a===ki)m=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===Vl)m=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,s,r,o,a=ki){const l=this.elements,c=1/(t-e),h=1/(i-s),f=1/(o-r),p=(t+e)*c,m=(i+s)*h;let g,x;if(a===ki)g=(o+r)*f,x=-2*f;else if(a===Vl)g=r*f,x=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=x,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};const fr=new ce,Yn=new qt,py=new ce(0,0,0),my=new ce(1,1,1),Ji=new ce,Na=new ce,An=new ce,wf=new qt,Tf=new xo;let Es=class r_{constructor(e=0,t=0,i=0,s=r_.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],f=s[2],p=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(vn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-vn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(vn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-vn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(vn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-vn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return wf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tf.setFromEuler(this),this.setFromQuaternion(Tf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Es.DEFAULT_ORDER="XYZ";let Ad=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},_y=0;const Af=new ce,pr=new xo,Ai=new qt,Fa=new ce,Io=new ce,gy=new ce,vy=new xo,Cf=new ce(1,0,0),Rf=new ce(0,1,0),Pf=new ce(0,0,1),Lf={type:"added"},xy={type:"removed"},mr={type:"childadded",child:null},Cc={type:"childremoved",child:null};let Qi=class Cl extends go{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_y++}),this.uuid=vo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Cl.DEFAULT_UP.clone();const e=new ce,t=new Es,i=new xo,s=new ce(1,1,1);function r(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new qt},normalMatrix:{value:new gt}}),this.matrix=new qt,this.matrixWorld=new qt,this.matrixAutoUpdate=Cl.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Cl.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ad,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return pr.setFromAxisAngle(e,t),this.quaternion.multiply(pr),this}rotateOnWorldAxis(e,t){return pr.setFromAxisAngle(e,t),this.quaternion.premultiply(pr),this}rotateX(e){return this.rotateOnAxis(Cf,e)}rotateY(e){return this.rotateOnAxis(Rf,e)}rotateZ(e){return this.rotateOnAxis(Pf,e)}translateOnAxis(e,t){return Af.copy(e).applyQuaternion(this.quaternion),this.position.add(Af.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Cf,e)}translateY(e){return this.translateOnAxis(Rf,e)}translateZ(e){return this.translateOnAxis(Pf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ai.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Fa.copy(e):Fa.set(e,t,i);const s=this.parent;this.updateWorldMatrix(!0,!1),Io.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ai.lookAt(Io,Fa,this.up):Ai.lookAt(Fa,Io,this.up),this.quaternion.setFromRotationMatrix(Ai),s&&(Ai.extractRotation(s.matrixWorld),pr.setFromRotationMatrix(Ai),this.quaternion.premultiply(pr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Lf),mr.child=e,this.dispatchEvent(mr),mr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(xy),Cc.child=e,this.dispatchEvent(Cc),Cc.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ai.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ai.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ai),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lf),mr.child=e,this.dispatchEvent(mr),mr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,s=this.children.length;i<s;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Io,e,gy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Io,vy,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];r(e.shapes,f)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),f=o(e.shapes),p=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),f.length>0&&(i.shapes=f),p.length>0&&(i.skeletons=p),m.length>0&&(i.animations=m),g.length>0&&(i.nodes=g)}return i.object=s,i;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}};Qi.DEFAULT_UP=new ce(0,1,0);Qi.DEFAULT_MATRIX_AUTO_UPDATE=!0;Qi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Qn=new ce,Ci=new ce,Rc=new ce,Ri=new ce,_r=new ce,gr=new ce,Df=new ce,Pc=new ce,Lc=new ce,Dc=new ce,Ic=new $t,Uc=new $t,Nc=new $t;let Uo=class Or{constructor(e=new ce,t=new ce,i=new ce){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Qn.subVectors(e,t),s.cross(Qn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Qn.subVectors(s,t),Ci.subVectors(i,t),Rc.subVectors(e,t);const o=Qn.dot(Qn),a=Qn.dot(Ci),l=Qn.dot(Rc),c=Ci.dot(Ci),h=Ci.dot(Rc),f=o*c-a*a;if(f===0)return r.set(0,0,0),null;const p=1/f,m=(c*l-a*h)*p,g=(o*h-a*l)*p;return r.set(1-m-g,g,m)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,Ri)===null?!1:Ri.x>=0&&Ri.y>=0&&Ri.x+Ri.y<=1}static getInterpolation(e,t,i,s,r,o,a,l){return this.getBarycoord(e,t,i,s,Ri)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Ri.x),l.addScaledVector(o,Ri.y),l.addScaledVector(a,Ri.z),l)}static getInterpolatedAttribute(e,t,i,s,r,o){return Ic.setScalar(0),Uc.setScalar(0),Nc.setScalar(0),Ic.fromBufferAttribute(e,t),Uc.fromBufferAttribute(e,i),Nc.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Ic,r.x),o.addScaledVector(Uc,r.y),o.addScaledVector(Nc,r.z),o}static isFrontFacing(e,t,i,s){return Qn.subVectors(i,t),Ci.subVectors(e,t),Qn.cross(Ci).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qn.subVectors(this.c,this.b),Ci.subVectors(this.a,this.b),Qn.cross(Ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Or.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Or.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Or.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Or.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Or.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let o,a;_r.subVectors(s,i),gr.subVectors(r,i),Pc.subVectors(e,i);const l=_r.dot(Pc),c=gr.dot(Pc);if(l<=0&&c<=0)return t.copy(i);Lc.subVectors(e,s);const h=_r.dot(Lc),f=gr.dot(Lc);if(h>=0&&f<=h)return t.copy(s);const p=l*f-h*c;if(p<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(i).addScaledVector(_r,o);Dc.subVectors(e,r);const m=_r.dot(Dc),g=gr.dot(Dc);if(g>=0&&m<=g)return t.copy(r);const x=m*c-l*g;if(x<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(i).addScaledVector(gr,a);const d=h*g-m*f;if(d<=0&&f-h>=0&&m-g>=0)return Df.subVectors(r,s),a=(f-h)/(f-h+(m-g)),t.copy(s).addScaledVector(Df,a);const u=1/(d+x+p);return o=x*u,a=p*u,t.copy(i).addScaledVector(_r,o).addScaledVector(gr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const o_={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},es={h:0,s:0,l:0},Oa={h:0,s:0,l:0};function Fc(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}let Rt=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=di){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,St.toWorkingColorSpace(this,t),this}setRGB(e,t,i,s=St.workingColorSpace){return this.r=e,this.g=t,this.b=i,St.toWorkingColorSpace(this,s),this}setHSL(e,t,i,s=St.workingColorSpace){if(e=wd(e,1),t=vn(t,0,1),i=vn(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=Fc(o,r,e+1/3),this.g=Fc(o,r,e),this.b=Fc(o,r,e-1/3)}return St.toWorkingColorSpace(this,s),this}setStyle(e,t=di){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=di){const i=o_[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zr(e.r),this.g=Zr(e.g),this.b=Zr(e.b),this}copyLinearToSRGB(e){return this.r=Mc(e.r),this.g=Mc(e.g),this.b=Mc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=di){return St.fromWorkingColorSpace(ln.copy(this),e),Math.round(vn(ln.r*255,0,255))*65536+Math.round(vn(ln.g*255,0,255))*256+Math.round(vn(ln.b*255,0,255))}getHexString(e=di){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=St.workingColorSpace){St.fromWorkingColorSpace(ln.copy(this),t);const i=ln.r,s=ln.g,r=ln.b,o=Math.max(i,s,r),a=Math.min(i,s,r);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case i:l=(s-r)/f+(s<r?6:0);break;case s:l=(r-i)/f+2;break;case r:l=(i-s)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=St.workingColorSpace){return St.fromWorkingColorSpace(ln.copy(this),t),e.r=ln.r,e.g=ln.g,e.b=ln.b,e}getStyle(e=di){St.fromWorkingColorSpace(ln.copy(this),e);const t=ln.r,i=ln.g,s=ln.b;return e!==di?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,t,i){return this.getHSL(es),this.setHSL(es.h+e,es.s+t,es.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(es),e.getHSL(Oa);const i=Yo(es.h,Oa.h,t),s=Yo(es.s,Oa.s,t),r=Yo(es.l,Oa.l,t);return this.setHSL(i,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*s,this.g=r[1]*t+r[4]*i+r[7]*s,this.b=r[2]*t+r[5]*i+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ln=new Rt;Rt.NAMES=o_;let My=0,nc=class extends go{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:My++}),this.uuid=vo(),this.name="",this.type="Material",this.blending=Qr,this.side=xs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Th,this.blendDst=Ah,this.blendEquation=Xs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rt(0,0,0),this.blendAlpha=0,this.depthFunc=io,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=gf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=lr,this.stencilZFail=lr,this.stencilZPass=lr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Qr&&(i.blending=this.blending),this.side!==xs&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Th&&(i.blendSrc=this.blendSrc),this.blendDst!==Ah&&(i.blendDst=this.blendDst),this.blendEquation!==Xs&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==io&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==gf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==lr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==lr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==lr&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=s(e.textures),o=s(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}},va=class extends nc{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rt(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 Es,this.combine=zm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const Bt=new ce,za=new Dt;let xi=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=vf,this.updateRanges=[],this.gpuType=zi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)za.fromBufferAttribute(this,t),za.applyMatrix3(e),this.setXY(t,za.x,za.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyMatrix3(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyMatrix4(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyNormalMatrix(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.transformDirection(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Fr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=pn(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Fr(t,this.array)),t}setX(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Fr(t,this.array)),t}setY(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Fr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Fr(t,this.array)),t}setW(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),i=pn(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,s){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),i=pn(i,this.array),s=pn(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),i=pn(i,this.array),s=pn(s,this.array),r=pn(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==vf&&(e.usage=this.usage),e}},a_=class extends xi{constructor(e,t,i){super(new Uint16Array(e),t,i)}},l_=class extends xi{constructor(e,t,i){super(new Uint32Array(e),t,i)}},Mi=class extends xi{constructor(e,t,i){super(new Float32Array(e),t,i)}},Ey=0;const Un=new qt,Oc=new Qi,vr=new ce,Cn=new Mo,No=new Mo,Jt=new ce;let Eo=class c_ extends go{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=vo(),this.name="",this.type="BufferGeometry",this.index=null,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(e){return Array.isArray(e)?this.index=new(Jm(e)?l_:a_)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new gt().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,i){return Un.makeTranslation(e,t,i),this.applyMatrix4(Un),this}scale(e,t,i){return Un.makeScale(e,t,i),this.applyMatrix4(Un),this}lookAt(e){return Oc.lookAt(e),Oc.updateMatrix(),this.applyMatrix4(Oc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vr).negate(),this.translate(vr.x,vr.y,vr.z),this}setFromPoints(e){const t=[];for(let i=0,s=e.length;i<s;i++){const r=e[i];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Mi(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mo);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ce(-1/0,-1/0,-1/0),new ce(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i<s;i++){const r=t[i];Cn.setFromBufferAttribute(r),this.morphTargetsRelative?(Jt.addVectors(this.boundingBox.min,Cn.min),this.boundingBox.expandByPoint(Jt),Jt.addVectors(this.boundingBox.max,Cn.max),this.boundingBox.expandByPoint(Jt)):(this.boundingBox.expandByPoint(Cn.min),this.boundingBox.expandByPoint(Cn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Td);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ce,1/0);return}if(e){const i=this.boundingSphere.center;if(Cn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];No.setFromBufferAttribute(a),this.morphTargetsRelative?(Jt.addVectors(Cn.min,No.min),Cn.expandByPoint(Jt),Jt.addVectors(Cn.max,No.max),Cn.expandByPoint(Jt)):(Cn.expandByPoint(No.min),Cn.expandByPoint(No.max))}Cn.getCenter(i);let s=0;for(let r=0,o=e.count;r<o;r++)Jt.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Jt));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)Jt.fromBufferAttribute(a,c),l&&(vr.fromBufferAttribute(e,c),Jt.add(vr)),s=Math.max(s,i.distanceToSquared(Jt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new xi(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let I=0;I<i.count;I++)a[I]=new ce,l[I]=new ce;const c=new ce,h=new ce,f=new ce,p=new Dt,m=new Dt,g=new Dt,x=new ce,d=new ce;function u(I,C,_){c.fromBufferAttribute(i,I),h.fromBufferAttribute(i,C),f.fromBufferAttribute(i,_),p.fromBufferAttribute(r,I),m.fromBufferAttribute(r,C),g.fromBufferAttribute(r,_),h.sub(c),f.sub(c),m.sub(p),g.sub(p);const b=1/(m.x*g.y-g.x*m.y);isFinite(b)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(b),d.copy(f).multiplyScalar(m.x).addScaledVector(h,-g.x).multiplyScalar(b),a[I].add(x),a[C].add(x),a[_].add(x),l[I].add(d),l[C].add(d),l[_].add(d))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let I=0,C=w.length;I<C;++I){const _=w[I],b=_.start,W=_.count;for(let z=b,G=b+W;z<G;z+=3)u(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const M=new ce,E=new ce,N=new ce,A=new ce;function T(I){N.fromBufferAttribute(s,I),A.copy(N);const C=a[I];M.copy(C),M.sub(N.multiplyScalar(N.dot(C))).normalize(),E.crossVectors(A,C);const b=E.dot(l[I])<0?-1:1;o.setXYZW(I,M.x,M.y,M.z,b)}for(let I=0,C=w.length;I<C;++I){const _=w[I],b=_.start,W=_.count;for(let z=b,G=b+W;z<G;z+=3)T(e.getX(z+0)),T(e.getX(z+1)),T(e.getX(z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new xi(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,m=i.count;p<m;p++)i.setXYZ(p,0,0,0);const s=new ce,r=new ce,o=new ce,a=new ce,l=new ce,c=new ce,h=new ce,f=new ce;if(e)for(let p=0,m=e.count;p<m;p+=3){const g=e.getX(p+0),x=e.getX(p+1),d=e.getX(p+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,d),h.subVectors(o,r),f.subVectors(s,r),h.cross(f),a.fromBufferAttribute(i,g),l.fromBufferAttribute(i,x),c.fromBufferAttribute(i,d),a.add(h),l.add(h),c.add(h),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(x,l.x,l.y,l.z),i.setXYZ(d,c.x,c.y,c.z)}else for(let p=0,m=t.count;p<m;p+=3)s.fromBufferAttribute(t,p+0),r.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),h.subVectors(o,r),f.subVectors(s,r),h.cross(f),i.setXYZ(p+0,h.x,h.y,h.z),i.setXYZ(p+1,h.x,h.y,h.z),i.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Jt.fromBufferAttribute(e,t),Jt.normalize(),e.setXYZ(t,Jt.x,Jt.y,Jt.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,f=a.normalized,p=new c.constructor(l.length*h);let m=0,g=0;for(let x=0,d=l.length;x<d;x++){a.isInterleavedBufferAttribute?m=l[x]*a.data.stride+a.offset:m=l[x]*h;for(let u=0;u<h;u++)p[g++]=c[m++]}return new xi(p,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new c_,i=this.index.array,s=this.attributes;for(const a in s){const l=s[a],c=e(l,i);t.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let h=0,f=c.length;h<f;h++){const p=c[h],m=e(p,i);l.push(m)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,p=c.length;f<p;f++){const m=c[f];h.push(m.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const s=e.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],f=r[c];for(let p=0,m=f.length;p<m;p++)h.push(f[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const If=new qt,Us=new s_,ka=new Td,Uf=new ce,Ba=new ce,Ha=new ce,Va=new ce,zc=new ce,Ga=new ce,Nf=new ce,Wa=new ce;let Hn=class extends Qi{constructor(e=new Eo,t=new va){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){const a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,s=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(s,e);const a=this.morphTargetInfluences;if(r&&a){Ga.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=a[l],f=r[l];h!==0&&(zc.fromBufferAttribute(f,e),o?Ga.addScaledVector(zc,h):Ga.addScaledVector(zc.sub(t),h))}t.add(Ga)}return t}raycast(e,t){const i=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ka.copy(i.boundingSphere),ka.applyMatrix4(r),Us.copy(e.ray).recast(e.near),!(ka.containsPoint(Us.origin)===!1&&(Us.intersectSphere(ka,Uf)===null||Us.origin.distanceToSquared(Uf)>(e.far-e.near)**2))&&(If.copy(r).invert(),Us.copy(e.ray).applyMatrix4(If),!(i.boundingBox!==null&&Us.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Us)))}_computeIntersections(e,t,i){let s;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,f=r.attributes.normal,p=r.groups,m=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,x=p.length;g<x;g++){const d=p[g],u=o[d.materialIndex],w=Math.max(d.start,m.start),M=Math.min(a.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,N=M;E<N;E+=3){const A=a.getX(E),T=a.getX(E+1),I=a.getX(E+2);s=$a(this,u,e,i,c,h,f,A,T,I),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,m.start),x=Math.min(a.count,m.start+m.count);for(let d=g,u=x;d<u;d+=3){const w=a.getX(d),M=a.getX(d+1),E=a.getX(d+2);s=$a(this,o,e,i,c,h,f,w,M,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,x=p.length;g<x;g++){const d=p[g],u=o[d.materialIndex],w=Math.max(d.start,m.start),M=Math.min(l.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,N=M;E<N;E+=3){const A=E,T=E+1,I=E+2;s=$a(this,u,e,i,c,h,f,A,T,I),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let d=g,u=x;d<u;d+=3){const w=d,M=d+1,E=d+2;s=$a(this,o,e,i,c,h,f,w,M,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}}};function yy(n,e,t,i,s,r,o,a){let l;if(e.side===Sn?l=i.intersectTriangle(o,r,s,!0,a):l=i.intersectTriangle(s,r,o,e.side===xs,a),l===null)return null;Wa.copy(a),Wa.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Wa);return c<t.near||c>t.far?null:{distance:c,point:Wa.clone(),object:n}}function $a(n,e,t,i,s,r,o,a,l,c){n.getVertexPosition(a,Ba),n.getVertexPosition(l,Ha),n.getVertexPosition(c,Va);const h=yy(n,e,t,i,Ba,Ha,Va,Nf);if(h){const f=new ce;Uo.getBarycoord(Nf,Ba,Ha,Va,f),s&&(h.uv=Uo.getInterpolatedAttribute(s,a,l,c,f,new Dt)),r&&(h.uv1=Uo.getInterpolatedAttribute(r,a,l,c,f,new Dt)),o&&(h.normal=Uo.getInterpolatedAttribute(o,a,l,c,f,new ce),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const p={a,b:l,c,normal:new ce,materialIndex:0};Uo.getNormal(Ba,Ha,Va,p.normal),h.face=p,h.barycoord=f}return h}let Cd=class h_ extends Eo{constructor(e=1,t=1,i=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:r,depthSegments:o};const a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],h=[],f=[];let p=0,m=0;g("z","y","x",-1,-1,i,t,e,o,r,0),g("z","y","x",1,-1,i,t,-e,o,r,1),g("x","z","y",1,1,e,i,t,s,o,2),g("x","z","y",1,-1,e,i,-t,s,o,3),g("x","y","z",1,-1,e,t,i,s,r,4),g("x","y","z",-1,-1,e,t,-i,s,r,5),this.setIndex(l),this.setAttribute("position",new Mi(c,3)),this.setAttribute("normal",new Mi(h,3)),this.setAttribute("uv",new Mi(f,2));function g(x,d,u,w,M,E,N,A,T,I,C){const _=E/T,b=N/I,W=E/2,z=N/2,G=A/2,K=T+1,H=I+1;let ie=0,B=0;const ue=new ce;for(let me=0;me<H;me++){const Me=me*b-z;for(let Ge=0;Ge<K;Ge++){const Qe=Ge*_-W;ue[x]=Qe*w,ue[d]=Me*M,ue[u]=G,c.push(ue.x,ue.y,ue.z),ue[x]=0,ue[d]=0,ue[u]=A>0?1:-1,h.push(ue.x,ue.y,ue.z),f.push(Ge/T),f.push(1-me/I),ie+=1}}for(let me=0;me<I;me++)for(let Me=0;Me<T;Me++){const Ge=p+Me+K*me,Qe=p+Me+K*(me+1),$=p+(Me+1)+K*(me+1),te=p+(Me+1)+K*me;l.push(Ge,Qe,te),l.push(Qe,$,te),B+=6}a.addGroup(m,B,C),m+=B,p+=ie}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new h_(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function lo(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const s=n[t][i];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=s.clone():Array.isArray(s)?e[t][i]=s.slice():e[t][i]=s}}return e}function _n(n){const e={};for(let t=0;t<n.length;t++){const i=lo(n[t]);for(const s in i)e[s]=i[s]}return e}function Sy(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function u_(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:St.workingColorSpace}const by={clone:lo,merge:_n};var wy=`void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,Ty=`void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`;let ys=class extends nc{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=wy,this.fragmentShader=Ty,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=lo(e.uniforms),this.uniformsGroups=Sy(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},d_=class extends Qi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qt,this.projectionMatrix=new qt,this.projectionMatrixInverse=new qt,this.coordinateSystem=ki}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const ts=new ce,Ff=new Dt,Of=new Dt;let On=class extends d_{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ua*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Xo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ua*2*Math.atan(Math.tan(Xo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ts.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ts.x,ts.y).multiplyScalar(-e/ts.z),ts.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ts.x,ts.y).multiplyScalar(-e/ts.z)}getViewSize(e,t){return this.getViewBounds(e,Ff,Of),t.subVectors(Of,Ff)}setViewOffset(e,t,i,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Xo*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*i/c,s*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};const xr=-90,Mr=1;let Ay=class extends Qi{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new On(xr,Mr,e,t);s.layers=this.layers,this.add(s);const r=new On(xr,Mr,e,t);r.layers=this.layers,this.add(r);const o=new On(xr,Mr,e,t);o.layers=this.layers,this.add(o);const a=new On(xr,Mr,e,t);a.layers=this.layers,this.add(a);const l=new On(xr,Mr,e,t);l.layers=this.layers,this.add(l);const c=new On(xr,Mr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===ki)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Vl)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,h]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,r),e.setRenderTarget(i,1,s),e.render(t,o),e.setRenderTarget(i,2,s),e.render(t,a),e.setRenderTarget(i,3,s),e.render(t,l),e.setRenderTarget(i,4,s),e.render(t,c),i.texture.generateMipmaps=x,e.setRenderTarget(i,5,s),e.render(t,h),e.setRenderTarget(f,p,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}},f_=class extends ai{constructor(e,t,i,s,r,o,a,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:so,super(e,t,i,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Cy=class extends Ms{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new f_(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:kn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={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 <begin_vertex> #include <project_vertex> } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include <common> void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},s=new Cd(5,5,5),r=new ys({name:"CubemapFromEquirect",uniforms:lo(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Sn,blending:ds});r.uniforms.tEquirect.value=t;const o=new Hn(s,r),a=t.minFilter;return t.minFilter===us&&(t.minFilter=kn),new Ay(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,s){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,s);e.setRenderTarget(r)}};const kc=new ce,Ry=new ce,Py=new gt;let Ws=class{constructor(e=new ce(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=kc.subVectors(i,t).cross(Ry.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(kc),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Py.getNormalMatrix(e),s=this.coplanarPoint(kc).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Ns=new Td,qa=new ce;let Rd=class{constructor(e=new Ws,t=new Ws,i=new Ws,s=new Ws,r=new Ws,o=new Ws){this.planes=[e,t,i,s,r,o]}set(e,t,i,s,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ki){const i=this.planes,s=e.elements,r=s[0],o=s[1],a=s[2],l=s[3],c=s[4],h=s[5],f=s[6],p=s[7],m=s[8],g=s[9],x=s[10],d=s[11],u=s[12],w=s[13],M=s[14],E=s[15];if(i[0].setComponents(l-r,p-c,d-m,E-u).normalize(),i[1].setComponents(l+r,p+c,d+m,E+u).normalize(),i[2].setComponents(l+o,p+h,d+g,E+w).normalize(),i[3].setComponents(l-o,p-h,d-g,E-w).normalize(),i[4].setComponents(l-a,p-f,d-x,E-M).normalize(),t===ki)i[5].setComponents(l+a,p+f,d+x,E+M).normalize();else if(t===Vl)i[5].setComponents(a,f,x,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ns.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ns.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ns)}intersectsSprite(e){return Ns.center.set(0,0,0),Ns.radius=.7071067811865476,Ns.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ns)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const s=t[i];if(qa.x=s.normal.x>0?e.max.x:e.min.x,qa.y=s.normal.y>0?e.max.y:e.min.y,qa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(qa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function p_(){let n=null,e=!1,t=null,i=null;function s(r,o){t(r,o),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function Ly(n){const e=new WeakMap;function t(a,l){const c=a.array,h=a.usage,f=c.byteLength,p=n.createBuffer();n.bindBuffer(l,p),n.bufferData(l,c,h),a.onUploadCallback();let m;if(c instanceof Float32Array)m=n.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=n.SHORT;else if(c instanceof Uint32Array)m=n.UNSIGNED_INT;else if(c instanceof Int32Array)m=n.INT;else if(c instanceof Int8Array)m=n.BYTE;else if(c instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,l,c){const h=l.array,f=l.updateRanges;if(n.bindBuffer(c,a),f.length===0)n.bufferSubData(c,0,h);else{f.sort((m,g)=>m.start-g.start);let p=0;for(let m=1;m<f.length;m++){const g=f[p],x=f[m];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++p,f[p]=x)}f.length=p+1;for(let m=0,g=f.length;m<g;m++){const x=f[m];n.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}let m_=class __ extends Eo{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,o=t/2,a=Math.floor(i),l=Math.floor(s),c=a+1,h=l+1,f=e/a,p=t/l,m=[],g=[],x=[],d=[];for(let u=0;u<h;u++){const w=u*p-o;for(let M=0;M<c;M++){const E=M*f-r;g.push(E,-w,0),x.push(0,0,1),d.push(M/a),d.push(1-u/l)}}for(let u=0;u<l;u++)for(let w=0;w<a;w++){const M=w+c*u,E=w+c*(u+1),N=w+1+c*(u+1),A=w+1+c*u;m.push(M,E,A),m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new Mi(g,3)),this.setAttribute("normal",new Mi(x,3)),this.setAttribute("uv",new Mi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new __(e.width,e.height,e.widthSegments,e.heightSegments)}};var Dy=`#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`,Iy=`#ifdef USE_ALPHAHASH const float ALPHA_HASH_SCALE = 0.05; float hash2D( vec2 value ) { return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); } float hash3D( vec3 value ) { return hash2D( vec2( hash2D( value.xy ), value.z ) ); } float getAlphaHashThreshold( vec3 position ) { float maxDeriv = max( length( dFdx( position.xyz ) ), length( dFdy( position.xyz ) ) ); float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); vec2 pixScales = vec2( exp2( floor( log2( pixScale ) ) ), exp2( ceil( log2( pixScale ) ) ) ); vec2 alpha = vec2( hash3D( floor( pixScales.x * position.xyz ) ), hash3D( floor( pixScales.y * position.xyz ) ) ); float lerpFactor = fract( log2( pixScale ) ); float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; float a = min( lerpFactor, 1.0 - lerpFactor ); vec3 cases = vec3( x * x / ( 2.0 * a * ( 1.0 - a ) ), ( x - 0.5 * a ) / ( 1.0 - a ), 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) ); float threshold = ( x < ( 1.0 - a ) ) ? ( ( x < a ) ? cases.x : cases.y ) : cases.z; return clamp( threshold , 1.0e-6, 1.0 ); } #endif`,Uy=`#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`,Ny=`#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,Fy=`#ifdef USE_ALPHATEST #ifdef ALPHA_TO_COVERAGE diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); if ( diffuseColor.a == 0.0 ) discard; #else if ( diffuseColor.a < alphaTest ) discard; #endif #endif`,Oy=`#ifdef USE_ALPHATEST uniform float alphaTest; #endif`,zy=`#ifdef USE_AOMAP float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_CLEARCOAT ) clearcoatSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_SHEEN ) sheenSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif #endif`,ky=`#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`,By=`#ifdef USE_BATCHING #if ! defined( GL_ANGLE_multi_draw ) #define gl_DrawID _gl_DrawID uniform int _gl_DrawID; #endif uniform highp sampler2D batchingTexture; uniform highp usampler2D batchingIdTexture; mat4 getBatchingMatrix( const in float i ) { int size = textureSize( batchingTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } float getIndirectIndex( const in int i ) { int size = textureSize( batchingIdTexture, 0 ).x; int x = i % size; int y = i / size; return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); } #endif #ifdef USE_BATCHING_COLOR uniform sampler2D batchingColorTexture; vec3 getBatchingColor( const in float i ) { int size = textureSize( batchingColorTexture, 0 ).x; int j = int( i ); int x = j % size; int y = j / size; return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb; } #endif`,Hy=`#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); #endif`,Vy=`vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`,Gy=`vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`,Wy=`float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } // validated`,$y=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,qy=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vBumpMapUv ); vec2 dSTdy = dFdy( vBumpMapUv ); float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,Xy=`#if NUM_CLIPPING_PLANES > 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`,Yy=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,Qy=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,jy=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,Zy=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,Ky=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,Jy=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,eS=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,tS=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } 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`,nS=`#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`,iS=`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`,sS=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,rS=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,oS=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,aS=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,lS="gl_FragColor = linearToOutputTexel( gl_FragColor );",cS=` const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( vec3( 0.8224621, 0.177538, 0.0 ), vec3( 0.0331941, 0.9668058, 0.0 ), vec3( 0.0170827, 0.0723974, 0.9105199 ) ); const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( vec3( 1.2249401, - 0.2249404, 0.0 ), vec3( - 0.0420569, 1.0420571, 0.0 ), vec3( - 0.0196376, - 0.0786361, 1.0982735 ) ); vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); } vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); } vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,hS=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,uS=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,dS=`#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`,fS=`#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`,pS=`#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`,mS=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,_S=`#ifdef USE_FOG varying float vFogDepth; #endif`,gS=`#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`,vS=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,xS=`#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 }`,MS=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,ES=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,yS=`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`,SS=`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`,bS=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,wS=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,TS=`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`,AS=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,CS=`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`,RS=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,PS=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,LS=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,DS=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,IS=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,US=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,NS=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,FS=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,OS=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,zS=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,kS=`#ifdef USE_MAP uniform sampler2D map; #endif`,BS=`#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`,HS=`#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`,VS=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,GS=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,WS=`#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`,$S=`#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`,qS=`#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`,XS=`#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`,YS=`#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`,QS=`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;`,jS=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,ZS=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,KS=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,JS=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,eb=`#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`,tb=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,nb=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,ib=`#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`,sb=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,rb=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ob=`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 ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,ab=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,lb=`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;`,cb=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,hb=`#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`,ub=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,db=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,fb=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,pb=`#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`,mb=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,_b=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,gb=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,vb=`#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`,xb=`#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`,Mb=`#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`,Eb=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,yb=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,Sb=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,bb=`#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; }`,wb=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,Tb=`#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`,Ab=`#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`,Cb=`#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`,Rb=`#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`,Pb=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const Lb=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,Db=`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 <tonemapping_fragment> #include <colorspace_fragment> }`,Ib=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,Ub=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include <cube_uv_reflection_fragment> void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include <tonemapping_fragment> #include <colorspace_fragment> }`,Nb=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,Fb=`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 <tonemapping_fragment> #include <colorspace_fragment> }`,Ob=`#include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> varying vec2 vHighPrecisionZW; void main() { #include <uv_vertex> #include <batching_vertex> #include <skinbase_vertex> #include <morphinstance_vertex> #ifdef USE_DISPLACEMENTMAP #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vHighPrecisionZW = gl_Position.zw; }`,zb=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include <common> #include <packing> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include <clipping_planes_fragment> #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <logdepthbuf_fragment> float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #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 }`,kb=`#define DISTANCE varying vec3 vWorldPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <batching_vertex> #include <skinbase_vertex> #include <morphinstance_vertex> #ifdef USE_DISPLACEMENTMAP #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <worldpos_vertex> #include <clipping_planes_vertex> vWorldPosition = worldPosition.xyz; }`,Bb=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include <common> #include <packing> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <clipping_planes_pars_fragment> void main () { vec4 diffuseColor = vec4( 1.0 ); #include <clipping_planes_fragment> #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,Hb=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> }`,Vb=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include <common> void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include <tonemapping_fragment> #include <colorspace_fragment> }`,Gb=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include <common> #include <uv_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { vLineDistance = scale * lineDistance; #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> }`,Wb=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include <common> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> }`,$b=`#include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <worldpos_vertex> #include <envmap_vertex> #include <fog_vertex> }`,qb=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include <common> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> 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 <aomap_fragment> reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,Xb=`#define LAMBERT varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <envmap_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,Yb=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_lambert_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_lambert_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,Qb=`#define MATCAP varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <color_pars_vertex> #include <displacementmap_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> vViewPosition = - mvPosition.xyz; }`,jb=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include <common> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <normal_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> 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 <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,Zb=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,Kb=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include <packing> #include <uv_pars_fragment> #include <normal_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,Jb=`#define PHONG varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <envmap_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,ew=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_phong_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_phong_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,tw=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,nw=`#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 <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <iridescence_fragment> #include <cube_uv_reflection_fragment> #include <envmap_common_pars_fragment> #include <envmap_physical_pars_fragment> #include <fog_pars_fragment> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_physical_pars_fragment> #include <transmission_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <clearcoat_pars_fragment> #include <iridescence_pars_fragment> #include <roughnessmap_pars_fragment> #include <metalnessmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <roughnessmap_fragment> #include <metalnessmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <clearcoat_normal_fragment_begin> #include <clearcoat_normal_fragment_maps> #include <emissivemap_fragment> #include <lights_physical_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include <transmission_fragment> vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,iw=`#define TOON varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,sw=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <gradientmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_toon_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_toon_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,rw=`uniform float size; uniform float scale; #include <common> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> #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 <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <project_vertex> gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <worldpos_vertex> #include <fog_vertex> }`,ow=`uniform vec3 diffuse; uniform float opacity; #include <common> #include <color_pars_fragment> #include <map_particle_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_particle_fragment> #include <color_fragment> #include <alphatest_fragment> #include <alphahash_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> }`,aw=`#include <common> #include <batching_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <shadowmap_pars_vertex> void main() { #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,lw=`uniform vec3 color; uniform float opacity; #include <common> #include <packing> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <logdepthbuf_pars_fragment> #include <shadowmap_pars_fragment> #include <shadowmask_pars_fragment> void main() { #include <logdepthbuf_fragment> gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> }`,cw=`uniform float rotation; uniform vec2 center; #include <common> #include <uv_pars_vertex> #include <fog_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> 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 <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> }`,hw=`uniform vec3 diffuse; uniform float opacity; #include <common> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> }`,dt={alphahash_fragment:Dy,alphahash_pars_fragment:Iy,alphamap_fragment:Uy,alphamap_pars_fragment:Ny,alphatest_fragment:Fy,alphatest_pars_fragment:Oy,aomap_fragment:zy,aomap_pars_fragment:ky,batching_pars_vertex:By,batching_vertex:Hy,begin_vertex:Vy,beginnormal_vertex:Gy,bsdfs:Wy,iridescence_fragment:$y,bumpmap_pars_fragment:qy,clipping_planes_fragment:Xy,clipping_planes_pars_fragment:Yy,clipping_planes_pars_vertex:Qy,clipping_planes_vertex:jy,color_fragment:Zy,color_pars_fragment:Ky,color_pars_vertex:Jy,color_vertex:eS,common:tS,cube_uv_reflection_fragment:nS,defaultnormal_vertex:iS,displacementmap_pars_vertex:sS,displacementmap_vertex:rS,emissivemap_fragment:oS,emissivemap_pars_fragment:aS,colorspace_fragment:lS,colorspace_pars_fragment:cS,envmap_fragment:hS,envmap_common_pars_fragment:uS,envmap_pars_fragment:dS,envmap_pars_vertex:fS,envmap_physical_pars_fragment:bS,envmap_vertex:pS,fog_vertex:mS,fog_pars_vertex:_S,fog_fragment:gS,fog_pars_fragment:vS,gradientmap_pars_fragment:xS,lightmap_pars_fragment:MS,lights_lambert_fragment:ES,lights_lambert_pars_fragment:yS,lights_pars_begin:SS,lights_toon_fragment:wS,lights_toon_pars_fragment:TS,lights_phong_fragment:AS,lights_phong_pars_fragment:CS,lights_physical_fragment:RS,lights_physical_pars_fragment:PS,lights_fragment_begin:LS,lights_fragment_maps:DS,lights_fragment_end:IS,logdepthbuf_fragment:US,logdepthbuf_pars_fragment:NS,logdepthbuf_pars_vertex:FS,logdepthbuf_vertex:OS,map_fragment:zS,map_pars_fragment:kS,map_particle_fragment:BS,map_particle_pars_fragment:HS,metalnessmap_fragment:VS,metalnessmap_pars_fragment:GS,morphinstance_vertex:WS,morphcolor_vertex:$S,morphnormal_vertex:qS,morphtarget_pars_vertex:XS,morphtarget_vertex:YS,normal_fragment_begin:QS,normal_fragment_maps:jS,normal_pars_fragment:ZS,normal_pars_vertex:KS,normal_vertex:JS,normalmap_pars_fragment:eb,clearcoat_normal_fragment_begin:tb,clearcoat_normal_fragment_maps:nb,clearcoat_pars_fragment:ib,iridescence_pars_fragment:sb,opaque_fragment:rb,packing:ob,premultiplied_alpha_fragment:ab,project_vertex:lb,dithering_fragment:cb,dithering_pars_fragment:hb,roughnessmap_fragment:ub,roughnessmap_pars_fragment:db,shadowmap_pars_fragment:fb,shadowmap_pars_vertex:pb,shadowmap_vertex:mb,shadowmask_pars_fragment:_b,skinbase_vertex:gb,skinning_pars_vertex:vb,skinning_vertex:xb,skinnormal_vertex:Mb,specularmap_fragment:Eb,specularmap_pars_fragment:yb,tonemapping_fragment:Sb,tonemapping_pars_fragment:bb,transmission_fragment:wb,transmission_pars_fragment:Tb,uv_pars_fragment:Ab,uv_pars_vertex:Cb,uv_vertex:Rb,worldpos_vertex:Pb,background_vert:Lb,background_frag:Db,backgroundCube_vert:Ib,backgroundCube_frag:Ub,cube_vert:Nb,cube_frag:Fb,depth_vert:Ob,depth_frag:zb,distanceRGBA_vert:kb,distanceRGBA_frag:Bb,equirect_vert:Hb,equirect_frag:Vb,linedashed_vert:Gb,linedashed_frag:Wb,meshbasic_vert:$b,meshbasic_frag:qb,meshlambert_vert:Xb,meshlambert_frag:Yb,meshmatcap_vert:Qb,meshmatcap_frag:jb,meshnormal_vert:Zb,meshnormal_frag:Kb,meshphong_vert:Jb,meshphong_frag:ew,meshphysical_vert:tw,meshphysical_frag:nw,meshtoon_vert:iw,meshtoon_frag:sw,points_vert:rw,points_frag:ow,shadow_vert:aw,shadow_frag:lw,sprite_vert:cw,sprite_frag:hw},ze={common:{diffuse:{value:new Rt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gt}},envmap:{envMap:{value:null},envMapRotation:{value:new gt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new gt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gt},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Rt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0},uvTransform:{value:new gt}},sprite:{diffuse:{value:new Rt(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}}},pi={basic:{uniforms:_n([ze.common,ze.specularmap,ze.envmap,ze.aomap,ze.lightmap,ze.fog]),vertexShader:dt.meshbasic_vert,fragmentShader:dt.meshbasic_frag},lambert:{uniforms:_n([ze.common,ze.specularmap,ze.envmap,ze.aomap,ze.lightmap,ze.emissivemap,ze.bumpmap,ze.normalmap,ze.displacementmap,ze.fog,ze.lights,{emissive:{value:new Rt(0)}}]),vertexShader:dt.meshlambert_vert,fragmentShader:dt.meshlambert_frag},phong:{uniforms:_n([ze.common,ze.specularmap,ze.envmap,ze.aomap,ze.lightmap,ze.emissivemap,ze.bumpmap,ze.normalmap,ze.displacementmap,ze.fog,ze.lights,{emissive:{value:new Rt(0)},specular:{value:new Rt(1118481)},shininess:{value:30}}]),vertexShader:dt.meshphong_vert,fragmentShader:dt.meshphong_frag},standard:{uniforms:_n([ze.common,ze.envmap,ze.aomap,ze.lightmap,ze.emissivemap,ze.bumpmap,ze.normalmap,ze.displacementmap,ze.roughnessmap,ze.metalnessmap,ze.fog,ze.lights,{emissive:{value:new Rt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag},toon:{uniforms:_n([ze.common,ze.aomap,ze.lightmap,ze.emissivemap,ze.bumpmap,ze.normalmap,ze.displacementmap,ze.gradientmap,ze.fog,ze.lights,{emissive:{value:new Rt(0)}}]),vertexShader:dt.meshtoon_vert,fragmentShader:dt.meshtoon_frag},matcap:{uniforms:_n([ze.common,ze.bumpmap,ze.normalmap,ze.displacementmap,ze.fog,{matcap:{value:null}}]),vertexShader:dt.meshmatcap_vert,fragmentShader:dt.meshmatcap_frag},points:{uniforms:_n([ze.points,ze.fog]),vertexShader:dt.points_vert,fragmentShader:dt.points_frag},dashed:{uniforms:_n([ze.common,ze.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dt.linedashed_vert,fragmentShader:dt.linedashed_frag},depth:{uniforms:_n([ze.common,ze.displacementmap]),vertexShader:dt.depth_vert,fragmentShader:dt.depth_frag},normal:{uniforms:_n([ze.common,ze.bumpmap,ze.normalmap,ze.displacementmap,{opacity:{value:1}}]),vertexShader:dt.meshnormal_vert,fragmentShader:dt.meshnormal_frag},sprite:{uniforms:_n([ze.sprite,ze.fog]),vertexShader:dt.sprite_vert,fragmentShader:dt.sprite_frag},background:{uniforms:{uvTransform:{value:new gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dt.background_vert,fragmentShader:dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new gt}},vertexShader:dt.backgroundCube_vert,fragmentShader:dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dt.cube_vert,fragmentShader:dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dt.equirect_vert,fragmentShader:dt.equirect_frag},distanceRGBA:{uniforms:_n([ze.common,ze.displacementmap,{referencePosition:{value:new ce},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dt.distanceRGBA_vert,fragmentShader:dt.distanceRGBA_frag},shadow:{uniforms:_n([ze.lights,ze.fog,{color:{value:new Rt(0)},opacity:{value:1}}]),vertexShader:dt.shadow_vert,fragmentShader:dt.shadow_frag}};pi.physical={uniforms:_n([pi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gt},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gt},sheen:{value:0},sheenColor:{value:new Rt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gt},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gt},attenuationDistance:{value:0},attenuationColor:{value:new Rt(0)},specularColor:{value:new Rt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gt},anisotropyVector:{value:new Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gt}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag};const Xa={r:0,b:0,g:0},Fs=new Es,uw=new qt;function dw(n,e,t,i,s,r,o){const a=new Rt(0);let l=r===!0?0:1,c,h,f=null,p=0,m=null;function g(w){let M=w.isScene===!0?w.background:null;return M&&M.isTexture&&(M=(w.backgroundBlurriness>0?t:e).get(M)),M}function x(w){let M=!1;const E=g(w);E===null?u(a,l):E&&E.isColor&&(u(E,1),M=!0);const N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||M)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function d(w,M){const E=g(M);E&&(E.isCubeTexture||E.mapping===ec)?(h===void 0&&(h=new Hn(new Cd(1,1,1),new ys({name:"BackgroundCubeMaterial",uniforms:lo(pi.backgroundCube.uniforms),vertexShader:pi.backgroundCube.vertexShader,fragmentShader:pi.backgroundCube.fragmentShader,side:Sn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(N,A,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),Fs.copy(M.backgroundRotation),Fs.x*=-1,Fs.y*=-1,Fs.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Fs.y*=-1,Fs.z*=-1),h.material.uniforms.envMap.value=E,h.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(uw.makeRotationFromEuler(Fs)),h.material.toneMapped=St.getTransfer(E.colorSpace)!==It,(f!==E||p!==E.version||m!==n.toneMapping)&&(h.material.needsUpdate=!0,f=E,p=E.version,m=n.toneMapping),h.layers.enableAll(),w.unshift(h,h.geometry,h.material,0,0,null)):E&&E.isTexture&&(c===void 0&&(c=new Hn(new m_(2,2),new ys({name:"BackgroundMaterial",uniforms:lo(pi.background.uniforms),vertexShader:pi.background.vertexShader,fragmentShader:pi.background.fragmentShader,side:xs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=E,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.toneMapped=St.getTransfer(E.colorSpace)!==It,E.matrixAutoUpdate===!0&&E.updateMatrix(),c.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||p!==E.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,f=E,p=E.version,m=n.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function u(w,M){w.getRGB(Xa,u_(n)),i.buffers.color.setClear(Xa.r,Xa.g,Xa.b,M,o)}return{getClearColor:function(){return a},setClearColor:function(w,M=1){a.set(w),l=M,u(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,u(a,l)},render:x,addToRenderList:d}}function fw(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=p(null);let r=s,o=!1;function a(_,b,W,z,G){let K=!1;const H=f(z,W,b);r!==H&&(r=H,c(r.object)),K=m(_,z,W,G),K&&g(_,z,W,G),G!==null&&e.update(G,n.ELEMENT_ARRAY_BUFFER),(K||o)&&(o=!1,E(_,b,W,z),G!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(G).buffer))}function l(){return n.createVertexArray()}function c(_){return n.bindVertexArray(_)}function h(_){return n.deleteVertexArray(_)}function f(_,b,W){const z=W.wireframe===!0;let G=i[_.id];G===void 0&&(G={},i[_.id]=G);let K=G[b.id];K===void 0&&(K={},G[b.id]=K);let H=K[z];return H===void 0&&(H=p(l()),K[z]=H),H}function p(_){const b=[],W=[],z=[];for(let G=0;G<t;G++)b[G]=0,W[G]=0,z[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:W,attributeDivisors:z,object:_,attributes:{},index:null}}function m(_,b,W,z){const G=r.attributes,K=b.attributes;let H=0;const ie=W.getAttributes();for(const B in ie)if(ie[B].location>=0){const me=G[B];let Me=K[B];if(Me===void 0&&(B==="instanceMatrix"&&_.instanceMatrix&&(Me=_.instanceMatrix),B==="instanceColor"&&_.instanceColor&&(Me=_.instanceColor)),me===void 0||me.attribute!==Me||Me&&me.data!==Me.data)return!0;H++}return r.attributesNum!==H||r.index!==z}function g(_,b,W,z){const G={},K=b.attributes;let H=0;const ie=W.getAttributes();for(const B in ie)if(ie[B].location>=0){let me=K[B];me===void 0&&(B==="instanceMatrix"&&_.instanceMatrix&&(me=_.instanceMatrix),B==="instanceColor"&&_.instanceColor&&(me=_.instanceColor));const Me={};Me.attribute=me,me&&me.data&&(Me.data=me.data),G[B]=Me,H++}r.attributes=G,r.attributesNum=H,r.index=z}function x(){const _=r.newAttributes;for(let b=0,W=_.length;b<W;b++)_[b]=0}function d(_){u(_,0)}function u(_,b){const W=r.newAttributes,z=r.enabledAttributes,G=r.attributeDivisors;W[_]=1,z[_]===0&&(n.enableVertexAttribArray(_),z[_]=1),G[_]!==b&&(n.vertexAttribDivisor(_,b),G[_]=b)}function w(){const _=r.newAttributes,b=r.enabledAttributes;for(let W=0,z=b.length;W<z;W++)b[W]!==_[W]&&(n.disableVertexAttribArray(W),b[W]=0)}function M(_,b,W,z,G,K,H){H===!0?n.vertexAttribIPointer(_,b,W,G,K):n.vertexAttribPointer(_,b,W,z,G,K)}function E(_,b,W,z){x();const G=z.attributes,K=W.getAttributes(),H=b.defaultAttributeValues;for(const ie in K){const B=K[ie];if(B.location>=0){let ue=G[ie];if(ue===void 0&&(ie==="instanceMatrix"&&_.instanceMatrix&&(ue=_.instanceMatrix),ie==="instanceColor"&&_.instanceColor&&(ue=_.instanceColor)),ue!==void 0){const me=ue.normalized,Me=ue.itemSize,Ge=e.get(ue);if(Ge===void 0)continue;const Qe=Ge.buffer,$=Ge.type,te=Ge.bytesPerElement,ve=$===n.INT||$===n.UNSIGNED_INT||ue.gpuType===vd;if(ue.isInterleavedBufferAttribute){const de=ue.data,Pe=de.stride,Le=ue.offset;if(de.isInstancedInterleavedBuffer){for(let He=0;He<B.locationSize;He++)u(B.location+He,de.meshPerAttribute);_.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let He=0;He<B.locationSize;He++)d(B.location+He);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let He=0;He<B.locationSize;He++)M(B.location+He,Me/B.locationSize,$,me,Pe*te,(Le+Me/B.locationSize*He)*te,ve)}else{if(ue.isInstancedBufferAttribute){for(let de=0;de<B.locationSize;de++)u(B.location+de,ue.meshPerAttribute);_.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let de=0;de<B.locationSize;de++)d(B.location+de);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let de=0;de<B.locationSize;de++)M(B.location+de,Me/B.locationSize,$,me,Me*te,Me/B.locationSize*de*te,ve)}}else if(H!==void 0){const me=H[ie];if(me!==void 0)switch(me.length){case 2:n.vertexAttrib2fv(B.location,me);break;case 3:n.vertexAttrib3fv(B.location,me);break;case 4:n.vertexAttrib4fv(B.location,me);break;default:n.vertexAttrib1fv(B.location,me)}}}}w()}function N(){I();for(const _ in i){const b=i[_];for(const W in b){const z=b[W];for(const G in z)h(z[G].object),delete z[G];delete b[W]}delete i[_]}}function A(_){if(i[_.id]===void 0)return;const b=i[_.id];for(const W in b){const z=b[W];for(const G in z)h(z[G].object),delete z[G];delete b[W]}delete i[_.id]}function T(_){for(const b in i){const W=i[b];if(W[_.id]===void 0)continue;const z=W[_.id];for(const G in z)h(z[G].object),delete z[G];delete W[_.id]}}function I(){C(),o=!0,r!==s&&(r=s,c(r.object))}function C(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:I,resetDefaultState:C,dispose:N,releaseStatesOfGeometry:A,releaseStatesOfProgram:T,initAttributes:x,enableAttribute:d,disableUnusedAttributes:w}}function pw(n,e,t){let i;function s(c){i=c}function r(c,h){n.drawArrays(i,c,h),t.update(h,i,1)}function o(c,h,f){f!==0&&(n.drawArraysInstanced(i,c,h,f),t.update(h,i,f))}function a(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,f);let m=0;for(let g=0;g<f;g++)m+=h[g];t.update(m,i,1)}function l(c,h,f,p){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<c.length;g++)o(c[g],h[g],p[g]);else{m.multiDrawArraysInstancedWEBGL(i,c,0,h,0,p,0,f);let g=0;for(let x=0;x<f;x++)g+=h[x];for(let x=0;x<p.length;x++)t.update(g,i,p[x])}}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function mw(n,e,t,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");s=n.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(T){return!(T!==ti&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(T){const I=T===ga&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==$i&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==zi&&!I)}function l(T){if(T==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,p=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(p===!0){const T=e.get("EXT_clip_control");T.clipControlEXT(T.LOWER_LEFT_EXT,T.ZERO_TO_ONE_EXT)}const m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),d=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),u=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),M=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=g>0,A=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reverseDepthBuffer:p,maxTextures:m,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:d,maxAttributes:u,maxVertexUniforms:w,maxVaryings:M,maxFragmentUniforms:E,vertexTextures:N,maxSamples:A}}function _w(n){const e=this;let t=null,i=0,s=!1,r=!1;const o=new Ws,a=new gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||i!==0||s;return s=p,i=f.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,p){t=h(f,p,0)},this.setState=function(f,p,m){const g=f.clippingPlanes,x=f.clipIntersection,d=f.clipShadows,u=n.get(f);if(!s||g===null||g.length===0||r&&!d)r?h(null):c();else{const w=r?0:i,M=w*4;let E=u.clippingState||null;l.value=E,E=h(g,p,M,m);for(let N=0;N!==M;++N)E[N]=t[N];u.clippingState=E,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(f,p,m,g){const x=f!==null?f.length:0;let d=null;if(x!==0){if(d=l.value,g!==!0||d===null){const u=m+x*4,w=p.matrixWorldInverse;a.getNormalMatrix(w),(d===null||d.length<u)&&(d=new Float32Array(u));for(let M=0,E=m;M!==x;++M,E+=4)o.copy(f[M]).applyMatrix4(w,a),o.normal.toArray(d,E),d[E+3]=o.constant}l.value=d,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,d}}function gw(n){let e=new WeakMap;function t(o,a){return a===Nh?o.mapping=so:a===Fh&&(o.mapping=ro),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Nh||a===Fh)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new Cy(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){const a=o.target;a.removeEventListener("dispose",s);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}let vw=class extends d_{constructor(e=-1,t=1,i=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const Hr=4,zf=[.125,.215,.35,.446,.526,.582],Ys=20,Bc=new vw,kf=new Rt;let Hc=null,Vc=0,Gc=0,Wc=!1;const $s=(1+Math.sqrt(5))/2,Er=1/$s,Bf=[new ce(-$s,Er,0),new ce($s,Er,0),new ce(-Er,0,$s),new ce(Er,0,$s),new ce(0,$s,-Er),new ce(0,$s,Er),new ce(-1,1,-1),new ce(1,1,-1),new ce(-1,1,1),new ce(1,1,1)];let Hf=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,s=100){Hc=this._renderer.getRenderTarget(),Vc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Wc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Wf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Gf(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Hc,Vc,Gc),this._renderer.xr.enabled=Wc,e.scissorTest=!1,Ya(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===so||e.mapping===ro?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Hc=this._renderer.getRenderTarget(),Vc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Wc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:kn,minFilter:kn,generateMipmaps:!1,type:ga,format:ti,colorSpace:Yi,depthBuffer:!1},s=Vf(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Vf(e,t,i);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=xw(r)),this._blurMaterial=Mw(r,e,t)}return s}_compileMaterial(e){const t=new Hn(this._lodPlanes[0],e);this._renderer.compile(t,Bc)}_sceneToCubeUV(e,t,i,s){const a=new On(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(kf),h.toneMapping=fs,h.autoClear=!1;const m=new va({name:"PMREM.Background",side:Sn,depthWrite:!1,depthTest:!1}),g=new Hn(new Cd,m);let x=!1;const d=e.background;d?d.isColor&&(m.color.copy(d),e.background=null,x=!0):(m.color.copy(kf),x=!0);for(let u=0;u<6;u++){const w=u%3;w===0?(a.up.set(0,l[u],0),a.lookAt(c[u],0,0)):w===1?(a.up.set(0,0,l[u]),a.lookAt(0,c[u],0)):(a.up.set(0,l[u],0),a.lookAt(0,0,c[u]));const M=this._cubeSize;Ya(s,w*M,u>2?M:0,M,M),h.setRenderTarget(s),x&&h.render(g,a),h.render(e,a)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=p,h.autoClear=f,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===so||e.mapping===ro;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Wf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Gf());const r=s?this._cubemapMaterial:this._equirectMaterial,o=new Hn(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Ya(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,Bc)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Bf[(s-r-1)%Bf.length];this._blur(e,r-1,r,o,a)}t.autoClear=i}_blur(e,t,i,s,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,s,"latitudinal",r),this._halfBlur(o,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new Hn(this._lodPlanes[s],c),p=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*Ys-1),x=r/g,d=isFinite(r)?1+Math.floor(h*x):Ys;d>Ys&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${Ys}`);const u=[];let w=0;for(let T=0;T<Ys;++T){const I=T/x,C=Math.exp(-I*I/2);u.push(C),T===0?w+=C:T<d&&(w+=2*C)}for(let T=0;T<u.length;T++)u[T]=u[T]/w;p.envMap.value=e.texture,p.samples.value=d,p.weights.value=u,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:M}=this;p.dTheta.value=g,p.mipInt.value=M-i;const E=this._sizeLods[s],N=3*E*(s>M-Hr?s-M+Hr:0),A=4*(this._cubeSize-E);Ya(t,N,A,3*E,2*E),l.setRenderTarget(t),l.render(f,Bc)}};function xw(n){const e=[],t=[],i=[];let s=n;const r=n-Hr+1+zf.length;for(let o=0;o<r;o++){const a=Math.pow(2,s);t.push(a);let l=1/a;o>n-Hr?l=zf[o-n+Hr-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),h=-c,f=1+c,p=[h,h,f,h,f,f,h,h,f,f,h,f],m=6,g=6,x=3,d=2,u=1,w=new Float32Array(x*g*m),M=new Float32Array(d*g*m),E=new Float32Array(u*g*m);for(let A=0;A<m;A++){const T=A%3*2/3-1,I=A>2?0:-1,C=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];w.set(C,x*g*A),M.set(p,d*g*A);const _=[A,A,A,A,A,A];E.set(_,u*g*A)}const N=new Eo;N.setAttribute("position",new xi(w,x)),N.setAttribute("uv",new xi(M,d)),N.setAttribute("faceIndex",new xi(E,u)),e.push(N),s>Hr&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Vf(n,e,t){const i=new Ms(n,e,t);return i.texture.mapping=ec,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ya(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Mw(n,e,t){const i=new Float32Array(Ys),s=new ce(0,1,0);return new ys({name:"SphericalGaussianBlur",defines:{n:Ys,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Pd(),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 <cube_uv_reflection_fragment> 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:ds,depthTest:!1,depthWrite:!1})}function Gf(){return new ys({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Pd(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include <common> void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:ds,depthTest:!1,depthWrite:!1})}function Wf(){return new ys({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Pd(),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:ds,depthTest:!1,depthWrite:!1})}function Pd(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function Ew(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===Nh||l===Fh,h=l===so||l===ro;if(c||h){let f=e.get(a);const p=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==p)return t===null&&(t=new Hf(n)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),f.texture;if(f!==void 0)return f.texture;{const m=a.image;return c&&m&&m.height>0||h&&m&&s(m)?(t===null&&(t=new Hf(n)),f=c?t.fromEquirectangular(a):t.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),a.addEventListener("dispose",r),f.texture):null}}}return a}function s(a){let l=0;const c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function yw(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let s;switch(i){case"WEBGL_depth_texture":s=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=n.getExtension(i)}return e[i]=s,s}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const s=t(i);return s===null&&Tl("THREE.WebGLRenderer: "+i+" extension not supported."),s}}}function Sw(n,e,t,i){const s={},r=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const g in p.attributes)e.remove(p.attributes[g]);for(const g in p.morphAttributes){const x=p.morphAttributes[g];for(let d=0,u=x.length;d<u;d++)e.remove(x[d])}p.removeEventListener("dispose",o),delete s[p.id];const m=r.get(p);m&&(e.remove(m),r.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function a(f,p){return s[p.id]===!0||(p.addEventListener("dispose",o),s[p.id]=!0,t.memory.geometries++),p}function l(f){const p=f.attributes;for(const g in p)e.update(p[g],n.ARRAY_BUFFER);const m=f.morphAttributes;for(const g in m){const x=m[g];for(let d=0,u=x.length;d<u;d++)e.update(x[d],n.ARRAY_BUFFER)}}function c(f){const p=[],m=f.index,g=f.attributes.position;let x=0;if(m!==null){const w=m.array;x=m.version;for(let M=0,E=w.length;M<E;M+=3){const N=w[M+0],A=w[M+1],T=w[M+2];p.push(N,A,A,T,T,N)}}else if(g!==void 0){const w=g.array;x=g.version;for(let M=0,E=w.length/3-1;M<E;M+=3){const N=M+0,A=M+1,T=M+2;p.push(N,A,A,T,T,N)}}else return;const d=new(Jm(p)?l_:a_)(p,1);d.version=x;const u=r.get(f);u&&e.remove(u),r.set(f,d)}function h(f){const p=r.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&c(f)}else c(f);return r.get(f)}return{get:a,update:l,getWireframeAttribute:h}}function bw(n,e,t){let i;function s(p){i=p}let r,o;function a(p){r=p.type,o=p.bytesPerElement}function l(p,m){n.drawElements(i,m,r,p*o),t.update(m,i,1)}function c(p,m,g){g!==0&&(n.drawElementsInstanced(i,m,r,p*o,g),t.update(m,i,g))}function h(p,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,m,0,r,p,0,g);let d=0;for(let u=0;u<g;u++)d+=m[u];t.update(d,i,1)}function f(p,m,g,x){if(g===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let u=0;u<p.length;u++)c(p[u]/o,m[u],x[u]);else{d.multiDrawElementsInstancedWEBGL(i,m,0,r,p,0,x,0,g);let u=0;for(let w=0;w<g;w++)u+=m[w];for(let w=0;w<x.length;w++)t.update(u,i,x[w])}}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function ww(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(r/3);break;case n.LINES:t.lines+=a*(r/2);break;case n.LINE_STRIP:t.lines+=a*(r-1);break;case n.LINE_LOOP:t.lines+=a*r;break;case n.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:i}}function Tw(n,e,t){const i=new WeakMap,s=new $t;function r(o,a,l){const c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=h!==void 0?h.length:0;let p=i.get(a);if(p===void 0||p.count!==f){let C=function(){T.dispose(),i.delete(a),a.removeEventListener("dispose",C)};p!==void 0&&p.texture.dispose();const m=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,d=a.morphAttributes.position||[],u=a.morphAttributes.normal||[],w=a.morphAttributes.color||[];let M=0;m===!0&&(M=1),g===!0&&(M=2),x===!0&&(M=3);let E=a.attributes.position.count*M,N=1;E>e.maxTextureSize&&(N=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*N*4*f),T=new n_(A,E,N,f);T.type=zi,T.needsUpdate=!0;const I=M*4;for(let _=0;_<f;_++){const b=d[_],W=u[_],z=w[_],G=E*N*4*_;for(let K=0;K<b.count;K++){const H=K*I;m===!0&&(s.fromBufferAttribute(b,K),A[G+H+0]=s.x,A[G+H+1]=s.y,A[G+H+2]=s.z,A[G+H+3]=0),g===!0&&(s.fromBufferAttribute(W,K),A[G+H+4]=s.x,A[G+H+5]=s.y,A[G+H+6]=s.z,A[G+H+7]=0),x===!0&&(s.fromBufferAttribute(z,K),A[G+H+8]=s.x,A[G+H+9]=s.y,A[G+H+10]=s.z,A[G+H+11]=z.itemSize===4?s.w:1)}}p={count:f,texture:T,size:new Dt(E,N)},i.set(a,p),a.addEventListener("dispose",C)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let m=0;for(let x=0;x<c.length;x++)m+=c[x];const g=a.morphTargetsRelative?1:1-m;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",p.size)}return{update:r}}function Aw(n,e,t,i){let s=new WeakMap;function r(l){const c=i.render.frame,h=l.geometry,f=e.get(l,h);if(s.get(f)!==c&&(e.update(f),s.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),s.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;s.get(p)!==c&&(p.update(),s.set(p,c))}return f}function o(){s=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}let g_=class extends ai{constructor(e,t,i,s,r,o,a,l,c,h=jr){if(h!==jr&&h!==ao)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===jr&&(i=tr),i===void 0&&h===ao&&(i=oo),super(null,s,r,o,a,l,h,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Bn,this.minFilter=l!==void 0?l:Bn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};const v_=new ai,$f=new g_(1,1),x_=new n_,M_=new dy,E_=new f_,qf=[],Xf=[],Yf=new Float32Array(16),Qf=new Float32Array(9),jf=new Float32Array(4);function yo(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=qf[s];if(r===void 0&&(r=new Float32Array(s),qf[s]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(r,a)}return r}function Xt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Yt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function ic(n,e){let t=Xf[e];t===void 0&&(t=new Int32Array(e),Xf[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function Cw(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Rw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;n.uniform2fv(this.addr,e),Yt(t,e)}}function Pw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Xt(t,e))return;n.uniform3fv(this.addr,e),Yt(t,e)}}function Lw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;n.uniform4fv(this.addr,e),Yt(t,e)}}function Dw(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Xt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Yt(t,e)}else{if(Xt(t,i))return;jf.set(i),n.uniformMatrix2fv(this.addr,!1,jf),Yt(t,i)}}function Iw(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Xt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Yt(t,e)}else{if(Xt(t,i))return;Qf.set(i),n.uniformMatrix3fv(this.addr,!1,Qf),Yt(t,i)}}function Uw(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Xt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Yt(t,e)}else{if(Xt(t,i))return;Yf.set(i),n.uniformMatrix4fv(this.addr,!1,Yf),Yt(t,i)}}function Nw(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function Fw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;n.uniform2iv(this.addr,e),Yt(t,e)}}function Ow(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;n.uniform3iv(this.addr,e),Yt(t,e)}}function zw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;n.uniform4iv(this.addr,e),Yt(t,e)}}function kw(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function Bw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;n.uniform2uiv(this.addr,e),Yt(t,e)}}function Hw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;n.uniform3uiv(this.addr,e),Yt(t,e)}}function Vw(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;n.uniform4uiv(this.addr,e),Yt(t,e)}}function Gw(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s);let r;this.type===n.SAMPLER_2D_SHADOW?($f.compareFunction=jm,r=$f):r=v_,t.setTexture2D(e||r,s)}function Ww(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture3D(e||M_,s)}function $w(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTextureCube(e||E_,s)}function qw(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture2DArray(e||x_,s)}function Xw(n){switch(n){case 5126:return Cw;case 35664:return Rw;case 35665:return Pw;case 35666:return Lw;case 35674:return Dw;case 35675:return Iw;case 35676:return Uw;case 5124:case 35670:return Nw;case 35667:case 35671:return Fw;case 35668:case 35672:return Ow;case 35669:case 35673:return zw;case 5125:return kw;case 36294:return Bw;case 36295:return Hw;case 36296:return Vw;case 35678:case 36198:case 36298:case 36306:case 35682:return Gw;case 35679:case 36299:case 36307:return Ww;case 35680:case 36300:case 36308:case 36293:return $w;case 36289:case 36303:case 36311:case 36292:return qw}}function Yw(n,e){n.uniform1fv(this.addr,e)}function Qw(n,e){const t=yo(e,this.size,2);n.uniform2fv(this.addr,t)}function jw(n,e){const t=yo(e,this.size,3);n.uniform3fv(this.addr,t)}function Zw(n,e){const t=yo(e,this.size,4);n.uniform4fv(this.addr,t)}function Kw(n,e){const t=yo(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Jw(n,e){const t=yo(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function eT(n,e){const t=yo(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function tT(n,e){n.uniform1iv(this.addr,e)}function nT(n,e){n.uniform2iv(this.addr,e)}function iT(n,e){n.uniform3iv(this.addr,e)}function sT(n,e){n.uniform4iv(this.addr,e)}function rT(n,e){n.uniform1uiv(this.addr,e)}function oT(n,e){n.uniform2uiv(this.addr,e)}function aT(n,e){n.uniform3uiv(this.addr,e)}function lT(n,e){n.uniform4uiv(this.addr,e)}function cT(n,e,t){const i=this.cache,s=e.length,r=ic(t,s);Xt(i,r)||(n.uniform1iv(this.addr,r),Yt(i,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||v_,r[o])}function hT(n,e,t){const i=this.cache,s=e.length,r=ic(t,s);Xt(i,r)||(n.uniform1iv(this.addr,r),Yt(i,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||M_,r[o])}function uT(n,e,t){const i=this.cache,s=e.length,r=ic(t,s);Xt(i,r)||(n.uniform1iv(this.addr,r),Yt(i,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||E_,r[o])}function dT(n,e,t){const i=this.cache,s=e.length,r=ic(t,s);Xt(i,r)||(n.uniform1iv(this.addr,r),Yt(i,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||x_,r[o])}function fT(n){switch(n){case 5126:return Yw;case 35664:return Qw;case 35665:return jw;case 35666:return Zw;case 35674:return Kw;case 35675:return Jw;case 35676:return eT;case 5124:case 35670:return tT;case 35667:case 35671:return nT;case 35668:case 35672:return iT;case 35669:case 35673:return sT;case 5125:return rT;case 36294:return oT;case 36295:return aT;case 36296:return lT;case 35678:case 36198:case 36298:case 36306:case 35682:return cT;case 35679:case 36299:case 36307:return hT;case 35680:case 36300:case 36308:case 36293:return uT;case 36289:case 36303:case 36311:case 36292:return dT}}let pT=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=Xw(t.type)}},mT=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=fT(t.type)}},_T=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const s=this.seq;for(let r=0,o=s.length;r!==o;++r){const a=s[r];a.setValue(e,t[a.id],i)}}};const $c=/(\w+)(\])?(\[|\.)?/g;function Zf(n,e){n.seq.push(e),n.map[e.id]=e}function gT(n,e,t){const i=n.name,s=i.length;for($c.lastIndex=0;;){const r=$c.exec(i),o=$c.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){Zf(t,c===void 0?new pT(a,n,e):new mT(a,n,e));break}else{let f=t.map[a];f===void 0&&(f=new _T(a),Zf(t,f)),t=f}}}let Rl=class{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){const r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);gT(r,o,this)}}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const o=e[s];o.id in t&&i.push(o)}return i}};function Kf(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const vT=37297;let xT=0;function MT(n,e){const t=n.split(` `),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(` `)}function ET(n){const e=St.getPrimaries(St.workingColorSpace),t=St.getPrimaries(n);let i;switch(e===t?i="":e===Hl&&t===Bl?i="LinearDisplayP3ToLinearSRGB":e===Bl&&t===Hl&&(i="LinearSRGBToLinearDisplayP3"),n){case Yi:case tc:return[i,"LinearTransferOETF"];case di:case bd:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function Jf(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=n.getShaderInfoLog(e).trim();if(i&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const o=parseInt(r[1]);return t.toUpperCase()+` `+s+` `+MT(n.getShaderSource(e),o)}else return s}function yT(n,e){const t=ET(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function ST(n,e){let t;switch(e){case yE:t="Linear";break;case SE:t="Reinhard";break;case bE:t="Cineon";break;case wE:t="ACESFilmic";break;case AE:t="AgX";break;case CE:t="Neutral";break;case TE:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Qa=new ce;function bT(){St.getLuminanceCoefficients(Qa);const n=Qa.x.toFixed(4),e=Qa.y.toFixed(4),t=Qa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function wT(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Vo).join(` `)}function TT(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function AT(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const r=n.getActiveAttrib(e,s),o=r.name;let a=1;r.type===n.FLOAT_MAT2&&(a=2),r.type===n.FLOAT_MAT3&&(a=3),r.type===n.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function Vo(n){return n!==""}function ep(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function tp(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const CT=/^[ \t]*#include +<([\w\d./]+)>/gm;function du(n){return n.replace(CT,PT)}const RT=new Map;function PT(n,e){let t=dt[e];if(t===void 0){const i=RT.get(e);if(i!==void 0)t=dt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return du(t)}const LT=/#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 np(n){return n.replace(LT,DT)}function DT(n,e,t,i){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function ip(n){let e=`precision ${n.precision} float; precision ${n.precision} int; precision ${n.precision} sampler2D; precision ${n.precision} samplerCube; precision ${n.precision} sampler3D; precision ${n.precision} sampler2DArray; precision ${n.precision} sampler2DShadow; precision ${n.precision} samplerCubeShadow; precision ${n.precision} sampler2DArrayShadow; precision ${n.precision} isampler2D; precision ${n.precision} isampler3D; precision ${n.precision} isamplerCube; precision ${n.precision} isampler2DArray; precision ${n.precision} usampler2D; precision ${n.precision} usampler3D; precision ${n.precision} usamplerCube; precision ${n.precision} usampler2DArray; `;return n.precision==="highp"?e+=` #define HIGH_PRECISION`:n.precision==="mediump"?e+=` #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=` #define LOW_PRECISION`),e}function IT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Om?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===tE?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Ni&&(e="SHADOWMAP_TYPE_VSM"),e}function UT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case so:case ro:e="ENVMAP_TYPE_CUBE";break;case ec:e="ENVMAP_TYPE_CUBE_UV";break}return e}function NT(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case ro:e="ENVMAP_MODE_REFRACTION";break}return e}function FT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case zm:e="ENVMAP_BLENDING_MULTIPLY";break;case ME:e="ENVMAP_BLENDING_MIX";break;case EE:e="ENVMAP_BLENDING_ADD";break}return e}function OT(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function zT(n,e,t,i){const s=n.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=IT(t),c=UT(t),h=NT(t),f=FT(t),p=OT(t),m=wT(t),g=TT(r),x=s.createProgram();let d,u,w=t.glslVersion?"#version "+t.glslVersion+` `:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Vo).join(` `),d.length>0&&(d+=` `),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Vo).join(` `),u.length>0&&(u+=` `)):(d=[ip(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Vo).join(` `),u=[ip(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==fs?"#define TONE_MAPPING":"",t.toneMapping!==fs?dt.tonemapping_pars_fragment:"",t.toneMapping!==fs?ST("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",dt.colorspace_pars_fragment,yT("linearToOutputTexel",t.outputColorSpace),bT(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Vo).join(` `)),o=du(o),o=ep(o,t),o=tp(o,t),a=du(a),a=ep(a,t),a=tp(a,t),o=np(o),a=np(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es `,d=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+d,u=["#define varying in",t.glslVersion===xf?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===xf?"":"#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(` `)+` `+u);const M=w+d+o,E=w+u+a,N=Kf(s,s.VERTEX_SHADER,M),A=Kf(s,s.FRAGMENT_SHADER,E);s.attachShader(x,N),s.attachShader(x,A),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function T(b){if(n.debug.checkShaderErrors){const W=s.getProgramInfoLog(x).trim(),z=s.getShaderInfoLog(N).trim(),G=s.getShaderInfoLog(A).trim();let K=!0,H=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(K=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,x,N,A);else{const ie=Jf(s,N,"vertex"),B=Jf(s,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+` Material Name: `+b.name+` Material Type: `+b.type+` Program Info Log: `+W+` `+ie+` `+B)}else W!==""?console.warn("THREE.WebGLProgram: Program Info Log:",W):(z===""||G==="")&&(H=!1);H&&(b.diagnostics={runnable:K,programLog:W,vertexShader:{log:z,prefix:d},fragmentShader:{log:G,prefix:u}})}s.deleteShader(N),s.deleteShader(A),I=new Rl(s,x),C=AT(s,x)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let C;this.getAttributes=function(){return C===void 0&&T(this),C};let _=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return _===!1&&(_=s.getProgramParameter(x,vT)),_},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=xT++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=N,this.fragmentShader=A,this}let kT=0,BT=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new HT(e),t.set(e,i)),i}},HT=class{constructor(e){this.id=kT++,this.code=e,this.usedTimes=0}};function VT(n,e,t,i,s,r,o){const a=new Ad,l=new BT,c=new Set,h=[],f=s.logarithmicDepthBuffer,p=s.reverseDepthBuffer,m=s.vertexTextures;let g=s.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function d(_){return c.add(_),_===0?"uv":`uv${_}`}function u(_,b,W,z,G){const K=z.fog,H=G.geometry,ie=_.isMeshStandardMaterial?z.environment:null,B=(_.isMeshStandardMaterial?t:e).get(_.envMap||ie),ue=B&&B.mapping===ec?B.image.height:null,me=x[_.type];_.precision!==null&&(g=s.getMaxPrecision(_.precision),g!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",g,"instead."));const Me=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Ge=Me!==void 0?Me.length:0;let Qe=0;H.morphAttributes.position!==void 0&&(Qe=1),H.morphAttributes.normal!==void 0&&(Qe=2),H.morphAttributes.color!==void 0&&(Qe=3);let $,te,ve,de;if(me){const st=pi[me];$=st.vertexShader,te=st.fragmentShader}else $=_.vertexShader,te=_.fragmentShader,l.update(_),ve=l.getVertexShaderID(_),de=l.getFragmentShaderID(_);const Pe=n.getRenderTarget(),Le=G.isInstancedMesh===!0,He=G.isBatchedMesh===!0,je=!!_.map,We=!!_.matcap,q=!!B,Z=!!_.aoMap,et=!!_.lightMap,$e=!!_.bumpMap,Ue=!!_.normalMap,Oe=!!_.displacementMap,Ve=!!_.emissiveMap,D=!!_.metalnessMap,v=!!_.roughnessMap,S=_.anisotropy>0,F=_.clearcoat>0,Q=_.dispersion>0,X=_.iridescence>0,ne=_.sheen>0,_e=_.transmission>0,fe=S&&!!_.anisotropyMap,Ae=F&&!!_.clearcoatMap,ge=F&&!!_.clearcoatNormalMap,le=F&&!!_.clearcoatRoughnessMap,Ee=X&&!!_.iridescenceMap,Ce=X&&!!_.iridescenceThicknessMap,ye=ne&&!!_.sheenColorMap,we=ne&&!!_.sheenRoughnessMap,Fe=!!_.specularMap,qe=!!_.specularColorMap,Y=!!_.specularIntensityMap,k=_e&&!!_.transmissionMap,j=_e&&!!_.thicknessMap,V=!!_.gradientMap,ee=!!_.alphaMap,he=_.alphaTest>0,be=!!_.alphaHash,Xe=!!_.extensions;let xt=fs;_.toneMapped&&(Pe===null||Pe.isXRRenderTarget===!0)&&(xt=n.toneMapping);const Je={shaderID:me,shaderType:_.type,shaderName:_.name,vertexShader:$,fragmentShader:te,defines:_.defines,customVertexShaderID:ve,customFragmentShaderID:de,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:g,batching:He,batchingColor:He&&G._colorsTexture!==null,instancing:Le,instancingColor:Le&&G.instanceColor!==null,instancingMorph:Le&&G.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:Pe===null?n.outputColorSpace:Pe.isXRRenderTarget===!0?Pe.texture.colorSpace:Yi,alphaToCoverage:!!_.alphaToCoverage,map:je,matcap:We,envMap:q,envMapMode:q&&B.mapping,envMapCubeUVHeight:ue,aoMap:Z,lightMap:et,bumpMap:$e,normalMap:Ue,displacementMap:m&&Oe,emissiveMap:Ve,normalMapObjectSpace:Ue&&_.normalMapType===IE,normalMapTangentSpace:Ue&&_.normalMapType===DE,metalnessMap:D,roughnessMap:v,anisotropy:S,anisotropyMap:fe,clearcoat:F,clearcoatMap:Ae,clearcoatNormalMap:ge,clearcoatRoughnessMap:le,dispersion:Q,iridescence:X,iridescenceMap:Ee,iridescenceThicknessMap:Ce,sheen:ne,sheenColorMap:ye,sheenRoughnessMap:we,specularMap:Fe,specularColorMap:qe,specularIntensityMap:Y,transmission:_e,transmissionMap:k,thicknessMap:j,gradientMap:V,opaque:_.transparent===!1&&_.blending===Qr&&_.alphaToCoverage===!1,alphaMap:ee,alphaTest:he,alphaHash:be,combine:_.combine,mapUv:je&&d(_.map.channel),aoMapUv:Z&&d(_.aoMap.channel),lightMapUv:et&&d(_.lightMap.channel),bumpMapUv:$e&&d(_.bumpMap.channel),normalMapUv:Ue&&d(_.normalMap.channel),displacementMapUv:Oe&&d(_.displacementMap.channel),emissiveMapUv:Ve&&d(_.emissiveMap.channel),metalnessMapUv:D&&d(_.metalnessMap.channel),roughnessMapUv:v&&d(_.roughnessMap.channel),anisotropyMapUv:fe&&d(_.anisotropyMap.channel),clearcoatMapUv:Ae&&d(_.clearcoatMap.channel),clearcoatNormalMapUv:ge&&d(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&d(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&d(_.iridescenceMap.channel),iridescenceThicknessMapUv:Ce&&d(_.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&d(_.sheenColorMap.channel),sheenRoughnessMapUv:we&&d(_.sheenRoughnessMap.channel),specularMapUv:Fe&&d(_.specularMap.channel),specularColorMapUv:qe&&d(_.specularColorMap.channel),specularIntensityMapUv:Y&&d(_.specularIntensityMap.channel),transmissionMapUv:k&&d(_.transmissionMap.channel),thicknessMapUv:j&&d(_.thicknessMap.channel),alphaMapUv:ee&&d(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(Ue||S),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!H.attributes.uv&&(je||ee),fog:!!K,useFog:_.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:_.flatShading===!0,sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reverseDepthBuffer:p,skinning:G.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Ge,morphTextureStride:Qe,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:_.dithering,shadowMapEnabled:n.shadowMap.enabled&&W.length>0,shadowMapType:n.shadowMap.type,toneMapping:xt,decodeVideoTexture:je&&_.map.isVideoTexture===!0&&St.getTransfer(_.map.colorSpace)===It,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Oi,flipSided:_.side===Sn,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:Xe&&_.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Xe&&_.extensions.multiDraw===!0||He)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Je.vertexUv1s=c.has(1),Je.vertexUv2s=c.has(2),Je.vertexUv3s=c.has(3),c.clear(),Je}function w(_){const b=[];if(_.shaderID?b.push(_.shaderID):(b.push(_.customVertexShaderID),b.push(_.customFragmentShaderID)),_.defines!==void 0)for(const W in _.defines)b.push(W),b.push(_.defines[W]);return _.isRawShaderMaterial===!1&&(M(b,_),E(b,_),b.push(n.outputColorSpace)),b.push(_.customProgramCacheKey),b.join()}function M(_,b){_.push(b.precision),_.push(b.outputColorSpace),_.push(b.envMapMode),_.push(b.envMapCubeUVHeight),_.push(b.mapUv),_.push(b.alphaMapUv),_.push(b.lightMapUv),_.push(b.aoMapUv),_.push(b.bumpMapUv),_.push(b.normalMapUv),_.push(b.displacementMapUv),_.push(b.emissiveMapUv),_.push(b.metalnessMapUv),_.push(b.roughnessMapUv),_.push(b.anisotropyMapUv),_.push(b.clearcoatMapUv),_.push(b.clearcoatNormalMapUv),_.push(b.clearcoatRoughnessMapUv),_.push(b.iridescenceMapUv),_.push(b.iridescenceThicknessMapUv),_.push(b.sheenColorMapUv),_.push(b.sheenRoughnessMapUv),_.push(b.specularMapUv),_.push(b.specularColorMapUv),_.push(b.specularIntensityMapUv),_.push(b.transmissionMapUv),_.push(b.thicknessMapUv),_.push(b.combine),_.push(b.fogExp2),_.push(b.sizeAttenuation),_.push(b.morphTargetsCount),_.push(b.morphAttributeCount),_.push(b.numDirLights),_.push(b.numPointLights),_.push(b.numSpotLights),_.push(b.numSpotLightMaps),_.push(b.numHemiLights),_.push(b.numRectAreaLights),_.push(b.numDirLightShadows),_.push(b.numPointLightShadows),_.push(b.numSpotLightShadows),_.push(b.numSpotLightShadowsWithMaps),_.push(b.numLightProbes),_.push(b.shadowMapType),_.push(b.toneMapping),_.push(b.numClippingPlanes),_.push(b.numClipIntersection),_.push(b.depthPacking)}function E(_,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),b.batchingColor&&a.enable(21),_.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reverseDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.alphaToCoverage&&a.enable(20),_.push(a.mask)}function N(_){const b=x[_.type];let W;if(b){const z=pi[b];W=by.clone(z.uniforms)}else W=_.uniforms;return W}function A(_,b){let W;for(let z=0,G=h.length;z<G;z++){const K=h[z];if(K.cacheKey===b){W=K,++W.usedTimes;break}}return W===void 0&&(W=new zT(n,b,_,r),h.push(W)),W}function T(_){if(--_.usedTimes===0){const b=h.indexOf(_);h[b]=h[h.length-1],h.pop(),_.destroy()}}function I(_){l.remove(_)}function C(){l.dispose()}return{getParameters:u,getProgramCacheKey:w,getUniforms:N,acquireProgram:A,releaseProgram:T,releaseShaderCache:I,programs:h,dispose:C}}function GT(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function s(o,a,l){n.get(o)[a]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function WT(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function sp(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function rp(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function o(f,p,m,g,x,d){let u=n[e];return u===void 0?(u={id:f.id,object:f,geometry:p,material:m,groupOrder:g,renderOrder:f.renderOrder,z:x,group:d},n[e]=u):(u.id=f.id,u.object=f,u.geometry=p,u.material=m,u.groupOrder=g,u.renderOrder=f.renderOrder,u.z=x,u.group=d),e++,u}function a(f,p,m,g,x,d){const u=o(f,p,m,g,x,d);m.transmission>0?i.push(u):m.transparent===!0?s.push(u):t.push(u)}function l(f,p,m,g,x,d){const u=o(f,p,m,g,x,d);m.transmission>0?i.unshift(u):m.transparent===!0?s.unshift(u):t.unshift(u)}function c(f,p){t.length>1&&t.sort(f||WT),i.length>1&&i.sort(p||sp),s.length>1&&s.sort(p||sp)}function h(){for(let f=e,p=n.length;f<p;f++){const m=n[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:s,init:r,push:a,unshift:l,finish:h,sort:c}}function $T(){let n=new WeakMap;function e(i,s){const r=n.get(i);let o;return r===void 0?(o=new rp,n.set(i,[o])):s>=r.length?(o=new rp,r.push(o)):o=r[s],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function qT(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new ce,color:new Rt};break;case"SpotLight":t={position:new ce,direction:new ce,color:new Rt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ce,color:new Rt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ce,skyColor:new Rt,groundColor:new Rt};break;case"RectAreaLight":t={color:new Rt,position:new ce,halfWidth:new ce,halfHeight:new ce};break}return n[e.id]=t,t}}}function XT(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let YT=0;function QT(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function jT(n){const e=new qT,t=XT(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new ce);const s=new ce,r=new qt,o=new qt;function a(c){let h=0,f=0,p=0;for(let C=0;C<9;C++)i.probe[C].set(0,0,0);let m=0,g=0,x=0,d=0,u=0,w=0,M=0,E=0,N=0,A=0,T=0;c.sort(QT);for(let C=0,_=c.length;C<_;C++){const b=c[C],W=b.color,z=b.intensity,G=b.distance,K=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=W.r*z,f+=W.g*z,p+=W.b*z;else if(b.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(b.sh.coefficients[H],z);T++}else if(b.isDirectionalLight){const H=e.get(b);if(H.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const ie=b.shadow,B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,i.directionalShadow[m]=B,i.directionalShadowMap[m]=K,i.directionalShadowMatrix[m]=b.shadow.matrix,w++}i.directional[m]=H,m++}else if(b.isSpotLight){const H=e.get(b);H.position.setFromMatrixPosition(b.matrixWorld),H.color.copy(W).multiplyScalar(z),H.distance=G,H.coneCos=Math.cos(b.angle),H.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),H.decay=b.decay,i.spot[x]=H;const ie=b.shadow;if(b.map&&(i.spotLightMap[N]=b.map,N++,ie.updateMatrices(b),b.castShadow&&A++),i.spotLightMatrix[x]=ie.matrix,b.castShadow){const B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,i.spotShadow[x]=B,i.spotShadowMap[x]=K,E++}x++}else if(b.isRectAreaLight){const H=e.get(b);H.color.copy(W).multiplyScalar(z),H.halfWidth.set(b.width*.5,0,0),H.halfHeight.set(0,b.height*.5,0),i.rectArea[d]=H,d++}else if(b.isPointLight){const H=e.get(b);if(H.color.copy(b.color).multiplyScalar(b.intensity),H.distance=b.distance,H.decay=b.decay,b.castShadow){const ie=b.shadow,B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,B.shadowCameraNear=ie.camera.near,B.shadowCameraFar=ie.camera.far,i.pointShadow[g]=B,i.pointShadowMap[g]=K,i.pointShadowMatrix[g]=b.shadow.matrix,M++}i.point[g]=H,g++}else if(b.isHemisphereLight){const H=e.get(b);H.skyColor.copy(b.color).multiplyScalar(z),H.groundColor.copy(b.groundColor).multiplyScalar(z),i.hemi[u]=H,u++}}d>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ze.LTC_FLOAT_1,i.rectAreaLTC2=ze.LTC_FLOAT_2):(i.rectAreaLTC1=ze.LTC_HALF_1,i.rectAreaLTC2=ze.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=f,i.ambient[2]=p;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==x||I.rectAreaLength!==d||I.hemiLength!==u||I.numDirectionalShadows!==w||I.numPointShadows!==M||I.numSpotShadows!==E||I.numSpotMaps!==N||I.numLightProbes!==T)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=d,i.point.length=g,i.hemi.length=u,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=E+N-A,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=T,I.directionalLength=m,I.pointLength=g,I.spotLength=x,I.rectAreaLength=d,I.hemiLength=u,I.numDirectionalShadows=w,I.numPointShadows=M,I.numSpotShadows=E,I.numSpotMaps=N,I.numLightProbes=T,i.version=YT++)}function l(c,h){let f=0,p=0,m=0,g=0,x=0;const d=h.matrixWorldInverse;for(let u=0,w=c.length;u<w;u++){const M=c[u];if(M.isDirectionalLight){const E=i.directional[f];E.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),f++}else if(M.isSpotLight){const E=i.spot[m];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),E.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),m++}else if(M.isRectAreaLight){const E=i.rectArea[g];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),o.identity(),r.copy(M.matrixWorld),r.premultiply(d),o.extractRotation(r),E.halfWidth.set(M.width*.5,0,0),E.halfHeight.set(0,M.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),g++}else if(M.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),p++}else if(M.isHemisphereLight){const E=i.hemi[x];E.direction.setFromMatrixPosition(M.matrixWorld),E.direction.transformDirection(d),x++}}}return{setup:a,setupView:l,state:i}}function op(n){const e=new jT(n),t=[],i=[];function s(h){c.camera=h,t.length=0,i.length=0}function r(h){t.push(h)}function o(h){i.push(h)}function a(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function ZT(n){let e=new WeakMap;function t(s,r=0){const o=e.get(s);let a;return o===void 0?(a=new op(n),e.set(s,[a])):r>=o.length?(a=new op(n),o.push(a)):a=o[r],a}function i(){e=new WeakMap}return{get:t,dispose:i}}let KT=class extends nc{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=PE,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},JT=class extends nc{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};const e1=`void main() { gl_Position = vec4( position, 1.0 ); }`,t1=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include <packing> void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function n1(n,e,t){let i=new Rd;const s=new Dt,r=new Dt,o=new $t,a=new KT({depthPacking:LE}),l=new JT,c={},h=t.maxTextureSize,f={[xs]:Sn,[Sn]:xs,[Oi]:Oi},p=new ys({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:e1,fragmentShader:t1}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const g=new Eo;g.setAttribute("position",new xi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Hn(g,p),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Om;let u=this.type;this.render=function(A,T,I){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||A.length===0)return;const C=n.getRenderTarget(),_=n.getActiveCubeFace(),b=n.getActiveMipmapLevel(),W=n.state;W.setBlending(ds),W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const z=u!==Ni&&this.type===Ni,G=u===Ni&&this.type!==Ni;for(let K=0,H=A.length;K<H;K++){const ie=A[K],B=ie.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",ie,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);const ue=B.getFrameExtents();if(s.multiply(ue),r.copy(B.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ue.x),s.x=r.x*ue.x,B.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ue.y),s.y=r.y*ue.y,B.mapSize.y=r.y)),B.map===null||z===!0||G===!0){const Me=this.type!==Ni?{minFilter:Bn,magFilter:Bn}:{};B.map!==null&&B.map.dispose(),B.map=new Ms(s.x,s.y,Me),B.map.texture.name=ie.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const me=B.getViewportCount();for(let Me=0;Me<me;Me++){const Ge=B.getViewport(Me);o.set(r.x*Ge.x,r.y*Ge.y,r.x*Ge.z,r.y*Ge.w),W.viewport(o),B.updateMatrices(ie,Me),i=B.getFrustum(),E(T,I,B.camera,ie,this.type)}B.isPointLightShadow!==!0&&this.type===Ni&&w(B,I),B.needsUpdate=!1}u=this.type,d.needsUpdate=!1,n.setRenderTarget(C,_,b)};function w(A,T){const I=e.update(x);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,m.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Ms(s.x,s.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(T,null,I,p,x,null),m.uniforms.shadow_pass.value=A.mapPass.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(T,null,I,m,x,null)}function M(A,T,I,C){let _=null;const b=I.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(b!==void 0)_=b;else if(_=I.isPointLight===!0?l:a,n.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){const W=_.uuid,z=T.uuid;let G=c[W];G===void 0&&(G={},c[W]=G);let K=G[z];K===void 0&&(K=_.clone(),G[z]=K,T.addEventListener("dispose",N)),_=K}if(_.visible=T.visible,_.wireframe=T.wireframe,C===Ni?_.side=T.shadowSide!==null?T.shadowSide:T.side:_.side=T.shadowSide!==null?T.shadowSide:f[T.side],_.alphaMap=T.alphaMap,_.alphaTest=T.alphaTest,_.map=T.map,_.clipShadows=T.clipShadows,_.clippingPlanes=T.clippingPlanes,_.clipIntersection=T.clipIntersection,_.displacementMap=T.displacementMap,_.displacementScale=T.displacementScale,_.displacementBias=T.displacementBias,_.wireframeLinewidth=T.wireframeLinewidth,_.linewidth=T.linewidth,I.isPointLight===!0&&_.isMeshDistanceMaterial===!0){const W=n.properties.get(_);W.light=I}return _}function E(A,T,I,C,_){if(A.visible===!1)return;if(A.layers.test(T.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&_===Ni)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,A.matrixWorld);const z=e.update(A),G=A.material;if(Array.isArray(G)){const K=z.groups;for(let H=0,ie=K.length;H<ie;H++){const B=K[H],ue=G[B.materialIndex];if(ue&&ue.visible){const me=M(A,ue,C,_);A.onBeforeShadow(n,A,T,I,z,me,B),n.renderBufferDirect(I,null,z,me,A,B),A.onAfterShadow(n,A,T,I,z,me,B)}}}else if(G.visible){const K=M(A,G,C,_);A.onBeforeShadow(n,A,T,I,z,K,null),n.renderBufferDirect(I,null,z,K,A,null),A.onAfterShadow(n,A,T,I,z,K,null)}}const W=A.children;for(let z=0,G=W.length;z<G;z++)E(W[z],T,I,C,_)}function N(A){A.target.removeEventListener("dispose",N);for(const I in c){const C=c[I],_=A.target.uuid;_ in C&&(C[_].dispose(),delete C[_])}}}const i1={[Ch]:Rh,[Ph]:Ih,[Lh]:Uh,[io]:Dh,[Rh]:Ch,[Ih]:Ph,[Uh]:Lh,[Dh]:io};function s1(n){function e(){let Y=!1;const k=new $t;let j=null;const V=new $t(0,0,0,0);return{setMask:function(ee){j!==ee&&!Y&&(n.colorMask(ee,ee,ee,ee),j=ee)},setLocked:function(ee){Y=ee},setClear:function(ee,he,be,Xe,xt){xt===!0&&(ee*=Xe,he*=Xe,be*=Xe),k.set(ee,he,be,Xe),V.equals(k)===!1&&(n.clearColor(ee,he,be,Xe),V.copy(k))},reset:function(){Y=!1,j=null,V.set(-1,0,0,0)}}}function t(){let Y=!1,k=!1,j=null,V=null,ee=null;return{setReversed:function(he){k=he},setTest:function(he){he?ve(n.DEPTH_TEST):de(n.DEPTH_TEST)},setMask:function(he){j!==he&&!Y&&(n.depthMask(he),j=he)},setFunc:function(he){if(k&&(he=i1[he]),V!==he){switch(he){case Ch:n.depthFunc(n.NEVER);break;case Rh:n.depthFunc(n.ALWAYS);break;case Ph:n.depthFunc(n.LESS);break;case io:n.depthFunc(n.LEQUAL);break;case Lh:n.depthFunc(n.EQUAL);break;case Dh:n.depthFunc(n.GEQUAL);break;case Ih:n.depthFunc(n.GREATER);break;case Uh:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}V=he}},setLocked:function(he){Y=he},setClear:function(he){ee!==he&&(n.clearDepth(he),ee=he)},reset:function(){Y=!1,j=null,V=null,ee=null}}}function i(){let Y=!1,k=null,j=null,V=null,ee=null,he=null,be=null,Xe=null,xt=null;return{setTest:function(Je){Y||(Je?ve(n.STENCIL_TEST):de(n.STENCIL_TEST))},setMask:function(Je){k!==Je&&!Y&&(n.stencilMask(Je),k=Je)},setFunc:function(Je,st,Ot){(j!==Je||V!==st||ee!==Ot)&&(n.stencilFunc(Je,st,Ot),j=Je,V=st,ee=Ot)},setOp:function(Je,st,Ot){(he!==Je||be!==st||Xe!==Ot)&&(n.stencilOp(Je,st,Ot),he=Je,be=st,Xe=Ot)},setLocked:function(Je){Y=Je},setClear:function(Je){xt!==Je&&(n.clearStencil(Je),xt=Je)},reset:function(){Y=!1,k=null,j=null,V=null,ee=null,he=null,be=null,Xe=null,xt=null}}}const s=new e,r=new t,o=new i,a=new WeakMap,l=new WeakMap;let c={},h={},f=new WeakMap,p=[],m=null,g=!1,x=null,d=null,u=null,w=null,M=null,E=null,N=null,A=new Rt(0,0,0),T=0,I=!1,C=null,_=null,b=null,W=null,z=null;const G=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,H=0;const ie=n.getParameter(n.VERSION);ie.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(ie)[1]),K=H>=1):ie.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),K=H>=2);let B=null,ue={};const me=n.getParameter(n.SCISSOR_BOX),Me=n.getParameter(n.VIEWPORT),Ge=new $t().fromArray(me),Qe=new $t().fromArray(Me);function $(Y,k,j,V){const ee=new Uint8Array(4),he=n.createTexture();n.bindTexture(Y,he),n.texParameteri(Y,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(Y,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let be=0;be<j;be++)Y===n.TEXTURE_3D||Y===n.TEXTURE_2D_ARRAY?n.texImage3D(k,0,n.RGBA,1,1,V,0,n.RGBA,n.UNSIGNED_BYTE,ee):n.texImage2D(k+be,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ee);return he}const te={};te[n.TEXTURE_2D]=$(n.TEXTURE_2D,n.TEXTURE_2D,1),te[n.TEXTURE_CUBE_MAP]=$(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),te[n.TEXTURE_2D_ARRAY]=$(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),te[n.TEXTURE_3D]=$(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),ve(n.DEPTH_TEST),r.setFunc(io),et(!1),$e(ff),ve(n.CULL_FACE),q(ds);function ve(Y){c[Y]!==!0&&(n.enable(Y),c[Y]=!0)}function de(Y){c[Y]!==!1&&(n.disable(Y),c[Y]=!1)}function Pe(Y,k){return h[Y]!==k?(n.bindFramebuffer(Y,k),h[Y]=k,Y===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=k),Y===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=k),!0):!1}function Le(Y,k){let j=p,V=!1;if(Y){j=f.get(k),j===void 0&&(j=[],f.set(k,j));const ee=Y.textures;if(j.length!==ee.length||j[0]!==n.COLOR_ATTACHMENT0){for(let he=0,be=ee.length;he<be;he++)j[he]=n.COLOR_ATTACHMENT0+he;j.length=ee.length,V=!0}}else j[0]!==n.BACK&&(j[0]=n.BACK,V=!0);V&&n.drawBuffers(j)}function He(Y){return m!==Y?(n.useProgram(Y),m=Y,!0):!1}const je={[Xs]:n.FUNC_ADD,[iE]:n.FUNC_SUBTRACT,[sE]:n.FUNC_REVERSE_SUBTRACT};je[rE]=n.MIN,je[oE]=n.MAX;const We={[aE]:n.ZERO,[lE]:n.ONE,[cE]:n.SRC_COLOR,[Th]:n.SRC_ALPHA,[mE]:n.SRC_ALPHA_SATURATE,[fE]:n.DST_COLOR,[uE]:n.DST_ALPHA,[hE]:n.ONE_MINUS_SRC_COLOR,[Ah]:n.ONE_MINUS_SRC_ALPHA,[pE]:n.ONE_MINUS_DST_COLOR,[dE]:n.ONE_MINUS_DST_ALPHA,[_E]:n.CONSTANT_COLOR,[gE]:n.ONE_MINUS_CONSTANT_COLOR,[vE]:n.CONSTANT_ALPHA,[xE]:n.ONE_MINUS_CONSTANT_ALPHA};function q(Y,k,j,V,ee,he,be,Xe,xt,Je){if(Y===ds){g===!0&&(de(n.BLEND),g=!1);return}if(g===!1&&(ve(n.BLEND),g=!0),Y!==nE){if(Y!==x||Je!==I){if((d!==Xs||M!==Xs)&&(n.blendEquation(n.FUNC_ADD),d=Xs,M=Xs),Je)switch(Y){case Qr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.ONE,n.ONE);break;case mf:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case _f:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Qr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case mf:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case _f:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}u=null,w=null,E=null,N=null,A.set(0,0,0),T=0,x=Y,I=Je}return}ee=ee||k,he=he||j,be=be||V,(k!==d||ee!==M)&&(n.blendEquationSeparate(je[k],je[ee]),d=k,M=ee),(j!==u||V!==w||he!==E||be!==N)&&(n.blendFuncSeparate(We[j],We[V],We[he],We[be]),u=j,w=V,E=he,N=be),(Xe.equals(A)===!1||xt!==T)&&(n.blendColor(Xe.r,Xe.g,Xe.b,xt),A.copy(Xe),T=xt),x=Y,I=!1}function Z(Y,k){Y.side===Oi?de(n.CULL_FACE):ve(n.CULL_FACE);let j=Y.side===Sn;k&&(j=!j),et(j),Y.blending===Qr&&Y.transparent===!1?q(ds):q(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.blendColor,Y.blendAlpha,Y.premultipliedAlpha),r.setFunc(Y.depthFunc),r.setTest(Y.depthTest),r.setMask(Y.depthWrite),s.setMask(Y.colorWrite);const V=Y.stencilWrite;o.setTest(V),V&&(o.setMask(Y.stencilWriteMask),o.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),o.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Oe(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ve(n.SAMPLE_ALPHA_TO_COVERAGE):de(n.SAMPLE_ALPHA_TO_COVERAGE)}function et(Y){C!==Y&&(Y?n.frontFace(n.CW):n.frontFace(n.CCW),C=Y)}function $e(Y){Y!==JM?(ve(n.CULL_FACE),Y!==_&&(Y===ff?n.cullFace(n.BACK):Y===eE?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):de(n.CULL_FACE),_=Y}function Ue(Y){Y!==b&&(K&&n.lineWidth(Y),b=Y)}function Oe(Y,k,j){Y?(ve(n.POLYGON_OFFSET_FILL),(W!==k||z!==j)&&(n.polygonOffset(k,j),W=k,z=j)):de(n.POLYGON_OFFSET_FILL)}function Ve(Y){Y?ve(n.SCISSOR_TEST):de(n.SCISSOR_TEST)}function D(Y){Y===void 0&&(Y=n.TEXTURE0+G-1),B!==Y&&(n.activeTexture(Y),B=Y)}function v(Y,k,j){j===void 0&&(B===null?j=n.TEXTURE0+G-1:j=B);let V=ue[j];V===void 0&&(V={type:void 0,texture:void 0},ue[j]=V),(V.type!==Y||V.texture!==k)&&(B!==j&&(n.activeTexture(j),B=j),n.bindTexture(Y,k||te[Y]),V.type=Y,V.texture=k)}function S(){const Y=ue[B];Y!==void 0&&Y.type!==void 0&&(n.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function F(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Q(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function X(){try{n.texSubImage2D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ne(){try{n.texSubImage3D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function fe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ae(){try{n.texStorage2D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{n.texStorage3D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function le(){try{n.texImage2D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{n.texImage3D.apply(n,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ce(Y){Ge.equals(Y)===!1&&(n.scissor(Y.x,Y.y,Y.z,Y.w),Ge.copy(Y))}function ye(Y){Qe.equals(Y)===!1&&(n.viewport(Y.x,Y.y,Y.z,Y.w),Qe.copy(Y))}function we(Y,k){let j=l.get(k);j===void 0&&(j=new WeakMap,l.set(k,j));let V=j.get(Y);V===void 0&&(V=n.getUniformBlockIndex(k,Y.name),j.set(Y,V))}function Fe(Y,k){const V=l.get(k).get(Y);a.get(k)!==V&&(n.uniformBlockBinding(k,V,Y.__bindingPointIndex),a.set(k,V))}function qe(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},B=null,ue={},h={},f=new WeakMap,p=[],m=null,g=!1,x=null,d=null,u=null,w=null,M=null,E=null,N=null,A=new Rt(0,0,0),T=0,I=!1,C=null,_=null,b=null,W=null,z=null,Ge.set(0,0,n.canvas.width,n.canvas.height),Qe.set(0,0,n.canvas.width,n.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:ve,disable:de,bindFramebuffer:Pe,drawBuffers:Le,useProgram:He,setBlending:q,setMaterial:Z,setFlipSided:et,setCullFace:$e,setLineWidth:Ue,setPolygonOffset:Oe,setScissorTest:Ve,activeTexture:D,bindTexture:v,unbindTexture:S,compressedTexImage2D:F,compressedTexImage3D:Q,texImage2D:le,texImage3D:Ee,updateUBOMapping:we,uniformBlockBinding:Fe,texStorage2D:Ae,texStorage3D:ge,texSubImage2D:X,texSubImage3D:ne,compressedTexSubImage2D:_e,compressedTexSubImage3D:fe,scissor:Ce,viewport:ye,reset:qe}}function ap(n,e,t,i){const s=r1(i);switch(t){case Gm:return n*e;case $m:return n*e;case qm:return n*e*2;case Xm:return n*e/s.components*s.byteLength;case Ed:return n*e/s.components*s.byteLength;case Ym:return n*e*2/s.components*s.byteLength;case yd:return n*e*2/s.components*s.byteLength;case Wm:return n*e*3/s.components*s.byteLength;case ti:return n*e*4/s.components*s.byteLength;case Sd:return n*e*4/s.components*s.byteLength;case El:case yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Sl:case bl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bh:case Vh:return Math.max(n,16)*Math.max(e,8)/4;case kh:case Hh:return Math.max(n,8)*Math.max(e,8)/2;case Gh:case Wh:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case $h:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case qh:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Xh:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Yh:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Qh:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case jh:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Zh:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Kh:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Jh:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case eu:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case tu:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case nu:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case iu:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case su:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ru:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case wl:case ou:case au:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Qm:case lu:return Math.ceil(n/4)*Math.ceil(e/4)*8;case cu:case hu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function r1(n){switch(n){case $i:case Bm:return{byteLength:1,components:1};case ha:case Hm:case ga:return{byteLength:2,components:1};case xd:case Md:return{byteLength:2,components:4};case tr:case vd:case zi:return{byteLength:4,components:1};case Vm:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}function o1(n,e,t,i,s,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Dt,h=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(D,v){return m?new OffscreenCanvas(D,v):Gl("canvas")}function x(D,v,S){let F=1;const Q=Ve(D);if((Q.width>S||Q.height>S)&&(F=S/Math.max(Q.width,Q.height)),F<1)if(typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&D instanceof ImageBitmap||typeof VideoFrame<"u"&&D instanceof VideoFrame){const X=Math.floor(F*Q.width),ne=Math.floor(F*Q.height);f===void 0&&(f=g(X,ne));const _e=v?g(X,ne):f;return _e.width=X,_e.height=ne,_e.getContext("2d").drawImage(D,0,0,X,ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+X+"x"+ne+")."),_e}else return"data"in D&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),D;return D}function d(D){return D.generateMipmaps&&D.minFilter!==Bn&&D.minFilter!==kn}function u(D){n.generateMipmap(D)}function w(D,v,S,F,Q=!1){if(D!==null){if(n[D]!==void 0)return n[D];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+D+"'")}let X=v;if(v===n.RED&&(S===n.FLOAT&&(X=n.R32F),S===n.HALF_FLOAT&&(X=n.R16F),S===n.UNSIGNED_BYTE&&(X=n.R8)),v===n.RED_INTEGER&&(S===n.UNSIGNED_BYTE&&(X=n.R8UI),S===n.UNSIGNED_SHORT&&(X=n.R16UI),S===n.UNSIGNED_INT&&(X=n.R32UI),S===n.BYTE&&(X=n.R8I),S===n.SHORT&&(X=n.R16I),S===n.INT&&(X=n.R32I)),v===n.RG&&(S===n.FLOAT&&(X=n.RG32F),S===n.HALF_FLOAT&&(X=n.RG16F),S===n.UNSIGNED_BYTE&&(X=n.RG8)),v===n.RG_INTEGER&&(S===n.UNSIGNED_BYTE&&(X=n.RG8UI),S===n.UNSIGNED_SHORT&&(X=n.RG16UI),S===n.UNSIGNED_INT&&(X=n.RG32UI),S===n.BYTE&&(X=n.RG8I),S===n.SHORT&&(X=n.RG16I),S===n.INT&&(X=n.RG32I)),v===n.RGB_INTEGER&&(S===n.UNSIGNED_BYTE&&(X=n.RGB8UI),S===n.UNSIGNED_SHORT&&(X=n.RGB16UI),S===n.UNSIGNED_INT&&(X=n.RGB32UI),S===n.BYTE&&(X=n.RGB8I),S===n.SHORT&&(X=n.RGB16I),S===n.INT&&(X=n.RGB32I)),v===n.RGBA_INTEGER&&(S===n.UNSIGNED_BYTE&&(X=n.RGBA8UI),S===n.UNSIGNED_SHORT&&(X=n.RGBA16UI),S===n.UNSIGNED_INT&&(X=n.RGBA32UI),S===n.BYTE&&(X=n.RGBA8I),S===n.SHORT&&(X=n.RGBA16I),S===n.INT&&(X=n.RGBA32I)),v===n.RGB&&S===n.UNSIGNED_INT_5_9_9_9_REV&&(X=n.RGB9_E5),v===n.RGBA){const ne=Q?kl:St.getTransfer(F);S===n.FLOAT&&(X=n.RGBA32F),S===n.HALF_FLOAT&&(X=n.RGBA16F),S===n.UNSIGNED_BYTE&&(X=ne===It?n.SRGB8_ALPHA8:n.RGBA8),S===n.UNSIGNED_SHORT_4_4_4_4&&(X=n.RGBA4),S===n.UNSIGNED_SHORT_5_5_5_1&&(X=n.RGB5_A1)}return(X===n.R16F||X===n.R32F||X===n.RG16F||X===n.RG32F||X===n.RGBA16F||X===n.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function M(D,v){let S;return D?v===null||v===tr||v===oo?S=n.DEPTH24_STENCIL8:v===zi?S=n.DEPTH32F_STENCIL8:v===ha&&(S=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===tr||v===oo?S=n.DEPTH_COMPONENT24:v===zi?S=n.DEPTH_COMPONENT32F:v===ha&&(S=n.DEPTH_COMPONENT16),S}function E(D,v){return d(D)===!0||D.isFramebufferTexture&&D.minFilter!==Bn&&D.minFilter!==kn?Math.log2(Math.max(v.width,v.height))+1:D.mipmaps!==void 0&&D.mipmaps.length>0?D.mipmaps.length:D.isCompressedTexture&&Array.isArray(D.image)?v.mipmaps.length:1}function N(D){const v=D.target;v.removeEventListener("dispose",N),T(v),v.isVideoTexture&&h.delete(v)}function A(D){const v=D.target;v.removeEventListener("dispose",A),C(v)}function T(D){const v=i.get(D);if(v.__webglInit===void 0)return;const S=D.source,F=p.get(S);if(F){const Q=F[v.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&I(D),Object.keys(F).length===0&&p.delete(S)}i.remove(D)}function I(D){const v=i.get(D);n.deleteTexture(v.__webglTexture);const S=D.source,F=p.get(S);delete F[v.__cacheKey],o.memory.textures--}function C(D){const v=i.get(D);if(D.depthTexture&&D.depthTexture.dispose(),D.isWebGLCubeRenderTarget)for(let F=0;F<6;F++){if(Array.isArray(v.__webglFramebuffer[F]))for(let Q=0;Q<v.__webglFramebuffer[F].length;Q++)n.deleteFramebuffer(v.__webglFramebuffer[F][Q]);else n.deleteFramebuffer(v.__webglFramebuffer[F]);v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer[F])}else{if(Array.isArray(v.__webglFramebuffer))for(let F=0;F<v.__webglFramebuffer.length;F++)n.deleteFramebuffer(v.__webglFramebuffer[F]);else n.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&n.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let F=0;F<v.__webglColorRenderbuffer.length;F++)v.__webglColorRenderbuffer[F]&&n.deleteRenderbuffer(v.__webglColorRenderbuffer[F]);v.__webglDepthRenderbuffer&&n.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const S=D.textures;for(let F=0,Q=S.length;F<Q;F++){const X=i.get(S[F]);X.__webglTexture&&(n.deleteTexture(X.__webglTexture),o.memory.textures--),i.remove(S[F])}i.remove(D)}let _=0;function b(){_=0}function W(){const D=_;return D>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+D+" texture units while this GPU supports only "+s.maxTextures),_+=1,D}function z(D){const v=[];return v.push(D.wrapS),v.push(D.wrapT),v.push(D.wrapR||0),v.push(D.magFilter),v.push(D.minFilter),v.push(D.anisotropy),v.push(D.internalFormat),v.push(D.format),v.push(D.type),v.push(D.generateMipmaps),v.push(D.premultiplyAlpha),v.push(D.flipY),v.push(D.unpackAlignment),v.push(D.colorSpace),v.join()}function G(D,v){const S=i.get(D);if(D.isVideoTexture&&Ue(D),D.isRenderTargetTexture===!1&&D.version>0&&S.__version!==D.version){const F=D.image;if(F===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(F.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Qe(S,D,v);return}}t.bindTexture(n.TEXTURE_2D,S.__webglTexture,n.TEXTURE0+v)}function K(D,v){const S=i.get(D);if(D.version>0&&S.__version!==D.version){Qe(S,D,v);return}t.bindTexture(n.TEXTURE_2D_ARRAY,S.__webglTexture,n.TEXTURE0+v)}function H(D,v){const S=i.get(D);if(D.version>0&&S.__version!==D.version){Qe(S,D,v);return}t.bindTexture(n.TEXTURE_3D,S.__webglTexture,n.TEXTURE0+v)}function ie(D,v){const S=i.get(D);if(D.version>0&&S.__version!==D.version){$(S,D,v);return}t.bindTexture(n.TEXTURE_CUBE_MAP,S.__webglTexture,n.TEXTURE0+v)}const B={[Oh]:n.REPEAT,[Zs]:n.CLAMP_TO_EDGE,[zh]:n.MIRRORED_REPEAT},ue={[Bn]:n.NEAREST,[RE]:n.NEAREST_MIPMAP_NEAREST,[Ra]:n.NEAREST_MIPMAP_LINEAR,[kn]:n.LINEAR,[vc]:n.LINEAR_MIPMAP_NEAREST,[us]:n.LINEAR_MIPMAP_LINEAR},me={[UE]:n.NEVER,[BE]:n.ALWAYS,[NE]:n.LESS,[jm]:n.LEQUAL,[FE]:n.EQUAL,[kE]:n.GEQUAL,[OE]:n.GREATER,[zE]:n.NOTEQUAL};function Me(D,v){if(v.type===zi&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===kn||v.magFilter===vc||v.magFilter===Ra||v.magFilter===us||v.minFilter===kn||v.minFilter===vc||v.minFilter===Ra||v.minFilter===us)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(D,n.TEXTURE_WRAP_S,B[v.wrapS]),n.texParameteri(D,n.TEXTURE_WRAP_T,B[v.wrapT]),(D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY)&&n.texParameteri(D,n.TEXTURE_WRAP_R,B[v.wrapR]),n.texParameteri(D,n.TEXTURE_MAG_FILTER,ue[v.magFilter]),n.texParameteri(D,n.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction&&(n.texParameteri(D,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(D,n.TEXTURE_COMPARE_FUNC,me[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Bn||v.minFilter!==Ra&&v.minFilter!==us||v.type===zi&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){const S=e.get("EXT_texture_filter_anisotropic");n.texParameterf(D,S.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Ge(D,v){let S=!1;D.__webglInit===void 0&&(D.__webglInit=!0,v.addEventListener("dispose",N));const F=v.source;let Q=p.get(F);Q===void 0&&(Q={},p.set(F,Q));const X=z(v);if(X!==D.__cacheKey){Q[X]===void 0&&(Q[X]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,S=!0),Q[X].usedTimes++;const ne=Q[D.__cacheKey];ne!==void 0&&(Q[D.__cacheKey].usedTimes--,ne.usedTimes===0&&I(v)),D.__cacheKey=X,D.__webglTexture=Q[X].texture}return S}function Qe(D,v,S){let F=n.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(F=n.TEXTURE_2D_ARRAY),v.isData3DTexture&&(F=n.TEXTURE_3D);const Q=Ge(D,v),X=v.source;t.bindTexture(F,D.__webglTexture,n.TEXTURE0+S);const ne=i.get(X);if(X.version!==ne.__version||Q===!0){t.activeTexture(n.TEXTURE0+S);const _e=St.getPrimaries(St.workingColorSpace),fe=v.colorSpace===cs?null:St.getPrimaries(v.colorSpace),Ae=v.colorSpace===cs||_e===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let ge=x(v.image,!1,s.maxTextureSize);ge=Oe(v,ge);const le=r.convert(v.format,v.colorSpace),Ee=r.convert(v.type);let Ce=w(v.internalFormat,le,Ee,v.colorSpace,v.isVideoTexture);Me(F,v);let ye;const we=v.mipmaps,Fe=v.isVideoTexture!==!0,qe=ne.__version===void 0||Q===!0,Y=X.dataReady,k=E(v,ge);if(v.isDepthTexture)Ce=M(v.format===ao,v.type),qe&&(Fe?t.texStorage2D(n.TEXTURE_2D,1,Ce,ge.width,ge.height):t.texImage2D(n.TEXTURE_2D,0,Ce,ge.width,ge.height,0,le,Ee,null));else if(v.isDataTexture)if(we.length>0){Fe&&qe&&t.texStorage2D(n.TEXTURE_2D,k,Ce,we[0].width,we[0].height);for(let j=0,V=we.length;j<V;j++)ye=we[j],Fe?Y&&t.texSubImage2D(n.TEXTURE_2D,j,0,0,ye.width,ye.height,le,Ee,ye.data):t.texImage2D(n.TEXTURE_2D,j,Ce,ye.width,ye.height,0,le,Ee,ye.data);v.generateMipmaps=!1}else Fe?(qe&&t.texStorage2D(n.TEXTURE_2D,k,Ce,ge.width,ge.height),Y&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ge.width,ge.height,le,Ee,ge.data)):t.texImage2D(n.TEXTURE_2D,0,Ce,ge.width,ge.height,0,le,Ee,ge.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Fe&&qe&&t.texStorage3D(n.TEXTURE_2D_ARRAY,k,Ce,we[0].width,we[0].height,ge.depth);for(let j=0,V=we.length;j<V;j++)if(ye=we[j],v.format!==ti)if(le!==null)if(Fe){if(Y)if(v.layerUpdates.size>0){const ee=ap(ye.width,ye.height,v.format,v.type);for(const he of v.layerUpdates){const be=ye.data.subarray(he*ee/ye.data.BYTES_PER_ELEMENT,(he+1)*ee/ye.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,j,0,0,he,ye.width,ye.height,1,le,be,0,0)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,j,0,0,0,ye.width,ye.height,ge.depth,le,ye.data,0,0)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,j,Ce,ye.width,ye.height,ge.depth,0,ye.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?Y&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,j,0,0,0,ye.width,ye.height,ge.depth,le,Ee,ye.data):t.texImage3D(n.TEXTURE_2D_ARRAY,j,Ce,ye.width,ye.height,ge.depth,0,le,Ee,ye.data)}else{Fe&&qe&&t.texStorage2D(n.TEXTURE_2D,k,Ce,we[0].width,we[0].height);for(let j=0,V=we.length;j<V;j++)ye=we[j],v.format!==ti?le!==null?Fe?Y&&t.compressedTexSubImage2D(n.TEXTURE_2D,j,0,0,ye.width,ye.height,le,ye.data):t.compressedTexImage2D(n.TEXTURE_2D,j,Ce,ye.width,ye.height,0,ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?Y&&t.texSubImage2D(n.TEXTURE_2D,j,0,0,ye.width,ye.height,le,Ee,ye.data):t.texImage2D(n.TEXTURE_2D,j,Ce,ye.width,ye.height,0,le,Ee,ye.data)}else if(v.isDataArrayTexture)if(Fe){if(qe&&t.texStorage3D(n.TEXTURE_2D_ARRAY,k,Ce,ge.width,ge.height,ge.depth),Y)if(v.layerUpdates.size>0){const j=ap(ge.width,ge.height,v.format,v.type);for(const V of v.layerUpdates){const ee=ge.data.subarray(V*j/ge.data.BYTES_PER_ELEMENT,(V+1)*j/ge.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,V,ge.width,ge.height,1,le,Ee,ee)}v.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ge.width,ge.height,ge.depth,le,Ee,ge.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ce,ge.width,ge.height,ge.depth,0,le,Ee,ge.data);else if(v.isData3DTexture)Fe?(qe&&t.texStorage3D(n.TEXTURE_3D,k,Ce,ge.width,ge.height,ge.depth),Y&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ge.width,ge.height,ge.depth,le,Ee,ge.data)):t.texImage3D(n.TEXTURE_3D,0,Ce,ge.width,ge.height,ge.depth,0,le,Ee,ge.data);else if(v.isFramebufferTexture){if(qe)if(Fe)t.texStorage2D(n.TEXTURE_2D,k,Ce,ge.width,ge.height);else{let j=ge.width,V=ge.height;for(let ee=0;ee<k;ee++)t.texImage2D(n.TEXTURE_2D,ee,Ce,j,V,0,le,Ee,null),j>>=1,V>>=1}}else if(we.length>0){if(Fe&&qe){const j=Ve(we[0]);t.texStorage2D(n.TEXTURE_2D,k,Ce,j.width,j.height)}for(let j=0,V=we.length;j<V;j++)ye=we[j],Fe?Y&&t.texSubImage2D(n.TEXTURE_2D,j,0,0,le,Ee,ye):t.texImage2D(n.TEXTURE_2D,j,Ce,le,Ee,ye);v.generateMipmaps=!1}else if(Fe){if(qe){const j=Ve(ge);t.texStorage2D(n.TEXTURE_2D,k,Ce,j.width,j.height)}Y&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,le,Ee,ge)}else t.texImage2D(n.TEXTURE_2D,0,Ce,le,Ee,ge);d(v)&&u(F),ne.__version=X.version,v.onUpdate&&v.onUpdate(v)}D.__version=v.version}function $(D,v,S){if(v.image.length!==6)return;const F=Ge(D,v),Q=v.source;t.bindTexture(n.TEXTURE_CUBE_MAP,D.__webglTexture,n.TEXTURE0+S);const X=i.get(Q);if(Q.version!==X.__version||F===!0){t.activeTexture(n.TEXTURE0+S);const ne=St.getPrimaries(St.workingColorSpace),_e=v.colorSpace===cs?null:St.getPrimaries(v.colorSpace),fe=v.colorSpace===cs||ne===_e?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,fe);const Ae=v.isCompressedTexture||v.image[0].isCompressedTexture,ge=v.image[0]&&v.image[0].isDataTexture,le=[];for(let V=0;V<6;V++)!Ae&&!ge?le[V]=x(v.image[V],!0,s.maxCubemapSize):le[V]=ge?v.image[V].image:v.image[V],le[V]=Oe(v,le[V]);const Ee=le[0],Ce=r.convert(v.format,v.colorSpace),ye=r.convert(v.type),we=w(v.internalFormat,Ce,ye,v.colorSpace),Fe=v.isVideoTexture!==!0,qe=X.__version===void 0||F===!0,Y=Q.dataReady;let k=E(v,Ee);Me(n.TEXTURE_CUBE_MAP,v);let j;if(Ae){Fe&&qe&&t.texStorage2D(n.TEXTURE_CUBE_MAP,k,we,Ee.width,Ee.height);for(let V=0;V<6;V++){j=le[V].mipmaps;for(let ee=0;ee<j.length;ee++){const he=j[ee];v.format!==ti?Ce!==null?Fe?Y&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee,0,0,he.width,he.height,Ce,he.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee,we,he.width,he.height,0,he.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?Y&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee,0,0,he.width,he.height,Ce,ye,he.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee,we,he.width,he.height,0,Ce,ye,he.data)}}}else{if(j=v.mipmaps,Fe&&qe){j.length>0&&k++;const V=Ve(le[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,k,we,V.width,V.height)}for(let V=0;V<6;V++)if(ge){Fe?Y&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,0,0,le[V].width,le[V].height,Ce,ye,le[V].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,we,le[V].width,le[V].height,0,Ce,ye,le[V].data);for(let ee=0;ee<j.length;ee++){const be=j[ee].image[V].image;Fe?Y&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee+1,0,0,be.width,be.height,Ce,ye,be.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee+1,we,be.width,be.height,0,Ce,ye,be.data)}}else{Fe?Y&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,0,0,Ce,ye,le[V]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,we,Ce,ye,le[V]);for(let ee=0;ee<j.length;ee++){const he=j[ee];Fe?Y&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee+1,0,0,Ce,ye,he.image[V]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+V,ee+1,we,Ce,ye,he.image[V])}}}d(v)&&u(n.TEXTURE_CUBE_MAP),X.__version=Q.version,v.onUpdate&&v.onUpdate(v)}D.__version=v.version}function te(D,v,S,F,Q,X){const ne=r.convert(S.format,S.colorSpace),_e=r.convert(S.type),fe=w(S.internalFormat,ne,_e,S.colorSpace);if(!i.get(v).__hasExternalTextures){const ge=Math.max(1,v.width>>X),le=Math.max(1,v.height>>X);Q===n.TEXTURE_3D||Q===n.TEXTURE_2D_ARRAY?t.texImage3D(Q,X,fe,ge,le,v.depth,0,ne,_e,null):t.texImage2D(Q,X,fe,ge,le,0,ne,_e,null)}t.bindFramebuffer(n.FRAMEBUFFER,D),$e(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,F,Q,i.get(S).__webglTexture,0,et(v)):(Q===n.TEXTURE_2D||Q>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,F,Q,i.get(S).__webglTexture,X),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ve(D,v,S){if(n.bindRenderbuffer(n.RENDERBUFFER,D),v.depthBuffer){const F=v.depthTexture,Q=F&&F.isDepthTexture?F.type:null,X=M(v.stencilBuffer,Q),ne=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=et(v);$e(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,_e,X,v.width,v.height):S?n.renderbufferStorageMultisample(n.RENDERBUFFER,_e,X,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,X,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ne,n.RENDERBUFFER,D)}else{const F=v.textures;for(let Q=0;Q<F.length;Q++){const X=F[Q],ne=r.convert(X.format,X.colorSpace),_e=r.convert(X.type),fe=w(X.internalFormat,ne,_e,X.colorSpace),Ae=et(v);S&&$e(v)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ae,fe,v.width,v.height):$e(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ae,fe,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,fe,v.width,v.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function de(D,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,D),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(v.depthTexture).__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),G(v.depthTexture,0);const F=i.get(v.depthTexture).__webglTexture,Q=et(v);if(v.depthTexture.format===jr)$e(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,F,0,Q):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,F,0);else if(v.depthTexture.format===ao)$e(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,F,0,Q):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,F,0);else throw new Error("Unknown depthTexture format")}function Pe(D){const v=i.get(D),S=D.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==D.depthTexture){const F=D.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),F){const Q=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,F.removeEventListener("dispose",Q)};F.addEventListener("dispose",Q),v.__depthDisposeCallback=Q}v.__boundDepthTexture=F}if(D.depthTexture&&!v.__autoAllocateDepthBuffer){if(S)throw new Error("target.depthTexture not supported in Cube render targets");de(v.__webglFramebuffer,D)}else if(S){v.__webglDepthbuffer=[];for(let F=0;F<6;F++)if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[F]),v.__webglDepthbuffer[F]===void 0)v.__webglDepthbuffer[F]=n.createRenderbuffer(),ve(v.__webglDepthbuffer[F],D,!1);else{const Q=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,X=v.__webglDepthbuffer[F];n.bindRenderbuffer(n.RENDERBUFFER,X),n.framebufferRenderbuffer(n.FRAMEBUFFER,Q,n.RENDERBUFFER,X)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=n.createRenderbuffer(),ve(v.__webglDepthbuffer,D,!1);else{const F=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Q=v.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,Q),n.framebufferRenderbuffer(n.FRAMEBUFFER,F,n.RENDERBUFFER,Q)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Le(D,v,S){const F=i.get(D);v!==void 0&&te(F.__webglFramebuffer,D,D.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),S!==void 0&&Pe(D)}function He(D){const v=D.texture,S=i.get(D),F=i.get(v);D.addEventListener("dispose",A);const Q=D.textures,X=D.isWebGLCubeRenderTarget===!0,ne=Q.length>1;if(ne||(F.__webglTexture===void 0&&(F.__webglTexture=n.createTexture()),F.__version=v.version,o.memory.textures++),X){S.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)if(v.mipmaps&&v.mipmaps.length>0){S.__webglFramebuffer[_e]=[];for(let fe=0;fe<v.mipmaps.length;fe++)S.__webglFramebuffer[_e][fe]=n.createFramebuffer()}else S.__webglFramebuffer[_e]=n.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){S.__webglFramebuffer=[];for(let _e=0;_e<v.mipmaps.length;_e++)S.__webglFramebuffer[_e]=n.createFramebuffer()}else S.__webglFramebuffer=n.createFramebuffer();if(ne)for(let _e=0,fe=Q.length;_e<fe;_e++){const Ae=i.get(Q[_e]);Ae.__webglTexture===void 0&&(Ae.__webglTexture=n.createTexture(),o.memory.textures++)}if(D.samples>0&&$e(D)===!1){S.__webglMultisampledFramebuffer=n.createFramebuffer(),S.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,S.__webglMultisampledFramebuffer);for(let _e=0;_e<Q.length;_e++){const fe=Q[_e];S.__webglColorRenderbuffer[_e]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,S.__webglColorRenderbuffer[_e]);const Ae=r.convert(fe.format,fe.colorSpace),ge=r.convert(fe.type),le=w(fe.internalFormat,Ae,ge,fe.colorSpace,D.isXRRenderTarget===!0),Ee=et(D);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,le,D.width,D.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.RENDERBUFFER,S.__webglColorRenderbuffer[_e])}n.bindRenderbuffer(n.RENDERBUFFER,null),D.depthBuffer&&(S.__webglDepthRenderbuffer=n.createRenderbuffer(),ve(S.__webglDepthRenderbuffer,D,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(X){t.bindTexture(n.TEXTURE_CUBE_MAP,F.__webglTexture),Me(n.TEXTURE_CUBE_MAP,v);for(let _e=0;_e<6;_e++)if(v.mipmaps&&v.mipmaps.length>0)for(let fe=0;fe<v.mipmaps.length;fe++)te(S.__webglFramebuffer[_e][fe],D,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+_e,fe);else te(S.__webglFramebuffer[_e],D,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0);d(v)&&u(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ne){for(let _e=0,fe=Q.length;_e<fe;_e++){const Ae=Q[_e],ge=i.get(Ae);t.bindTexture(n.TEXTURE_2D,ge.__webglTexture),Me(n.TEXTURE_2D,Ae),te(S.__webglFramebuffer,D,Ae,n.COLOR_ATTACHMENT0+_e,n.TEXTURE_2D,0),d(Ae)&&u(n.TEXTURE_2D)}t.unbindTexture()}else{let _e=n.TEXTURE_2D;if((D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(_e=D.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(_e,F.__webglTexture),Me(_e,v),v.mipmaps&&v.mipmaps.length>0)for(let fe=0;fe<v.mipmaps.length;fe++)te(S.__webglFramebuffer[fe],D,v,n.COLOR_ATTACHMENT0,_e,fe);else te(S.__webglFramebuffer,D,v,n.COLOR_ATTACHMENT0,_e,0);d(v)&&u(_e),t.unbindTexture()}D.depthBuffer&&Pe(D)}function je(D){const v=D.textures;for(let S=0,F=v.length;S<F;S++){const Q=v[S];if(d(Q)){const X=D.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,ne=i.get(Q).__webglTexture;t.bindTexture(X,ne),u(X),t.unbindTexture()}}}const We=[],q=[];function Z(D){if(D.samples>0){if($e(D)===!1){const v=D.textures,S=D.width,F=D.height;let Q=n.COLOR_BUFFER_BIT;const X=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ne=i.get(D),_e=v.length>1;if(_e)for(let fe=0;fe<v.length;fe++)t.bindFramebuffer(n.FRAMEBUFFER,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ne.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ne.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ne.__webglFramebuffer);for(let fe=0;fe<v.length;fe++){if(D.resolveDepthBuffer&&(D.depthBuffer&&(Q|=n.DEPTH_BUFFER_BIT),D.stencilBuffer&&D.resolveStencilBuffer&&(Q|=n.STENCIL_BUFFER_BIT)),_e){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ne.__webglColorRenderbuffer[fe]);const Ae=i.get(v[fe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ae,0)}n.blitFramebuffer(0,0,S,F,0,0,S,F,Q,n.NEAREST),l===!0&&(We.length=0,q.length=0,We.push(n.COLOR_ATTACHMENT0+fe),D.depthBuffer&&D.resolveDepthBuffer===!1&&(We.push(X),q.push(X),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,q)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,We))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),_e)for(let fe=0;fe<v.length;fe++){t.bindFramebuffer(n.FRAMEBUFFER,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,ne.__webglColorRenderbuffer[fe]);const Ae=i.get(v[fe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ne.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,Ae,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ne.__webglMultisampledFramebuffer)}else if(D.depthBuffer&&D.resolveDepthBuffer===!1&&l){const v=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[v])}}}function et(D){return Math.min(s.maxSamples,D.samples)}function $e(D){const v=i.get(D);return D.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function Ue(D){const v=o.render.frame;h.get(D)!==v&&(h.set(D,v),D.update())}function Oe(D,v){const S=D.colorSpace,F=D.format,Q=D.type;return D.isCompressedTexture===!0||D.isVideoTexture===!0||S!==Yi&&S!==cs&&(St.getTransfer(S)===It?(F!==ti||Q!==$i)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",S)),v}function Ve(D){return typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement?(c.width=D.naturalWidth||D.width,c.height=D.naturalHeight||D.height):typeof VideoFrame<"u"&&D instanceof VideoFrame?(c.width=D.displayWidth,c.height=D.displayHeight):(c.width=D.width,c.height=D.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=b,this.setTexture2D=G,this.setTexture2DArray=K,this.setTexture3D=H,this.setTextureCube=ie,this.rebindTextures=Le,this.setupRenderTarget=He,this.updateRenderTargetMipmap=je,this.updateMultisampleRenderTarget=Z,this.setupDepthRenderbuffer=Pe,this.setupFrameBufferTexture=te,this.useMultisampledRTT=$e}function a1(n,e){function t(i,s=cs){let r;const o=St.getTransfer(s);if(i===$i)return n.UNSIGNED_BYTE;if(i===xd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Md)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Vm)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Bm)return n.BYTE;if(i===Hm)return n.SHORT;if(i===ha)return n.UNSIGNED_SHORT;if(i===vd)return n.INT;if(i===tr)return n.UNSIGNED_INT;if(i===zi)return n.FLOAT;if(i===ga)return n.HALF_FLOAT;if(i===Gm)return n.ALPHA;if(i===Wm)return n.RGB;if(i===ti)return n.RGBA;if(i===$m)return n.LUMINANCE;if(i===qm)return n.LUMINANCE_ALPHA;if(i===jr)return n.DEPTH_COMPONENT;if(i===ao)return n.DEPTH_STENCIL;if(i===Xm)return n.RED;if(i===Ed)return n.RED_INTEGER;if(i===Ym)return n.RG;if(i===yd)return n.RG_INTEGER;if(i===Sd)return n.RGBA_INTEGER;if(i===El||i===yl||i===Sl||i===bl)if(o===It)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===El)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===yl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Sl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===bl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===El)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===yl)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Sl)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===bl)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kh||i===Bh||i===Hh||i===Vh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kh)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Bh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Hh)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Vh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Gh||i===Wh||i===$h)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Gh||i===Wh)return o===It?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===$h)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===qh||i===Xh||i===Yh||i===Qh||i===jh||i===Zh||i===Kh||i===Jh||i===eu||i===tu||i===nu||i===iu||i===su||i===ru)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===qh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Xh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Yh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===jh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Zh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Kh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Jh)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===eu)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===tu)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nu)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===iu)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===su)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ru)return o===It?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===wl||i===ou||i===au)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===wl)return o===It?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ou)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===au)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Qm||i===lu||i===cu||i===hu)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===wl)return r.COMPRESSED_RED_RGTC1_EXT;if(i===lu)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===cu)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hu)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===oo?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}let l1=class extends On{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Vr=class extends Qi{constructor(){super(),this.isGroup=!0,this.type="Group"}};const c1={type:"move"};let qc=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Vr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ce,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ce),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ce,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ce),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let s=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const x of e.hand.values()){const d=t.getJointPose(x,i),u=this._getHandJoint(c,x);d!==null&&(u.matrix.fromArray(d.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=d.radius),u.visible=d!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=h.position.distanceTo(f.position),m=.02,g=.005;c.inputState.pinching&&p>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(c1)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}};const h1=` void main() { gl_Position = vec4( position, 1.0 ); }`,u1=` 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; } }`;let d1=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const s=new ai,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ys({vertexShader:h1,fragmentShader:u1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Hn(new m_(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},f1=class extends go{constructor(e,t){super();const i=this;let s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,f=null,p=null,m=null,g=null;const x=new d1,d=t.getContextAttributes();let u=null,w=null;const M=[],E=[],N=new Dt;let A=null;const T=new On;T.layers.enable(1),T.viewport=new $t;const I=new On;I.layers.enable(2),I.viewport=new $t;const C=[T,I],_=new l1;_.layers.enable(1),_.layers.enable(2);let b=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let te=M[$];return te===void 0&&(te=new qc,M[$]=te),te.getTargetRaySpace()},this.getControllerGrip=function($){let te=M[$];return te===void 0&&(te=new qc,M[$]=te),te.getGripSpace()},this.getHand=function($){let te=M[$];return te===void 0&&(te=new qc,M[$]=te),te.getHandSpace()};function z($){const te=E.indexOf($.inputSource);if(te===-1)return;const ve=M[te];ve!==void 0&&(ve.update($.inputSource,$.frame,c||o),ve.dispatchEvent({type:$.type,data:$.inputSource}))}function G(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",G),s.removeEventListener("inputsourceschange",K);for(let $=0;$<M.length;$++){const te=E[$];te!==null&&(E[$]=null,M[$].disconnect(te))}b=null,W=null,x.reset(),e.setRenderTarget(u),m=null,p=null,f=null,s=null,w=null,Qe.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function($){if(s=$,s!==null){if(u=e.getRenderTarget(),s.addEventListener("select",z),s.addEventListener("selectstart",z),s.addEventListener("selectend",z),s.addEventListener("squeeze",z),s.addEventListener("squeezestart",z),s.addEventListener("squeezeend",z),s.addEventListener("end",G),s.addEventListener("inputsourceschange",K),d.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),s.renderState.layers===void 0){const te={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,t,te),s.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),w=new Ms(m.framebufferWidth,m.framebufferHeight,{format:ti,type:$i,colorSpace:e.outputColorSpace,stencilBuffer:d.stencil})}else{let te=null,ve=null,de=null;d.depth&&(de=d.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,te=d.stencil?ao:jr,ve=d.stencil?oo:tr);const Pe={colorFormat:t.RGBA8,depthFormat:de,scaleFactor:r};f=new XRWebGLBinding(s,t),p=f.createProjectionLayer(Pe),s.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),w=new Ms(p.textureWidth,p.textureHeight,{format:ti,type:$i,depthTexture:new g_(p.textureWidth,p.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:d.stencil,colorSpace:e.outputColorSpace,samples:d.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),Qe.setContext(s),Qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function K($){for(let te=0;te<$.removed.length;te++){const ve=$.removed[te],de=E.indexOf(ve);de>=0&&(E[de]=null,M[de].disconnect(ve))}for(let te=0;te<$.added.length;te++){const ve=$.added[te];let de=E.indexOf(ve);if(de===-1){for(let Le=0;Le<M.length;Le++)if(Le>=E.length){E.push(ve),de=Le;break}else if(E[Le]===null){E[Le]=ve,de=Le;break}if(de===-1)break}const Pe=M[de];Pe&&Pe.connect(ve)}}const H=new ce,ie=new ce;function B($,te,ve){H.setFromMatrixPosition(te.matrixWorld),ie.setFromMatrixPosition(ve.matrixWorld);const de=H.distanceTo(ie),Pe=te.projectionMatrix.elements,Le=ve.projectionMatrix.elements,He=Pe[14]/(Pe[10]-1),je=Pe[14]/(Pe[10]+1),We=(Pe[9]+1)/Pe[5],q=(Pe[9]-1)/Pe[5],Z=(Pe[8]-1)/Pe[0],et=(Le[8]+1)/Le[0],$e=He*Z,Ue=He*et,Oe=de/(-Z+et),Ve=Oe*-Z;if(te.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Ve),$.translateZ(Oe),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Pe[10]===-1)$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{const D=He+Oe,v=je+Oe,S=$e-Ve,F=Ue+(de-Ve),Q=We*je/v*D,X=q*je/v*D;$.projectionMatrix.makePerspective(S,F,Q,X,D,v),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function ue($,te){te===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(te.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let te=$.near,ve=$.far;x.texture!==null&&(x.depthNear>0&&(te=x.depthNear),x.depthFar>0&&(ve=x.depthFar)),_.near=I.near=T.near=te,_.far=I.far=T.far=ve,(b!==_.near||W!==_.far)&&(s.updateRenderState({depthNear:_.near,depthFar:_.far}),b=_.near,W=_.far);const de=$.parent,Pe=_.cameras;ue(_,de);for(let Le=0;Le<Pe.length;Le++)ue(Pe[Le],de);Pe.length===2?B(_,T,I):_.projectionMatrix.copy(T.projectionMatrix),me($,_,de)};function me($,te,ve){ve===null?$.matrix.copy(te.matrixWorld):($.matrix.copy(ve.matrixWorld),$.matrix.invert(),$.matrix.multiply(te.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=ua*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return _},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function($){l=$,p!==null&&(p.fixedFoveation=$),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=$)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(_)};let Me=null;function Ge($,te){if(h=te.getViewerPose(c||o),g=te,h!==null){const ve=h.views;m!==null&&(e.setRenderTargetFramebuffer(w,m.framebuffer),e.setRenderTarget(w));let de=!1;ve.length!==_.cameras.length&&(_.cameras.length=0,de=!0);for(let Le=0;Le<ve.length;Le++){const He=ve[Le];let je=null;if(m!==null)je=m.getViewport(He);else{const q=f.getViewSubImage(p,He);je=q.viewport,Le===0&&(e.setRenderTargetTextures(w,q.colorTexture,p.ignoreDepthValues?void 0:q.depthStencilTexture),e.setRenderTarget(w))}let We=C[Le];We===void 0&&(We=new On,We.layers.enable(Le),We.viewport=new $t,C[Le]=We),We.matrix.fromArray(He.transform.matrix),We.matrix.decompose(We.position,We.quaternion,We.scale),We.projectionMatrix.fromArray(He.projectionMatrix),We.projectionMatrixInverse.copy(We.projectionMatrix).invert(),We.viewport.set(je.x,je.y,je.width,je.height),Le===0&&(_.matrix.copy(We.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale)),de===!0&&_.cameras.push(We)}const Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")){const Le=f.getDepthInformation(ve[0]);Le&&Le.isValid&&Le.texture&&x.init(e,Le,s.renderState)}}for(let ve=0;ve<M.length;ve++){const de=E[ve],Pe=M[ve];de!==null&&Pe!==void 0&&Pe.update(de,te,c||o)}Me&&Me($,te),te.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:te}),g=null}const Qe=new p_;Qe.setAnimationLoop(Ge),this.setAnimationLoop=function($){Me=$},this.dispose=function(){}}};const Os=new Es,p1=new qt;function m1(n,e){function t(d,u){d.matrixAutoUpdate===!0&&d.updateMatrix(),u.value.copy(d.matrix)}function i(d,u){u.color.getRGB(d.fogColor.value,u_(n)),u.isFog?(d.fogNear.value=u.near,d.fogFar.value=u.far):u.isFogExp2&&(d.fogDensity.value=u.density)}function s(d,u,w,M,E){u.isMeshBasicMaterial||u.isMeshLambertMaterial?r(d,u):u.isMeshToonMaterial?(r(d,u),f(d,u)):u.isMeshPhongMaterial?(r(d,u),h(d,u)):u.isMeshStandardMaterial?(r(d,u),p(d,u),u.isMeshPhysicalMaterial&&m(d,u,E)):u.isMeshMatcapMaterial?(r(d,u),g(d,u)):u.isMeshDepthMaterial?r(d,u):u.isMeshDistanceMaterial?(r(d,u),x(d,u)):u.isMeshNormalMaterial?r(d,u):u.isLineBasicMaterial?(o(d,u),u.isLineDashedMaterial&&a(d,u)):u.isPointsMaterial?l(d,u,w,M):u.isSpriteMaterial?c(d,u):u.isShadowMaterial?(d.color.value.copy(u.color),d.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function r(d,u){d.opacity.value=u.opacity,u.color&&d.diffuse.value.copy(u.color),u.emissive&&d.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.bumpMap&&(d.bumpMap.value=u.bumpMap,t(u.bumpMap,d.bumpMapTransform),d.bumpScale.value=u.bumpScale,u.side===Sn&&(d.bumpScale.value*=-1)),u.normalMap&&(d.normalMap.value=u.normalMap,t(u.normalMap,d.normalMapTransform),d.normalScale.value.copy(u.normalScale),u.side===Sn&&d.normalScale.value.negate()),u.displacementMap&&(d.displacementMap.value=u.displacementMap,t(u.displacementMap,d.displacementMapTransform),d.displacementScale.value=u.displacementScale,d.displacementBias.value=u.displacementBias),u.emissiveMap&&(d.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,d.emissiveMapTransform)),u.specularMap&&(d.specularMap.value=u.specularMap,t(u.specularMap,d.specularMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest);const w=e.get(u),M=w.envMap,E=w.envMapRotation;M&&(d.envMap.value=M,Os.copy(E),Os.x*=-1,Os.y*=-1,Os.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Os.y*=-1,Os.z*=-1),d.envMapRotation.value.setFromMatrix4(p1.makeRotationFromEuler(Os)),d.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=u.reflectivity,d.ior.value=u.ior,d.refractionRatio.value=u.refractionRatio),u.lightMap&&(d.lightMap.value=u.lightMap,d.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,d.lightMapTransform)),u.aoMap&&(d.aoMap.value=u.aoMap,d.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,d.aoMapTransform))}function o(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform))}function a(d,u){d.dashSize.value=u.dashSize,d.totalSize.value=u.dashSize+u.gapSize,d.scale.value=u.scale}function l(d,u,w,M){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.size.value=u.size*w,d.scale.value=M*.5,u.map&&(d.map.value=u.map,t(u.map,d.uvTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function c(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.rotation.value=u.rotation,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function h(d,u){d.specular.value.copy(u.specular),d.shininess.value=Math.max(u.shininess,1e-4)}function f(d,u){u.gradientMap&&(d.gradientMap.value=u.gradientMap)}function p(d,u){d.metalness.value=u.metalness,u.metalnessMap&&(d.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,d.metalnessMapTransform)),d.roughness.value=u.roughness,u.roughnessMap&&(d.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,d.roughnessMapTransform)),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)}function m(d,u,w){d.ior.value=u.ior,u.sheen>0&&(d.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),d.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(d.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,d.sheenColorMapTransform)),u.sheenRoughnessMap&&(d.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,d.sheenRoughnessMapTransform))),u.clearcoat>0&&(d.clearcoat.value=u.clearcoat,d.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(d.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,d.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(d.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===Sn&&d.clearcoatNormalScale.value.negate())),u.dispersion>0&&(d.dispersion.value=u.dispersion),u.iridescence>0&&(d.iridescence.value=u.iridescence,d.iridescenceIOR.value=u.iridescenceIOR,d.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(d.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,d.iridescenceMapTransform)),u.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),u.transmission>0&&(d.transmission.value=u.transmission,d.transmissionSamplerMap.value=w.texture,d.transmissionSamplerSize.value.set(w.width,w.height),u.transmissionMap&&(d.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,d.transmissionMapTransform)),d.thickness.value=u.thickness,u.thicknessMap&&(d.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=u.attenuationDistance,d.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(d.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(d.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=u.specularIntensity,d.specularColor.value.copy(u.specularColor),u.specularColorMap&&(d.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,d.specularColorMapTransform)),u.specularIntensityMap&&(d.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,u){u.matcap&&(d.matcap.value=u.matcap)}function x(d,u){const w=e.get(u).light;d.referencePosition.value.setFromMatrixPosition(w.matrixWorld),d.nearDistance.value=w.shadow.camera.near,d.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function _1(n,e,t,i){let s={},r={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,M){const E=M.program;i.uniformBlockBinding(w,E)}function c(w,M){let E=s[w.id];E===void 0&&(g(w),E=h(w),s[w.id]=E,w.addEventListener("dispose",d));const N=M.program;i.updateUBOMapping(w,N);const A=e.render.frame;r[w.id]!==A&&(p(w),r[w.id]=A)}function h(w){const M=f();w.__bindingPointIndex=M;const E=n.createBuffer(),N=w.__size,A=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,N,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,M,E),E}function f(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(w){const M=s[w.id],E=w.uniforms,N=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,M);for(let A=0,T=E.length;A<T;A++){const I=Array.isArray(E[A])?E[A]:[E[A]];for(let C=0,_=I.length;C<_;C++){const b=I[C];if(m(b,A,C,N)===!0){const W=b.__offset,z=Array.isArray(b.value)?b.value:[b.value];let G=0;for(let K=0;K<z.length;K++){const H=z[K],ie=x(H);typeof H=="number"||typeof H=="boolean"?(b.__data[0]=H,n.bufferSubData(n.UNIFORM_BUFFER,W+G,b.__data)):H.isMatrix3?(b.__data[0]=H.elements[0],b.__data[1]=H.elements[1],b.__data[2]=H.elements[2],b.__data[3]=0,b.__data[4]=H.elements[3],b.__data[5]=H.elements[4],b.__data[6]=H.elements[5],b.__data[7]=0,b.__data[8]=H.elements[6],b.__data[9]=H.elements[7],b.__data[10]=H.elements[8],b.__data[11]=0):(H.toArray(b.__data,G),G+=ie.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,W,b.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(w,M,E,N){const A=w.value,T=M+"_"+E;if(N[T]===void 0)return typeof A=="number"||typeof A=="boolean"?N[T]=A:N[T]=A.clone(),!0;{const I=N[T];if(typeof A=="number"||typeof A=="boolean"){if(I!==A)return N[T]=A,!0}else if(I.equals(A)===!1)return I.copy(A),!0}return!1}function g(w){const M=w.uniforms;let E=0;const N=16;for(let T=0,I=M.length;T<I;T++){const C=Array.isArray(M[T])?M[T]:[M[T]];for(let _=0,b=C.length;_<b;_++){const W=C[_],z=Array.isArray(W.value)?W.value:[W.value];for(let G=0,K=z.length;G<K;G++){const H=z[G],ie=x(H),B=E%N,ue=B%ie.boundary,me=B+ue;E+=ue,me!==0&&N-me<ie.storage&&(E+=N-me),W.__data=new Float32Array(ie.storage/Float32Array.BYTES_PER_ELEMENT),W.__offset=E,E+=ie.storage}}}const A=E%N;return A>0&&(E+=N-A),w.__size=E,w.__cache={},this}function x(w){const M={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(M.boundary=4,M.storage=4):w.isVector2?(M.boundary=8,M.storage=8):w.isVector3||w.isColor?(M.boundary=16,M.storage=12):w.isVector4?(M.boundary=16,M.storage=16):w.isMatrix3?(M.boundary=48,M.storage=48):w.isMatrix4?(M.boundary=64,M.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),M}function d(w){const M=w.target;M.removeEventListener("dispose",d);const E=o.indexOf(M.__bindingPointIndex);o.splice(E,1),n.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function u(){for(const w in s)n.deleteBuffer(s[w]);o=[],s={},r={}}return{bind:l,update:c,dispose:u}}let g1=class{constructor(e={}){const{canvas:t=iy(),context:i=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=o;const m=new Uint32Array(4),g=new Int32Array(4);let x=null,d=null;const u=[],w=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=di,this.toneMapping=fs,this.toneMappingExposure=1;const M=this;let E=!1,N=0,A=0,T=null,I=-1,C=null;const _=new $t,b=new $t;let W=null;const z=new Rt(0);let G=0,K=t.width,H=t.height,ie=1,B=null,ue=null;const me=new $t(0,0,K,H),Me=new $t(0,0,K,H);let Ge=!1;const Qe=new Rd;let $=!1,te=!1;const ve=new qt,de=new qt,Pe=new ce,Le=new $t,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let je=!1;function We(){return T===null?ie:1}let q=i;function Z(P,y){return t.getContext(P,y)}try{const P={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${gd}`),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",he,!1),q===null){const y="webgl2";if(q=Z(y,P),q===null)throw Z(y)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let et,$e,Ue,Oe,Ve,D,v,S,F,Q,X,ne,_e,fe,Ae,ge,le,Ee,Ce,ye,we,Fe,qe,Y;function k(){et=new yw(q),et.init(),Fe=new a1(q,et),$e=new mw(q,et,e,Fe),Ue=new s1(q),$e.reverseDepthBuffer&&Ue.buffers.depth.setReversed(!0),Oe=new ww(q),Ve=new GT,D=new o1(q,et,Ue,Ve,$e,Fe,Oe),v=new gw(M),S=new Ew(M),F=new Ly(q),qe=new fw(q,F),Q=new Sw(q,F,Oe,qe),X=new Aw(q,Q,F,Oe),Ce=new Tw(q,$e,D),ge=new _w(Ve),ne=new VT(M,v,S,et,$e,qe,ge),_e=new m1(M,Ve),fe=new $T,Ae=new ZT(et),Ee=new dw(M,v,S,Ue,X,p,l),le=new n1(M,X,$e),Y=new _1(q,Oe,$e,Ue),ye=new pw(q,et,Oe),we=new bw(q,et,Oe),Oe.programs=ne.programs,M.capabilities=$e,M.extensions=et,M.properties=Ve,M.renderLists=fe,M.shadowMap=le,M.state=Ue,M.info=Oe}k();const j=new f1(M,q);this.xr=j,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const P=et.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=et.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(P){P!==void 0&&(ie=P,this.setSize(K,H,!1))},this.getSize=function(P){return P.set(K,H)},this.setSize=function(P,y,R=!0){if(j.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=P,H=y,t.width=Math.floor(P*ie),t.height=Math.floor(y*ie),R===!0&&(t.style.width=P+"px",t.style.height=y+"px"),this.setViewport(0,0,P,y)},this.getDrawingBufferSize=function(P){return P.set(K*ie,H*ie).floor()},this.setDrawingBufferSize=function(P,y,R){K=P,H=y,ie=R,t.width=Math.floor(P*R),t.height=Math.floor(y*R),this.setViewport(0,0,P,y)},this.getCurrentViewport=function(P){return P.copy(_)},this.getViewport=function(P){return P.copy(me)},this.setViewport=function(P,y,R,U){P.isVector4?me.set(P.x,P.y,P.z,P.w):me.set(P,y,R,U),Ue.viewport(_.copy(me).multiplyScalar(ie).round())},this.getScissor=function(P){return P.copy(Me)},this.setScissor=function(P,y,R,U){P.isVector4?Me.set(P.x,P.y,P.z,P.w):Me.set(P,y,R,U),Ue.scissor(b.copy(Me).multiplyScalar(ie).round())},this.getScissorTest=function(){return Ge},this.setScissorTest=function(P){Ue.setScissorTest(Ge=P)},this.setOpaqueSort=function(P){B=P},this.setTransparentSort=function(P){ue=P},this.getClearColor=function(P){return P.copy(Ee.getClearColor())},this.setClearColor=function(){Ee.setClearColor.apply(Ee,arguments)},this.getClearAlpha=function(){return Ee.getClearAlpha()},this.setClearAlpha=function(){Ee.setClearAlpha.apply(Ee,arguments)},this.clear=function(P=!0,y=!0,R=!0){let U=0;if(P){let L=!1;if(T!==null){const O=T.texture.format;L=O===Sd||O===yd||O===Ed}if(L){const O=T.texture.type,oe=O===$i||O===tr||O===ha||O===oo||O===xd||O===Md,pe=Ee.getClearColor(),xe=Ee.getClearAlpha(),Se=pe.r,Re=pe.g,Te=pe.b;oe?(m[0]=Se,m[1]=Re,m[2]=Te,m[3]=xe,q.clearBufferuiv(q.COLOR,0,m)):(g[0]=Se,g[1]=Re,g[2]=Te,g[3]=xe,q.clearBufferiv(q.COLOR,0,g))}else U|=q.COLOR_BUFFER_BIT}y&&(U|=q.DEPTH_BUFFER_BIT,q.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),R&&(U|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(U)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",V,!1),t.removeEventListener("webglcontextrestored",ee,!1),t.removeEventListener("webglcontextcreationerror",he,!1),fe.dispose(),Ae.dispose(),Ve.dispose(),v.dispose(),S.dispose(),X.dispose(),qe.dispose(),Y.dispose(),ne.dispose(),j.dispose(),j.removeEventListener("sessionstart",In),j.removeEventListener("sessionend",Ao),li.stop()};function V(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const P=Oe.autoReset,y=le.enabled,R=le.autoUpdate,U=le.needsUpdate,L=le.type;k(),Oe.autoReset=P,le.enabled=y,le.autoUpdate=R,le.needsUpdate=U,le.type=L}function he(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function be(P){const y=P.target;y.removeEventListener("dispose",be),Xe(y)}function Xe(P){xt(P),Ve.remove(P)}function xt(P){const y=Ve.get(P).programs;y!==void 0&&(y.forEach(function(R){ne.releaseProgram(R)}),P.isShaderMaterial&&ne.releaseShaderCache(P))}this.renderBufferDirect=function(P,y,R,U,L,O){y===null&&(y=He);const oe=L.isMesh&&L.matrixWorld.determinant()<0,pe=Aa(P,y,R,U,L);Ue.setMaterial(U,oe);let xe=R.index,Se=1;if(U.wireframe===!0){if(xe=Q.getWireframeAttribute(R),xe===void 0)return;Se=2}const Re=R.drawRange,Te=R.attributes.position;let De=Re.start*Se,Ye=(Re.start+Re.count)*Se;O!==null&&(De=Math.max(De,O.start*Se),Ye=Math.min(Ye,(O.start+O.count)*Se)),xe!==null?(De=Math.max(De,0),Ye=Math.min(Ye,xe.count)):Te!=null&&(De=Math.max(De,0),Ye=Math.min(Ye,Te.count));const Ze=Ye-De;if(Ze<0||Ze===1/0)return;qe.setup(L,U,pe,R,xe);let _t,tt=ye;if(xe!==null&&(_t=F.get(xe),tt=we,tt.setIndex(_t)),L.isMesh)U.wireframe===!0?(Ue.setLineWidth(U.wireframeLinewidth*We()),tt.setMode(q.LINES)):tt.setMode(q.TRIANGLES);else if(L.isLine){let Ie=U.linewidth;Ie===void 0&&(Ie=1),Ue.setLineWidth(Ie*We()),L.isLineSegments?tt.setMode(q.LINES):L.isLineLoop?tt.setMode(q.LINE_LOOP):tt.setMode(q.LINE_STRIP)}else L.isPoints?tt.setMode(q.POINTS):L.isSprite&&tt.setMode(q.TRIANGLES);if(L.isBatchedMesh)if(L._multiDrawInstances!==null)tt.renderMultiDrawInstances(L._multiDrawStarts,L._multiDrawCounts,L._multiDrawCount,L._multiDrawInstances);else if(et.get("WEBGL_multi_draw"))tt.renderMultiDraw(L._multiDrawStarts,L._multiDrawCounts,L._multiDrawCount);else{const Ie=L._multiDrawStarts,Be=L._multiDrawCounts,ut=L._multiDrawCount,ot=xe?F.get(xe).bytesPerElement:1,Zt=Ve.get(U).currentProgram.getUniforms();for(let kt=0;kt<ut;kt++)Zt.setValue(q,"_gl_DrawID",kt),tt.render(Ie[kt]/ot,Be[kt])}else if(L.isInstancedMesh)tt.renderInstances(De,Ze,L.count);else if(R.isInstancedBufferGeometry){const Ie=R._maxInstanceCount!==void 0?R._maxInstanceCount:1/0,Be=Math.min(R.instanceCount,Ie);tt.renderInstances(De,Ze,Be)}else tt.render(De,Ze)};function Je(P,y,R){P.transparent===!0&&P.side===Oi&&P.forceSinglePass===!1?(P.side=Sn,P.needsUpdate=!0,Ps(P,y,R),P.side=xs,P.needsUpdate=!0,Ps(P,y,R),P.side=Oi):Ps(P,y,R)}this.compile=function(P,y,R=null){R===null&&(R=P),d=Ae.get(R),d.init(y),w.push(d),R.traverseVisible(function(L){L.isLight&&L.layers.test(y.layers)&&(d.pushLight(L),L.castShadow&&d.pushShadow(L))}),P!==R&&P.traverseVisible(function(L){L.isLight&&L.layers.test(y.layers)&&(d.pushLight(L),L.castShadow&&d.pushShadow(L))}),d.setupLights();const U=new Set;return P.traverse(function(L){if(!(L.isMesh||L.isPoints||L.isLine||L.isSprite))return;const O=L.material;if(O)if(Array.isArray(O))for(let oe=0;oe<O.length;oe++){const pe=O[oe];Je(pe,R,L),U.add(pe)}else Je(O,R,L),U.add(O)}),w.pop(),d=null,U},this.compileAsync=function(P,y,R=null){const U=this.compile(P,y,R);return new Promise(L=>{function O(){if(U.forEach(function(oe){Ve.get(oe).currentProgram.isReady()&&U.delete(oe)}),U.size===0){L(P);return}setTimeout(O,10)}et.get("KHR_parallel_shader_compile")!==null?O():setTimeout(O,10)})};let st=null;function Ot(P){st&&st(P)}function In(){li.stop()}function Ao(){li.start()}const li=new p_;li.setAnimationLoop(Ot),typeof self<"u"&&li.setContext(self),this.setAnimationLoop=function(P){st=P,j.setAnimationLoop(P),P===null?li.stop():li.start()},j.addEventListener("sessionstart",In),j.addEventListener("sessionend",Ao),this.render=function(P,y){if(y!==void 0&&y.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),y.parent===null&&y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),j.enabled===!0&&j.isPresenting===!0&&(j.cameraAutoUpdate===!0&&j.updateCamera(y),y=j.getCamera()),P.isScene===!0&&P.onBeforeRender(M,P,y,T),d=Ae.get(P,w.length),d.init(y),w.push(d),de.multiplyMatrices(y.projectionMatrix,y.matrixWorldInverse),Qe.setFromProjectionMatrix(de),te=this.localClippingEnabled,$=ge.init(this.clippingPlanes,te),x=fe.get(P,u.length),x.init(),u.push(x),j.enabled===!0&&j.isPresenting===!0){const O=M.xr.getDepthSensingMesh();O!==null&&$n(O,y,-1/0,M.sortObjects)}$n(P,y,0,M.sortObjects),x.finish(),M.sortObjects===!0&&x.sort(B,ue),je=j.enabled===!1||j.isPresenting===!1||j.hasDepthSensing()===!1,je&&Ee.addToRenderList(x,P),this.info.render.frame++,$===!0&&ge.beginShadows();const R=d.state.shadowsArray;le.render(R,P,y),$===!0&&ge.endShadows(),this.info.autoReset===!0&&this.info.reset();const U=x.opaque,L=x.transmissive;if(d.setupLights(),y.isArrayCamera){const O=y.cameras;if(L.length>0)for(let oe=0,pe=O.length;oe<pe;oe++){const xe=O[oe];Co(U,L,P,xe)}je&&Ee.render(P);for(let oe=0,pe=O.length;oe<pe;oe++){const xe=O[oe];ar(x,P,xe,xe.viewport)}}else L.length>0&&Co(U,L,P,y),je&&Ee.render(P),ar(x,P,y);T!==null&&(D.updateMultisampleRenderTarget(T),D.updateRenderTargetMipmap(T)),P.isScene===!0&&P.onAfterRender(M,P,y),qe.resetDefaultState(),I=-1,C=null,w.pop(),w.length>0?(d=w[w.length-1],$===!0&&ge.setGlobalState(M.clippingPlanes,d.state.camera)):d=null,u.pop(),u.length>0?x=u[u.length-1]:x=null};function $n(P,y,R,U){if(P.visible===!1)return;if(P.layers.test(y.layers)){if(P.isGroup)R=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(y);else if(P.isLight)d.pushLight(P),P.castShadow&&d.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||Qe.intersectsSprite(P)){U&&Le.setFromMatrixPosition(P.matrixWorld).applyMatrix4(de);const oe=X.update(P),pe=P.material;pe.visible&&x.push(P,oe,pe,R,Le.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||Qe.intersectsObject(P))){const oe=X.update(P),pe=P.material;if(U&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),Le.copy(P.boundingSphere.center)):(oe.boundingSphere===null&&oe.computeBoundingSphere(),Le.copy(oe.boundingSphere.center)),Le.applyMatrix4(P.matrixWorld).applyMatrix4(de)),Array.isArray(pe)){const xe=oe.groups;for(let Se=0,Re=xe.length;Se<Re;Se++){const Te=xe[Se],De=pe[Te.materialIndex];De&&De.visible&&x.push(P,oe,De,R,Le.z,Te)}}else pe.visible&&x.push(P,oe,pe,R,Le.z,null)}}const O=P.children;for(let oe=0,pe=O.length;oe<pe;oe++)$n(O[oe],y,R,U)}function ar(P,y,R,U){const L=P.opaque,O=P.transmissive,oe=P.transparent;d.setupLightsView(R),$===!0&&ge.setGlobalState(M.clippingPlanes,R),U&&Ue.viewport(_.copy(U)),L.length>0&&Cs(L,y,R),O.length>0&&Cs(O,y,R),oe.length>0&&Cs(oe,y,R),Ue.buffers.depth.setTest(!0),Ue.buffers.depth.setMask(!0),Ue.buffers.color.setMask(!0),Ue.setPolygonOffset(!1)}function Co(P,y,R,U){if((R.isScene===!0?R.overrideMaterial:null)!==null)return;d.state.transmissionRenderTarget[U.id]===void 0&&(d.state.transmissionRenderTarget[U.id]=new Ms(1,1,{generateMipmaps:!0,type:et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float")?ga:$i,minFilter:us,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:St.workingColorSpace}));const O=d.state.transmissionRenderTarget[U.id],oe=U.viewport||_;O.setSize(oe.z,oe.w);const pe=M.getRenderTarget();M.setRenderTarget(O),M.getClearColor(z),G=M.getClearAlpha(),G<1&&M.setClearColor(16777215,.5),M.clear(),je&&Ee.render(R);const xe=M.toneMapping;M.toneMapping=fs;const Se=U.viewport;if(U.viewport!==void 0&&(U.viewport=void 0),d.setupLightsView(U),$===!0&&ge.setGlobalState(M.clippingPlanes,U),Cs(P,R,U),D.updateMultisampleRenderTarget(O),D.updateRenderTargetMipmap(O),et.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let Te=0,De=y.length;Te<De;Te++){const Ye=y[Te],Ze=Ye.object,_t=Ye.geometry,tt=Ye.material,Ie=Ye.group;if(tt.side===Oi&&Ze.layers.test(U.layers)){const Be=tt.side;tt.side=Sn,tt.needsUpdate=!0,Rs(Ze,R,U,_t,tt,Ie),tt.side=Be,tt.needsUpdate=!0,Re=!0}}Re===!0&&(D.updateMultisampleRenderTarget(O),D.updateRenderTargetMipmap(O))}M.setRenderTarget(pe),M.setClearColor(z,G),Se!==void 0&&(U.viewport=Se),M.toneMapping=xe}function Cs(P,y,R){const U=y.isScene===!0?y.overrideMaterial:null;for(let L=0,O=P.length;L<O;L++){const oe=P[L],pe=oe.object,xe=oe.geometry,Se=U===null?oe.material:U,Re=oe.group;pe.layers.test(R.layers)&&Rs(pe,y,R,xe,Se,Re)}}function Rs(P,y,R,U,L,O){P.onBeforeRender(M,y,R,U,L,O),P.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),L.onBeforeRender(M,y,R,U,P,O),L.transparent===!0&&L.side===Oi&&L.forceSinglePass===!1?(L.side=Sn,L.needsUpdate=!0,M.renderBufferDirect(R,y,U,L,P,O),L.side=xs,L.needsUpdate=!0,M.renderBufferDirect(R,y,U,L,P,O),L.side=Oi):M.renderBufferDirect(R,y,U,L,P,O),P.onAfterRender(M,y,R,U,L,O)}function Ps(P,y,R){y.isScene!==!0&&(y=He);const U=Ve.get(P),L=d.state.lights,O=d.state.shadowsArray,oe=L.state.version,pe=ne.getParameters(P,L.state,O,y,R),xe=ne.getProgramCacheKey(pe);let Se=U.programs;U.environment=P.isMeshStandardMaterial?y.environment:null,U.fog=y.fog,U.envMap=(P.isMeshStandardMaterial?S:v).get(P.envMap||U.environment),U.envMapRotation=U.environment!==null&&P.envMap===null?y.environmentRotation:P.envMapRotation,Se===void 0&&(P.addEventListener("dispose",be),Se=new Map,U.programs=Se);let Re=Se.get(xe);if(Re!==void 0){if(U.currentProgram===Re&&U.lightsStateVersion===oe)return Ro(P,pe),Re}else pe.uniforms=ne.getUniforms(P),P.onBeforeCompile(pe,M),Re=ne.acquireProgram(pe,xe),Se.set(xe,Re),U.uniforms=pe.uniforms;const Te=U.uniforms;return(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&(Te.clippingPlanes=ge.uniform),Ro(P,pe),U.needsLights=_c(P),U.lightsStateVersion=oe,U.needsLights&&(Te.ambientLightColor.value=L.state.ambient,Te.lightProbe.value=L.state.probe,Te.directionalLights.value=L.state.directional,Te.directionalLightShadows.value=L.state.directionalShadow,Te.spotLights.value=L.state.spot,Te.spotLightShadows.value=L.state.spotShadow,Te.rectAreaLights.value=L.state.rectArea,Te.ltc_1.value=L.state.rectAreaLTC1,Te.ltc_2.value=L.state.rectAreaLTC2,Te.pointLights.value=L.state.point,Te.pointLightShadows.value=L.state.pointShadow,Te.hemisphereLights.value=L.state.hemi,Te.directionalShadowMap.value=L.state.directionalShadowMap,Te.directionalShadowMatrix.value=L.state.directionalShadowMatrix,Te.spotShadowMap.value=L.state.spotShadowMap,Te.spotLightMatrix.value=L.state.spotLightMatrix,Te.spotLightMap.value=L.state.spotLightMap,Te.pointShadowMap.value=L.state.pointShadowMap,Te.pointShadowMatrix.value=L.state.pointShadowMatrix),U.currentProgram=Re,U.uniformsList=null,Re}function Ls(P){if(P.uniformsList===null){const y=P.currentProgram.getUniforms();P.uniformsList=Rl.seqWithValue(y.seq,P.uniforms)}return P.uniformsList}function Ro(P,y){const R=Ve.get(P);R.outputColorSpace=y.outputColorSpace,R.batching=y.batching,R.batchingColor=y.batchingColor,R.instancing=y.instancing,R.instancingColor=y.instancingColor,R.instancingMorph=y.instancingMorph,R.skinning=y.skinning,R.morphTargets=y.morphTargets,R.morphNormals=y.morphNormals,R.morphColors=y.morphColors,R.morphTargetsCount=y.morphTargetsCount,R.numClippingPlanes=y.numClippingPlanes,R.numIntersection=y.numClipIntersection,R.vertexAlphas=y.vertexAlphas,R.vertexTangents=y.vertexTangents,R.toneMapping=y.toneMapping}function Aa(P,y,R,U,L){y.isScene!==!0&&(y=He),D.resetTextureUnits();const O=y.fog,oe=U.isMeshStandardMaterial?y.environment:null,pe=T===null?M.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:Yi,xe=(U.isMeshStandardMaterial?S:v).get(U.envMap||oe),Se=U.vertexColors===!0&&!!R.attributes.color&&R.attributes.color.itemSize===4,Re=!!R.attributes.tangent&&(!!U.normalMap||U.anisotropy>0),Te=!!R.morphAttributes.position,De=!!R.morphAttributes.normal,Ye=!!R.morphAttributes.color;let Ze=fs;U.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Ze=M.toneMapping);const _t=R.morphAttributes.position||R.morphAttributes.normal||R.morphAttributes.color,tt=_t!==void 0?_t.length:0,Ie=Ve.get(U),Be=d.state.lights;if($===!0&&(te===!0||P!==C)){const Kt=P===C&&U.id===I;ge.setState(U,P,Kt)}let ut=!1;U.version===Ie.__version?(Ie.needsLights&&Ie.lightsStateVersion!==Be.state.version||Ie.outputColorSpace!==pe||L.isBatchedMesh&&Ie.batching===!1||!L.isBatchedMesh&&Ie.batching===!0||L.isBatchedMesh&&Ie.batchingColor===!0&&L.colorTexture===null||L.isBatchedMesh&&Ie.batchingColor===!1&&L.colorTexture!==null||L.isInstancedMesh&&Ie.instancing===!1||!L.isInstancedMesh&&Ie.instancing===!0||L.isSkinnedMesh&&Ie.skinning===!1||!L.isSkinnedMesh&&Ie.skinning===!0||L.isInstancedMesh&&Ie.instancingColor===!0&&L.instanceColor===null||L.isInstancedMesh&&Ie.instancingColor===!1&&L.instanceColor!==null||L.isInstancedMesh&&Ie.instancingMorph===!0&&L.morphTexture===null||L.isInstancedMesh&&Ie.instancingMorph===!1&&L.morphTexture!==null||Ie.envMap!==xe||U.fog===!0&&Ie.fog!==O||Ie.numClippingPlanes!==void 0&&(Ie.numClippingPlanes!==ge.numPlanes||Ie.numIntersection!==ge.numIntersection)||Ie.vertexAlphas!==Se||Ie.vertexTangents!==Re||Ie.morphTargets!==Te||Ie.morphNormals!==De||Ie.morphColors!==Ye||Ie.toneMapping!==Ze||Ie.morphTargetsCount!==tt)&&(ut=!0):(ut=!0,Ie.__version=U.version);let ot=Ie.currentProgram;ut===!0&&(ot=Ps(U,y,L));let Zt=!1,kt=!1,sn=!1;const Pt=ot.getUniforms(),Mt=Ie.uniforms;if(Ue.useProgram(ot.program)&&(Zt=!0,kt=!0,sn=!0),U.id!==I&&(I=U.id,kt=!0),Zt||C!==P){$e.reverseDepthBuffer?(ve.copy(P.projectionMatrix),ry(ve),oy(ve),Pt.setValue(q,"projectionMatrix",ve)):Pt.setValue(q,"projectionMatrix",P.projectionMatrix),Pt.setValue(q,"viewMatrix",P.matrixWorldInverse);const Kt=Pt.map.cameraPosition;Kt!==void 0&&Kt.setValue(q,Pe.setFromMatrixPosition(P.matrixWorld)),$e.logarithmicDepthBuffer&&Pt.setValue(q,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&Pt.setValue(q,"isOrthographic",P.isOrthographicCamera===!0),C!==P&&(C=P,kt=!0,sn=!0)}if(L.isSkinnedMesh){Pt.setOptional(q,L,"bindMatrix"),Pt.setOptional(q,L,"bindMatrixInverse");const Kt=L.skeleton;Kt&&(Kt.boneTexture===null&&Kt.computeBoneTexture(),Pt.setValue(q,"boneTexture",Kt.boneTexture,D))}L.isBatchedMesh&&(Pt.setOptional(q,L,"batchingTexture"),Pt.setValue(q,"batchingTexture",L._matricesTexture,D),Pt.setOptional(q,L,"batchingIdTexture"),Pt.setValue(q,"batchingIdTexture",L._indirectTexture,D),Pt.setOptional(q,L,"batchingColorTexture"),L._colorsTexture!==null&&Pt.setValue(q,"batchingColorTexture",L._colorsTexture,D));const En=R.morphAttributes;if((En.position!==void 0||En.normal!==void 0||En.color!==void 0)&&Ce.update(L,R,ot),(kt||Ie.receiveShadow!==L.receiveShadow)&&(Ie.receiveShadow=L.receiveShadow,Pt.setValue(q,"receiveShadow",L.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Mt.envMap.value=xe,Mt.flipEnvMap.value=xe.isCubeTexture&&xe.isRenderTargetTexture===!1?-1:1),U.isMeshStandardMaterial&&U.envMap===null&&y.environment!==null&&(Mt.envMapIntensity.value=y.environmentIntensity),kt&&(Pt.setValue(q,"toneMappingExposure",M.toneMappingExposure),Ie.needsLights&&mc(Mt,sn),O&&U.fog===!0&&_e.refreshFogUniforms(Mt,O),_e.refreshMaterialUniforms(Mt,U,ie,H,d.state.transmissionRenderTarget[P.id]),Rl.upload(q,Ls(Ie),Mt,D)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(Rl.upload(q,Ls(Ie),Mt,D),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&Pt.setValue(q,"center",L.center),Pt.setValue(q,"modelViewMatrix",L.modelViewMatrix),Pt.setValue(q,"normalMatrix",L.normalMatrix),Pt.setValue(q,"modelMatrix",L.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){const Kt=U.uniformsGroups;for(let on=0,ci=Kt.length;on<ci;on++){const qn=Kt[on];Y.update(qn,ot),Y.bind(qn,ot)}}return ot}function mc(P,y){P.ambientLightColor.needsUpdate=y,P.lightProbe.needsUpdate=y,P.directionalLights.needsUpdate=y,P.directionalLightShadows.needsUpdate=y,P.pointLights.needsUpdate=y,P.pointLightShadows.needsUpdate=y,P.spotLights.needsUpdate=y,P.spotLightShadows.needsUpdate=y,P.rectAreaLights.needsUpdate=y,P.hemisphereLights.needsUpdate=y}function _c(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(P,y,R){Ve.get(P.texture).__webglTexture=y,Ve.get(P.depthTexture).__webglTexture=R;const U=Ve.get(P);U.__hasExternalTextures=!0,U.__autoAllocateDepthBuffer=R===void 0,U.__autoAllocateDepthBuffer||et.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),U.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(P,y){const R=Ve.get(P);R.__webglFramebuffer=y,R.__useDefaultFramebuffer=y===void 0},this.setRenderTarget=function(P,y=0,R=0){T=P,N=y,A=R;let U=!0,L=null,O=!1,oe=!1;if(P){const xe=Ve.get(P);if(xe.__useDefaultFramebuffer!==void 0)Ue.bindFramebuffer(q.FRAMEBUFFER,null),U=!1;else if(xe.__webglFramebuffer===void 0)D.setupRenderTarget(P);else if(xe.__hasExternalTextures)D.rebindTextures(P,Ve.get(P.texture).__webglTexture,Ve.get(P.depthTexture).__webglTexture);else if(P.depthBuffer){const Te=P.depthTexture;if(xe.__boundDepthTexture!==Te){if(Te!==null&&Ve.has(Te)&&(P.width!==Te.image.width||P.height!==Te.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(P)}}const Se=P.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(oe=!0);const Re=Ve.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(Array.isArray(Re[y])?L=Re[y][R]:L=Re[y],O=!0):P.samples>0&&D.useMultisampledRTT(P)===!1?L=Ve.get(P).__webglMultisampledFramebuffer:Array.isArray(Re)?L=Re[R]:L=Re,_.copy(P.viewport),b.copy(P.scissor),W=P.scissorTest}else _.copy(me).multiplyScalar(ie).floor(),b.copy(Me).multiplyScalar(ie).floor(),W=Ge;if(Ue.bindFramebuffer(q.FRAMEBUFFER,L)&&U&&Ue.drawBuffers(P,L),Ue.viewport(_),Ue.scissor(b),Ue.setScissorTest(W),O){const xe=Ve.get(P.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+y,xe.__webglTexture,R)}else if(oe){const xe=Ve.get(P.texture),Se=y||0;q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,xe.__webglTexture,R||0,Se)}I=-1},this.readRenderTargetPixels=function(P,y,R,U,L,O,oe){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pe=Ve.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&oe!==void 0&&(pe=pe[oe]),pe){Ue.bindFramebuffer(q.FRAMEBUFFER,pe);try{const xe=P.texture,Se=xe.format,Re=xe.type;if(!$e.textureFormatReadable(Se)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!$e.textureTypeReadable(Re)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}y>=0&&y<=P.width-U&&R>=0&&R<=P.height-L&&q.readPixels(y,R,U,L,Fe.convert(Se),Fe.convert(Re),O)}finally{const xe=T!==null?Ve.get(T).__webglFramebuffer:null;Ue.bindFramebuffer(q.FRAMEBUFFER,xe)}}},this.readRenderTargetPixelsAsync=async function(P,y,R,U,L,O,oe){if(!(P&&P.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let pe=Ve.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&oe!==void 0&&(pe=pe[oe]),pe){const xe=P.texture,Se=xe.format,Re=xe.type;if(!$e.textureFormatReadable(Se))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!$e.textureTypeReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(y>=0&&y<=P.width-U&&R>=0&&R<=P.height-L){Ue.bindFramebuffer(q.FRAMEBUFFER,pe);const Te=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,Te),q.bufferData(q.PIXEL_PACK_BUFFER,O.byteLength,q.STREAM_READ),q.readPixels(y,R,U,L,Fe.convert(Se),Fe.convert(Re),0);const De=T!==null?Ve.get(T).__webglFramebuffer:null;Ue.bindFramebuffer(q.FRAMEBUFFER,De);const Ye=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await sy(q,Ye,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,Te),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,O),q.deleteBuffer(Te),q.deleteSync(Ye),O}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(P,y=null,R=0){P.isTexture!==!0&&(Tl("WebGLRenderer: copyFramebufferToTexture function signature has changed."),y=arguments[0]||null,P=arguments[1]);const U=Math.pow(2,-R),L=Math.floor(P.image.width*U),O=Math.floor(P.image.height*U),oe=y!==null?y.x:0,pe=y!==null?y.y:0;D.setTexture2D(P,0),q.copyTexSubImage2D(q.TEXTURE_2D,R,0,0,oe,pe,L,O),Ue.unbindTexture()},this.copyTextureToTexture=function(P,y,R=null,U=null,L=0){P.isTexture!==!0&&(Tl("WebGLRenderer: copyTextureToTexture function signature has changed."),U=arguments[0]||null,P=arguments[1],y=arguments[2],L=arguments[3]||0,R=null);let O,oe,pe,xe,Se,Re;R!==null?(O=R.max.x-R.min.x,oe=R.max.y-R.min.y,pe=R.min.x,xe=R.min.y):(O=P.image.width,oe=P.image.height,pe=0,xe=0),U!==null?(Se=U.x,Re=U.y):(Se=0,Re=0);const Te=Fe.convert(y.format),De=Fe.convert(y.type);D.setTexture2D(y,0),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,y.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,y.unpackAlignment);const Ye=q.getParameter(q.UNPACK_ROW_LENGTH),Ze=q.getParameter(q.UNPACK_IMAGE_HEIGHT),_t=q.getParameter(q.UNPACK_SKIP_PIXELS),tt=q.getParameter(q.UNPACK_SKIP_ROWS),Ie=q.getParameter(q.UNPACK_SKIP_IMAGES),Be=P.isCompressedTexture?P.mipmaps[L]:P.image;q.pixelStorei(q.UNPACK_ROW_LENGTH,Be.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Be.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,pe),q.pixelStorei(q.UNPACK_SKIP_ROWS,xe),P.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,L,Se,Re,O,oe,Te,De,Be.data):P.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,L,Se,Re,Be.width,Be.height,Te,Be.data):q.texSubImage2D(q.TEXTURE_2D,L,Se,Re,O,oe,Te,De,Be),q.pixelStorei(q.UNPACK_ROW_LENGTH,Ye),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Ze),q.pixelStorei(q.UNPACK_SKIP_PIXELS,_t),q.pixelStorei(q.UNPACK_SKIP_ROWS,tt),q.pixelStorei(q.UNPACK_SKIP_IMAGES,Ie),L===0&&y.generateMipmaps&&q.generateMipmap(q.TEXTURE_2D),Ue.unbindTexture()},this.copyTextureToTexture3D=function(P,y,R=null,U=null,L=0){P.isTexture!==!0&&(Tl("WebGLRenderer: copyTextureToTexture3D function signature has changed."),R=arguments[0]||null,U=arguments[1]||null,P=arguments[2],y=arguments[3],L=arguments[4]||0);let O,oe,pe,xe,Se,Re,Te,De,Ye;const Ze=P.isCompressedTexture?P.mipmaps[L]:P.image;R!==null?(O=R.max.x-R.min.x,oe=R.max.y-R.min.y,pe=R.max.z-R.min.z,xe=R.min.x,Se=R.min.y,Re=R.min.z):(O=Ze.width,oe=Ze.height,pe=Ze.depth,xe=0,Se=0,Re=0),U!==null?(Te=U.x,De=U.y,Ye=U.z):(Te=0,De=0,Ye=0);const _t=Fe.convert(y.format),tt=Fe.convert(y.type);let Ie;if(y.isData3DTexture)D.setTexture3D(y,0),Ie=q.TEXTURE_3D;else if(y.isDataArrayTexture||y.isCompressedArrayTexture)D.setTexture2DArray(y,0),Ie=q.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,y.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,y.unpackAlignment);const Be=q.getParameter(q.UNPACK_ROW_LENGTH),ut=q.getParameter(q.UNPACK_IMAGE_HEIGHT),ot=q.getParameter(q.UNPACK_SKIP_PIXELS),Zt=q.getParameter(q.UNPACK_SKIP_ROWS),kt=q.getParameter(q.UNPACK_SKIP_IMAGES);q.pixelStorei(q.UNPACK_ROW_LENGTH,Ze.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Ze.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,xe),q.pixelStorei(q.UNPACK_SKIP_ROWS,Se),q.pixelStorei(q.UNPACK_SKIP_IMAGES,Re),P.isDataTexture||P.isData3DTexture?q.texSubImage3D(Ie,L,Te,De,Ye,O,oe,pe,_t,tt,Ze.data):y.isCompressedArrayTexture?q.compressedTexSubImage3D(Ie,L,Te,De,Ye,O,oe,pe,_t,Ze.data):q.texSubImage3D(Ie,L,Te,De,Ye,O,oe,pe,_t,tt,Ze),q.pixelStorei(q.UNPACK_ROW_LENGTH,Be),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,ut),q.pixelStorei(q.UNPACK_SKIP_PIXELS,ot),q.pixelStorei(q.UNPACK_SKIP_ROWS,Zt),q.pixelStorei(q.UNPACK_SKIP_IMAGES,kt),L===0&&y.generateMipmaps&&q.generateMipmap(Ie),Ue.unbindTexture()},this.initRenderTarget=function(P){Ve.get(P).__webglFramebuffer===void 0&&D.setupRenderTarget(P)},this.initTexture=function(P){P.isCubeTexture?D.setTextureCube(P,0):P.isData3DTexture?D.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?D.setTexture2DArray(P,0):D.setTexture2D(P,0),Ue.unbindTexture()},this.resetState=function(){N=0,A=0,T=null,Ue.reset(),qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ki}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===bd?"display-p3":"srgb",t.unpackColorSpace=St.workingColorSpace===tc?"display-p3":"srgb"}},lp=class extends Qi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Es,this.environmentIntensity=1,this.environmentRotation=new Es,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Ld=class y_ extends Eo{constructor(e=1,t=32,i=16,s=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:s,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const h=[],f=new ce,p=new ce,m=[],g=[],x=[],d=[];for(let u=0;u<=i;u++){const w=[],M=u/i;let E=0;u===0&&o===0?E=.5/t:u===i&&l===Math.PI&&(E=-.5/t);for(let N=0;N<=t;N++){const A=N/t;f.x=-e*Math.cos(s+A*r)*Math.sin(o+M*a),f.y=e*Math.cos(o+M*a),f.z=e*Math.sin(s+A*r)*Math.sin(o+M*a),g.push(f.x,f.y,f.z),p.copy(f).normalize(),x.push(p.x,p.y,p.z),d.push(A+E,1-M),w.push(c++)}h.push(w)}for(let u=0;u<i;u++)for(let w=0;w<t;w++){const M=h[u][w+1],E=h[u][w],N=h[u+1][w],A=h[u+1][w+1];(u!==0||o>0)&&m.push(M,E,A),(u!==i-1||l<Math.PI)&&m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new Mi(g,3)),this.setAttribute("normal",new Mi(x,3)),this.setAttribute("uv",new Mi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new y_(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};const fu={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class v1{constructor(e,t,i){const s=this;let r=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,p=c.length;f<p;f+=2){const m=c[f],g=c[f+1];if(m.global&&(m.lastIndex=0),m.test(h))return g}return null}}}const x1=new v1;let Dd=class{constructor(e){this.manager=e!==void 0?e:x1,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(s,r){i.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Dd.DEFAULT_MATERIAL_NAME="__DEFAULT";const cp=new qt;let M1=class{constructor(e,t,i=0,s=1/0){this.ray=new s_(e,t),this.near=i,this.far=s,this.camera=null,this.layers=new Ad,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return cp.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cp),this}intersectObject(e,t=!0,i=[]){return pu(e,this,i,t),i.sort(hp),i}intersectObjects(e,t=!0,i=[]){for(let s=0,r=e.length;s<r;s++)pu(e[s],this,i,t);return i.sort(hp),i}};function hp(n,e){return n.distance-e.distance}function pu(n,e,t,i){let s=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(s=!1),s===!0&&i===!0){const r=n.children;for(let o=0,a=r.length;o<a;o++)pu(r[o],e,t,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:gd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=gd);/*! * Photo Sphere Viewer 5.11.1 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2024 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) */var E1=Object.defineProperty,Id=(n,e)=>{for(var t in e)E1(n,t,{get:e[t],enumerable:!0})},da={};Id(da,{ACTIONS:()=>R_,ANIMATION_MIN_DURATION:()=>mu,CAPTURE_EVENTS_CLASS:()=>xa,CTRLZOOM_TIMEOUT:()=>C_,DBLCLICK_DELAY:()=>w_,DEFAULT_TRANSITION:()=>S_,EASINGS:()=>Pl,ICONS:()=>si,IDS:()=>rn,KEY_CODES:()=>tn,LONGTOUCH_DELAY:()=>T_,MOVE_THRESHOLD:()=>b_,SPHERE_RADIUS:()=>nr,TWOFINGERSOVERLAY_DELAY:()=>A_,VIEWER_DATA:()=>Ss});var y1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 40 432 432"><g transform="rotate(0, 256, 256)"><path fill="currentColor" d="M425.23 210.55H227.39a5 5 0 01-3.53-8.53l56.56-56.57a45.5 45.5 0 000-64.28 45.15 45.15 0 00-32.13-13.3 45.15 45.15 0 00-32.14 13.3L41.32 256l174.83 174.83a45.15 45.15 0 0032.14 13.3 45.15 45.15 0 0032.13-13.3 45.5 45.5 0 000-64.28l-56.57-56.57a5 5 0 013.54-8.53h197.84c25.06 0 45.45-20.39 45.45-45.45s-20.4-45.45-45.45-45.45z"/></g><!-- Created by Flatart from the Noun Project --></svg> `,S1='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g fill="currentColor" transform=" translate(50, 50) rotate(45)"><rect x="-5" y="-65" width="10" height="130"/><rect x="-65" y="-5" width="130" height="10"/></g></svg>',b1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="currentColor" d="M83.3 35.6h-17V3H32.2v32.6H16.6l33.6 32.7 33-32.7z"/><path fill="currentColor" d="M83.3 64.2v16.3H16.6V64.2H-.1v32.6H100V64.2H83.3z"/><!--Created by Michael Zenaty from the Noun Project--></svg> `,w1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="currentColor" d="M100 40H87.1V18.8h-21V6H100zM100 93.2H66V80.3h21.1v-21H100zM34 93.2H0v-34h12.9v21.1h21zM12.9 40H0V6h34v12.9H12.8z"/><!--Created by Garrett Knoll from the Noun Project--></svg> `,T1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="currentColor" d="M66 7h13v21h21v13H66zM66 60.3h34v12.9H79v21H66zM0 60.3h34v34H21V73.1H0zM21 7h13v34H0V28h21z"/><!--Created by Garrett Knoll from the Noun Project--></svg> `,A1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="currentColor" d="M28.3 26.1c-1 2.6-1.9 4.8-2.6 7-2.5 7.4-5 14.7-7.2 22-1.3 4.4.5 7.2 4.3 7.8 1.3.2 2.8.2 4.2-.1 8.2-2 11.9-8.6 15.7-15.2l-2.2 2a18.8 18.8 0 0 1-7.4 5.2 2 2 0 0 1-1.6-.2c-.2-.1 0-1 0-1.4l.8-1.8L41.9 28c.5-1.4.9-3 .7-4.4-.2-2.6-3-4.4-6.3-4.4-8.8.2-15 4.5-19.5 11.8-.2.3-.2.6-.3 1.3 3.7-2.8 6.8-6.1 11.8-6.2z"/><circle fill="currentColor" cx="39.3" cy="9.2" r="8.2"/><!--Created by Arafat Uddin from the Noun Project--></svg> `,C1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 10 80 80"><g fill="currentColor"><circle r="10" cx="20" cy="20"/><circle r="10" cx="50" cy="20"/><circle r="10" cx="80" cy="20"/><circle r="10" cx="20" cy="50"/><circle r="10" cx="50" cy="50"/><circle r="10" cx="80" cy="50"/><circle r="10" cx="20" cy="80"/><circle r="10" cx="50" cy="80"/><circle r="10" cx="80" cy="80"/></g><!-- Created by Richard Kunák from the Noun Project--></svg> `,R1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill="currentColor" d="M14.043 12.22a7.738 7.738 0 1 0-1.823 1.822l4.985 4.985c.503.504 1.32.504 1.822 0a1.285 1.285 0 0 0 0-1.822l-4.984-4.985zm-6.305 1.043a5.527 5.527 0 1 1 0-11.053 5.527 5.527 0 0 1 0 11.053z"/><path fill="currentColor" d="M8.728 4.009H6.744v2.737H4.006V8.73h2.738v2.736h1.984V8.73h2.737V6.746H8.728z"/><!--Created by Ryan Canning from the Noun Project--></svg> `,P1=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill="currentColor" d="M14.043 12.22a7.738 7.738 0 1 0-1.823 1.822l4.985 4.985c.503.504 1.32.504 1.822 0a1.285 1.285 0 0 0 0-1.822l-4.984-4.985zm-6.305 1.043a5.527 5.527 0 1 1 0-11.053 5.527 5.527 0 0 1 0 11.053z"/><path fill="currentColor" d="M4.006 6.746h7.459V8.73H4.006z"/><!--Created by Ryan Canning from the Noun Project--></svg> `,S_=1500,mu=500,b_=4,w_=300,T_=500,A_=100,C_=2e3,nr=10,Ss="photoSphereViewer",xa="psv--capture-event",R_=(n=>(n.ROTATE_UP="ROTATE_UP",n.ROTATE_DOWN="ROTATE_DOWN",n.ROTATE_RIGHT="ROTATE_RIGHT",n.ROTATE_LEFT="ROTATE_LEFT",n.ZOOM_IN="ZOOM_IN",n.ZOOM_OUT="ZOOM_OUT",n))(R_||{}),rn={MENU:"menu",TWO_FINGERS:"twoFingers",CTRL_ZOOM:"ctrlZoom",ERROR:"error",DESCRIPTION:"description"},tn={Enter:"Enter",Control:"Control",Escape:"Escape",Space:" ",PageUp:"PageUp",PageDown:"PageDown",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Delete:"Delete",Plus:"+",Minus:"-"},si={arrow:y1,close:S1,download:b1,fullscreenIn:w1,fullscreenOut:T1,info:A1,menu:C1,zoomIn:R1,zoomOut:P1},Pl={linear:n=>n,inQuad:n=>n*n,outQuad:n=>n*(2-n),inOutQuad:n=>n<.5?2*n*n:-1+(4-2*n)*n,inCubic:n=>n*n*n,outCubic:n=>--n*n*n+1,inOutCubic:n=>n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1,inQuart:n=>n*n*n*n,outQuart:n=>1- --n*n*n*n,inOutQuart:n=>n<.5?8*n*n*n*n:1-8*--n*n*n*n,inQuint:n=>n*n*n*n*n,outQuint:n=>1+--n*n*n*n*n,inOutQuint:n=>n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n,inSine:n=>1-Math.cos(n*(Math.PI/2)),outSine:n=>Math.sin(n*(Math.PI/2)),inOutSine:n=>.5-.5*Math.cos(Math.PI*n),inExpo:n=>Math.pow(2,10*(n-1)),outExpo:n=>1-Math.pow(2,-10*n),inOutExpo:n=>(n=n*2-1)<0?.5*Math.pow(2,10*n):1-.5*Math.pow(2,-10*n),inCirc:n=>1-Math.sqrt(1-n*n),outCirc:n=>Math.sqrt(1-(n-1)*(n-1)),inOutCirc:n=>(n*=2)<1?.5-.5*Math.sqrt(1-n*n):.5+.5*Math.sqrt(1-(n-=2)*n)},rt={};Id(rt,{Animation:()=>Yl,Dynamic:()=>Go,MultiDynamic:()=>Z_,PressHandler:()=>lc,Slider:()=>J_,SliderDirection:()=>K_,addClasses:()=>Ud,angle:()=>L_,applyEulerInverse:()=>Mu,checkClosedShadowDom:()=>Q_,checkStylesheet:()=>Y_,checkVersion:()=>Bd,cleanCssPosition:()=>q_,clone:()=>rc,createTexture:()=>xu,cssPositionIsOrdered:()=>kd,dasherize:()=>N1,deepEqual:()=>G_,deepmerge:()=>H_,distance:()=>P_,exitFullscreen:()=>B_,firstNonNull:()=>ui,getAbortError:()=>gu,getAngle:()=>I_,getClosest:()=>N_,getConfigParser:()=>ac,getElement:()=>U_,getEventTarget:()=>Wl,getMatchingTarget:()=>F_,getPosition:()=>O_,getShortestArc:()=>D_,getStyleProperty:()=>gi,getTouchData:()=>_u,getXMPValue:()=>Ln,greatArcDistance:()=>D1,hasParent:()=>U1,invertResolvableBoolean:()=>oc,isAbortError:()=>$_,isEmpty:()=>V_,isExtendedPosition:()=>zd,isFullscreenEnabled:()=>z_,isNil:()=>nn,isPlainObject:()=>Fd,logWarn:()=>Lt,mergePanoData:()=>j_,parseAngle:()=>fi,parsePoint:()=>F1,parseSpeed:()=>X_,removeClasses:()=>I1,requestFullscreen:()=>k_,resolveBoolean:()=>Od,speedToDuration:()=>vu,sum:()=>L1,throttle:()=>Nd,toggleClass:()=>sc,wrap:()=>Qo});function Qo(n,e){let t=n%e;return t<0&&(t+=e),t}function L1(n){return n.reduce((e,t)=>e+t,0)}function P_(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function L_(n,e){return Math.atan2(e.y-n.y,e.x-n.x)}function D_(n,e){return[0,Math.PI*2,-Math.PI*2].reduce((i,s)=>{const r=e-n+s;return Math.abs(r)<Math.abs(i)?r:i},1/0)}function I_(n,e){return Math.acos(Math.cos(n.pitch)*Math.cos(e.pitch)*Math.cos(n.yaw-e.yaw)+Math.sin(n.pitch)*Math.sin(e.pitch))}function D1([n,e],[t,i]){n-t>Math.PI?n-=2*Math.PI:n-t<-Math.PI&&(n+=2*Math.PI);const s=(t-n)*Math.cos((e+i)/2),r=i-e;return Math.sqrt(s*s+r*r)}function U_(n){return typeof n=="string"?n.match(/^[a-z]/i)?document.getElementById(n):document.querySelector(n):n}function sc(n,e,t){t===void 0?n.classList.toggle(e):t?n.classList.add(e):t||n.classList.remove(e)}function Ud(n,e){n.classList.add(...e.split(" ").filter(t=>!!t))}function I1(n,e){n.classList.remove(...e.split(" ").filter(t=>!!t))}function U1(n,e){let t=n;do{if(t===e)return!0;t=t.parentElement}while(t);return!1}function N_(n,e){if(!(n!=null&&n.matches))return null;let t=n;do{if(t.matches(e))return t;t=t.parentElement}while(t);return null}function Wl(n){return(n==null?void 0:n.composedPath()[0])||null}function F_(n,e){return n?n.composedPath().find(t=>!(t instanceof HTMLElement)&&!(t instanceof SVGElement)?!1:t.matches(e)):null}function O_(n){let e=0,t=0,i=n;for(;i;)e+=i.offsetLeft-i.scrollLeft+i.clientLeft,t+=i.offsetTop-i.scrollTop+i.clientTop,i=i.offsetParent;return e-=window.scrollX,t-=window.scrollY,{x:e,y:t}}function gi(n,e){return window.getComputedStyle(n).getPropertyValue(e)}function _u(n){if(n.touches.length<2)return null;const e={x:n.touches[0].clientX,y:n.touches[0].clientY},t={x:n.touches[1].clientX,y:n.touches[1].clientY};return{distance:P_(e,t),angle:L_(e,t),center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}}var $l;function z_(n,e=!1){return e?n===$l:document.fullscreenElement===n}function k_(n,e=!1){e?($l=n,n.classList.add("psv-fullscreen-emulation"),document.dispatchEvent(new Event("fullscreenchange"))):n.requestFullscreen()}function B_(n=!1){n?($l.classList.remove("psv-fullscreen-emulation"),$l=null,document.dispatchEvent(new Event("fullscreenchange"))):document.exitFullscreen()}function N1(n){return n.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}function Nd(n,e){let t=!1;return function(...i){t||(t=!0,setTimeout(()=>{n.apply(this,i),t=!1},e))}}function Fd(n){if(typeof n!="object"||n===null||Object.prototype.toString.call(n)!=="[object Object]")return!1;if(Object.getPrototypeOf(n)===null)return!0;let e=n;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}function H_(n,e){const t=e;return function i(s,r){return Array.isArray(r)?(!s||!Array.isArray(s)?s=[]:s.length=0,r.forEach((o,a)=>{s[a]=i(null,o)})):typeof r=="object"?((!s||Array.isArray(s))&&(s={}),Object.keys(r).forEach(o=>{typeof r[o]!="object"||!r[o]||!Fd(r[o])?s[o]=r[o]:r[o]!==t&&(s[o]?i(s[o],r[o]):s[o]=i(null,r[o]))})):s=r,s}(n,e)}function rc(n){return H_(null,n)}function V_(n){return!n||Object.keys(n).length===0&&n.constructor===Object}function nn(n){return n==null}function ui(...n){for(const e of n)if(!nn(e))return e;return null}function G_(n,e){if(n===e)return!0;if(up(n)&&up(e)){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(const t of Object.keys(n))if(!G_(n[t],e[t]))return!1;return!0}else return!1}function up(n){return typeof n=="object"&&n!==null}var Ke=class W_ extends Error{constructor(e,t){var i;super(t&&t instanceof Error?`${e}: ${t.message}`:e),this.name="PSVError",(i=Error.captureStackTrace)==null||i.call(Error,this,W_)}};function Od(n,e){Fd(n)?(e(n.initial,!0),n.promise.then(t=>e(t,!1))):e(n,!0)}function oc(n){return{initial:!n.initial,promise:n.promise.then(e=>!e)}}function gu(){const n=new Error("Loading was aborted.");return n.name="AbortError",n}function $_(n){return(n==null?void 0:n.name)==="AbortError"}function Lt(n){console.warn(`PhotoSphereViewer: ${n}`)}function zd(n){return!n||Array.isArray(n)?!1:[["textureX","textureY"],["yaw","pitch"]].some(([e,t])=>n[e]!==void 0&&n[t]!==void 0)}function Ln(n,e,t=!0){let i=n.match("<GPano:"+e+">(.*)</GPano:"+e+">");if(i!==null){const s=t?parseInt(i[1],10):parseFloat(i[1]);return isNaN(s)?null:s}if(i=n.match("GPano:"+e+'="(.*?)"'),i!==null){const s=t?parseInt(i[1],10):parseFloat(i[1]);return isNaN(s)?null:s}return null}var dp={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},ql=["left","center","right"],Xl=["top","center","bottom"],fp=[...ql,...Xl],Fn="center";function F1(n){if(!n)return{x:.5,y:.5};if(typeof n=="object")return n;let e=n.toLocaleLowerCase().split(" ").slice(0,2);e.length===1&&(dp[e[0]]?e=[e[0],Fn]:e=[e[0],e[0]]);const t=e[1]!=="left"&&e[1]!=="right"&&e[0]!=="top"&&e[0]!=="bottom";e=e.map(s=>dp[s]||s),t||e.reverse();const i=e.join(" ").match(/^([0-9.]+)% ([0-9.]+)%$/);return i?{x:parseFloat(i[1])/100,y:parseFloat(i[2])/100}:{x:.5,y:.5}}function q_(n,{allowCenter:e,cssOrder:t}={allowCenter:!0,cssOrder:!0}){return n?(typeof n=="string"&&(n=n.split(" ")),n.length===1&&(n[0]===Fn?n=[Fn,Fn]:ql.indexOf(n[0])!==-1?n=[Fn,n[0]]:Xl.indexOf(n[0])!==-1&&(n=[n[0],Fn])),n.length!==2||fp.indexOf(n[0])===-1||fp.indexOf(n[1])===-1?(Lt(`Unparsable position ${n}`),null):!e&&n[0]===Fn&&n[1]===Fn?(Lt("Invalid position center center"),null):(t&&!kd(n)&&(n=[n[1],n[0]]),n[1]===Fn&&ql.indexOf(n[0])!==-1&&(n=[Fn,n[0]]),n[0]===Fn&&Xl.indexOf(n[1])!==-1&&(n=[n[1],Fn]),n)):null}function kd(n){return Xl.indexOf(n[0])!==-1&&ql.indexOf(n[1])!==-1}function X_(n){let e;if(typeof n=="string"){const t=n.toString().trim();let i=parseFloat(t.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1"));const s=t.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();switch(s.match(/(pm|per minute)$/)&&(i/=60),s){case"dpm":case"degrees per minute":case"dps":case"degrees per second":e=Ut.degToRad(i);break;case"rdpm":case"radians per minute":case"rdps":case"radians per second":e=i;break;case"rpm":case"revolutions per minute":case"rps":case"revolutions per second":e=i*Math.PI*2;break;default:throw new Ke(`Unknown speed unit "${s}"`)}}else e=n;return e}function vu(n,e){if(typeof n!="number"){const t=X_(n);return e/Math.abs(t)*1e3}else return Math.abs(n)}function fi(n,e=!1,t=e){let i;if(typeof n=="string"){const s=n.toLowerCase().trim().match(/^(-?[0-9]+(?:\.[0-9]*)?)(.*)$/);if(!s)throw new Ke(`Unknown angle "${n}"`);const r=parseFloat(s[1]),o=s[2];if(o)switch(o){case"deg":case"degs":i=Ut.degToRad(r);break;case"rad":case"rads":i=r;break;default:throw new Ke(`Unknown angle unit "${o}"`)}else i=r}else if(typeof n=="number"&&!isNaN(n))i=n;else throw new Ke(`Unknown angle "${n}"`);return i=Qo(e?i+Math.PI:i,Math.PI*2),e?Ut.clamp(i-Math.PI,-Math.PI/(t?2:1),Math.PI/(t?2:1)):i}function xu(n,e=!1){const t=new ai(n);return t.needsUpdate=!0,t.minFilter=e?us:kn,t.generateMipmaps=e,t.anisotropy=e?2:1,t}var pp=new xo;function Mu(n,e){pp.setFromEuler(e).invert(),n.applyQuaternion(pp)}function ac(n,e){const t=function(i){const s=rc({...n,...i}),r={};for(let[o,a]of Object.entries(s)){if(e&&o in e)a=e[o](a,{rawConfig:s,defValue:n[o]});else if(!(o in n)){Lt(`Unknown option ${o}`);continue}r[o]=a}return r};return t.defaults=n,t.parsers=e||{},t}function Y_(n,e){gi(n,`--psv-${e}-loaded`)!=="true"&&console.error(`PhotoSphereViewer: stylesheet "@photo-sphere-viewer/${e}/index.css" is not loaded`)}function Bd(n,e,t){e&&e!==t&&console.error(`PhotoSphereViewer: @photo-sphere-viewer/${n} is in version ${e} but @photo-sphere-viewer/core is in version ${t}`)}function Q_(n){do{if(n instanceof ShadowRoot&&n.mode==="closed"){console.error("PhotoSphereViewer: closed shadow DOM detected, the viewer might not work as expected");return}n=n.parentNode}while(n)}function j_(n,e,t,i){if(!t&&!i){const r=Math.max(n,e*2),o=Math.round(r/2),a=Math.round((r-n)/2),l=Math.round((o-e)/2);t={fullWidth:r,fullHeight:o,croppedWidth:n,croppedHeight:e,croppedX:a,croppedY:l}}const s={isEquirectangular:!0,fullWidth:ui(t==null?void 0:t.fullWidth,i==null?void 0:i.fullWidth),fullHeight:ui(t==null?void 0:t.fullHeight,i==null?void 0:i.fullHeight),croppedWidth:ui(t==null?void 0:t.croppedWidth,i==null?void 0:i.croppedWidth,n),croppedHeight:ui(t==null?void 0:t.croppedHeight,i==null?void 0:i.croppedHeight,e),croppedX:ui(t==null?void 0:t.croppedX,i==null?void 0:i.croppedX,0),croppedY:ui(t==null?void 0:t.croppedY,i==null?void 0:i.croppedY,0),poseHeading:ui(t==null?void 0:t.poseHeading,i==null?void 0:i.poseHeading,0),posePitch:ui(t==null?void 0:t.posePitch,i==null?void 0:i.posePitch,0),poseRoll:ui(t==null?void 0:t.poseRoll,i==null?void 0:i.poseRoll,0),initialHeading:i==null?void 0:i.initialHeading,initialPitch:i==null?void 0:i.initialPitch,initialFov:i==null?void 0:i.initialFov};return!s.fullWidth&&s.fullHeight?s.fullWidth=s.fullHeight*2:(!s.fullWidth||!s.fullHeight)&&(s.fullWidth=s.fullWidth??n,s.fullHeight=s.fullHeight??e),(s.croppedWidth!==n||s.croppedHeight!==e)&&Lt(`Invalid panoData, croppedWidth/croppedHeight is not coherent with the loaded image. panoData: ${s.croppedWidth}x${s.croppedHeight}, image: ${n}x${e}`),Math.abs(s.fullWidth-s.fullHeight*2)>1&&(Lt("Invalid panoData, fullWidth should be twice fullHeight"),s.fullHeight=Math.round(s.fullWidth/2)),s.croppedX+s.croppedWidth>s.fullWidth&&(Lt("Invalid panoData, croppedX + croppedWidth > fullWidth"),s.croppedX=s.fullWidth-s.croppedWidth),s.croppedY+s.croppedHeight>s.fullHeight&&(Lt("Invalid panoData, croppedY + croppedHeight > fullHeight"),s.croppedY=s.fullHeight-s.croppedHeight),s.croppedX<0&&(Lt("Invalid panoData, croppedX < 0"),s.croppedX=0),s.croppedY<0&&(Lt("Invalid panoData, croppedY < 0"),s.croppedY=0),s}var Yl=class{constructor(n){this.easing=Pl.linear,this.callbacks=[],this.resolved=!1,this.cancelled=!1,this.options=n,n?(n.easing&&(this.easing=typeof n.easing=="function"?n.easing:Pl[n.easing]||Pl.linear),this.delayTimeout=setTimeout(()=>{this.delayTimeout=void 0,this.animationFrame=window.requestAnimationFrame(e=>this.__run(e))},n.delay||0)):this.resolved=!0}__run(n){if(this.cancelled)return;this.start||(this.start=n);const e=(n-this.start)/this.options.duration,t={};if(e<1){for(const[i,s]of Object.entries(this.options.properties))if(s){const r=s.start+(s.end-s.start)*this.easing(e);t[i]=r}this.options.onTick(t,e),this.animationFrame=window.requestAnimationFrame(i=>this.__run(i))}else{for(const[i,s]of Object.entries(this.options.properties))s&&(t[i]=s.end);this.options.onTick(t,1),this.__resolve(!0),this.animationFrame=void 0}}__resolve(n){n?this.resolved=!0:this.cancelled=!0,this.callbacks.forEach(e=>e(n)),this.callbacks.length=0}then(n){return this.resolved||this.cancelled?Promise.resolve(this.resolved).then(n):new Promise(e=>{this.callbacks.push(e)}).then(n)}cancel(){!this.cancelled&&!this.resolved&&(this.__resolve(!1),this.delayTimeout&&(window.clearTimeout(this.delayTimeout),this.delayTimeout=void 0),this.animationFrame&&(window.cancelAnimationFrame(this.animationFrame),this.animationFrame=void 0))}},Go=class{constructor(n,e){if(this.fn=n,this.mode=0,this.speed=0,this.speedMult=0,this.currentSpeed=0,this.target=0,this.__current=0,this.min=e.min,this.max=e.max,this.wrap=e.wrap,this.current=e.defaultValue,this.wrap&&this.min!==0)throw new Ke("invalid config");this.fn&&this.fn(this.current)}get current(){return this.__current}set current(n){this.__current=n}setSpeed(n){this.speed=n}goto(n,e=1){this.mode=2,this.target=this.wrap?Qo(n,this.max):Ut.clamp(n,this.min,this.max),this.speedMult=e}step(n,e=1){e===0?this.setValue(this.current+n):(this.mode!==2&&(this.target=this.current),this.goto(this.target+n,e))}roll(n=!1,e=1){this.mode=1,this.target=n?-1/0:1/0,this.speedMult=e}stop(){this.mode=0}setValue(n){return this.target=this.wrap?Qo(n,this.max):Ut.clamp(n,this.min,this.max),this.mode=0,this.currentSpeed=0,this.target!==this.current?(this.current=this.target,this.fn&&this.fn(this.current),!0):!1}update(n){if(this.mode===2){this.wrap&&Math.abs(this.target-this.current)>this.max/2&&(this.current=this.current<this.target?this.current+this.max:this.current-this.max);const i=this.currentSpeed*this.currentSpeed/(this.speed*this.speedMult*4);Math.abs(this.target-this.current)<=i&&(this.mode=0)}let e=this.mode===0?0:this.speed*this.speedMult;this.target<this.current&&(e=-e),this.currentSpeed<e?this.currentSpeed=Math.min(e,this.currentSpeed+n/1e3*this.speed*this.speedMult*2):this.currentSpeed>e&&(this.currentSpeed=Math.max(e,this.currentSpeed-n/1e3*this.speed*this.speedMult*2));let t=null;return this.current>this.target&&this.currentSpeed?t=Math.max(this.target,this.current+this.currentSpeed*n/1e3):this.current<this.target&&this.currentSpeed&&(t=Math.min(this.target,this.current+this.currentSpeed*n/1e3)),t!==null&&(t=this.wrap?Qo(t,this.max):Ut.clamp(t,this.min,this.max),t!==this.current)?(this.current=t,this.fn&&this.fn(this.current),!0):!1}},Z_=class{constructor(n,e){this.fn=n,this.dynamics=e,this.fn&&this.fn(this.current)}get current(){return Object.entries(this.dynamics).reduce((n,[e,t])=>(n[e]=t.current,n),{})}setSpeed(n){for(const e of Object.values(this.dynamics))e.setSpeed(n)}goto(n,e=1){for(const[t,i]of Object.entries(n))this.dynamics[t].goto(i,e)}step(n,e=1){if(e===0)this.setValue(Object.keys(n).reduce((t,i)=>(t[i]=n[i]+this.dynamics[i].current,t),{}));else for(const[t,i]of Object.entries(n))this.dynamics[t].step(i,e)}roll(n,e=1){for(const[t,i]of Object.entries(n))this.dynamics[t].roll(i,e)}stop(){for(const n of Object.values(this.dynamics))n.stop()}setValue(n){let e=!1;for(const[t,i]of Object.entries(n))e=this.dynamics[t].setValue(i)||e;return e&&this.fn&&this.fn(this.current),e}update(n){let e=!1;for(const t of Object.values(this.dynamics))e=t.update(n)||e;return e&&this.fn&&this.fn(this.current),e}},lc=class{constructor(n=200){this.delay=n,this.time=0,this.delay=n}get pending(){return this.time!==0}down(n){this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),this.time=new Date().getTime(),this.data=n}up(n){if(!this.time)return;Date.now()-this.time<this.delay?this.timeout=setTimeout(()=>{n(this.data),this.timeout=void 0,this.time=0,this.data=void 0},this.delay):(n(this.data),this.time=0,this.data=void 0)}},K_=(n=>(n.VERTICAL="VERTICAL",n.HORIZONTAL="HORIZONTAL",n))(K_||{}),J_=class{constructor(n,e,t){this.container=n,this.direction=e,this.listener=t,this.mousedown=!1,this.mouseover=!1,this.container.addEventListener("click",this),this.container.addEventListener("mousedown",this),this.container.addEventListener("mouseenter",this),this.container.addEventListener("mouseleave",this),this.container.addEventListener("touchstart",this),this.container.addEventListener("mousemove",this,!0),this.container.addEventListener("touchmove",this,!0),window.addEventListener("mouseup",this),window.addEventListener("touchend",this)}get isVertical(){return this.direction==="VERTICAL"}get isHorizontal(){return this.direction==="HORIZONTAL"}destroy(){window.removeEventListener("mouseup",this),window.removeEventListener("touchend",this)}handleEvent(n){switch(n.type){case"click":n.stopPropagation();break;case"mousedown":this.__onMouseDown(n);break;case"mouseenter":this.__onMouseEnter(n);break;case"mouseleave":this.__onMouseLeave(n);break;case"touchstart":this.__onTouchStart(n);break;case"mousemove":this.__onMouseMove(n);break;case"touchmove":this.__onTouchMove(n);break;case"mouseup":this.__onMouseUp(n);break;case"touchend":this.__onTouchEnd(n);break}}__onMouseDown(n){this.mousedown=!0,this.__update(n.clientX,n.clientY,!0)}__onMouseEnter(n){this.mouseover=!0,this.__update(n.clientX,n.clientY,!0)}__onTouchStart(n){this.mouseover=!0,this.mousedown=!0;const e=n.changedTouches[0];this.__update(e.clientX,e.clientY,!0)}__onMouseMove(n){(this.mousedown||this.mouseover)&&(n.stopPropagation(),this.__update(n.clientX,n.clientY,!0))}__onTouchMove(n){if(this.mousedown||this.mouseover){n.stopPropagation();const e=n.changedTouches[0];this.__update(e.clientX,e.clientY,!0)}}__onMouseUp(n){this.mousedown&&(this.mousedown=!1,this.__update(n.clientX,n.clientY,!1))}__onMouseLeave(n){this.mouseover&&(this.mouseover=!1,this.__update(n.clientX,n.clientY,!0))}__onTouchEnd(n){if(this.mousedown){this.mouseover=!1,this.mousedown=!1;const e=n.changedTouches[0];this.__update(e.clientX,e.clientY,!1)}}__update(n,e,t){const i=this.container.getBoundingClientRect();let s;this.isVertical?s=Ut.clamp((i.bottom-e)/i.height,0,1):s=Ut.clamp((n-i.left)/i.width,0,1),this.listener({value:s,click:!t,mousedown:this.mousedown,mouseover:this.mouseover,cursor:{clientX:n,clientY:e}})}},ct={};Id(ct,{BeforeAnimateEvent:()=>Hd,BeforeRenderEvent:()=>jo,BeforeRotateEvent:()=>lg,ClickEvent:()=>ug,ConfigChangedEvent:()=>bn,DoubleClickEvent:()=>_g,FullscreenEvent:()=>Zo,HideNotificationEvent:()=>Ko,HideOverlayEvent:()=>Sg,HidePanelEvent:()=>ps,HideTooltipEvent:()=>Cg,KeypressEvent:()=>ms,LoadProgressEvent:()=>Ig,ObjectEnterEvent:()=>vv,ObjectEvent:()=>cc,ObjectHoverEvent:()=>Sv,ObjectLeaveEvent:()=>yu,PanoramaErrorEvent:()=>Hg,PanoramaLoadEvent:()=>Fg,PanoramaLoadedEvent:()=>Eu,PositionUpdatedEvent:()=>Jo,ReadyEvent:()=>ta,RenderEvent:()=>Jg,RollUpdatedEvent:()=>ea,ShowNotificationEvent:()=>na,ShowOverlayEvent:()=>sv,ShowPanelEvent:()=>_s,ShowTooltipEvent:()=>cv,SizeUpdatedEvent:()=>ia,StopAllEvent:()=>sa,TransitionDoneEvent:()=>Wg,ViewerEvent:()=>wt,ZoomUpdatedEvent:()=>Vi});var eg=class extends Event{constructor(n,e=!1){super(n,{cancelable:e})}},tg=class extends EventTarget{dispatchEvent(n){return super.dispatchEvent(n)}addEventListener(n,e,t){super.addEventListener(n,e,t)}removeEventListener(n,e,t){super.removeEventListener(n,e,t)}},wt=class extends eg{},ng=class ig extends wt{constructor(e,t){super(ig.type,!0),this.position=e,this.zoomLevel=t}};ng.type="before-animate";var Hd=ng,sg=class rg extends wt{constructor(e,t){super(rg.type),this.timestamp=e,this.elapsed=t}};sg.type="before-render";var jo=sg,og=class ag extends wt{constructor(e){super(ag.type,!0),this.position=e}};og.type="before-rotate";var lg=og,cg=class hg extends wt{constructor(e){super(hg.type),this.data=e}};cg.type="click";var ug=cg,dg=class fg extends wt{constructor(e){super(fg.type),this.options=e}containsOptions(...e){return e.some(t=>this.options.includes(t))}};dg.type="config-changed";var bn=dg,pg=class mg extends wt{constructor(e){super(mg.type),this.data=e}};pg.type="dblclick";var _g=pg,gg=class vg extends wt{constructor(e){super(vg.type),this.fullscreenEnabled=e}};gg.type="fullscreen";var Zo=gg,xg=class Mg extends wt{constructor(e){super(Mg.type),this.notificationId=e}};xg.type="hide-notification";var Ko=xg,Eg=class yg extends wt{constructor(e){super(yg.type),this.overlayId=e}};Eg.type="hide-overlay";var Sg=Eg,bg=class wg extends wt{constructor(e){super(wg.type),this.panelId=e}};bg.type="hide-panel";var ps=bg,Tg=class Ag extends wt{constructor(e){super(Ag.type),this.tooltipData=e}};Tg.type="hide-tooltip";var Cg=Tg,Rg=class Pg extends wt{constructor(e,t){super(Pg.type,!0),this.key=e,this.originalEvent=t}};Rg.type="key-press";var ms=Rg,Lg=class Dg extends wt{constructor(e){super(Dg.type),this.progress=e}};Lg.type="load-progress";var Ig=Lg,Ug=class Ng extends wt{constructor(e){super(Ng.type),this.panorama=e}};Ug.type="panorama-load";var Fg=Ug,Og=class zg extends wt{constructor(e){super(zg.type),this.data=e}};Og.type="panorama-loaded";var Eu=Og,kg=class Bg extends wt{constructor(e,t){super(Bg.type),this.panorama=e,this.error=t}};kg.type="panorama-error";var Hg=kg,Vg=class Gg extends wt{constructor(e){super(Gg.type),this.completed=e}};Vg.type="transition-done";var Wg=Vg,$g=class qg extends wt{constructor(e){super(qg.type),this.position=e}};$g.type="position-updated";var Jo=$g,Xg=class Yg extends wt{constructor(e){super(Yg.type),this.roll=e}};Xg.type="roll-updated";var ea=Xg,Qg=class jg extends wt{constructor(){super(jg.type)}};Qg.type="ready";var ta=Qg,Zg=class Kg extends wt{constructor(){super(Kg.type)}};Zg.type="render";var Jg=Zg,ev=class tv extends wt{constructor(e){super(tv.type),this.notificationId=e}};ev.type="show-notification";var na=ev,nv=class iv extends wt{constructor(e){super(iv.type),this.overlayId=e}};nv.type="show-overlay";var sv=nv,rv=class ov extends wt{constructor(e){super(ov.type),this.panelId=e}};rv.type="show-panel";var _s=rv,av=class lv extends wt{constructor(e,t){super(lv.type),this.tooltip=e,this.tooltipData=t}};av.type="show-tooltip";var cv=av,hv=class uv extends wt{constructor(e){super(uv.type),this.size=e}};hv.type="size-updated";var ia=hv,dv=class fv extends wt{constructor(){super(fv.type)}};dv.type="stop-all";var sa=dv,pv=class mv extends wt{constructor(e){super(mv.type),this.zoomLevel=e}};pv.type="zoom-updated";var Vi=pv,cc=class extends wt{constructor(n,e,t,i,s){super(n),this.originalEvent=e,this.object=t,this.viewerPoint=i,this.userDataKey=s}},_v=class gv extends cc{constructor(e,t,i,s){super(gv.type,e,t,i,s)}};_v.type="enter-object";var vv=_v,xv=class Mv extends cc{constructor(e,t,i,s){super(Mv.type,e,t,i,s)}};xv.type="leave-object";var yu=xv,Ev=class yv extends cc{constructor(e,t,i,s){super(yv.type,e,t,i,s)}};Ev.type="hover-object";var Sv=Ev,Vd=class{constructor(n){this.viewer=n}init(){}destroy(){}supportsTransition(n){return!1}supportsPreload(n){return!1}textureCoordsToSphericalCoords(n,e){throw new Ke("Current adapter does not support texture coordinates.")}sphericalCoordsToTextureCoords(n,e){throw new Ke("Current adapter does not support texture coordinates.")}};Vd.supportsDownload=!1;function mp(n){if(n){for(const[,e]of[["_",n],...Object.entries(n)])if(e.prototype instanceof Vd)return Bd(e.id,e.VERSION,"5.11.1"),e}return null}var Fo=`${Ss}_touchSupport`,xn={loaded:!1,pixelRatio:1,isWebGLSupported:!1,maxTextureWidth:0,isTouchEnabled:null,__maxCanvasWidth:null,isIphone:!1,get maxCanvasWidth(){return this.__maxCanvasWidth===null&&(this.__maxCanvasWidth=k1(this.maxTextureWidth)),this.__maxCanvasWidth},load(){if(!this.loaded){const n=O1();this.pixelRatio=window.devicePixelRatio||1,this.isWebGLSupported=!!n,this.maxTextureWidth=n?n.getParameter(n.MAX_TEXTURE_SIZE):0,this.isTouchEnabled=z1(),this.isIphone=/iPhone/i.test(navigator.userAgent),this.loaded=!0}if(!xn.isWebGLSupported)throw new Ke("WebGL 2 is not supported.");if(xn.maxTextureWidth===0)throw new Ke("Unable to detect system capabilities")}};function O1(){try{return document.createElement("canvas").getContext("webgl2")}catch{return null}}function z1(){let n="ontouchstart"in window||navigator.maxTouchPoints>0;Fo in localStorage&&(n=localStorage[Fo]==="true");const e=new Promise(t=>{const i=()=>{window.removeEventListener("mousedown",s),window.removeEventListener("touchstart",r),clearTimeout(a)},s=()=>{i(),localStorage[Fo]=!1,t(!1)},r=()=>{i(),localStorage[Fo]=!0,t(!0)},o=()=>{i(),localStorage[Fo]=n,t(n)};window.addEventListener("mousedown",s,!1),window.addEventListener("touchstart",r,!1);const a=setTimeout(o,1e4)});return{initial:n,promise:e}}function k1(n){let e=n,t=!1;for(;e>1024&&!t;){const i=document.createElement("canvas"),s=i.getContext("2d");i.width=e,i.height=e/2,s.fillStyle="white",s.fillRect(0,0,1,1);try{s.getImageData(0,0,1,1).data[0]>0&&(t=!0)}catch{}i.width=0,i.height=0,t||(e/=2)}if(t)return e;throw new Ke("Unable to detect system capabilities")}var B1=ac({backgroundColor:null,interpolateBackground:!1,resolution:64,useXmpData:!0,blur:!1},{resolution:n=>{if(!n||!Ut.isPowerOfTwo(n))throw new Ke("EquirectangularAdapter resolution must be power of two.");return n},backgroundColor:n=>(n&&Lt("EquirectangularAdapter.backgroundColor is deprecated, use 'canvasBackground' main option instead."),n),interpolateBackground:n=>(n&&Lt("EquirectangularAdapter.interpolateBackground is not supported anymore."),!1)}),Ma=class extends Vd{constructor(n,e){super(n),this.config=B1(e),this.SPHERE_SEGMENTS=this.config.resolution,this.SPHERE_HORIZONTAL_SEGMENTS=this.SPHERE_SEGMENTS/2,this.config.backgroundColor&&(n.config.canvasBackground=e.backgroundColor)}supportsTransition(){return!0}supportsPreload(){return!0}textureCoordsToSphericalCoords(n,e){if(nn(n.textureX)||nn(n.textureY))throw new Ke("Texture position is missing 'textureX' or 'textureY'");const t=(n.textureX+e.croppedX)/e.fullWidth*Math.PI*2,i=(n.textureY+e.croppedY)/e.fullHeight*Math.PI;return{yaw:t>=Math.PI?t-Math.PI:t+Math.PI,pitch:Math.PI/2-i}}sphericalCoordsToTextureCoords(n,e){const t=n.yaw/Math.PI/2*e.fullWidth,i=n.pitch/Math.PI*e.fullHeight;let s=Math.round(n.yaw<Math.PI?t+e.fullWidth/2:t-e.fullWidth/2)-e.croppedX,r=Math.round(e.fullHeight/2-i)-e.croppedY;return(s<0||s>e.croppedWidth||r<0||r>e.croppedHeight)&&(s=r=void 0),{textureX:s,textureY:r}}async loadTexture(n,e=!0,t,i=this.config.useXmpData){if(typeof n!="string"&&(typeof n!="object"||!n.path))return Promise.reject(new Ke("Invalid panorama url, are you using the right adapter?"));let s;typeof n=="string"?s={path:n,data:t}:s={data:t,...n};const r=await this.viewer.textureLoader.loadFile(s.path,e?h=>this.viewer.loader.setProgress(h):null,s.path),o=i?await this.loadXMP(r):null,a=await this.viewer.textureLoader.blobToImage(r);typeof s.data=="function"&&(s.data=s.data(a,o));const l=j_(a.width,a.height,s.data,o),c=this.createEquirectangularTexture(a);return{panorama:n,texture:c,panoData:l,cacheKey:s.path}}async loadXMP(n){const e=await this.loadBlobAsString(n),t=e.indexOf("<x:xmpmeta");if(t===-1)return null;const i=e.indexOf("</x:xmpmeta>",t);if(i===-1)return null;const s=e.substring(t,i);return s.includes("GPano:")?{fullWidth:Ln(s,"FullPanoWidthPixels"),fullHeight:Ln(s,"FullPanoHeightPixels"),croppedWidth:Ln(s,"CroppedAreaImageWidthPixels"),croppedHeight:Ln(s,"CroppedAreaImageHeightPixels"),croppedX:Ln(s,"CroppedAreaLeftPixels"),croppedY:Ln(s,"CroppedAreaTopPixels"),poseHeading:Ln(s,"PoseHeadingDegrees",!1),posePitch:Ln(s,"PosePitchDegrees",!1),poseRoll:Ln(s,"PoseRollDegrees",!1),initialHeading:Ln(s,"InitialViewHeadingDegrees",!1),initialPitch:Ln(s,"InitialViewPitchDegrees",!1),initialFov:Ln(s,"InitialHorizontalFOVDegrees",!1)}:null}loadBlobAsString(n){return new Promise((e,t)=>{const i=new FileReader;i.onload=()=>e(i.result),i.onerror=t,i.readAsText(n)})}createEquirectangularTexture(n){if(this.config.blur||n.width>xn.maxTextureWidth){const e=Math.min(1,xn.maxCanvasWidth/n.width),t=new OffscreenCanvas(Math.floor(n.width*e),Math.floor(n.height*e)),i=t.getContext("2d");return this.config.blur&&(i.filter=`blur(${t.width/2048}px)`),i.drawImage(n,0,0,t.width,t.height),xu(t)}return xu(n)}createMesh(n){const e=n.croppedX/n.fullWidth*2*Math.PI,t=n.croppedWidth/n.fullWidth*2*Math.PI,i=n.croppedY/n.fullHeight*Math.PI,s=n.croppedHeight/n.fullHeight*Math.PI,r=new Ld(nr,Math.round(this.SPHERE_SEGMENTS/(2*Math.PI)*t),Math.round(this.SPHERE_HORIZONTAL_SEGMENTS/Math.PI*s),-Math.PI/2+e,t,i,s).scale(-1,1,1),o=new va({depthTest:!1,depthWrite:!1});return new Hn(r,o)}setTexture(n,e){n.material.map=e.texture}setTextureOpacity(n,e){n.material.opacity=e,n.material.transparent=e<1}disposeTexture({texture:n}){n.dispose()}disposeMesh(n){n.geometry.dispose(),n.material.dispose()}};Ma.id="equirectangular";Ma.VERSION="5.11.1";Ma.supportsDownload=!0;var bv=class extends Ma{constructor(n,e){super(n,{resolution:(e==null?void 0:e.resolution)??64,useXmpData:!1})}async loadTexture(n,e){const t=await super.loadTexture(n,e,null,!1);return t.panoData=null,t}createMesh(){const n=new Ld(nr,this.SPHERE_SEGMENTS,this.SPHERE_HORIZONTAL_SEGMENTS).scale(-1,1,1).toNonIndexed(),e=n.getAttribute("uv"),t=n.getAttribute("normal");for(let s=0;s<e.count;s++)for(let r=0;r<3;r++){const o=s*3+r,a=t.getX(o),l=t.getY(o),c=t.getZ(o),h=.947;if(s<e.count/6){const f=a===0&&c===0?1:Math.acos(l)/Math.sqrt(a*a+c*c)*(2/Math.PI);e.setXY(o,a*(h/4)*f+1/4,c*(h/2)*f+1/2)}else{const f=a===0&&c===0?1:Math.acos(-l)/Math.sqrt(a*a+c*c)*(2/Math.PI);e.setXY(o,-a*(h/4)*f+3/4,c*(h/2)*f+1/2)}}n.rotateX(-Math.PI/2),n.rotateY(Math.PI);const i=new va({depthTest:!1,depthWrite:!1});return new Hn(n,i)}};bv.id="dual-fisheye";bv.VERSION="5.11.1";var rr=class wv{constructor(e,t){this.parent=e,this.children=[],this.container=document.createElement("div"),this.state={visible:!0},this.viewer=e instanceof wv?e.viewer:e,this.container.className=t.className||"",this.parent.children.push(this),this.parent.container.appendChild(this.container)}destroy(){this.parent.container.removeChild(this.container);const e=this.parent.children.indexOf(this);e!==-1&&this.parent.children.splice(e,1),this.children.slice().forEach(t=>t.destroy()),this.children.length=0}toggle(e=!this.isVisible()){e?this.show():this.hide()}hide(e){this.container.style.display="none",this.state.visible=!1}show(e){this.container.style.display="",this.state.visible=!0}isVisible(){return this.state.visible}},H1=ac({id:null,className:null,title:null,hoverScale:!1,collapsable:!1,tabbable:!0,icon:null,iconActive:null}),Mn=class extends rr{constructor(n,e){super(n,{className:`psv-button ${e.hoverScale?"psv-button--hover-scale":""} ${e.className||""}`}),this.state={visible:!0,enabled:!0,supported:!0,collapsed:!1,active:!1,width:0},this.config=H1(e),e.id||(this.config.id=this.constructor.id),e.icon&&this.__setIcon(e.icon),this.state.width=this.container.offsetWidth,this.config.title?this.container.title=this.viewer.config.lang[this.config.title]??this.config.title:this.id&&this.id in this.viewer.config.lang&&(this.container.title=this.viewer.config.lang[this.id]),e.tabbable&&(this.container.tabIndex=0),this.container.addEventListener("click",t=>{this.state.enabled&&this.onClick(),t.stopPropagation()}),this.container.addEventListener("keydown",t=>{t.key===tn.Enter&&this.state.enabled&&(this.onClick(),t.stopPropagation())})}get id(){return this.config.id}get title(){return this.container.title}get content(){return this.container.innerHTML}get width(){return this.state.width}get collapsable(){return this.config.collapsable}show(n=!0){this.isVisible()||(this.state.visible=!0,this.state.collapsed||(this.container.style.display=""),n&&this.viewer.navbar.autoSize())}hide(n=!0){this.isVisible()&&(this.state.visible=!1,this.container.style.display="none",n&&this.viewer.navbar.autoSize())}checkSupported(){Od(this.isSupported(),(n,e)=>{this.state&&(this.state.supported=n,e?n||this.hide():this.toggle(n))})}autoSize(){}isSupported(){return!0}toggleActive(n=!this.state.active){n!==this.state.active&&(this.state.active=n,sc(this.container,"psv-button--active",this.state.active),this.config.iconActive&&this.__setIcon(this.state.active?this.config.iconActive:this.config.icon))}disable(){this.container.classList.add("psv-button--disabled"),this.state.enabled=!1}enable(){this.container.classList.remove("psv-button--disabled"),this.state.enabled=!0}collapse(){this.state.collapsed=!0,this.container.style.display="none"}uncollapse(){this.state.collapsed=!1,this.state.visible&&(this.container.style.display="")}__setIcon(n){this.container.innerHTML=n,Ud(this.container.querySelector("svg"),"psv-button-svg")}},V1=class extends Mn{constructor(n,e){var t,i;super(n,{id:e.id??`psvButton-${Math.random().toString(36).substring(2)}`,className:`psv-custom-button ${e.className||""}`,hoverScale:!1,collapsable:e.collapsable!==!1,tabbable:e.tabbable!==!1,title:e.title}),this.customOnClick=e.onClick,e.content&&(typeof e.content=="string"?this.container.innerHTML=e.content:(this.container.classList.add("psv-custom-button--no-padding"),e.content.style.height="100%",(i=(t=e.content).attachViewer)==null||i.call(t,this.viewer),this.container.appendChild(e.content))),this.state.width=this.container.offsetWidth,e.disabled&&this.disable(),e.visible===!1&&this.hide()}onClick(){var n;(n=this.customOnClick)==null||n.call(this,this.viewer)}},fa=class extends Mn{constructor(n){super(n,{className:"psv-description-button",hoverScale:!0,collapsable:!1,tabbable:!0,icon:si.info}),this.mode=0,this.viewer.addEventListener(Ko.type,this),this.viewer.addEventListener(na.type,this),this.viewer.addEventListener(ps.type,this),this.viewer.addEventListener(_s.type,this),this.viewer.addEventListener(bn.type,this)}destroy(){this.viewer.removeEventListener(Ko.type,this),this.viewer.removeEventListener(na.type,this),this.viewer.removeEventListener(ps.type,this),this.viewer.removeEventListener(_s.type,this),this.viewer.removeEventListener(bn.type,this),super.destroy()}handleEvent(n){if(n instanceof bn){n.containsOptions("description")&&this.autoSize(!0);return}if(!this.mode)return;let e=!1;n instanceof Ko?e=this.mode===1:n instanceof na?e=this.mode===1&&n.notificationId!==rn.DESCRIPTION:n instanceof ps?e=this.mode===2:n instanceof _s&&(e=this.mode===2&&n.panelId!==rn.DESCRIPTION),e&&(this.toggleActive(!1),this.mode=0)}onClick(){this.mode?this.__close():this.__open()}hide(n){super.hide(n),this.mode&&this.__close()}autoSize(n=!1){if(n){const e=this.viewer.navbar.getButton("caption",!1),t=e&&!e.isVisible(),i=!!this.viewer.config.description;t||i?this.show(!1):this.hide(!1)}}__close(){switch(this.mode){case 1:this.viewer.notification.hide(rn.DESCRIPTION);break;case 2:this.viewer.panel.hide(rn.DESCRIPTION);break}}__open(){this.toggleActive(!0),this.viewer.config.description?(this.mode=2,this.viewer.panel.show({id:rn.DESCRIPTION,content:(this.viewer.config.caption?`<p>${this.viewer.config.caption}</p>`:"")+this.viewer.config.description})):(this.mode=1,this.viewer.notification.show({id:rn.DESCRIPTION,content:this.viewer.config.caption}))}};fa.id="description";var Tv=class extends Mn{constructor(n){super(n,{className:"psv-download-button",hoverScale:!0,collapsable:!0,tabbable:!0,icon:si.download}),this.viewer.addEventListener(bn.type,this)}destroy(){this.viewer.removeEventListener(bn.type,this),super.destroy()}handleEvent(n){n instanceof bn&&n.containsOptions("downloadUrl")&&this.checkSupported()}onClick(){const n=document.createElement("a");n.href=this.viewer.config.downloadUrl||this.viewer.config.panorama,n.href.startsWith("data:")&&!this.viewer.config.downloadName?n.download="panorama."+n.href.substring(0,n.href.indexOf(";")).split("/").pop():n.download=this.viewer.config.downloadName||n.href.split("/").pop(),n.target="_blank",this.viewer.container.appendChild(n),n.click(),setTimeout(()=>{this.viewer.container.removeChild(n)},100)}checkSupported(){this.viewer.adapter.constructor.supportsDownload||this.viewer.config.downloadUrl?this.show():this.hide()}};Tv.id="download";var Av=class extends Mn{constructor(n){super(n,{className:"psv-fullscreen-button",hoverScale:!0,collapsable:!1,tabbable:!0,icon:si.fullscreenIn,iconActive:si.fullscreenOut}),this.viewer.addEventListener(Zo.type,this)}destroy(){this.viewer.removeEventListener(Zo.type,this),super.destroy()}handleEvent(n){n instanceof Zo&&this.toggleActive(n.fullscreenEnabled)}onClick(){this.viewer.toggleFullscreen()}};Av.id="fullscreen";var G1="psvButton",W1=(n,e)=>` <div class="psv-panel-menu psv-panel-menu--stripped"> <h1 class="psv-panel-menu-title">${si.menu} ${e}</h1> <ul class="psv-panel-menu-list"> ${n.map(t=>` <li data-psv-button="${t.id}" class="psv-panel-menu-item" tabindex="0"> <span class="psv-panel-menu-item-icon">${t.content}</span> <span class="psv-panel-menu-item-label">${t.title}</span> </li> `).join("")} </ul> </div> `,Ll=class extends Mn{constructor(n){super(n,{className:"psv-menu-button",hoverScale:!0,collapsable:!1,tabbable:!0,icon:si.menu}),this.viewer.addEventListener(_s.type,this),this.viewer.addEventListener(ps.type,this),super.hide()}destroy(){this.viewer.removeEventListener(_s.type,this),this.viewer.removeEventListener(ps.type,this),super.destroy()}handleEvent(n){n instanceof _s?this.toggleActive(n.panelId===rn.MENU):n instanceof ps&&this.toggleActive(!1)}onClick(){this.state.active?this.__hideMenu():this.__showMenu()}hide(n){super.hide(n),this.__hideMenu()}show(n){super.show(n),this.state.active&&this.__showMenu()}__showMenu(){this.viewer.panel.show({id:rn.MENU,content:W1(this.viewer.navbar.collapsed,this.viewer.config.lang.menu),noMargin:!0,clickHandler:n=>{const e=n?N_(n,".psv-panel-menu-item"):void 0,t=e?e.dataset[G1]:void 0;t&&(this.viewer.navbar.getButton(t).onClick(),this.__hideMenu())}})}__hideMenu(){this.viewer.panel.hide(rn.MENU)}};Ll.id="menu";function $1(n){let e=0;switch(n){case 0:e=90;break;case 1:e=-90;break;case 3:e=180;break;default:e=0;break}return si.arrow.replace("rotate(0",`rotate(${e}`)}var Ea=class extends Mn{constructor(n,e){super(n,{className:"psv-move-button",hoverScale:!0,collapsable:!1,tabbable:!0,icon:$1(e)}),this.direction=e,this.handler=new lc,this.container.addEventListener("mousedown",this),this.container.addEventListener("keydown",this),this.container.addEventListener("keyup",this),this.viewer.container.addEventListener("mouseup",this),this.viewer.container.addEventListener("touchend",this)}destroy(){this.__onMouseUp(),this.viewer.container.removeEventListener("mouseup",this),this.viewer.container.removeEventListener("touchend",this),super.destroy()}handleEvent(n){switch(n.type){case"mousedown":this.__onMouseDown();break;case"mouseup":this.__onMouseUp();break;case"touchend":this.__onMouseUp();break;case"keydown":n.key===tn.Enter&&this.__onMouseDown();break;case"keyup":n.key===tn.Enter&&this.__onMouseUp();break}}onClick(){}isSupported(){return oc(xn.isTouchEnabled)}__onMouseDown(){if(!this.state.enabled)return;const n={};switch(this.direction){case 0:n.pitch=!1;break;case 1:n.pitch=!0;break;case 3:n.yaw=!1;break;default:n.yaw=!0;break}this.viewer.stopAll(),this.viewer.dynamics.position.roll(n),this.handler.down()}__onMouseUp(){this.state.enabled&&this.handler.up(()=>{this.viewer.dynamics.position.stop(),this.viewer.resetIdleTimer()})}};Ea.groupId="move";var Cv=class extends Ea{constructor(n){super(n,1)}};Cv.id="moveDown";var Rv=class extends Ea{constructor(n){super(n,2)}};Rv.id="moveLeft";var Pv=class extends Ea{constructor(n){super(n,3)}};Pv.id="moveRight";var Lv=class extends Ea{constructor(n){super(n,0)}};Lv.id="moveUp";var Gd=class extends Mn{constructor(n,e,t){super(n,{className:"psv-zoom-button",hoverScale:!0,collapsable:!1,tabbable:!0,icon:e}),this.direction=t,this.handler=new lc,this.container.addEventListener("mousedown",this),this.container.addEventListener("keydown",this),this.container.addEventListener("keyup",this),this.viewer.container.addEventListener("mouseup",this),this.viewer.container.addEventListener("touchend",this)}destroy(){this.__onMouseUp(),this.viewer.container.removeEventListener("mouseup",this),this.viewer.container.removeEventListener("touchend",this),super.destroy()}handleEvent(n){switch(n.type){case"mousedown":this.__onMouseDown();break;case"mouseup":this.__onMouseUp();break;case"touchend":this.__onMouseUp();break;case"keydown":n.key===tn.Enter&&this.__onMouseDown();break;case"keyup":n.key===tn.Enter&&this.__onMouseUp();break}}onClick(){}isSupported(){return oc(xn.isTouchEnabled)}__onMouseDown(){this.state.enabled&&(this.viewer.dynamics.zoom.roll(this.direction===1),this.handler.down())}__onMouseUp(){this.state.enabled&&this.handler.up(()=>this.viewer.dynamics.zoom.stop())}};Gd.groupId="zoom";var Dv=class extends Gd{constructor(n){super(n,si.zoomIn,0)}};Dv.id="zoomIn";var Iv=class extends Gd{constructor(n){super(n,si.zoomOut,1)}};Iv.id="zoomOut";var Wd=class extends Mn{constructor(n){super(n,{className:"psv-zoom-range",hoverScale:!1,collapsable:!1,tabbable:!1}),this.zoomRange=document.createElement("div"),this.zoomRange.className="psv-zoom-range-line",this.container.appendChild(this.zoomRange),this.zoomValue=document.createElement("div"),this.zoomValue.className="psv-zoom-range-handle",this.zoomRange.appendChild(this.zoomValue),this.slider=new J_(this.container,"HORIZONTAL",e=>this.__onSliderUpdate(e)),this.mediaMinWidth=parseInt(gi(this.container,"max-width"),10),this.viewer.addEventListener(Vi.type,this),this.viewer.state.ready?this.__moveZoomValue(this.viewer.getZoomLevel()):this.viewer.addEventListener(ta.type,this)}destroy(){this.slider.destroy(),this.viewer.removeEventListener(Vi.type,this),this.viewer.removeEventListener(ta.type,this),super.destroy()}handleEvent(n){n instanceof Vi?this.__moveZoomValue(n.zoomLevel):n instanceof ta&&this.__moveZoomValue(this.viewer.getZoomLevel())}onClick(){}isSupported(){return oc(xn.isTouchEnabled)}autoSize(){this.state.supported&&(this.viewer.state.size.width<=this.mediaMinWidth&&this.state.visible?this.hide(!1):this.viewer.state.size.width>this.mediaMinWidth&&!this.state.visible&&this.show(!1))}__moveZoomValue(n){this.zoomValue.style.left=n/100*this.zoomRange.offsetWidth-this.zoomValue.offsetWidth/2+"px"}__onSliderUpdate(n){n.mousedown&&this.viewer.zoom(n.value*100)}};Wd.id="zoomRange";Wd.groupId="zoom";var Uv=class extends tg{constructor(n){super(),this.viewer=n}init(){}destroy(){}},Nv=class extends Uv{constructor(n,e){super(n),this.config=this.constructor.configParser(e)}setOption(n,e){this.setOptions({[n]:e})}setOptions(n){const e={...this.config,...n},t=this.constructor,i=t.configParser,s=t.readonlyOptions,r=t.id;for(let[o,a]of Object.entries(n)){if(!(o in i.defaults)){Lt(`${r}: Unknown option "${o}"`);continue}if(s.includes(o)){Lt(`${r}: Option "${o}" cannot be updated`);continue}o in i.parsers&&(a=i.parsers[o](a,{rawConfig:e,defValue:i.defaults[o]})),this.config[o]=a}}};Nv.readonlyOptions=[];function Su(n){if(n){for(const[,e]of[["_",n],...Object.entries(n)])if(e.prototype instanceof Uv)return Bd(e.id,e.VERSION,"5.11.1"),e}return null}var bs={panorama:null,container:null,adapter:[Ma,null],plugins:[],caption:null,description:null,downloadUrl:null,downloadName:null,loadingImg:null,loadingTxt:"",size:null,fisheye:0,minFov:30,maxFov:90,defaultZoomLvl:50,defaultYaw:0,defaultPitch:0,sphereCorrection:null,moveSpeed:1,zoomSpeed:1,moveInertia:.8,mousewheel:!0,mousemove:!0,mousewheelCtrlKey:!1,touchmoveTwoFingers:!1,panoData:null,requestHeaders:null,canvasBackground:"#000",rendererParameters:{alpha:!0,antialias:!0},withCredentials:!1,navbar:["zoom","move","download","description","caption","fullscreen"],lang:{zoom:"Zoom",zoomOut:"Zoom out",zoomIn:"Zoom in",moveUp:"Move up",moveDown:"Move down",moveLeft:"Move left",moveRight:"Move right",description:"Description",download:"Download",fullscreen:"Fullscreen",loading:"Loading...",menu:"Menu",close:"Close",twoFingers:"Use two fingers to navigate",ctrlZoom:"Use ctrl + scroll to zoom the image",loadError:"The panorama cannot be loaded",webglError:"Your browser does not seem to support WebGL"},keyboard:"fullscreen",keyboardActions:{[tn.ArrowUp]:"ROTATE_UP",[tn.ArrowDown]:"ROTATE_DOWN",[tn.ArrowRight]:"ROTATE_RIGHT",[tn.ArrowLeft]:"ROTATE_LEFT",[tn.PageUp]:"ZOOM_IN",[tn.PageDown]:"ZOOM_OUT",[tn.Plus]:"ZOOM_IN",[tn.Minus]:"ZOOM_OUT"}},_p={panorama:"Use setPanorama method to change the panorama",panoData:"Use setPanorama method to change the panorama",container:"Cannot change viewer container",adapter:"Cannot change adapter",plugins:"Cannot change plugins"},bu={container:n=>{if(!n)throw new Ke("No value given for container.");return n},adapter:(n,{defValue:e})=>{if(n?Array.isArray(n)?n=[mp(n[0]),n[1]]:n=[mp(n),null]:n=e,!n[0])throw new Ke("An undefined value was given for adapter.");if(!n[0].id)throw new Ke("Adapter has no id.");return n[0].id==="little-planet"&&(Lt("LittlePlanetAdapter support has been removed, use `{ fisheye: 2, maxFov: 130 }` to achieve similar effect."),n=e),n},defaultYaw:n=>fi(n),defaultPitch:n=>fi(n,!0),defaultZoomLvl:n=>Ut.clamp(n,0,100),minFov:(n,{rawConfig:e})=>(e.maxFov<n&&(Lt("maxFov cannot be lower than minFov"),n=e.maxFov),Ut.clamp(n,1,179)),maxFov:(n,{rawConfig:e})=>(n<e.minFov&&(n=e.minFov),Ut.clamp(n,1,179)),moveInertia:(n,{defValue:e})=>n===!0?e:n===!1?0:n,lang:n=>({...bs.lang,...n}),keyboard:n=>n?typeof n=="object"?(Lt("Use keyboardActions to configure the keyboard actions, keyboard option must be either true, false, 'fullscreen' or 'always'"),"fullscreen"):n==="always"?"always":"fullscreen":!1,keyboardActions:(n,{rawConfig:e})=>e.keyboard&&typeof e.keyboard=="object"?e.keyboard:n,fisheye:n=>n===!0?1:n===!1?0:n,requestHeaders:n=>n&&typeof n=="object"?()=>n:typeof n=="function"?n:null,rendererParameters:(n,{defValue:e})=>({...n,...e}),plugins:n=>n.map((e,t)=>{if(Array.isArray(e)?e=[Su(e[0]),e[1]]:e=[Su(e),null],!e[0])throw new Ke(`An undefined value was given for plugin ${t}.`);if(!e[0].id)throw new Ke(`Plugin ${t} has no id.`);return e}),navbar:n=>n===!1?null:n===!0?rc(bs.navbar):typeof n=="string"?n.split(/[ ,]/):n},q1=ac(bs,bu),Gr=class extends Mn{constructor(n){super(n,{className:"psv-caption",hoverScale:!1,collapsable:!1,tabbable:!0}),this.contentWidth=0,this.state.width=0,this.contentElt=document.createElement("div"),this.contentElt.className="psv-caption-content",this.container.appendChild(this.contentElt),this.setCaption(this.viewer.config.caption)}hide(){this.contentElt.style.display="none",this.state.visible=!1}show(){this.contentElt.style.display="",this.state.visible=!0}onClick(){}setCaption(n){this.show(),this.contentElt.innerHTML=n??"",this.contentElt.innerHTML?this.contentWidth=this.contentElt.offsetWidth:this.contentWidth=0,this.autoSize()}autoSize(){this.toggle(this.container.offsetWidth>=this.contentWidth),this.__refreshButton()}__refreshButton(){var n;(n=this.viewer.navbar.getButton(fa.id,!1))==null||n.autoSize(!0)}};Gr.id="caption";var wu={},Ql={};function $d(n,e){if(!n.id)throw new Ke("Button id is required");if(wu[n.id]=n,n.groupId&&(Ql[n.groupId]=Ql[n.groupId]||[]).push(n),e){const t=bs.navbar;switch(e){case"start":t.unshift(n.id);break;case"end":t.push(n.id);break;default:{const[i,s]=e.split(":"),r=t.indexOf(i);if(!i||!s||r===-1)throw new Ke(`Invalid defaultPosition ${e}`);t.splice(r+(s==="right"?1:0),0,n.id)}}}}[Iv,Wd,Dv,fa,Gr,Tv,Av,Rv,Pv,Lv,Cv].forEach(n=>$d(n));var X1=class extends rr{constructor(n){super(n,{className:`psv-navbar ${xa}`}),this.collapsed=[],this.state.visible=!1}show(){this.viewer.container.classList.add("psv--has-navbar"),this.container.classList.add("psv-navbar--open"),this.state.visible=!0}hide(){this.viewer.container.classList.remove("psv--has-navbar"),this.container.classList.remove("psv-navbar--open"),this.state.visible=!1}setButtons(n){this.children.slice().forEach(e=>e.destroy()),this.children.length=0,n.indexOf(Gr.id)!==-1&&n.indexOf(fa.id)===-1&&n.splice(n.indexOf(Gr.id),0,fa.id),n.forEach(e=>{typeof e=="object"?new V1(this,e):wu[e]?new wu[e](this):Ql[e]?Ql[e].forEach(t=>{new t(this)}):Lt(`Unknown button ${e}`)}),new Ll(this),this.children.forEach(e=>{e instanceof Mn&&e.checkSupported()}),this.autoSize()}setCaption(n){this.children.some(e=>e instanceof Gr?(e.setCaption(n),!0):!1)}getButton(n,e=!0){const t=this.children.find(i=>i instanceof Mn&&i.id===n);return!t&&e&&Lt(`button "${n}" not found in the navbar`),t}autoSize(){var i;this.children.forEach(s=>{s instanceof Mn&&s.autoSize()});const n=this.container.offsetWidth;let e=0;const t=[];this.children.forEach(s=>{s.isVisible()&&s instanceof Mn&&(e+=s.width,s.collapsable&&t.push(s))}),e!==0&&(n<e&&t.length>0?(t.forEach(s=>s.collapse()),this.collapsed=t,this.getButton(Ll.id).show(!1)):n>=e&&this.collapsed.length>0&&(this.collapsed.forEach(s=>s.uncollapse()),this.collapsed=[],this.getButton(Ll.id).hide(!1)),(i=this.getButton(Gr.id,!1))==null||i.autoSize())}};fu.enabled=!1;var zr={enabled:!0,maxItems:10,ttl:10*60,items:{},purgeInterval:null,init(){fu.enabled&&(Lt("ThreeJS cache should be disabled"),fu.enabled=!1),!this.purgeInterval&&this.enabled&&(this.purgeInterval=setInterval(()=>this.purge(),60*1e3))},add(n,e,t){this.enabled&&e&&(this.items[e]=this.items[e]??{files:{},lastAccess:null},this.items[e].files[n]=t,this.items[e].lastAccess=Date.now())},get(n,e){if(this.enabled&&e&&this.items[e])return this.items[e].lastAccess=Date.now(),this.items[e].files[n]},remove(n,e){this.enabled&&e&&this.items[e]&&(delete this.items[e].files[n],Object.keys(this.items[e].files).length===0&&delete this.items[e])},purge(){Object.entries(this.items).sort(([,n],[,e])=>e.lastAccess-n.lastAccess).forEach(([n,{lastAccess:e}],t)=>{t>0&&(Date.now()-e>=this.ttl*1e3||t>=this.maxItems)&&delete this.items[n]})}},Y1=class extends rr{constructor(n){super(n,{className:"psv-loader-container"}),this.loader=document.createElement("div"),this.loader.className="psv-loader",this.container.appendChild(this.loader),this.size=this.loader.offsetWidth,this.canvas=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.canvas.setAttribute("class","psv-loader-canvas"),this.canvas.setAttribute("viewBox",`0 0 ${this.size} ${this.size}`),this.loader.appendChild(this.canvas),this.textColor=gi(this.loader,"color"),this.color=gi(this.canvas,"color"),this.border=parseInt(gi(this.loader,"--psv-loader-border"),10),this.thickness=parseInt(gi(this.loader,"--psv-loader-tickness"),10),this.viewer.addEventListener(bn.type,this),this.__updateContent(),this.hide()}destroy(){this.viewer.removeEventListener(bn.type,this),super.destroy()}handleEvent(n){n instanceof bn&&n.containsOptions("loadingImg","loadingTxt")&&this.__updateContent()}setProgress(n){const e=Math.min(n,99.999)/100*Math.PI*2,t=this.size/2,i=t,s=this.thickness/2+this.border,r=(this.size-this.thickness)/2-this.border,o=Math.sin(e)*r+t,a=-Math.cos(e)*r+t,l=n>50?"1":"0";this.canvas.innerHTML=` <circle cx="${t}" cy="${t}" r="${t}" fill="${this.color}"/> <path d="M ${i} ${s} A ${r} ${r} 0 ${l} 1 ${o} ${a}" fill="none" stroke="${this.textColor}" stroke-width="${this.thickness}" stroke-linecap="round"/> `,this.viewer.dispatchEvent(new Ig(Math.round(n)))}__updateContent(){const n=this.loader.querySelector(".psv-loader-image, .psv-loader-text");n&&this.loader.removeChild(n);let e;if(this.viewer.config.loadingImg?(e=document.createElement("img"),e.className="psv-loader-image",e.src=this.viewer.config.loadingImg):this.viewer.config.loadingTxt!==null&&(e=document.createElement("div"),e.className="psv-loader-text",e.innerHTML=this.viewer.config.loadingTxt||this.viewer.config.lang.loading),e){const t=Math.round(Math.sqrt(2*Math.pow(this.size/2-this.thickness/2-this.border,2)));e.style.maxWidth=t+"px",e.style.maxHeight=t+"px",this.loader.appendChild(e)}}},Q1=class extends rr{constructor(n){super(n,{className:"psv-notification"}),this.state={visible:!1,contentId:null,timeout:null},this.content=document.createElement("div"),this.content.className="psv-notification-content",this.container.appendChild(this.content),this.content.addEventListener("click",()=>this.hide())}isVisible(n){return this.state.visible&&(!n||!this.state.contentId||this.state.contentId===n)}toggle(){throw new Ke("Notification cannot be toggled")}show(n){this.state.timeout&&(clearTimeout(this.state.timeout),this.state.timeout=null),typeof n=="string"&&(n={content:n}),this.state.contentId=n.id||null,this.content.innerHTML=n.content,this.container.classList.add("psv-notification--visible"),this.state.visible=!0,this.viewer.dispatchEvent(new na(n.id)),n.timeout&&(this.state.timeout=setTimeout(()=>this.hide(this.state.contentId),n.timeout))}hide(n){if(this.isVisible(n)){const e=this.state.contentId;this.container.classList.remove("psv-notification--visible"),this.state.visible=!1,this.state.contentId=null,this.viewer.dispatchEvent(new Ko(e))}}},j1=class extends rr{constructor(n){super(n,{className:`psv-overlay ${xa}`}),this.state={visible:!1,contentId:null,dissmisable:!0},this.image=document.createElement("div"),this.image.className="psv-overlay-image",this.container.appendChild(this.image),this.title=document.createElement("div"),this.title.className="psv-overlay-title",this.container.appendChild(this.title),this.text=document.createElement("div"),this.text.className="psv-overlay-text",this.container.appendChild(this.text),this.container.addEventListener("click",this),this.viewer.addEventListener(ms.type,this),super.hide()}destroy(){this.viewer.removeEventListener(ms.type,this),super.destroy()}handleEvent(n){n.type==="click"?this.isVisible()&&this.state.dissmisable&&(this.hide(),n.stopPropagation()):n instanceof ms&&this.isVisible()&&this.state.dissmisable&&n.key===tn.Escape&&(this.hide(),n.preventDefault())}isVisible(n){return this.state.visible&&(!n||!this.state.contentId||this.state.contentId===n)}toggle(){throw new Ke("Overlay cannot be toggled")}show(n){typeof n=="string"&&(n={title:n}),this.state.contentId=n.id||null,this.state.dissmisable=n.dissmisable!==!1,this.image.innerHTML=n.image||"",this.title.innerHTML=n.title||"",this.text.innerHTML=n.text||"",super.show(),this.viewer.dispatchEvent(new sv(n.id))}hide(n){if(this.isVisible(n)){const e=this.state.contentId;super.hide(),this.state.contentId=null,this.viewer.dispatchEvent(new Sg(e))}}},Z1=200,Xc="psv-panel-content--no-interaction",K1=class extends rr{constructor(n){super(n,{className:`psv-panel ${xa}`}),this.state={visible:!1,contentId:null,mouseX:0,mouseY:0,mousedown:!1,clickHandler:null,keyHandler:null,width:{}};const e=document.createElement("div");e.className="psv-panel-resizer",this.container.appendChild(e);const t=document.createElement("div");t.className="psv-panel-close-button",t.innerHTML=si.close,t.title=n.config.lang.close,this.container.appendChild(t),this.content=document.createElement("div"),this.content.className="psv-panel-content",this.container.appendChild(this.content),this.container.addEventListener("wheel",i=>i.stopPropagation()),t.addEventListener("click",()=>this.hide()),e.addEventListener("mousedown",this),e.addEventListener("touchstart",this),this.viewer.container.addEventListener("mouseup",this),this.viewer.container.addEventListener("touchend",this),this.viewer.container.addEventListener("mousemove",this),this.viewer.container.addEventListener("touchmove",this),this.viewer.addEventListener(ms.type,this)}destroy(){this.viewer.removeEventListener(ms.type,this),this.viewer.container.removeEventListener("mousemove",this),this.viewer.container.removeEventListener("touchmove",this),this.viewer.container.removeEventListener("mouseup",this),this.viewer.container.removeEventListener("touchend",this),super.destroy()}handleEvent(n){switch(n.type){case"mousedown":this.__onMouseDown(n);break;case"touchstart":this.__onTouchStart(n);break;case"mousemove":this.__onMouseMove(n);break;case"touchmove":this.__onTouchMove(n);break;case"mouseup":this.__onMouseUp(n);break;case"touchend":this.__onTouchEnd(n);break;case ms.type:this.__onKeyPress(n);break}}isVisible(n){return this.state.visible&&(!n||!this.state.contentId||this.state.contentId===n)}toggle(){throw new Ke("Panel cannot be toggled")}show(n){typeof n=="string"&&(n={content:n});const e=this.isVisible(n.id);this.state.contentId=n.id||null,this.state.visible=!0,this.state.clickHandler&&(this.content.removeEventListener("click",this.state.clickHandler),this.content.removeEventListener("keydown",this.state.keyHandler),this.state.clickHandler=null,this.state.keyHandler=null),n.id&&this.state.width[n.id]?this.container.style.width=this.state.width[n.id]:n.width?this.container.style.width=n.width:this.container.style.width=null,this.content.innerHTML=n.content,this.content.scrollTop=0,this.container.classList.add("psv-panel--open"),sc(this.content,"psv-panel-content--no-margin",n.noMargin===!0),n.clickHandler&&(this.state.clickHandler=t=>{n.clickHandler(Wl(t))},this.state.keyHandler=t=>{t.key===tn.Enter&&n.clickHandler(Wl(t))},this.content.addEventListener("click",this.state.clickHandler),this.content.addEventListener("keydown",this.state.keyHandler),e||setTimeout(()=>{var t;(t=this.content.querySelector("a,button,[tabindex]"))==null||t.focus()},300)),this.viewer.dispatchEvent(new _s(n.id))}hide(n){if(this.isVisible(n)){const e=this.state.contentId;this.state.visible=!1,this.state.contentId=null,this.content.innerHTML=null,this.container.classList.remove("psv-panel--open"),this.state.clickHandler&&(this.content.removeEventListener("click",this.state.clickHandler),this.state.clickHandler=null),this.viewer.dispatchEvent(new ps(e))}}__onMouseDown(n){n.stopPropagation(),this.__startResize(n.clientX,n.clientY)}__onTouchStart(n){if(n.stopPropagation(),n.touches.length===1){const e=n.touches[0];this.__startResize(e.clientX,e.clientY)}}__onMouseUp(n){this.state.mousedown&&(n.stopPropagation(),this.state.mousedown=!1,this.content.classList.remove(Xc))}__onTouchEnd(n){this.state.mousedown&&(n.stopPropagation(),n.touches.length===0&&(this.state.mousedown=!1,this.content.classList.remove(Xc)))}__onMouseMove(n){this.state.mousedown&&(n.stopPropagation(),this.__resize(n.clientX,n.clientY))}__onTouchMove(n){if(this.state.mousedown){const e=n.touches[0];this.__resize(e.clientX,e.clientY)}}__onKeyPress(n){this.isVisible()&&n.key===tn.Escape&&(this.hide(),n.preventDefault())}__startResize(n,e){this.state.mouseX=n,this.state.mouseY=e,this.state.mousedown=!0,this.content.classList.add(Xc)}__resize(n,e){const t=n,i=e,s=Math.max(Z1,this.container.offsetWidth-(t-this.state.mouseX))+"px";this.state.contentId&&(this.state.width[this.state.contentId]=s),this.container.style.width=s,this.state.mouseX=t,this.state.mouseY=i}},J1=class extends rr{constructor(n,e){super(n,{className:"psv-tooltip"}),this.state={visible:!0,arrow:0,border:0,state:0,width:0,height:0,pos:"",config:null,data:null,hideTimeout:null},this.content=document.createElement("div"),this.content.className="psv-tooltip-content",this.container.appendChild(this.content),this.arrow=document.createElement("div"),this.arrow.className="psv-tooltip-arrow",this.container.appendChild(this.arrow),this.container.addEventListener("transitionend",this),this.container.addEventListener("touchdown",t=>t.stopPropagation()),this.container.addEventListener("mousedown",t=>t.stopPropagation()),this.container.style.top="-1000px",this.container.style.left="-1000px",this.show(e)}handleEvent(n){n.type==="transitionend"&&this.__onTransitionEnd(n)}destroy(){clearTimeout(this.state.hideTimeout),delete this.state.data,super.destroy()}toggle(){throw new Ke("Tooltip cannot be toggled")}show(n){if(this.state.state!==0)throw new Ke("Initialized tooltip cannot be re-initialized");n.className&&Ud(this.container,n.className),n.style&&Object.assign(this.container.style,n.style),this.state.state=3,this.update(n.content,n),this.state.data=n.data,this.state.state=1,this.viewer.dispatchEvent(new cv(this,this.state.data)),this.__waitImages()}update(n,e){this.content.innerHTML=n;const t=this.container.getBoundingClientRect();this.state.width=t.right-t.left,this.state.height=t.bottom-t.top,this.state.arrow=parseInt(gi(this.arrow,"border-top-width"),10),this.state.border=parseInt(gi(this.container,"border-top-left-radius"),10),this.move(e??this.state.config),this.__waitImages()}move(n){var a;if(this.state.state!==1&&this.state.state!==3)throw new Ke("Uninitialized tooltip cannot be moved");n.box=n.box??((a=this.state.config)==null?void 0:a.box)??{width:0,height:0},this.state.config=n;const e=this.container,t=this.arrow,i={posClass:q_(n.position,{allowCenter:!1,cssOrder:!1})||["top","center"],width:this.state.width,height:this.state.height,top:0,left:0,arrowTop:0,arrowLeft:0};this.__computeTooltipPosition(i,n);let s=null,r=null;if(i.top<0?s="bottom":i.top+i.height>this.viewer.state.size.height&&(s="top"),i.left<0?r="right":i.left+i.width>this.viewer.state.size.width&&(r="left"),r||s){const l=kd(i.posClass);s&&(i.posClass[l?0:1]=s),r&&(i.posClass[l?1:0]=r),this.__computeTooltipPosition(i,n)}e.style.top=i.top+"px",e.style.left=i.left+"px",t.style.top=i.arrowTop+"px",t.style.left=i.arrowLeft+"px";const o=i.posClass.join("-");o!==this.state.pos&&(e.classList.remove(`psv-tooltip--${this.state.pos}`),this.state.pos=o,e.classList.add(`psv-tooltip--${this.state.pos}`))}hide(){this.container.classList.remove("psv-tooltip--visible"),this.state.state=2,this.viewer.dispatchEvent(new Cg(this.state.data));const n=parseFloat(gi(this.container,"transition-duration"));this.state.hideTimeout=setTimeout(()=>{this.destroy()},n*2)}__onTransitionEnd(n){if(n.propertyName==="transform")switch(this.state.state){case 1:this.container.classList.add("psv-tooltip--visible"),this.state.state=3;break;case 2:this.state.state=0,this.destroy();break}}__computeTooltipPosition(n,e){const t=this.state.arrow,i=e.top,s=n.height,r=e.left,o=n.width,a=t+this.state.border,l=e.box.width/2+t*2,c=e.box.height/2+t*2;switch(n.posClass.join("-")){case"top-left":n.top=i-c-s,n.left=r+a-o,n.arrowTop=s,n.arrowLeft=o-a-t;break;case"top-center":n.top=i-c-s,n.left=r-o/2,n.arrowTop=s,n.arrowLeft=o/2-t;break;case"top-right":n.top=i-c-s,n.left=r-a,n.arrowTop=s,n.arrowLeft=t;break;case"bottom-left":n.top=i+c,n.left=r+a-o,n.arrowTop=-t*2,n.arrowLeft=o-a-t;break;case"bottom-center":n.top=i+c,n.left=r-o/2,n.arrowTop=-t*2,n.arrowLeft=o/2-t;break;case"bottom-right":n.top=i+c,n.left=r-a,n.arrowTop=-t*2,n.arrowLeft=t;break;case"left-top":n.top=i+a-s,n.left=r-l-o,n.arrowTop=s-a-t,n.arrowLeft=o;break;case"center-left":n.top=i-s/2,n.left=r-l-o,n.arrowTop=s/2-t,n.arrowLeft=o;break;case"left-bottom":n.top=i-a,n.left=r-l-o,n.arrowTop=t,n.arrowLeft=o;break;case"right-top":n.top=i+a-s,n.left=r+l,n.arrowTop=s-a-t,n.arrowLeft=-t*2;break;case"center-right":n.top=i-s/2,n.left=r+l,n.arrowTop=s/2-t,n.arrowLeft=-t*2;break;case"right-bottom":n.top=i-a,n.left=r+l,n.arrowTop=t,n.arrowLeft=-t*2;break}}__waitImages(){const n=this.content.querySelectorAll("img");if(n.length>0){const e=[];n.forEach(t=>{t.complete||e.push(new Promise(i=>{t.onload=i,t.onerror=i}))}),e.length&&Promise.all(e).then(()=>{if(this.state.state===1||this.state.state===3){const t=this.container.getBoundingClientRect();this.state.width=t.right-t.left,this.state.height=t.bottom-t.top,this.move(this.state.config)}})}}},eA=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="15 15 70 70"><path fill="currentColor" d="M50,16.2c-18.6,0-33.8,15.1-33.8,33.8S31.4,83.7,50,83.7S83.8,68.6,83.8,50S68.6,16.2,50,16.2z M50,80.2c-16.7,0-30.2-13.6-30.2-30.2S33.3,19.7,50,19.7S80.3,33.3,80.3,50S66.7,80.2,50,80.2z"/><rect fill="currentColor" x="48" y="31.7" width="4" height="28"/><rect fill="currentColor" x="48" y="63.2" width="4" height="5"/><!--Created by Shastry from the Noun Project--></svg> `,ya=class{constructor(n){this.viewer=n,this.config=n.config,this.state=n.state}destroy(){}},jn=new ce,ja=new Es(0,0,0,"ZXY"),tA=class extends ya{constructor(n){super(n)}fovToZoomLevel(n){const e=Math.round((n-this.config.minFov)/(this.config.maxFov-this.config.minFov)*100);return Ut.clamp(e-2*(e-50),0,100)}zoomLevelToFov(n){return this.config.maxFov+n/100*(this.config.minFov-this.config.maxFov)}vFovToHFov(n){return Ut.radToDeg(2*Math.atan(Math.tan(Ut.degToRad(n)/2)*this.state.aspect))}hFovToVFov(n){return Ut.radToDeg(2*Math.atan(Math.tan(Ut.degToRad(n)/2)/this.state.aspect))}getAnimationProperties(n,e,t){const i=!nn(e),s=!nn(t),r={};let o=null;if(i){const a=this.viewer.getPosition(),l=D_(a.yaw,e.yaw);r.yaw={start:a.yaw,end:a.yaw+l},r.pitch={start:a.pitch,end:e.pitch},o=vu(n,I_(a,e))}if(s){const a=this.viewer.getZoomLevel(),l=Math.abs(t-a);r.zoom={start:a,end:t},o===null&&(o=vu(n,Math.PI/4*l/100))}return o===null?typeof n=="number"?o=n:o=mu:o=Math.max(mu,o),{duration:o,properties:r}}textureCoordsToSphericalCoords(n){var t;if(!((t=this.state.textureData)!=null&&t.panoData))throw new Ke("Current adapter does not support texture coordinates or no texture has been loaded");const e=this.viewer.adapter.textureCoordsToSphericalCoords(n,this.state.textureData.panoData);return!ja.equals(this.viewer.renderer.panoramaPose)||!ja.equals(this.viewer.renderer.sphereCorrection)?(this.sphericalCoordsToVector3(e,jn),jn.applyEuler(this.viewer.renderer.panoramaPose),jn.applyEuler(this.viewer.renderer.sphereCorrection),this.vector3ToSphericalCoords(jn)):e}sphericalCoordsToTextureCoords(n){var e;if(!((e=this.state.textureData)!=null&&e.panoData))throw new Ke("Current adapter does not support texture coordinates or no texture has been loaded");return(!ja.equals(this.viewer.renderer.panoramaPose)||!ja.equals(this.viewer.renderer.sphereCorrection))&&(this.sphericalCoordsToVector3(n,jn),Mu(jn,this.viewer.renderer.sphereCorrection),Mu(jn,this.viewer.renderer.panoramaPose),n=this.vector3ToSphericalCoords(jn)),this.viewer.adapter.sphericalCoordsToTextureCoords(n,this.state.textureData.panoData)}sphericalCoordsToVector3(n,e,t=nr){return e||(e=new ce),e.x=t*-Math.cos(n.pitch)*Math.sin(n.yaw),e.y=t*Math.sin(n.pitch),e.z=t*Math.cos(n.pitch)*Math.cos(n.yaw),e}vector3ToSphericalCoords(n){const e=Math.acos(n.y/Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)),t=Math.atan2(n.x,n.z);return{yaw:t<0?-t:Math.PI*2-t,pitch:Math.PI/2-e}}viewerCoordsToVector3(n){const e=this.viewer.renderer.getIntersections(n).filter(t=>t.object.userData[Ss]);return e.length?e[0].point:null}viewerCoordsToSphericalCoords(n){const e=this.viewerCoordsToVector3(n);return e?this.vector3ToSphericalCoords(e):null}vector3ToViewerCoords(n){const e=n.clone();return e.project(this.viewer.renderer.camera),{x:Math.round((e.x+1)/2*this.state.size.width),y:Math.round((1-e.y)/2*this.state.size.height)}}sphericalCoordsToViewerCoords(n){return this.sphericalCoordsToVector3(n,jn),this.vector3ToViewerCoords(jn)}isPointVisible(n){let e,t;if(n instanceof ce)e=n,t=this.vector3ToViewerCoords(n);else if(zd(n))e=this.sphericalCoordsToVector3(n,jn),t=this.vector3ToViewerCoords(e);else return!1;return e.dot(this.viewer.state.direction)>0&&t.x>=0&&t.x<=this.viewer.state.size.width&&t.y>=0&&t.y<=this.viewer.state.size.height}cleanPosition(n){if("yaw"in n||"pitch"in n){if(!("yaw"in n)||!("pitch"in n))throw new Ke("Position is missing 'yaw' or 'pitch'");return{yaw:fi(n.yaw),pitch:fi(n.pitch,!0)}}else return this.textureCoordsToSphericalCoords(n)}cleanSphereCorrection(n){return{pan:fi((n==null?void 0:n.pan)||0),tilt:fi((n==null?void 0:n.tilt)||0,!0),roll:fi((n==null?void 0:n.roll)||0,!0,!1)}}cleanPanoramaPose(n){return{pan:Ut.degToRad((n==null?void 0:n.poseHeading)||0),tilt:Ut.degToRad((n==null?void 0:n.posePitch)||0),roll:Ut.degToRad((n==null?void 0:n.poseRoll)||0)}}cleanPanoramaOptions(n,e){return e!=null&&e.isEquirectangular&&(nn(n.zoom)&&!nn(e.initialFov)&&(n={...n,zoom:this.fovToZoomLevel(this.hFovToVFov(e.initialFov))}),nn(n.position)&&!nn(e.initialHeading)&&!nn(e.initialPitch)&&(n={...n,position:{yaw:fi(e.initialHeading),pitch:fi(e.initialPitch,!0)}})),n}},nA=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="currentColor" d="M33.38 33.2a1.96 1.96 0 0 0 1.5-3.23 10.61 10.61 0 0 1 7.18-17.51c.7-.06 1.31-.49 1.61-1.12a13.02 13.02 0 0 1 11.74-7.43c7.14 0 12.96 5.8 12.96 12.9 0 3.07-1.1 6.05-3.1 8.38-.7.82-.61 2.05.21 2.76.83.7 2.07.6 2.78-.22a16.77 16.77 0 0 0 4.04-10.91C72.3 7.54 64.72 0 55.4 0a16.98 16.98 0 0 0-14.79 8.7 14.6 14.6 0 0 0-12.23 14.36c0 3.46 1.25 6.82 3.5 9.45.4.45.94.69 1.5.69m45.74 43.55a22.13 22.13 0 0 1-5.23 12.4c-4 4.55-9.53 6.86-16.42 6.86-12.6 0-20.1-10.8-20.17-10.91a1.82 1.82 0 0 0-.08-.1c-5.3-6.83-14.55-23.82-17.27-28.87-.05-.1 0-.21.02-.23a6.3 6.3 0 0 1 8.24 1.85l9.38 12.59a1.97 1.97 0 0 0 3.54-1.17V25.34a4 4 0 0 1 1.19-2.87 3.32 3.32 0 0 1 2.4-.95c1.88.05 3.4 1.82 3.4 3.94v24.32a1.96 1.96 0 0 0 3.93 0v-33.1a3.5 3.5 0 0 1 7 0v35.39a1.96 1.96 0 0 0 3.93 0v-.44c.05-2.05 1.6-3.7 3.49-3.7 1.93 0 3.5 1.7 3.5 3.82v5.63c0 .24.04.48.13.71l.1.26a1.97 1.97 0 0 0 3.76-.37c.33-1.78 1.77-3.07 3.43-3.07 1.9 0 3.45 1.67 3.5 3.74l-1.77 18.1zM77.39 51c-1.25 0-2.45.32-3.5.9v-.15c0-4.27-3.33-7.74-7.42-7.74-1.26 0-2.45.33-3.5.9V16.69a7.42 7.42 0 0 0-14.85 0v1.86a7 7 0 0 0-3.28-.94 7.21 7.21 0 0 0-5.26 2.07 7.92 7.92 0 0 0-2.38 5.67v37.9l-5.83-7.82a10.2 10.2 0 0 0-13.35-2.92 4.1 4.1 0 0 0-1.53 5.48C20 64.52 28.74 80.45 34.07 87.34c.72 1.04 9.02 12.59 23.4 12.59 7.96 0 14.66-2.84 19.38-8.2a26.06 26.06 0 0 0 6.18-14.6l1.78-18.2v-.2c0-4.26-3.32-7.73-7.42-7.73z"/><!--Created by AomAm from the Noun Project--></svg> `,iA=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 17 79 79"><path fill="currentColor" d="M38.1 29.27c-.24 0-.44.2-.44.45v10.7a.45.45 0 00.9 0v-10.7c0-.25-.2-.45-.45-.45zm10.2 26.66a11.54 11.54 0 01-8.48-6.14.45.45 0 10-.8.41 12.45 12.45 0 009.22 6.62.45.45 0 00.07-.9zm24.55-13.08a23.04 23.04 0 00-22.56-23v7.07l-.01.05a2.83 2.83 0 012.39 2.78v14.03l.09-.02h8.84v-9.22a.45.45 0 11.9 0v9.22h10.35v-.9zm0 27.33V44.66H62.5c-.02 2.01-.52 4-1.47 5.76a.45.45 0 01-.61.18.45.45 0 01-.19-.61 11.54 11.54 0 001.36-5.33h-8.83l-.1-.01a2.83 2.83 0 01-2.83 2.84h-.04-.04a2.83 2.83 0 01-2.83-2.83v-14.9a2.82 2.82 0 012.47-2.8v-7.11a23.04 23.04 0 00-22.57 23v.91h14.72V29.88a8.2 8.2 0 015.02-7.57c.22-.1.5.01.59.24.1.23-.01.5-.24.6a7.3 7.3 0 00-4.47 6.73v13.88h3.9a.45.45 0 110 .9h-3.9v.15a7.32 7.32 0 0011.23 6.17.45.45 0 01.49.76 8.22 8.22 0 01-12.62-6.93v-.15H26.82v25.52a23.04 23.04 0 0023.01 23.01 23.04 23.04 0 0023.02-23.01zm1.8-27.33v27.33A24.85 24.85 0 0149.84 95a24.85 24.85 0 01-24.82-24.82V42.85a24.85 24.85 0 0124.82-24.82 24.85 24.85 0 0124.83 24.82zM57.98 29.88v9.36a.45.45 0 11-.9 0v-9.36a7.28 7.28 0 00-3.4-6.17.45.45 0 01.49-.76 8.18 8.18 0 013.8 6.93z"/><!-- Created by Icon Island from the Noun Project --></svg> `,hc=class Fv{constructor(){this.$=Fv.IDLE}is(...e){return e.some(t=>this.$&t)}set(e){this.$=e}add(e){this.$|=e}remove(e){this.$&=~e}};hc.IDLE=0;hc.CLICK=1;hc.MOVING=2;var Ht=hc,sA=class extends ya{constructor(n){super(n),this.data={startMouseX:0,startMouseY:0,mouseX:0,mouseY:0,pinchDist:0,moveDelta:{yaw:0,pitch:0,zoom:0},accumulatorFactor:0,ctrlKeyDown:!1,dblclickData:null,dblclickTimeout:null,longtouchTimeout:null,twofingersTimeout:null,ctrlZoomTimeout:null},this.step=new Ht,this.keyHandler=new lc,this.resizeObserver=new ResizeObserver(Nd(()=>this.viewer.autoSize(),50)),this.moveThreshold=b_*xn.pixelRatio}init(){window.addEventListener("keydown",this,{passive:!1}),window.addEventListener("keyup",this),this.viewer.container.addEventListener("mousedown",this),window.addEventListener("mousemove",this,{passive:!1}),window.addEventListener("mouseup",this),this.viewer.container.addEventListener("touchstart",this,{passive:!1}),window.addEventListener("touchmove",this,{passive:!1}),window.addEventListener("touchend",this,{passive:!1}),this.viewer.container.addEventListener("wheel",this,{passive:!1}),document.addEventListener("fullscreenchange",this),this.resizeObserver.observe(this.viewer.container),this.viewer.addEventListener(jo.type,this),this.viewer.addEventListener(sa.type,this)}destroy(){window.removeEventListener("keydown",this),window.removeEventListener("keyup",this),this.viewer.container.removeEventListener("mousedown",this),window.removeEventListener("mousemove",this),window.removeEventListener("mouseup",this),this.viewer.container.removeEventListener("touchstart",this),window.removeEventListener("touchmove",this),window.removeEventListener("touchend",this),this.viewer.container.removeEventListener("wheel",this),document.removeEventListener("fullscreenchange",this),this.resizeObserver.disconnect(),this.viewer.removeEventListener(jo.type,this),this.viewer.removeEventListener(sa.type,this),clearTimeout(this.data.dblclickTimeout),clearTimeout(this.data.longtouchTimeout),clearTimeout(this.data.twofingersTimeout),clearTimeout(this.data.ctrlZoomTimeout),super.destroy()}handleEvent(n){switch(n.type){case"keydown":this.__onKeyDown(n);break;case"keyup":this.__onKeyUp();break;case"mousemove":this.__onMouseMove(n);break;case"mouseup":this.__onMouseUp(n);break;case"touchmove":this.__onTouchMove(n);break;case"touchend":this.__onTouchEnd(n);break;case"fullscreenchange":this.__onFullscreenChange();break;case jo.type:this.__applyMoveDelta();break;case sa.type:this.__clearMoveDelta();break}if(!F_(n,"."+xa))switch(n.type){case"mousedown":this.__onMouseDown(n);break;case"touchstart":this.__onTouchStart(n);break;case"wheel":this.__onMouseWheel(n);break}}__onKeyDown(n){var t;if(this.config.mousewheelCtrlKey&&(this.data.ctrlKeyDown=n.key===tn.Control,this.data.ctrlKeyDown&&(clearTimeout(this.data.ctrlZoomTimeout),this.viewer.overlay.hide(rn.CTRL_ZOOM))),!this.viewer.dispatchEvent(new ms(n.key,n))||!this.state.keyboardEnabled)return;const e=(t=this.config.keyboardActions)==null?void 0:t[n.key];if(typeof e=="function"){e(this.viewer,n),n.preventDefault();return}if(!(n.ctrlKey||n.altKey||n.shiftKey||n.metaKey)&&e&&!this.keyHandler.pending){switch(e!=="ZOOM_IN"&&e!=="ZOOM_OUT"&&this.viewer.stopAll(),e){case"ROTATE_UP":this.viewer.dynamics.position.roll({pitch:!1});break;case"ROTATE_DOWN":this.viewer.dynamics.position.roll({pitch:!0});break;case"ROTATE_RIGHT":this.viewer.dynamics.position.roll({yaw:!1});break;case"ROTATE_LEFT":this.viewer.dynamics.position.roll({yaw:!0});break;case"ZOOM_IN":this.viewer.dynamics.zoom.roll(!1);break;case"ZOOM_OUT":this.viewer.dynamics.zoom.roll(!0);break}this.keyHandler.down(e),n.preventDefault()}}__onKeyUp(){this.data.ctrlKeyDown=!1,this.state.keyboardEnabled&&this.keyHandler.up(n=>{n==="ZOOM_IN"||n==="ZOOM_OUT"?this.viewer.dynamics.zoom.stop():(this.viewer.dynamics.position.stop(),this.viewer.resetIdleTimer())})}__onMouseDown(n){this.step.add(Ht.CLICK),this.data.startMouseX=n.clientX,this.data.startMouseY=n.clientY}__onMouseUp(n){this.step.is(Ht.CLICK,Ht.MOVING)&&this.__stopMove(n.clientX,n.clientY,n,n.button===2)}__onMouseMove(n){this.config.mousemove&&this.step.is(Ht.CLICK,Ht.MOVING)&&(n.preventDefault(),this.__doMove(n.clientX,n.clientY)),this.__handleObjectsEvents(n)}__onTouchStart(n){n.touches.length===1?(this.step.add(Ht.CLICK),this.data.startMouseX=n.touches[0].clientX,this.data.startMouseY=n.touches[0].clientY,this.data.longtouchTimeout||(this.data.longtouchTimeout=setTimeout(()=>{const e=n.touches[0];this.__stopMove(e.clientX,e.clientY,n,!0),this.data.longtouchTimeout=null},T_))):n.touches.length===2&&(this.step.set(Ht.IDLE),this.__cancelLongTouch(),this.config.mousemove&&(this.__cancelTwoFingersOverlay(),this.__startMoveZoom(n),n.preventDefault()))}__onTouchEnd(n){if(this.__cancelLongTouch(),this.step.is(Ht.CLICK,Ht.MOVING)){if(n.preventDefault(),this.__cancelTwoFingersOverlay(),n.touches.length===1)this.__stopMove(this.data.mouseX,this.data.mouseY);else if(n.touches.length===0){const e=n.changedTouches[0];this.__stopMove(e.clientX,e.clientY,n)}}}__onTouchMove(n){if(this.__cancelLongTouch(),!!this.config.mousemove)if(n.touches.length===1){if(this.config.touchmoveTwoFingers)this.step.is(Ht.CLICK)&&!this.data.twofingersTimeout&&(this.data.twofingersTimeout=setTimeout(()=>{this.viewer.overlay.show({id:rn.TWO_FINGERS,image:nA,title:this.config.lang.twoFingers})},A_));else if(this.step.is(Ht.CLICK,Ht.MOVING)){n.preventDefault();const e=n.touches[0];this.__doMove(e.clientX,e.clientY)}}else this.__doMoveZoom(n),this.__cancelTwoFingersOverlay()}__cancelLongTouch(){this.data.longtouchTimeout&&(clearTimeout(this.data.longtouchTimeout),this.data.longtouchTimeout=null)}__cancelTwoFingersOverlay(){this.config.touchmoveTwoFingers&&(this.data.twofingersTimeout&&(clearTimeout(this.data.twofingersTimeout),this.data.twofingersTimeout=null),this.viewer.overlay.hide(rn.TWO_FINGERS))}__onMouseWheel(n){if(!this.config.mousewheel||!n.deltaY)return;if(this.config.mousewheelCtrlKey&&!this.data.ctrlKeyDown){this.viewer.overlay.show({id:rn.CTRL_ZOOM,image:iA,title:this.config.lang.ctrlZoom}),clearTimeout(this.data.ctrlZoomTimeout),this.data.ctrlZoomTimeout=setTimeout(()=>this.viewer.overlay.hide(rn.CTRL_ZOOM),C_);return}n.preventDefault(),n.stopPropagation();const e=n.deltaY/Math.abs(n.deltaY)*5*this.config.zoomSpeed;e!==0&&this.viewer.dynamics.zoom.step(-e,5)}__onFullscreenChange(){const n=this.viewer.isFullscreenEnabled();this.config.keyboard==="fullscreen"&&(n?this.viewer.startKeyboardControl():this.viewer.stopKeyboardControl()),this.viewer.dispatchEvent(new Zo(n))}__resetMove(){this.step.set(Ht.IDLE),this.data.mouseX=0,this.data.mouseY=0,this.data.startMouseX=0,this.data.startMouseY=0}__startMoveZoom(n){this.viewer.stopAll(),this.__resetMove();const e=_u(n);this.step.set(Ht.MOVING),this.data.accumulatorFactor=this.config.moveInertia,{distance:this.data.pinchDist,center:{x:this.data.mouseX,y:this.data.mouseY}}=e}__stopMove(n,e,t,i=!1){this.step.is(Ht.CLICK)&&!this.__moveThresholdReached(n,e)&&this.__doClick(n,e,t,i),this.config.moveInertia&&(this.data.accumulatorFactor=Math.pow(this.config.moveInertia,.5)),this.__resetMove(),this.viewer.resetIdleTimer()}__doClick(n,e,t,i=!1){const s=this.viewer.container.getBoundingClientRect(),r=n-s.left,o=e-s.top,a=this.viewer.renderer.getIntersections({x:r,y:o}),l=a.find(c=>c.object.userData[Ss]);if(l){const c=this.viewer.dataHelper.vector3ToSphericalCoords(l.point),h={rightclick:i,originalEvent:t,target:Wl(t),clientX:n,clientY:e,viewerX:r,viewerY:o,yaw:c.yaw,pitch:c.pitch,objects:a.map(f=>f.object).filter(f=>!f.userData[Ss])};try{const f=this.viewer.dataHelper.sphericalCoordsToTextureCoords(h);Object.assign(h,f)}catch{}this.data.dblclickTimeout?(Math.abs(this.data.dblclickData.clientX-h.clientX)<this.moveThreshold&&Math.abs(this.data.dblclickData.clientY-h.clientY)<this.moveThreshold&&this.viewer.dispatchEvent(new _g(this.data.dblclickData)),clearTimeout(this.data.dblclickTimeout),this.data.dblclickTimeout=null,this.data.dblclickData=null):(this.viewer.dispatchEvent(new ug(h)),this.data.dblclickData=rc(h),this.data.dblclickTimeout=setTimeout(()=>{this.data.dblclickTimeout=null,this.data.dblclickData=null},w_))}}__handleObjectsEvents(n){if(!V_(this.state.objectsObservers)&&n.composedPath().includes(this.viewer.container)){const e=O_(this.viewer.container),t={x:n.clientX-e.x,y:n.clientY-e.y},i=this.viewer.renderer.getIntersections(t),s=(r,o,a)=>{this.viewer.dispatchEvent(new a(n,r,t,o))};for(const[r,o]of Object.entries(this.state.objectsObservers)){const a=i.find(l=>l.object.userData[r]);a?(o&&a.object!==o&&(s(o,r,yu),this.state.objectsObservers[r]=null),o?s(a.object,r,Sv):(this.state.objectsObservers[r]=a.object,s(a.object,r,vv))):o&&(s(o,r,yu),this.state.objectsObservers[r]=null)}}}__doMove(n,e){if(this.step.is(Ht.CLICK)&&this.__moveThresholdReached(n,e))this.viewer.stopAll(),this.__resetMove(),this.step.set(Ht.MOVING),this.data.mouseX=n,this.data.mouseY=e,this.data.accumulatorFactor=this.config.moveInertia;else if(this.step.is(Ht.MOVING)){const t=(n-this.data.mouseX)*Math.cos(this.state.roll)-(e-this.data.mouseY)*Math.sin(this.state.roll),i=(e-this.data.mouseY)*Math.cos(this.state.roll)+(n-this.data.mouseX)*Math.sin(this.state.roll),s={yaw:this.config.moveSpeed*(t/this.state.size.width)*Ut.degToRad(this.state.hFov),pitch:this.config.moveSpeed*(i/this.state.size.height)*Ut.degToRad(this.state.vFov)};this.data.moveDelta.yaw+=s.yaw,this.data.moveDelta.pitch+=s.pitch,this.data.mouseX=n,this.data.mouseY=e}}__moveThresholdReached(n,e){return Math.abs(n-this.data.startMouseX)>=this.moveThreshold||Math.abs(e-this.data.startMouseY)>=this.moveThreshold}__doMoveZoom(n){if(this.step.is(Ht.MOVING)){n.preventDefault();const e=_u(n);this.__doMove(e.center.x,e.center.y),this.data.moveDelta.zoom+=this.config.zoomSpeed*((e.distance-this.data.pinchDist)/xn.pixelRatio),this.data.pinchDist=e.distance}}__applyMoveDelta(){if(Math.abs(this.data.moveDelta.yaw)>0||Math.abs(this.data.moveDelta.pitch)>0){const e=this.viewer.getPosition();this.viewer.rotate({yaw:e.yaw-this.data.moveDelta.yaw*(1-this.config.moveInertia),pitch:e.pitch+this.data.moveDelta.pitch*(1-this.config.moveInertia)}),this.data.moveDelta.yaw*=this.data.accumulatorFactor,this.data.moveDelta.pitch*=this.data.accumulatorFactor,Math.abs(this.data.moveDelta.yaw)<=.001&&(this.data.moveDelta.yaw=0),Math.abs(this.data.moveDelta.pitch)<=.001&&(this.data.moveDelta.pitch=0)}if(Math.abs(this.data.moveDelta.zoom)>0){const e=this.viewer.getZoomLevel();this.viewer.zoom(e+this.data.moveDelta.zoom*(1-this.config.moveInertia)),this.data.moveDelta.zoom*=this.config.moveInertia,Math.abs(this.data.moveDelta.zoom)<=.001&&(this.data.moveDelta.zoom=0)}}__clearMoveDelta(){this.data.moveDelta.yaw=0,this.data.moveDelta.pitch=0,this.data.moveDelta.zoom=0}};St.enabled=!1;var Za=new Dt,gp=new qt,vp=new Mo,rA=class extends ya{constructor(n){super(n),this.frustumNeedsUpdate=!0,this.renderer=new g1(this.config.rendererParameters),this.renderer.setPixelRatio(xn.pixelRatio),this.renderer.outputColorSpace=Yi,this.renderer.domElement.className="psv-canvas",this.renderer.domElement.style.background=this.config.canvasBackground,this.scene=new lp,this.camera=new On(50,16/9,.1,2*nr),this.camera.matrixAutoUpdate=!1;const e=new Hn(new Ld(nr).scale(-1,1,1),new va({opacity:0,transparent:!0,depthTest:!1,depthWrite:!1}));e.userData={[Ss]:!0},this.scene.add(e),this.raycaster=new M1,this.frustum=new Rd,this.container=document.createElement("div"),this.container.className="psv-canvas-container",this.container.appendChild(this.renderer.domElement),this.viewer.container.appendChild(this.container),this.viewer.addEventListener(ia.type,this),this.viewer.addEventListener(Vi.type,this),this.viewer.addEventListener(Jo.type,this),this.viewer.addEventListener(ea.type,this),this.viewer.addEventListener(bn.type,this),this.hide()}get panoramaPose(){return this.mesh.rotation}get sphereCorrection(){return this.meshContainer.rotation}init(){this.show(),this.renderer.setAnimationLoop(n=>this.__renderLoop(n))}destroy(){this.renderer.setAnimationLoop(null),this.cleanScene(this.scene),this.renderer.dispose(),this.viewer.container.removeChild(this.container),this.viewer.removeEventListener(ia.type,this),this.viewer.removeEventListener(Vi.type,this),this.viewer.removeEventListener(Jo.type,this),this.viewer.removeEventListener(ea.type,this),this.viewer.removeEventListener(bn.type,this),super.destroy()}handleEvent(n){switch(n.type){case ia.type:this.__onSizeUpdated();break;case Vi.type:this.__onZoomUpdated();break;case Jo.type:this.__onPositionUpdated();break;case ea.type:this.__onPositionUpdated();break;case bn.type:n.containsOptions("fisheye")&&this.__onPositionUpdated(),n.containsOptions("canvasBackground")&&(this.renderer.domElement.style.background=this.config.canvasBackground);break}}hide(){this.container.style.opacity="0"}show(){this.container.style.opacity="1"}setCustomRenderer(n){n?this.customRenderer=n(this.renderer):this.customRenderer=null,this.viewer.needsUpdate()}__onSizeUpdated(){this.renderer.setSize(this.state.size.width,this.state.size.height),this.camera.aspect=this.state.aspect,this.camera.updateProjectionMatrix(),this.viewer.needsUpdate(),this.frustumNeedsUpdate=!0}__onZoomUpdated(){this.camera.fov=this.state.vFov,this.camera.updateProjectionMatrix(),this.viewer.needsUpdate(),this.frustumNeedsUpdate=!0}__onPositionUpdated(){this.camera.position.set(0,0,0),this.camera.lookAt(this.state.direction),this.config.fisheye&&this.camera.position.copy(this.state.direction).multiplyScalar(this.config.fisheye/2).negate(),this.camera.rotateZ(-this.state.roll),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.viewer.needsUpdate(),this.frustumNeedsUpdate=!0}__renderLoop(n){const e=this.timestamp?n-this.timestamp:0;this.timestamp=n,this.viewer.dispatchEvent(new jo(n,e)),this.viewer.dynamics.update(e),(this.state.needsUpdate||this.state.continuousUpdateCount>0)&&(this.state.needsUpdate=!1,(this.customRenderer||this.renderer).render(this.scene,this.camera),this.viewer.dispatchEvent(new Jg))}setTexture(n){this.meshContainer||(this.meshContainer=new Vr,this.scene.add(this.meshContainer)),this.state.textureData&&this.viewer.adapter.disposeTexture(this.state.textureData),this.mesh&&(this.meshContainer.remove(this.mesh),this.viewer.adapter.disposeMesh(this.mesh)),this.mesh=this.viewer.adapter.createMesh(n.panoData),this.viewer.adapter.setTexture(this.mesh,n,!1),this.meshContainer.add(this.mesh),this.state.textureData=n,this.viewer.needsUpdate()}setPanoramaPose(n,e=this.mesh){const t=this.viewer.dataHelper.cleanPanoramaPose(n),i=(t.pan?1:0)+(t.tilt?1:0)+(t.roll?1:0);!Wr.useNewAnglesOrder&&i>1&&(Lt("'panoData' Euler angles have changed in version 5.11.0."),Lt("Remove your 'useNewAnglesOrder' override to remove this warning (you might have to adapt your poseHeading/posePitch/poseRoll parameters).")),Wr.useNewAnglesOrder?e.rotation.set(t.tilt,t.pan,t.roll,"YXZ"):e.rotation.set(-t.tilt,-t.pan,-t.roll,"ZXY")}setSphereCorrection(n,e=this.meshContainer){const t=this.viewer.dataHelper.cleanSphereCorrection(n),i=(t.pan?1:0)+(t.tilt?1:0)+(t.roll?1:0);!Wr.useNewAnglesOrder&&i>1&&(Lt("'sphereCorrection' Euler angles have changed in version 5.11.0."),Lt("Remove your 'useNewAnglesOrder' override to remove this warning (you might have to adapt your poseHeading/posePitch/poseRoll parameters).")),Wr.useNewAnglesOrder?e.rotation.set(t.tilt,t.pan,t.roll,"YXZ"):e.rotation.set(t.tilt,t.pan,t.roll,"ZXY")}transition(n,e){const t=!nn(e.position),i=!nn(e.zoom),s=new Hd(t?this.viewer.dataHelper.cleanPosition(e.position):void 0,e.zoom);this.viewer.dispatchEvent(s);const r=new Vr,o=this.viewer.adapter.createMesh(n.panoData);if(this.viewer.adapter.setTexture(o,n,!0),this.viewer.adapter.setTextureOpacity(o,0),this.setPanoramaPose(n.panoData,o),this.setSphereCorrection(e.sphereCorrection,r),t&&e.transition==="fade-only"){const h=this.viewer.getPosition(),f=new ce(0,1,0);r.rotateOnWorldAxis(f,s.position.yaw-h.yaw);const p=new ce(0,1,0).cross(this.camera.getWorldDirection(new ce)).normalize();r.rotateOnWorldAxis(p,s.position.pitch-h.pitch)}r.add(o),this.scene.add(r),this.renderer.setRenderTarget(new Ms),this.renderer.render(this.scene,this.camera),this.renderer.setRenderTarget(null);const{duration:a,properties:l}=this.viewer.dataHelper.getAnimationProperties(e.speed,e.transition===!0?s.position:null,s.zoomLevel),c=new Yl({properties:{...l,opacity:{start:0,end:1}},duration:a,easing:"inOutCubic",onTick:h=>{this.viewer.adapter.setTextureOpacity(o,h.opacity),t&&e.transition===!0&&this.viewer.dynamics.position.setValue({yaw:h.yaw,pitch:h.pitch}),i&&this.viewer.dynamics.zoom.setValue(h.zoom),this.viewer.needsUpdate()}});return c.then(h=>{r.remove(o),this.scene.remove(r),h?(this.viewer.adapter.disposeTexture(this.state.textureData),this.meshContainer.remove(this.mesh),this.viewer.adapter.disposeMesh(this.mesh),this.mesh=o,this.meshContainer.add(o),this.state.textureData=n,this.setPanoramaPose(n.panoData),this.setSphereCorrection(e.sphereCorrection),t&&e.transition==="fade-only"&&this.viewer.rotate(e.position)):(this.viewer.adapter.disposeTexture(n),this.viewer.adapter.disposeMesh(o))}),c}getIntersections(n){var t;Za.x=2*n.x/this.state.size.width-1,Za.y=-2*n.y/this.state.size.height+1,this.raycaster.setFromCamera(Za,this.camera);const e=this.raycaster.intersectObjects(this.scene.children,!0).filter(i=>i.object.visible).filter(i=>i.object.isMesh&&!!i.object.userData);return(t=this.customRenderer)!=null&&t.getIntersections&&e.push(...this.customRenderer.getIntersections(this.raycaster,Za)),e}isObjectVisible(n){if(!n)return!1;if(this.frustumNeedsUpdate&&(gp.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(gp),this.frustumNeedsUpdate=!1),n.isVector3)return this.frustum.containsPoint(n);if(n.isMesh&&n.geometry){const e=n;return e.geometry.boundingBox||e.geometry.computeBoundingBox(),vp.copy(e.geometry.boundingBox).applyMatrix4(e.matrixWorld),this.frustum.intersectsBox(vp)}else return n.isObject3D?this.frustum.intersectsObject(n):!1}addObject(n){this.scene.add(n)}removeObject(n){this.scene.remove(n)}cleanScene(n){const e=t=>{var i;(i=t.map)==null||i.dispose(),t.uniforms&&Object.values(t.uniforms).forEach(s=>{var r,o;(o=(r=s.value)==null?void 0:r.dispose)==null||o.call(r)}),t.dispose()};n.traverse(t=>{var i,s;(i=t.geometry)==null||i.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(r=>{e(r)}):e(t.material)),t instanceof lp||(s=t.dispose)==null||s.call(t),t!==n&&this.cleanScene(t)})}},oA=class extends Dd{load(n,e,t,i,s){const r=new Request(n,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(r,{signal:s}).then(o=>{if(o.status===200||o.status===0){const a=o.body.getReader(),l=o.headers.get("Content-Length")||o.headers.get("X-File-Size"),c=l?parseInt(l):0,h=c!==0;let f=0;const p=new ReadableStream({start(m){g();function g(){a.read().then(({done:x,value:d})=>{if(x)m.close();else{f+=d.byteLength;const u=new ProgressEvent("progress",{lengthComputable:h,loaded:f,total:c});t(u),m.enqueue(d),g()}}).catch(x=>{i(x)})}}});return new Response(p)}else throw new Error(`fetch for "${o.url}" responded with ${o.status}: ${o.statusText}`)}).then(o=>o.blob()).then(o=>{e(o)}).catch(o=>{i(o)})}},aA=class extends Dd{load(n,e,t,i){const s=document.createElement("img");function r(){l(),e(this)}function o(c){if(l(),i!=null&&i.aborted){const h=new Error;h.name="AbortError",h.message="The operation was aborted.",t(h)}else t(c)}function a(){s.src=""}function l(){s.removeEventListener("load",r,!1),s.removeEventListener("error",o,!1),i==null||i.removeEventListener("abort",a,!1)}return s.addEventListener("load",r,!1),s.addEventListener("error",o,!1),i==null||i.addEventListener("abort",a,!1),!n.startsWith("data:")&&this.crossOrigin!==void 0&&(s.crossOrigin=this.crossOrigin),s.src=n,s}},lA=class extends ya{constructor(n){super(n),this.abortCtrl={},this.fileLoader=new oA,this.imageLoader=new aA,this.config.withCredentials&&(this.fileLoader.setWithCredentials(!0),this.imageLoader.setCrossOrigin("use-credentials"))}destroy(){this.abortLoading(),super.destroy()}abortLoading(){Object.values(this.abortCtrl).forEach(n=>n.abort()),this.abortCtrl={}}loadFile(n,e,t){const i=zr.get(n,t);if(i){if(i instanceof Blob)return e==null||e(100),Promise.resolve(i);zr.remove(n,t)}return this.config.requestHeaders&&this.fileLoader.setRequestHeader(this.config.requestHeaders(n)),new Promise((s,r)=>{let o=0;e==null||e(o),this.fileLoader.load(n,a=>{o=100,e==null||e(o),zr.add(n,t,a),s(a)},a=>{if(a.lengthComputable){const l=a.loaded/a.total*100;l>o&&(o=l,e==null||e(o))}},a=>{r(a)},this.__getAbortSignal(t))})}loadImage(n,e,t){const i=zr.get(n,t);return i?(e==null||e(100),i instanceof Blob?this.blobToImage(i):Promise.resolve(i)):!e&&!this.config.requestHeaders?new Promise((s,r)=>{this.imageLoader.load(n,o=>{zr.add(n,t,o),s(o)},o=>{r(o)},this.__getAbortSignal(t))}):this.loadFile(n,e,t).then(s=>this.blobToImage(s))}blobToImage(n){return new Promise((e,t)=>{const i=document.createElement("img");i.onload=()=>{URL.revokeObjectURL(i.src),e(i)},i.onerror=t,i.src=URL.createObjectURL(n)})}preloadPanorama(n){return this.viewer.adapter.supportsPreload(n)?this.viewer.adapter.loadTexture(n,!1):Promise.reject(new Ke("Current adapter does not support preload"))}__getAbortSignal(n){var e;return n?((e=this.abortCtrl[n])!=null&&e.signal.aborted&&delete this.abortCtrl[n],this.abortCtrl[n]||(this.abortCtrl[n]=new AbortController),this.abortCtrl[n].signal):null}},cA=class extends ya{constructor(n){super(n),this.zoom=new Go(e=>{this.viewer.state.vFov=this.viewer.dataHelper.zoomLevelToFov(e),this.viewer.state.hFov=this.viewer.dataHelper.vFovToHFov(this.viewer.state.vFov),this.viewer.dispatchEvent(new Vi(e))},{defaultValue:this.viewer.config.defaultZoomLvl,min:0,max:100,wrap:!1}),this.position=new Z_(e=>{this.viewer.dataHelper.sphericalCoordsToVector3(e,this.viewer.state.direction),this.viewer.dispatchEvent(new Jo(e))},{yaw:new Go(null,{defaultValue:this.config.defaultYaw,min:0,max:2*Math.PI,wrap:!0}),pitch:new Go(null,{defaultValue:this.config.defaultPitch,min:-Math.PI/2,max:Math.PI/2,wrap:!1})}),this.roll=new Go(e=>{this.viewer.state.roll=e,this.viewer.dispatchEvent(new ea(e))},{defaultValue:0,min:-Math.PI,max:Math.PI,wrap:!1}),this.updateSpeeds()}updateSpeeds(){this.zoom.setSpeed(this.config.zoomSpeed*50),this.position.setSpeed(Ut.degToRad(this.config.moveSpeed*50)),this.roll.setSpeed(Ut.degToRad(this.config.moveSpeed*50))}update(n){this.zoom.update(n),this.position.update(n),this.roll.update(n)}},hA=class{constructor(){this.ready=!1,this.needsUpdate=!1,this.continuousUpdateCount=0,this.keyboardEnabled=!1,this.direction=new ce(0,0,nr),this.roll=0,this.vFov=60,this.hFov=60,this.aspect=1,this.animation=null,this.transitionAnimation=null,this.loadingPromise=null,this.idleTime=-1,this.objectsObservers={},this.size={width:0,height:0}}},Wr=class extends tg{constructor(n){var e,t,i;if(super(),this.plugins={},this.children=[],this.onResize=Nd(()=>this.navbar.autoSize(),500),this.parent=U_(n.container),!this.parent)throw new Ke('"container" element not found.');this.parent[Ss]=this,this.container=document.createElement("div"),this.container.classList.add("psv-container"),this.parent.appendChild(this.container),Q_(this.parent),Y_(this.container,"core"),this.state=new hA,this.config=q1(n),this.__setSize(this.config.size),this.overlay=new j1(this);try{xn.load()}catch(s){console.error(s),this.showError(this.config.lang.webglError);return}zr.init(),this.adapter=new this.config.adapter[0](this,this.config.adapter[1]),this.renderer=new rA(this),this.textureLoader=new lA(this),this.eventsHandler=new sA(this),this.dataHelper=new tA(this),this.dynamics=new cA(this),(t=(e=this.adapter).init)==null||t.call(e),this.loader=new Y1(this),this.navbar=new X1(this),this.panel=new K1(this),this.notification=new Q1(this),this.autoSize(),this.setCursor(null),Od(xn.isTouchEnabled,s=>{sc(this.container,"psv--is-touch",s)}),this.config.plugins.forEach(([s,r])=>{this.plugins[s.id]=new s(this,r)});for(const s of Object.values(this.plugins))(i=s.init)==null||i.call(s);this.config.navbar&&this.navbar.setButtons(this.config.navbar),this.state.loadingPromise||(this.config.panorama?this.setPanorama(this.config.panorama):this.loader.show())}destroy(){var n,e,t,i,s,r;this.stopAll(),this.stopKeyboardControl(),this.exitFullscreen();for(const[o,a]of Object.entries(this.plugins))a.destroy(),delete this.plugins[o];this.children.slice().forEach(o=>o.destroy()),this.children.length=0,(n=this.eventsHandler)==null||n.destroy(),(e=this.renderer)==null||e.destroy(),(t=this.textureLoader)==null||t.destroy(),(i=this.dataHelper)==null||i.destroy(),(s=this.adapter)==null||s.destroy(),(r=this.dynamics)==null||r.destroy(),this.parent.removeChild(this.container),delete this.parent[Ss]}init(){this.eventsHandler.init(),this.renderer.init(),this.config.navbar&&this.navbar.show(),this.config.keyboard==="always"&&this.startKeyboardControl(),this.resetIdleTimer(),this.state.ready=!0,this.dispatchEvent(new ta)}resetIdleTimer(){this.state.idleTime=performance.now()}disableIdleTimer(){this.state.idleTime=-1}getPlugin(n){if(typeof n=="string")return this.plugins[n];{const e=Su(n);return e?this.plugins[e.id]:null}}getPosition(){return this.dataHelper.cleanPosition(this.dynamics.position.current)}getZoomLevel(){return this.dynamics.zoom.current}getSize(){return{...this.state.size}}isFullscreenEnabled(){return z_(this.parent,xn.isIphone)}needsUpdate(){this.state.needsUpdate=!0}needsContinuousUpdate(n){n?this.state.continuousUpdateCount++:this.state.continuousUpdateCount>0&&this.state.continuousUpdateCount--}autoSize(){(this.container.clientWidth!==this.state.size.width||this.container.clientHeight!==this.state.size.height)&&(this.state.size.width=Math.round(this.container.clientWidth),this.state.size.height=Math.round(this.container.clientHeight),this.state.aspect=this.state.size.width/this.state.size.height,this.state.hFov=this.dataHelper.vFovToHFov(this.state.vFov),this.dispatchEvent(new ia(this.getSize())),this.onResize())}setPanorama(n,e={}){var s;this.textureLoader.abortLoading(),(s=this.state.transitionAnimation)==null||s.cancel(),this.state.ready||["sphereCorrection","panoData"].forEach(r=>{r in e||(e[r]=this.config[r])}),e.transition===void 0&&(e.transition=!0),e.speed===void 0&&(e.speed=S_),e.showLoader===void 0&&(e.showLoader=!0),e.caption===void 0&&(e.caption=this.config.caption),e.description===void 0&&(e.description=this.config.description),!e.panoData&&typeof this.config.panoData=="function"&&(e.panoData=this.config.panoData),this.hideError(),this.resetIdleTimer(),this.config.panorama=n,this.config.caption=e.caption,this.config.description=e.description;const t=r=>{if($_(r))return!1;if(this.loader.hide(),this.state.loadingPromise=null,r)throw this.navbar.setCaption(""),this.showError(this.config.lang.loadError),console.error(r),this.dispatchEvent(new Hg(n,r)),r;return this.navbar.setCaption(this.config.caption),!0};this.navbar.setCaption(`<em>${this.config.lang.loading}</em>`),(e.showLoader||!this.state.ready)&&this.loader.show(),this.dispatchEvent(new Fg(n));const i=this.adapter.loadTexture(this.config.panorama,!0,e.panoData).then(r=>{if(r.panorama!==this.config.panorama)throw this.adapter.disposeTexture(r),gu();const o=this.dataHelper.cleanPanoramaOptions(e,r.panoData);return(!nn(o.zoom)||!nn(o.position))&&this.stopAll(),{textureData:r,cleanOptions:o}});return!e.transition||!this.state.ready||!this.adapter.supportsTransition(this.config.panorama)?this.state.loadingPromise=i.then(({textureData:r,cleanOptions:o})=>{this.renderer.show(),this.renderer.setTexture(r),this.renderer.setPanoramaPose(r.panoData),this.renderer.setSphereCorrection(e.sphereCorrection),this.state.ready||this.init(),this.dispatchEvent(new Eu(r)),nn(o.zoom)||this.zoom(o.zoom),nn(o.position)||this.rotate(o.position)}).then(()=>t(),r=>t(r)):this.state.loadingPromise=i.then(({textureData:r,cleanOptions:o})=>(this.loader.hide(),this.dispatchEvent(new Eu(r)),this.state.transitionAnimation=this.renderer.transition(r,o),this.state.transitionAnimation)).then(r=>{if(this.state.transitionAnimation=null,this.dispatchEvent(new Wg(r)),!r)throw gu()}).then(()=>t(),r=>t(r)),this.state.loadingPromise}setOptions(n){const e={...this.config,...n};for(let[t,i]of Object.entries(n)){if(!(t in bs)){Lt(`Unknown option ${t}`);continue}if(t in _p){Lt(_p[t]);continue}switch(t in bu&&(i=bu[t](i,{rawConfig:e,defValue:bs[t]})),this.config[t]=i,t){case"mousemove":this.state.cursorOverride||this.setCursor(null);break;case"caption":this.navbar.setCaption(this.config.caption);break;case"size":this.resize(this.config.size);break;case"sphereCorrection":this.renderer.setSphereCorrection(this.config.sphereCorrection);break;case"navbar":case"lang":this.navbar.setButtons(this.config.navbar);break;case"moveSpeed":case"zoomSpeed":this.dynamics.updateSpeeds();break;case"minFov":case"maxFov":this.dynamics.zoom.setValue(this.dataHelper.fovToZoomLevel(this.state.vFov)),this.dispatchEvent(new Vi(this.getZoomLevel()));break;case"keyboard":this.config.keyboard==="always"?this.startKeyboardControl():this.stopKeyboardControl();break}}this.needsUpdate(),this.dispatchEvent(new bn(Object.keys(n)))}setOption(n,e){this.setOptions({[n]:e})}showError(n){this.overlay.show({id:rn.ERROR,image:eA,title:n,dissmisable:!1})}hideError(){this.overlay.hide(rn.ERROR)}rotate(n){const e=new lg(this.dataHelper.cleanPosition(n));this.dispatchEvent(e),!e.defaultPrevented&&this.dynamics.position.setValue(e.position)}zoom(n){this.dynamics.zoom.setValue(n)}zoomIn(n=1){this.dynamics.zoom.step(n)}zoomOut(n=1){this.dynamics.zoom.step(-n)}animate(n){const e=zd(n),t=!nn(n.zoom),i=new Hd(e?this.dataHelper.cleanPosition(n):void 0,n.zoom);if(this.dispatchEvent(i),i.defaultPrevented)return;this.stopAll();const{duration:s,properties:r}=this.dataHelper.getAnimationProperties(n.speed,i.position,i.zoomLevel);return s?(this.state.animation=new Yl({properties:r,duration:s,easing:n.easing||"inOutSine",onTick:o=>{e&&this.dynamics.position.setValue({yaw:o.yaw,pitch:o.pitch}),t&&this.dynamics.zoom.setValue(o.zoom)}}),this.state.animation.then(()=>{this.state.animation=null,this.resetIdleTimer()}),this.state.animation):(e&&this.rotate(i.position),t&&this.zoom(i.zoomLevel),new Yl(null))}stopAnimation(){return this.state.animation?(this.state.animation.cancel(),this.state.animation):Promise.resolve()}resize(n){this.__setSize(n),this.autoSize()}__setSize(n){const e=n;["width","height"].forEach(t=>{n&&e[t]&&(/^[0-9.]+$/.test(e[t])&&(e[t]+="px"),this.parent.style[t]=e[t])})}enterFullscreen(){this.isFullscreenEnabled()||k_(this.parent,xn.isIphone)}exitFullscreen(){this.isFullscreenEnabled()&&B_(xn.isIphone)}toggleFullscreen(){this.isFullscreenEnabled()?this.exitFullscreen():this.enterFullscreen()}startKeyboardControl(){this.state.keyboardEnabled=!0}stopKeyboardControl(){this.state.keyboardEnabled=!1}createTooltip(n){return new J1(this,n)}setCursor(n){this.state.cursorOverride=n,n?this.container.style.cursor=n:this.container.style.cursor=this.config.mousemove?"move":"default"}observeObjects(n){this.state.objectsObservers[n]||(this.state.objectsObservers[n]=null)}unobserveObjects(n){delete this.state.objectsObservers[n]}stopAll(){return this.dispatchEvent(new sa),this.disableIdleTimer(),this.stopAnimation()}};Wr.useNewAnglesOrder=!0;/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT */const qd="170",Kr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},$r={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},uA=0,xp=1,dA=2,Ov=1,fA=2,Fi=3,ws=0,wn=1,_i=2,gs=0,Jr=1,Mp=2,Ep=3,yp=4,pA=5,Qs=100,mA=101,_A=102,gA=103,vA=104,xA=200,MA=201,EA=202,yA=203,Tu=204,Au=205,SA=206,bA=207,wA=208,TA=209,AA=210,CA=211,RA=212,PA=213,LA=214,Cu=0,Ru=1,Pu=2,co=3,Lu=4,Du=5,Iu=6,Uu=7,zv=0,DA=1,IA=2,vs=0,UA=1,NA=2,FA=3,OA=4,zA=5,kA=6,BA=7,kv=300,ho=301,uo=302,Nu=303,Fu=304,uc=306,Ou=1e3,Ks=1001,zu=1002,ii=1003,HA=1004,Ka=1005,Vn=1006,Yc=1007,Js=1008,qi=1009,Bv=1010,Hv=1011,pa=1012,Xd=1013,ir=1014,Bi=1015,Sa=1016,Yd=1017,Qd=1018,fo=1020,Vv=35902,Gv=1021,Wv=1022,ni=1023,$v=1024,qv=1025,eo=1026,po=1027,Xv=1028,jd=1029,Yv=1030,Zd=1031,Kd=1033,Dl=33776,Il=33777,Ul=33778,Nl=33779,ku=35840,Bu=35841,Hu=35842,Vu=35843,Gu=36196,Wu=37492,$u=37496,qu=37808,Xu=37809,Yu=37810,Qu=37811,ju=37812,Zu=37813,Ku=37814,Ju=37815,ed=37816,td=37817,nd=37818,id=37819,sd=37820,rd=37821,Fl=36492,od=36494,ad=36495,Qv=36283,ld=36284,cd=36285,hd=36286,VA=3200,GA=3201,jv=0,WA=1,hs="",Dn="srgb",So="srgb-linear",dc="linear",At="srgb",yr=7680,Sp=519,$A=512,qA=513,XA=514,Zv=515,YA=516,QA=517,jA=518,ZA=519,bp=35044,wp="300 es",Hi=2e3,jl=2001;class or{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}}const cn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Tp=1234567;const ra=Math.PI/180,ma=180/Math.PI;function bo(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(cn[n&255]+cn[n>>8&255]+cn[n>>16&255]+cn[n>>24&255]+"-"+cn[e&255]+cn[e>>8&255]+"-"+cn[e>>16&15|64]+cn[e>>24&255]+"-"+cn[t&63|128]+cn[t>>8&255]+"-"+cn[t>>16&255]+cn[t>>24&255]+cn[i&255]+cn[i>>8&255]+cn[i>>16&255]+cn[i>>24&255]).toLowerCase()}function un(n,e,t){return Math.max(e,Math.min(t,n))}function Jd(n,e){return(n%e+e)%e}function KA(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function JA(n,e,t){return n!==e?(t-n)/(e-n):0}function oa(n,e,t){return(1-t)*n+t*e}function eC(n,e,t,i){return oa(n,e,1-Math.exp(-t*i))}function tC(n,e=1){return e-Math.abs(Jd(n,e*2)-e)}function nC(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function iC(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function sC(n,e){return n+Math.floor(Math.random()*(e-n+1))}function rC(n,e){return n+Math.random()*(e-n)}function oC(n){return n*(.5-Math.random())}function aC(n){n!==void 0&&(Tp=n);let e=Tp+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function lC(n){return n*ra}function cC(n){return n*ma}function hC(n){return(n&n-1)===0&&n!==0}function uC(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function dC(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function fC(n,e,t,i,s){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+i)/2),h=o((e+i)/2),f=r((e-i)/2),p=o((e-i)/2),m=r((i-e)/2),g=o((i-e)/2);switch(s){case"XYX":n.set(a*h,l*f,l*p,a*c);break;case"YZY":n.set(l*p,a*h,l*f,a*c);break;case"ZXZ":n.set(l*f,l*p,a*h,a*c);break;case"XZX":n.set(a*h,l*g,l*m,a*c);break;case"YXY":n.set(l*m,a*h,l*g,a*c);break;case"ZYZ":n.set(l*g,l*m,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function kr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function mn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const ud={DEG2RAD:ra,RAD2DEG:ma,generateUUID:bo,clamp:un,euclideanModulo:Jd,mapLinear:KA,inverseLerp:JA,lerp:oa,damp:eC,pingpong:tC,smoothstep:nC,smootherstep:iC,randInt:sC,randFloat:rC,randFloatSpread:oC,seededRandom:aC,degToRad:lC,radToDeg:cC,isPowerOfTwo:hC,ceilPowerOfTwo:uC,floorPowerOfTwo:dC,setQuaternionFromProperEuler:fC,normalize:mn,denormalize:kr};class at{constructor(e=0,t=0){at.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(un(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*s+e.x,this.y=r*s+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ht{constructor(e,t,i,s,r,o,a,l,c){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c)}set(e,t,i,s,r,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=i,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],h=i[4],f=i[7],p=i[2],m=i[5],g=i[8],x=s[0],d=s[3],u=s[6],w=s[1],M=s[4],E=s[7],N=s[2],A=s[5],T=s[8];return r[0]=o*x+a*w+l*N,r[3]=o*d+a*M+l*A,r[6]=o*u+a*E+l*T,r[1]=c*x+h*w+f*N,r[4]=c*d+h*M+f*A,r[7]=c*u+h*E+f*T,r[2]=p*x+m*w+g*N,r[5]=p*d+m*M+g*A,r[8]=p*u+m*E+g*T,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-i*r*h+i*a*l+s*r*c-s*o*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,p=a*l-h*r,m=c*r-o*l,g=t*f+i*p+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=f*x,e[1]=(s*c-h*i)*x,e[2]=(a*i-s*o)*x,e[3]=p*x,e[4]=(h*t-s*l)*x,e[5]=(s*r-a*t)*x,e[6]=m*x,e[7]=(i*l-c*t)*x,e[8]=(o*t-i*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Qc.makeScale(e,t)),this}rotate(e){return this.premultiply(Qc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Qc=new ht;function Kv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Zl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function pC(){const n=Zl("canvas");return n.style.display="block",n}const Ap={};function Wo(n){n in Ap||(Ap[n]=!0,console.warn(n))}function mC(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}function _C(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function gC(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Et={enabled:!0,workingColorSpace:So,spaces:{},convert:function(n,e,t){return this.enabled===!1||e===t||!e||!t||(this.spaces[e].transfer===At&&(n.r=Gi(n.r),n.g=Gi(n.g),n.b=Gi(n.b)),this.spaces[e].primaries!==this.spaces[t].primaries&&(n.applyMatrix3(this.spaces[e].toXYZ),n.applyMatrix3(this.spaces[t].fromXYZ)),this.spaces[t].transfer===At&&(n.r=to(n.r),n.g=to(n.g),n.b=to(n.b))),n},fromWorkingColorSpace:function(n,e){return this.convert(n,this.workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===hs?dc:this.spaces[n].transfer},getLuminanceCoefficients:function(n,e=this.workingColorSpace){return n.fromArray(this.spaces[e].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,e,t){return n.copy(this.spaces[e].toXYZ).multiply(this.spaces[t].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace}};function Gi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function to(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const Cp=[.64,.33,.3,.6,.15,.06],Rp=[.2126,.7152,.0722],Pp=[.3127,.329],Lp=new ht().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Dp=new ht().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);Et.define({[So]:{primaries:Cp,whitePoint:Pp,transfer:dc,toXYZ:Lp,fromXYZ:Dp,luminanceCoefficients:Rp,workingColorSpaceConfig:{unpackColorSpace:Dn},outputColorSpaceConfig:{drawingBufferColorSpace:Dn}},[Dn]:{primaries:Cp,whitePoint:Pp,transfer:At,toXYZ:Lp,fromXYZ:Dp,luminanceCoefficients:Rp,outputColorSpaceConfig:{drawingBufferColorSpace:Dn}}});let Sr;class vC{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Sr===void 0&&(Sr=Zl("canvas")),Sr.width=e.width,Sr.height=e.height;const i=Sr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Sr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Zl("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=Gi(r[o]/255)*255;return i.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Gi(t[i]/255)*255):t[i]=Gi(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let xC=0;class Jv{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:xC++}),this.uuid=bo(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(jc(s[o].image)):r.push(jc(s[o]))}else r=jc(s);i.url=r}return t||(e.images[this.uuid]=i),i}}function jc(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?vC.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let MC=0;class dn extends or{constructor(e=dn.DEFAULT_IMAGE,t=dn.DEFAULT_MAPPING,i=Ks,s=Ks,r=Vn,o=Js,a=ni,l=qi,c=dn.DEFAULT_ANISOTROPY,h=hs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:MC++}),this.uuid=bo(),this.name="",this.source=new Jv(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new at(0,0),this.repeat=new at(1,1),this.center=new at(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==kv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ou:e.x=e.x-Math.floor(e.x);break;case Ks:e.x=e.x<0?0:1;break;case zu:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ou:e.y=e.y-Math.floor(e.y);break;case Ks:e.y=e.y<0?0:1;break;case zu:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}dn.DEFAULT_IMAGE=null;dn.DEFAULT_MAPPING=kv;dn.DEFAULT_ANISOTROPY=1;class zt{constructor(e=0,t=0,i=0,s=1){zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],h=l[4],f=l[8],p=l[1],m=l[5],g=l[9],x=l[2],d=l[6],u=l[10];if(Math.abs(h-p)<.01&&Math.abs(f-x)<.01&&Math.abs(g-d)<.01){if(Math.abs(h+p)<.1&&Math.abs(f+x)<.1&&Math.abs(g+d)<.1&&Math.abs(c+m+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const M=(c+1)/2,E=(m+1)/2,N=(u+1)/2,A=(h+p)/4,T=(f+x)/4,I=(g+d)/4;return M>E&&M>N?M<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(M),s=A/i,r=T/i):E>N?E<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(E),i=A/s,r=I/s):N<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(N),i=T/r,s=I/r),this.set(i,s,r,t),this}let w=Math.sqrt((d-g)*(d-g)+(f-x)*(f-x)+(p-h)*(p-h));return Math.abs(w)<.001&&(w=1),this.x=(d-g)/w,this.y=(f-x)/w,this.z=(p-h)/w,this.w=Math.acos((c+m+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}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 EC extends or{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new zt(0,0,e,t),this.scissorTest=!1,this.viewport=new zt(0,0,e,t);const s={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Vn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const r=new dn(s,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);r.flipY=!1,r.generateMipmaps=i.generateMipmaps,r.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,s=e.textures.length;i<s;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Jv(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class sr extends EC{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class e0 extends dn{constructor(e=null,t=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=ii,this.minFilter=ii,this.wrapR=Ks,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class yC extends dn{constructor(e=null,t=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=ii,this.minFilter=ii,this.wrapR=Ks,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ts{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,o,a){let l=i[s+0],c=i[s+1],h=i[s+2],f=i[s+3];const p=r[o+0],m=r[o+1],g=r[o+2],x=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(a===1){e[t+0]=p,e[t+1]=m,e[t+2]=g,e[t+3]=x;return}if(f!==x||l!==p||c!==m||h!==g){let d=1-a;const u=l*p+c*m+h*g+f*x,w=u>=0?1:-1,M=1-u*u;if(M>Number.EPSILON){const N=Math.sqrt(M),A=Math.atan2(N,u*w);d=Math.sin(d*A)/N,a=Math.sin(a*A)/N}const E=a*w;if(l=l*d+p*E,c=c*d+m*E,h=h*d+g*E,f=f*d+x*E,d===1-a){const N=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=N,c*=N,h*=N,f*=N}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,s,r,o){const a=i[s],l=i[s+1],c=i[s+2],h=i[s+3],f=r[o],p=r[o+1],m=r[o+2],g=r[o+3];return e[t]=a*g+h*f+l*m-c*p,e[t+1]=l*g+h*p+c*f-a*m,e[t+2]=c*g+h*m+a*p-l*f,e[t+3]=h*g-a*f-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),h=a(s/2),f=a(r/2),p=l(i/2),m=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=p*h*f+c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f-p*m*g;break;case"YXZ":this._x=p*h*f+c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f+p*m*g;break;case"ZXY":this._x=p*h*f-c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f-p*m*g;break;case"ZYX":this._x=p*h*f-c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f+p*m*g;break;case"YZX":this._x=p*h*f+c*m*g,this._y=c*m*f+p*h*g,this._z=c*h*g-p*m*f,this._w=c*h*f-p*m*g;break;case"XZY":this._x=p*h*f-c*m*g,this._y=c*m*f-p*h*g,this._z=c*h*g+p*m*f,this._w=c*h*f+p*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],f=t[10],p=i+a+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(h-l)*m,this._y=(r-c)*m,this._z=(o-s)*m}else if(i>a&&i>f){const m=2*Math.sqrt(1+i-a-f);this._w=(h-l)/m,this._x=.25*m,this._y=(s+o)/m,this._z=(r+c)/m}else if(a>f){const m=2*Math.sqrt(1+a-i-f);this._w=(r-c)/m,this._x=(s+o)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+f-i-a);this._w=(o-s)/m,this._x=(r+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(un(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-i*c,this._z=r*h+o*c+i*l-s*a,this._w=o*h-i*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,s=this._y,r=this._z,o=this._w;let a=o*e._w+i*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=s,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-t;return this._w=m*o+t*this._w,this._x=m*i+t*this._x,this._y=m*s+t*this._y,this._z=m*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=o*f+this._w*p,this._x=i*f+this._x*p,this._y=s*f+this._y*p,this._z=r*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class re{constructor(e=0,t=0,i=0){re.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ip.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ip.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*i),h=2*(a*t-r*s),f=2*(r*i-o*t);return this.x=t+l*c+o*f-a*h,this.y=i+l*h+a*c-r*f,this.z=s+l*f+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-i*l,this.z=i*a-s*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Zc.copy(this).projectOnVector(e),this.sub(Zc)}reflect(e){return this.sub(Zc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(un(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Zc=new re,Ip=new Ts;class ba{constructor(e=new re(1/0,1/0,1/0),t=new re(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Zn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Zn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Zn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Zn):Zn.fromBufferAttribute(r,o),Zn.applyMatrix4(e.matrixWorld),this.expandByPoint(Zn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ja.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ja.copy(i.boundingBox)),Ja.applyMatrix4(e.matrixWorld),this.union(Ja)}const s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Zn),Zn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Oo),el.subVectors(this.max,Oo),br.subVectors(e.a,Oo),wr.subVectors(e.b,Oo),Tr.subVectors(e.c,Oo),ns.subVectors(wr,br),is.subVectors(Tr,wr),zs.subVectors(br,Tr);let t=[0,-ns.z,ns.y,0,-is.z,is.y,0,-zs.z,zs.y,ns.z,0,-ns.x,is.z,0,-is.x,zs.z,0,-zs.x,-ns.y,ns.x,0,-is.y,is.x,0,-zs.y,zs.x,0];return!Kc(t,br,wr,Tr,el)||(t=[1,0,0,0,1,0,0,0,1],!Kc(t,br,wr,Tr,el))?!1:(tl.crossVectors(ns,is),t=[tl.x,tl.y,tl.z],Kc(t,br,wr,Tr,el))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Zn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Pi=[new re,new re,new re,new re,new re,new re,new re,new re],Zn=new re,Ja=new ba,br=new re,wr=new re,Tr=new re,ns=new re,is=new re,zs=new re,Oo=new re,el=new re,tl=new re,ks=new re;function Kc(n,e,t,i,s){for(let r=0,o=n.length-3;r<=o;r+=3){ks.fromArray(n,r);const a=s.x*Math.abs(ks.x)+s.y*Math.abs(ks.y)+s.z*Math.abs(ks.z),l=e.dot(ks),c=t.dot(ks),h=i.dot(ks);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const SC=new ba,zo=new re,Jc=new re;class ef{constructor(e=new re,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):SC.setFromPoints(e).getCenter(i);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;zo.subVectors(e,this.center);const t=zo.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(zo,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Jc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zo.copy(e.center).add(Jc)),this.expandByPoint(zo.copy(e.center).sub(Jc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Li=new re,eh=new re,nl=new re,ss=new re,th=new re,il=new re,nh=new re;class tf{constructor(e=new re,t=new re(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Li.copy(this.origin).addScaledVector(this.direction,t),Li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){eh.copy(e).add(t).multiplyScalar(.5),nl.copy(t).sub(e).normalize(),ss.copy(this.origin).sub(eh);const r=e.distanceTo(t)*.5,o=-this.direction.dot(nl),a=ss.dot(this.direction),l=-ss.dot(nl),c=ss.lengthSq(),h=Math.abs(1-o*o);let f,p,m,g;if(h>0)if(f=o*l-a,p=o*a-l,g=r*h,f>=0)if(p>=-g)if(p<=g){const x=1/h;f*=x,p*=x,m=f*(f+o*p+2*a)+p*(o*f+p+2*l)+c}else p=r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p=-r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p<=-g?(f=Math.max(0,-(-o*r+a)),p=f>0?-r:Math.min(Math.max(-r,-l),r),m=-f*f+p*(p+2*l)+c):p<=g?(f=0,p=Math.min(Math.max(-r,-l),r),m=p*(p+2*l)+c):(f=Math.max(0,-(o*r+a)),p=f>0?r:Math.min(Math.max(-r,-l),r),m=-f*f+p*(p+2*l)+c);else p=o>0?-r:r,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),s&&s.copy(eh).addScaledVector(nl,p),m}intersectSphere(e,t){Li.subVectors(e.center,this.origin);const i=Li.dot(this.direction),s=Li.dot(Li)-i*i,r=e.radius*e.radius;if(s>r)return null;const o=Math.sqrt(r-s),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,s=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,s=(e.min.x-p.x)*c),h>=0?(r=(e.min.y-p.y)*h,o=(e.max.y-p.y)*h):(r=(e.max.y-p.y)*h,o=(e.min.y-p.y)*h),i>o||r>s||((r>i||isNaN(i))&&(i=r),(o<s||isNaN(s))&&(s=o),f>=0?(a=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(a=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),i>l||a>s)||((a>i||i!==i)&&(i=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,Li)!==null}intersectTriangle(e,t,i,s,r){th.subVectors(t,e),il.subVectors(i,e),nh.crossVectors(th,il);let o=this.direction.dot(nh),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ss.subVectors(this.origin,e);const l=a*this.direction.dot(il.crossVectors(ss,il));if(l<0)return null;const c=a*this.direction.dot(th.cross(ss));if(c<0||l+c>o)return null;const h=-a*ss.dot(nh);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ft{constructor(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d){Ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d)}set(e,t,i,s,r,o,a,l,c,h,f,p,m,g,x,d){const u=this.elements;return u[0]=e,u[4]=t,u[8]=i,u[12]=s,u[1]=r,u[5]=o,u[9]=a,u[13]=l,u[2]=c,u[6]=h,u[10]=f,u[14]=p,u[3]=m,u[7]=g,u[11]=x,u[15]=d,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ft().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,s=1/Ar.setFromMatrixColumn(e,0).length(),r=1/Ar.setFromMatrixColumn(e,1).length(),o=1/Ar.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),f=Math.sin(r);if(e.order==="XYZ"){const p=o*h,m=o*f,g=a*h,x=a*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=m+g*c,t[5]=p-x*c,t[9]=-a*l,t[2]=x-p*c,t[6]=g+m*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*h,m=l*f,g=c*h,x=c*f;t[0]=p+x*a,t[4]=g*a-m,t[8]=o*c,t[1]=o*f,t[5]=o*h,t[9]=-a,t[2]=m*a-g,t[6]=x+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*h,m=l*f,g=c*h,x=c*f;t[0]=p-x*a,t[4]=-o*f,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*h,t[9]=x-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*h,m=o*f,g=a*h,x=a*f;t[0]=l*h,t[4]=g*c-m,t[8]=p*c+x,t[1]=l*f,t[5]=x*c+p,t[9]=m*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=x-p*f,t[8]=g*f+m,t[1]=f,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=m*f+g,t[10]=p-x*f}else if(e.order==="XZY"){const p=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=p*f+x,t[5]=o*h,t[9]=m*f-g,t[2]=g*f-m,t[6]=a*h,t[10]=x*f+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(bC,e,wC)}lookAt(e,t,i){const s=this.elements;return Rn.subVectors(e,t),Rn.lengthSq()===0&&(Rn.z=1),Rn.normalize(),rs.crossVectors(i,Rn),rs.lengthSq()===0&&(Math.abs(i.z)===1?Rn.x+=1e-4:Rn.z+=1e-4,Rn.normalize(),rs.crossVectors(i,Rn)),rs.normalize(),sl.crossVectors(Rn,rs),s[0]=rs.x,s[4]=sl.x,s[8]=Rn.x,s[1]=rs.y,s[5]=sl.y,s[9]=Rn.y,s[2]=rs.z,s[6]=sl.z,s[10]=Rn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],h=i[1],f=i[5],p=i[9],m=i[13],g=i[2],x=i[6],d=i[10],u=i[14],w=i[3],M=i[7],E=i[11],N=i[15],A=s[0],T=s[4],I=s[8],C=s[12],_=s[1],b=s[5],W=s[9],z=s[13],G=s[2],K=s[6],H=s[10],ie=s[14],B=s[3],ue=s[7],me=s[11],Me=s[15];return r[0]=o*A+a*_+l*G+c*B,r[4]=o*T+a*b+l*K+c*ue,r[8]=o*I+a*W+l*H+c*me,r[12]=o*C+a*z+l*ie+c*Me,r[1]=h*A+f*_+p*G+m*B,r[5]=h*T+f*b+p*K+m*ue,r[9]=h*I+f*W+p*H+m*me,r[13]=h*C+f*z+p*ie+m*Me,r[2]=g*A+x*_+d*G+u*B,r[6]=g*T+x*b+d*K+u*ue,r[10]=g*I+x*W+d*H+u*me,r[14]=g*C+x*z+d*ie+u*Me,r[3]=w*A+M*_+E*G+N*B,r[7]=w*T+M*b+E*K+N*ue,r[11]=w*I+M*W+E*H+N*me,r[15]=w*C+M*z+E*ie+N*Me,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],f=e[6],p=e[10],m=e[14],g=e[3],x=e[7],d=e[11],u=e[15];return g*(+r*l*f-s*c*f-r*a*p+i*c*p+s*a*m-i*l*m)+x*(+t*l*m-t*c*p+r*o*p-s*o*m+s*c*h-r*l*h)+d*(+t*c*f-t*a*m-r*o*f+i*o*m+r*a*h-i*c*h)+u*(-s*a*h-t*l*f+t*a*p+s*o*f-i*o*p+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=e[9],p=e[10],m=e[11],g=e[12],x=e[13],d=e[14],u=e[15],w=f*d*c-x*p*c+x*l*m-a*d*m-f*l*u+a*p*u,M=g*p*c-h*d*c-g*l*m+o*d*m+h*l*u-o*p*u,E=h*x*c-g*f*c+g*a*m-o*x*m-h*a*u+o*f*u,N=g*f*l-h*x*l-g*a*p+o*x*p+h*a*d-o*f*d,A=t*w+i*M+s*E+r*N;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/A;return e[0]=w*T,e[1]=(x*p*r-f*d*r-x*s*m+i*d*m+f*s*u-i*p*u)*T,e[2]=(a*d*r-x*l*r+x*s*c-i*d*c-a*s*u+i*l*u)*T,e[3]=(f*l*r-a*p*r-f*s*c+i*p*c+a*s*m-i*l*m)*T,e[4]=M*T,e[5]=(h*d*r-g*p*r+g*s*m-t*d*m-h*s*u+t*p*u)*T,e[6]=(g*l*r-o*d*r-g*s*c+t*d*c+o*s*u-t*l*u)*T,e[7]=(o*p*r-h*l*r+h*s*c-t*p*c-o*s*m+t*l*m)*T,e[8]=E*T,e[9]=(g*f*r-h*x*r-g*i*m+t*x*m+h*i*u-t*f*u)*T,e[10]=(o*x*r-g*a*r+g*i*c-t*x*c-o*i*u+t*a*u)*T,e[11]=(h*a*r-o*f*r-h*i*c+t*f*c+o*i*m-t*a*m)*T,e[12]=N*T,e[13]=(h*x*s-g*f*s+g*i*p-t*x*p-h*i*d+t*f*d)*T,e[14]=(g*a*s-o*x*s-g*i*l+t*x*l+o*i*d-t*a*d)*T,e[15]=(o*f*s-h*a*s+h*i*l-t*f*l-o*i*p+t*a*p)*T,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+i,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+i,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,o){return this.set(1,i,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,f=a+a,p=r*c,m=r*h,g=r*f,x=o*h,d=o*f,u=a*f,w=l*c,M=l*h,E=l*f,N=i.x,A=i.y,T=i.z;return s[0]=(1-(x+u))*N,s[1]=(m+E)*N,s[2]=(g-M)*N,s[3]=0,s[4]=(m-E)*A,s[5]=(1-(p+u))*A,s[6]=(d+w)*A,s[7]=0,s[8]=(g+M)*T,s[9]=(d-w)*T,s[10]=(1-(p+x))*T,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;let r=Ar.set(s[0],s[1],s[2]).length();const o=Ar.set(s[4],s[5],s[6]).length(),a=Ar.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],Kn.copy(this);const c=1/r,h=1/o,f=1/a;return Kn.elements[0]*=c,Kn.elements[1]*=c,Kn.elements[2]*=c,Kn.elements[4]*=h,Kn.elements[5]*=h,Kn.elements[6]*=h,Kn.elements[8]*=f,Kn.elements[9]*=f,Kn.elements[10]*=f,t.setFromRotationMatrix(Kn),i.x=r,i.y=o,i.z=a,this}makePerspective(e,t,i,s,r,o,a=Hi){const l=this.elements,c=2*r/(t-e),h=2*r/(i-s),f=(t+e)/(t-e),p=(i+s)/(i-s);let m,g;if(a===Hi)m=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===jl)m=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,s,r,o,a=Hi){const l=this.elements,c=1/(t-e),h=1/(i-s),f=1/(o-r),p=(t+e)*c,m=(i+s)*h;let g,x;if(a===Hi)g=(o+r)*f,x=-2*f;else if(a===jl)g=r*f,x=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=x,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ar=new re,Kn=new Ft,bC=new re(0,0,0),wC=new re(1,1,1),rs=new re,sl=new re,Rn=new re,Up=new Ft,Np=new Ts;class bi{constructor(e=0,t=0,i=0,s=bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],f=s[2],p=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(un(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-un(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(un(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-un(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(un(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-un(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Up.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Up,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Np.setFromEuler(this),this.setFromQuaternion(Np,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}bi.DEFAULT_ORDER="XYZ";class nf{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let TC=0;const Fp=new re,Cr=new Ts,Di=new Ft,rl=new re,ko=new re,AC=new re,CC=new Ts,Op=new re(1,0,0),zp=new re(0,1,0),kp=new re(0,0,1),Bp={type:"added"},RC={type:"removed"},Rr={type:"childadded",child:null},ih={type:"childremoved",child:null};class Tn extends or{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:TC++}),this.uuid=bo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Tn.DEFAULT_UP.clone();const e=new re,t=new bi,i=new Ts,s=new re(1,1,1);function r(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Ft},normalMatrix:{value:new ht}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=Tn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Tn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.multiply(Cr),this}rotateOnWorldAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.premultiply(Cr),this}rotateX(e){return this.rotateOnAxis(Op,e)}rotateY(e){return this.rotateOnAxis(zp,e)}rotateZ(e){return this.rotateOnAxis(kp,e)}translateOnAxis(e,t){return Fp.copy(e).applyQuaternion(this.quaternion),this.position.add(Fp.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Op,e)}translateY(e){return this.translateOnAxis(zp,e)}translateZ(e){return this.translateOnAxis(kp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Di.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?rl.copy(e):rl.set(e,t,i);const s=this.parent;this.updateWorldMatrix(!0,!1),ko.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Di.lookAt(ko,rl,this.up):Di.lookAt(rl,ko,this.up),this.quaternion.setFromRotationMatrix(Di),s&&(Di.extractRotation(s.matrixWorld),Cr.setFromRotationMatrix(Di),this.quaternion.premultiply(Cr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Bp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(RC),ih.child=e,this.dispatchEvent(ih),ih.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Di.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Di.multiply(e.parent.matrixWorld)),e.applyMatrix4(Di),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Bp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,s=this.children.length;i<s;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ko,e,AC),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ko,CC,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];r(e.shapes,f)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),f=o(e.shapes),p=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),f.length>0&&(i.shapes=f),p.length>0&&(i.skeletons=p),m.length>0&&(i.animations=m),g.length>0&&(i.nodes=g)}return i.object=s,i;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}}Tn.DEFAULT_UP=new re(0,1,0);Tn.DEFAULT_MATRIX_AUTO_UPDATE=!0;Tn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Jn=new re,Ii=new re,sh=new re,Ui=new re,Pr=new re,Lr=new re,Hp=new re,rh=new re,oh=new re,ah=new re,lh=new zt,ch=new zt,hh=new zt;class ei{constructor(e=new re,t=new re,i=new re){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Jn.subVectors(e,t),s.cross(Jn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Jn.subVectors(s,t),Ii.subVectors(i,t),sh.subVectors(e,t);const o=Jn.dot(Jn),a=Jn.dot(Ii),l=Jn.dot(sh),c=Ii.dot(Ii),h=Ii.dot(sh),f=o*c-a*a;if(f===0)return r.set(0,0,0),null;const p=1/f,m=(c*l-a*h)*p,g=(o*h-a*l)*p;return r.set(1-m-g,g,m)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,Ui)===null?!1:Ui.x>=0&&Ui.y>=0&&Ui.x+Ui.y<=1}static getInterpolation(e,t,i,s,r,o,a,l){return this.getBarycoord(e,t,i,s,Ui)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Ui.x),l.addScaledVector(o,Ui.y),l.addScaledVector(a,Ui.z),l)}static getInterpolatedAttribute(e,t,i,s,r,o){return lh.setScalar(0),ch.setScalar(0),hh.setScalar(0),lh.fromBufferAttribute(e,t),ch.fromBufferAttribute(e,i),hh.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(lh,r.x),o.addScaledVector(ch,r.y),o.addScaledVector(hh,r.z),o}static isFrontFacing(e,t,i,s){return Jn.subVectors(i,t),Ii.subVectors(e,t),Jn.cross(Ii).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Jn.subVectors(this.c,this.b),Ii.subVectors(this.a,this.b),Jn.cross(Ii).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ei.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ei.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return ei.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return ei.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ei.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let o,a;Pr.subVectors(s,i),Lr.subVectors(r,i),rh.subVectors(e,i);const l=Pr.dot(rh),c=Lr.dot(rh);if(l<=0&&c<=0)return t.copy(i);oh.subVectors(e,s);const h=Pr.dot(oh),f=Lr.dot(oh);if(h>=0&&f<=h)return t.copy(s);const p=l*f-h*c;if(p<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(i).addScaledVector(Pr,o);ah.subVectors(e,r);const m=Pr.dot(ah),g=Lr.dot(ah);if(g>=0&&m<=g)return t.copy(r);const x=m*c-l*g;if(x<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(i).addScaledVector(Lr,a);const d=h*g-m*f;if(d<=0&&f-h>=0&&m-g>=0)return Hp.subVectors(r,s),a=(f-h)/(f-h+(m-g)),t.copy(s).addScaledVector(Hp,a);const u=1/(d+x+p);return o=x*u,a=p*u,t.copy(i).addScaledVector(Pr,o).addScaledVector(Lr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const t0={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},os={h:0,s:0,l:0},ol={h:0,s:0,l:0};function uh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class bt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Dn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Et.toWorkingColorSpace(this,t),this}setRGB(e,t,i,s=Et.workingColorSpace){return this.r=e,this.g=t,this.b=i,Et.toWorkingColorSpace(this,s),this}setHSL(e,t,i,s=Et.workingColorSpace){if(e=Jd(e,1),t=un(t,0,1),i=un(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=uh(o,r,e+1/3),this.g=uh(o,r,e),this.b=uh(o,r,e-1/3)}return Et.toWorkingColorSpace(this,s),this}setStyle(e,t=Dn){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Dn){const i=t0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=to(e.r),this.g=to(e.g),this.b=to(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Dn){return Et.fromWorkingColorSpace(hn.copy(this),e),Math.round(un(hn.r*255,0,255))*65536+Math.round(un(hn.g*255,0,255))*256+Math.round(un(hn.b*255,0,255))}getHexString(e=Dn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Et.workingColorSpace){Et.fromWorkingColorSpace(hn.copy(this),t);const i=hn.r,s=hn.g,r=hn.b,o=Math.max(i,s,r),a=Math.min(i,s,r);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case i:l=(s-r)/f+(s<r?6:0);break;case s:l=(r-i)/f+2;break;case r:l=(i-s)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Et.workingColorSpace){return Et.fromWorkingColorSpace(hn.copy(this),t),e.r=hn.r,e.g=hn.g,e.b=hn.b,e}getStyle(e=Dn){Et.fromWorkingColorSpace(hn.copy(this),e);const t=hn.r,i=hn.g,s=hn.b;return e!==Dn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,t,i){return this.getHSL(os),this.setHSL(os.h+e,os.s+t,os.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(os),e.getHSL(ol);const i=oa(os.h,ol.h,t),s=oa(os.s,ol.s,t),r=oa(os.l,ol.l,t);return this.setHSL(i,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*s,this.g=r[1]*t+r[4]*i+r[7]*s,this.b=r[2]*t+r[5]*i+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const hn=new bt;bt.NAMES=t0;let PC=0;class wa extends or{static get type(){return"Material"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:PC++}),this.uuid=bo(),this.name="",this.blending=Jr,this.side=ws,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Tu,this.blendDst=Au,this.blendEquation=Qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new bt(0,0,0),this.blendAlpha=0,this.depthFunc=co,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Sp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yr,this.stencilZFail=yr,this.stencilZPass=yr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Jr&&(i.blending=this.blending),this.side!==ws&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tu&&(i.blendSrc=this.blendSrc),this.blendDst!==Au&&(i.blendDst=this.blendDst),this.blendEquation!==Qs&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==co&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Sp&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==yr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==yr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==yr&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=s(e.textures),o=s(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class sf extends wa{static get type(){return"MeshBasicMaterial"}constructor(e){super(),this.isMeshBasicMaterial=!0,this.color=new bt(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 bi,this.combine=zv,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Vt=new re,al=new at;class Ei{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=bp,this.updateRanges=[],this.gpuType=Bi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)al.fromBufferAttribute(this,t),al.applyMatrix3(e),this.setXY(t,al.x,al.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Vt.fromBufferAttribute(this,t),Vt.applyMatrix3(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Vt.fromBufferAttribute(this,t),Vt.applyMatrix4(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Vt.fromBufferAttribute(this,t),Vt.applyNormalMatrix(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Vt.fromBufferAttribute(this,t),Vt.transformDirection(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=kr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mn(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=kr(t,this.array)),t}setX(e,t){return this.normalized&&(t=mn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=kr(t,this.array)),t}setY(e,t){return this.normalized&&(t=mn(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=kr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mn(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=kr(t,this.array)),t}setW(e,t){return this.normalized&&(t=mn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=mn(t,this.array),i=mn(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,s){return e*=this.itemSize,this.normalized&&(t=mn(t,this.array),i=mn(i,this.array),s=mn(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e*=this.itemSize,this.normalized&&(t=mn(t,this.array),i=mn(i,this.array),s=mn(s,this.array),r=mn(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bp&&(e.usage=this.usage),e}}class n0 extends Ei{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class i0 extends Ei{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class yi extends Ei{constructor(e,t,i){super(new Float32Array(e),t,i)}}let LC=0;const Nn=new Ft,dh=new Tn,Dr=new re,Pn=new ba,Bo=new ba,en=new re;class As extends or{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:LC++}),this.uuid=bo(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,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(e){return Array.isArray(e)?this.index=new(Kv(e)?i0:n0)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new ht().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Nn.makeRotationFromQuaternion(e),this.applyMatrix4(Nn),this}rotateX(e){return Nn.makeRotationX(e),this.applyMatrix4(Nn),this}rotateY(e){return Nn.makeRotationY(e),this.applyMatrix4(Nn),this}rotateZ(e){return Nn.makeRotationZ(e),this.applyMatrix4(Nn),this}translate(e,t,i){return Nn.makeTranslation(e,t,i),this.applyMatrix4(Nn),this}scale(e,t,i){return Nn.makeScale(e,t,i),this.applyMatrix4(Nn),this}lookAt(e){return dh.lookAt(e),dh.updateMatrix(),this.applyMatrix4(dh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Dr).negate(),this.translate(Dr.x,Dr.y,Dr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;s<r;s++){const o=e[s];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new yi(i,3))}else{for(let i=0,s=t.count;i<s;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ba);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new re(-1/0,-1/0,-1/0),new re(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i<s;i++){const r=t[i];Pn.setFromBufferAttribute(r),this.morphTargetsRelative?(en.addVectors(this.boundingBox.min,Pn.min),this.boundingBox.expandByPoint(en),en.addVectors(this.boundingBox.max,Pn.max),this.boundingBox.expandByPoint(en)):(this.boundingBox.expandByPoint(Pn.min),this.boundingBox.expandByPoint(Pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ef);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new re,1/0);return}if(e){const i=this.boundingSphere.center;if(Pn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];Bo.setFromBufferAttribute(a),this.morphTargetsRelative?(en.addVectors(Pn.min,Bo.min),Pn.expandByPoint(en),en.addVectors(Pn.max,Bo.max),Pn.expandByPoint(en)):(Pn.expandByPoint(Bo.min),Pn.expandByPoint(Bo.max))}Pn.getCenter(i);let s=0;for(let r=0,o=e.count;r<o;r++)en.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(en));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)en.fromBufferAttribute(a,c),l&&(Dr.fromBufferAttribute(e,c),en.add(Dr)),s=Math.max(s,i.distanceToSquared(en))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ei(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let I=0;I<i.count;I++)a[I]=new re,l[I]=new re;const c=new re,h=new re,f=new re,p=new at,m=new at,g=new at,x=new re,d=new re;function u(I,C,_){c.fromBufferAttribute(i,I),h.fromBufferAttribute(i,C),f.fromBufferAttribute(i,_),p.fromBufferAttribute(r,I),m.fromBufferAttribute(r,C),g.fromBufferAttribute(r,_),h.sub(c),f.sub(c),m.sub(p),g.sub(p);const b=1/(m.x*g.y-g.x*m.y);isFinite(b)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(b),d.copy(f).multiplyScalar(m.x).addScaledVector(h,-g.x).multiplyScalar(b),a[I].add(x),a[C].add(x),a[_].add(x),l[I].add(d),l[C].add(d),l[_].add(d))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let I=0,C=w.length;I<C;++I){const _=w[I],b=_.start,W=_.count;for(let z=b,G=b+W;z<G;z+=3)u(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const M=new re,E=new re,N=new re,A=new re;function T(I){N.fromBufferAttribute(s,I),A.copy(N);const C=a[I];M.copy(C),M.sub(N.multiplyScalar(N.dot(C))).normalize(),E.crossVectors(A,C);const b=E.dot(l[I])<0?-1:1;o.setXYZW(I,M.x,M.y,M.z,b)}for(let I=0,C=w.length;I<C;++I){const _=w[I],b=_.start,W=_.count;for(let z=b,G=b+W;z<G;z+=3)T(e.getX(z+0)),T(e.getX(z+1)),T(e.getX(z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ei(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,m=i.count;p<m;p++)i.setXYZ(p,0,0,0);const s=new re,r=new re,o=new re,a=new re,l=new re,c=new re,h=new re,f=new re;if(e)for(let p=0,m=e.count;p<m;p+=3){const g=e.getX(p+0),x=e.getX(p+1),d=e.getX(p+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,d),h.subVectors(o,r),f.subVectors(s,r),h.cross(f),a.fromBufferAttribute(i,g),l.fromBufferAttribute(i,x),c.fromBufferAttribute(i,d),a.add(h),l.add(h),c.add(h),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(x,l.x,l.y,l.z),i.setXYZ(d,c.x,c.y,c.z)}else for(let p=0,m=t.count;p<m;p+=3)s.fromBufferAttribute(t,p+0),r.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),h.subVectors(o,r),f.subVectors(s,r),h.cross(f),i.setXYZ(p+0,h.x,h.y,h.z),i.setXYZ(p+1,h.x,h.y,h.z),i.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)en.fromBufferAttribute(e,t),en.normalize(),e.setXYZ(t,en.x,en.y,en.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,f=a.normalized,p=new c.constructor(l.length*h);let m=0,g=0;for(let x=0,d=l.length;x<d;x++){a.isInterleavedBufferAttribute?m=l[x]*a.data.stride+a.offset:m=l[x]*h;for(let u=0;u<h;u++)p[g++]=c[m++]}return new Ei(p,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new As,i=this.index.array,s=this.attributes;for(const a in s){const l=s[a],c=e(l,i);t.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let h=0,f=c.length;h<f;h++){const p=c[h],m=e(p,i);l.push(m)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,p=c.length;f<p;f++){const m=c[f];h.push(m.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const s=e.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],f=r[c];for(let p=0,m=f.length;p<m;p++)h.push(f[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Vp=new Ft,Bs=new tf,ll=new ef,Gp=new re,cl=new re,hl=new re,ul=new re,fh=new re,dl=new re,Wp=new re,fl=new re;class Gn extends Tn{constructor(e=new As,t=new sf){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){const a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,s=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(s,e);const a=this.morphTargetInfluences;if(r&&a){dl.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=a[l],f=r[l];h!==0&&(fh.fromBufferAttribute(f,e),o?dl.addScaledVector(fh,h):dl.addScaledVector(fh.sub(t),h))}t.add(dl)}return t}raycast(e,t){const i=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ll.copy(i.boundingSphere),ll.applyMatrix4(r),Bs.copy(e.ray).recast(e.near),!(ll.containsPoint(Bs.origin)===!1&&(Bs.intersectSphere(ll,Gp)===null||Bs.origin.distanceToSquared(Gp)>(e.far-e.near)**2))&&(Vp.copy(r).invert(),Bs.copy(e.ray).applyMatrix4(Vp),!(i.boundingBox!==null&&Bs.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Bs)))}_computeIntersections(e,t,i){let s;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,f=r.attributes.normal,p=r.groups,m=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,x=p.length;g<x;g++){const d=p[g],u=o[d.materialIndex],w=Math.max(d.start,m.start),M=Math.min(a.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,N=M;E<N;E+=3){const A=a.getX(E),T=a.getX(E+1),I=a.getX(E+2);s=pl(this,u,e,i,c,h,f,A,T,I),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,m.start),x=Math.min(a.count,m.start+m.count);for(let d=g,u=x;d<u;d+=3){const w=a.getX(d),M=a.getX(d+1),E=a.getX(d+2);s=pl(this,o,e,i,c,h,f,w,M,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,x=p.length;g<x;g++){const d=p[g],u=o[d.materialIndex],w=Math.max(d.start,m.start),M=Math.min(l.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,N=M;E<N;E+=3){const A=E,T=E+1,I=E+2;s=pl(this,u,e,i,c,h,f,A,T,I),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let d=g,u=x;d<u;d+=3){const w=d,M=d+1,E=d+2;s=pl(this,o,e,i,c,h,f,w,M,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}}}function DC(n,e,t,i,s,r,o,a){let l;if(e.side===wn?l=i.intersectTriangle(o,r,s,!0,a):l=i.intersectTriangle(s,r,o,e.side===ws,a),l===null)return null;fl.copy(a),fl.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(fl);return c<t.near||c>t.far?null:{distance:c,point:fl.clone(),object:n}}function pl(n,e,t,i,s,r,o,a,l,c){n.getVertexPosition(a,cl),n.getVertexPosition(l,hl),n.getVertexPosition(c,ul);const h=DC(n,e,t,i,cl,hl,ul,Wp);if(h){const f=new re;ei.getBarycoord(Wp,cl,hl,ul,f),s&&(h.uv=ei.getInterpolatedAttribute(s,a,l,c,f,new at)),r&&(h.uv1=ei.getInterpolatedAttribute(r,a,l,c,f,new at)),o&&(h.normal=ei.getInterpolatedAttribute(o,a,l,c,f,new re),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const p={a,b:l,c,normal:new re,materialIndex:0};ei.getNormal(cl,hl,ul,p.normal),h.face=p,h.barycoord=f}return h}class wo extends As{constructor(e=1,t=1,i=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:r,depthSegments:o};const a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],h=[],f=[];let p=0,m=0;g("z","y","x",-1,-1,i,t,e,o,r,0),g("z","y","x",1,-1,i,t,-e,o,r,1),g("x","z","y",1,1,e,i,t,s,o,2),g("x","z","y",1,-1,e,i,-t,s,o,3),g("x","y","z",1,-1,e,t,i,s,r,4),g("x","y","z",-1,-1,e,t,-i,s,r,5),this.setIndex(l),this.setAttribute("position",new yi(c,3)),this.setAttribute("normal",new yi(h,3)),this.setAttribute("uv",new yi(f,2));function g(x,d,u,w,M,E,N,A,T,I,C){const _=E/T,b=N/I,W=E/2,z=N/2,G=A/2,K=T+1,H=I+1;let ie=0,B=0;const ue=new re;for(let me=0;me<H;me++){const Me=me*b-z;for(let Ge=0;Ge<K;Ge++){const Qe=Ge*_-W;ue[x]=Qe*w,ue[d]=Me*M,ue[u]=G,c.push(ue.x,ue.y,ue.z),ue[x]=0,ue[d]=0,ue[u]=A>0?1:-1,h.push(ue.x,ue.y,ue.z),f.push(Ge/T),f.push(1-me/I),ie+=1}}for(let me=0;me<I;me++)for(let Me=0;Me<T;Me++){const Ge=p+Me+K*me,Qe=p+Me+K*(me+1),$=p+(Me+1)+K*(me+1),te=p+(Me+1)+K*me;l.push(Ge,Qe,te),l.push(Qe,$,te),B+=6}a.addGroup(m,B,C),m+=B,p+=ie}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wo(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mo(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const s=n[t][i];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=s.clone():Array.isArray(s)?e[t][i]=s.slice():e[t][i]=s}}return e}function gn(n){const e={};for(let t=0;t<n.length;t++){const i=mo(n[t]);for(const s in i)e[s]=i[s]}return e}function IC(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function s0(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Et.workingColorSpace}const UC={clone:mo,merge:gn};var NC=`void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,FC=`void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`;class Xi extends wa{static get type(){return"ShaderMaterial"}constructor(e){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=NC,this.fragmentShader=FC,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=mo(e.uniforms),this.uniformsGroups=IC(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class r0 extends Tn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=Hi}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const as=new re,$p=new at,qp=new at;class zn extends r0{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ma*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ra*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ma*2*Math.atan(Math.tan(ra*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){as.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(as.x,as.y).multiplyScalar(-e/as.z),as.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(as.x,as.y).multiplyScalar(-e/as.z)}getViewSize(e,t){return this.getViewBounds(e,$p,qp),t.subVectors(qp,$p)}setViewOffset(e,t,i,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ra*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*i/c,s*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ir=-90,Ur=1;class OC extends Tn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new zn(Ir,Ur,e,t);s.layers=this.layers,this.add(s);const r=new zn(Ir,Ur,e,t);r.layers=this.layers,this.add(r);const o=new zn(Ir,Ur,e,t);o.layers=this.layers,this.add(o);const a=new zn(Ir,Ur,e,t);a.layers=this.layers,this.add(a);const l=new zn(Ir,Ur,e,t);l.layers=this.layers,this.add(l);const c=new zn(Ir,Ur,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===Hi)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===jl)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,h]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,r),e.setRenderTarget(i,1,s),e.render(t,o),e.setRenderTarget(i,2,s),e.render(t,a),e.setRenderTarget(i,3,s),e.render(t,l),e.setRenderTarget(i,4,s),e.render(t,c),i.texture.generateMipmaps=x,e.setRenderTarget(i,5,s),e.render(t,h),e.setRenderTarget(f,p,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class o0 extends dn{constructor(e,t,i,s,r,o,a,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:ho,super(e,t,i,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class zC extends sr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new o0(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Vn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={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 <begin_vertex> #include <project_vertex> } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include <common> void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},s=new wo(5,5,5),r=new Xi({name:"CubemapFromEquirect",uniforms:mo(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:wn,blending:gs});r.uniforms.tEquirect.value=t;const o=new Gn(s,r),a=t.minFilter;return t.minFilter===Js&&(t.minFilter=Vn),new OC(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,s){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,s);e.setRenderTarget(r)}}const ph=new re,kC=new re,BC=new ht;class ls{constructor(e=new re(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=ph.subVectors(i,t).cross(kC.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(ph),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||BC.getNormalMatrix(e),s=this.coplanarPoint(ph).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Hs=new ef,ml=new re;class a0{constructor(e=new ls,t=new ls,i=new ls,s=new ls,r=new ls,o=new ls){this.planes=[e,t,i,s,r,o]}set(e,t,i,s,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Hi){const i=this.planes,s=e.elements,r=s[0],o=s[1],a=s[2],l=s[3],c=s[4],h=s[5],f=s[6],p=s[7],m=s[8],g=s[9],x=s[10],d=s[11],u=s[12],w=s[13],M=s[14],E=s[15];if(i[0].setComponents(l-r,p-c,d-m,E-u).normalize(),i[1].setComponents(l+r,p+c,d+m,E+u).normalize(),i[2].setComponents(l+o,p+h,d+g,E+w).normalize(),i[3].setComponents(l-o,p-h,d-g,E-w).normalize(),i[4].setComponents(l-a,p-f,d-x,E-M).normalize(),t===Hi)i[5].setComponents(l+a,p+f,d+x,E+M).normalize();else if(t===jl)i[5].setComponents(a,f,x,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hs)}intersectsSprite(e){return Hs.center.set(0,0,0),Hs.radius=.7071067811865476,Hs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hs)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const s=t[i];if(ml.x=s.normal.x>0?e.max.x:e.min.x,ml.y=s.normal.y>0?e.max.y:e.min.y,ml.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ml)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function l0(){let n=null,e=!1,t=null,i=null;function s(r,o){t(r,o),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function HC(n){const e=new WeakMap;function t(a,l){const c=a.array,h=a.usage,f=c.byteLength,p=n.createBuffer();n.bindBuffer(l,p),n.bufferData(l,c,h),a.onUploadCallback();let m;if(c instanceof Float32Array)m=n.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=n.SHORT;else if(c instanceof Uint32Array)m=n.UNSIGNED_INT;else if(c instanceof Int32Array)m=n.INT;else if(c instanceof Int8Array)m=n.BYTE;else if(c instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,l,c){const h=l.array,f=l.updateRanges;if(n.bindBuffer(c,a),f.length===0)n.bufferSubData(c,0,h);else{f.sort((m,g)=>m.start-g.start);let p=0;for(let m=1;m<f.length;m++){const g=f[p],x=f[m];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++p,f[p]=x)}f.length=p+1;for(let m=0,g=f.length;m<g;m++){const x=f[m];n.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}class Ta extends As{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,o=t/2,a=Math.floor(i),l=Math.floor(s),c=a+1,h=l+1,f=e/a,p=t/l,m=[],g=[],x=[],d=[];for(let u=0;u<h;u++){const w=u*p-o;for(let M=0;M<c;M++){const E=M*f-r;g.push(E,-w,0),x.push(0,0,1),d.push(M/a),d.push(1-u/l)}}for(let u=0;u<l;u++)for(let w=0;w<a;w++){const M=w+c*u,E=w+c*(u+1),N=w+1+c*(u+1),A=w+1+c*u;m.push(M,E,A),m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new yi(g,3)),this.setAttribute("normal",new yi(x,3)),this.setAttribute("uv",new yi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ta(e.width,e.height,e.widthSegments,e.heightSegments)}}var VC=`#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`,GC=`#ifdef USE_ALPHAHASH const float ALPHA_HASH_SCALE = 0.05; float hash2D( vec2 value ) { return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); } float hash3D( vec3 value ) { return hash2D( vec2( hash2D( value.xy ), value.z ) ); } float getAlphaHashThreshold( vec3 position ) { float maxDeriv = max( length( dFdx( position.xyz ) ), length( dFdy( position.xyz ) ) ); float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); vec2 pixScales = vec2( exp2( floor( log2( pixScale ) ) ), exp2( ceil( log2( pixScale ) ) ) ); vec2 alpha = vec2( hash3D( floor( pixScales.x * position.xyz ) ), hash3D( floor( pixScales.y * position.xyz ) ) ); float lerpFactor = fract( log2( pixScale ) ); float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; float a = min( lerpFactor, 1.0 - lerpFactor ); vec3 cases = vec3( x * x / ( 2.0 * a * ( 1.0 - a ) ), ( x - 0.5 * a ) / ( 1.0 - a ), 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) ); float threshold = ( x < ( 1.0 - a ) ) ? ( ( x < a ) ? cases.x : cases.y ) : cases.z; return clamp( threshold , 1.0e-6, 1.0 ); } #endif`,WC=`#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`,$C=`#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,qC=`#ifdef USE_ALPHATEST #ifdef ALPHA_TO_COVERAGE diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); if ( diffuseColor.a == 0.0 ) discard; #else if ( diffuseColor.a < alphaTest ) discard; #endif #endif`,XC=`#ifdef USE_ALPHATEST uniform float alphaTest; #endif`,YC=`#ifdef USE_AOMAP float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_CLEARCOAT ) clearcoatSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_SHEEN ) sheenSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif #endif`,QC=`#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`,jC=`#ifdef USE_BATCHING #if ! defined( GL_ANGLE_multi_draw ) #define gl_DrawID _gl_DrawID uniform int _gl_DrawID; #endif uniform highp sampler2D batchingTexture; uniform highp usampler2D batchingIdTexture; mat4 getBatchingMatrix( const in float i ) { int size = textureSize( batchingTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } float getIndirectIndex( const in int i ) { int size = textureSize( batchingIdTexture, 0 ).x; int x = i % size; int y = i / size; return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); } #endif #ifdef USE_BATCHING_COLOR uniform sampler2D batchingColorTexture; vec3 getBatchingColor( const in float i ) { int size = textureSize( batchingColorTexture, 0 ).x; int j = int( i ); int x = j % size; int y = j / size; return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb; } #endif`,ZC=`#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); #endif`,KC=`vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`,JC=`vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`,eR=`float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } // validated`,tR=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,nR=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vBumpMapUv ); vec2 dSTdy = dFdy( vBumpMapUv ); float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,iR=`#if NUM_CLIPPING_PLANES > 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`,sR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,rR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,oR=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,aR=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,lR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,cR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,hR=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,uR=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } 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`,dR=`#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`,fR=`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`,pR=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,mR=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,_R=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,gR=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,vR="gl_FragColor = linearToOutputTexel( gl_FragColor );",xR=`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 ); }`,MR=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,ER=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,yR=`#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`,SR=`#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`,bR=`#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`,wR=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,TR=`#ifdef USE_FOG varying float vFogDepth; #endif`,AR=`#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`,CR=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,RR=`#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 }`,PR=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,LR=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,DR=`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`,IR=`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`,UR=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,NR=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,FR=`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`,OR=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,zR=`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`,kR=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,BR=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,HR=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,VR=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,GR=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,WR=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,$R=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,qR=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,XR=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,YR=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,QR=`#ifdef USE_MAP uniform sampler2D map; #endif`,jR=`#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`,ZR=`#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`,KR=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,JR=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,eP=`#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`,tP=`#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`,nP=`#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`,iP=`#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`,sP=`#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`,rP=`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;`,oP=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,aP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,lP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,cP=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,hP=`#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`,uP=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,dP=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,fP=`#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`,pP=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,mP=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_P=`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 ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,gP=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,vP=`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;`,xP=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,MP=`#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`,EP=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,yP=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,SP=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,bP=`#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`,wP=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,TP=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,AP=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,CP=`#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`,RP=`#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`,PP=`#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`,LP=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,DP=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,IP=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,UP=`#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; }`,NP=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,FP=`#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`,OP=`#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`,zP=`#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`,kP=`#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`,BP=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const HP=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,VP=`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 <tonemapping_fragment> #include <colorspace_fragment> }`,GP=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,WP=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include <cube_uv_reflection_fragment> void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include <tonemapping_fragment> #include <colorspace_fragment> }`,$P=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,qP=`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 <tonemapping_fragment> #include <colorspace_fragment> }`,XP=`#include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> varying vec2 vHighPrecisionZW; void main() { #include <uv_vertex> #include <batching_vertex> #include <skinbase_vertex> #include <morphinstance_vertex> #ifdef USE_DISPLACEMENTMAP #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vHighPrecisionZW = gl_Position.zw; }`,YP=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include <common> #include <packing> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include <clipping_planes_fragment> #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <logdepthbuf_fragment> float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #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 }`,QP=`#define DISTANCE varying vec3 vWorldPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <batching_vertex> #include <skinbase_vertex> #include <morphinstance_vertex> #ifdef USE_DISPLACEMENTMAP #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <worldpos_vertex> #include <clipping_planes_vertex> vWorldPosition = worldPosition.xyz; }`,jP=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include <common> #include <packing> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <clipping_planes_pars_fragment> void main () { vec4 diffuseColor = vec4( 1.0 ); #include <clipping_planes_fragment> #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,ZP=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> }`,KP=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include <common> void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include <tonemapping_fragment> #include <colorspace_fragment> }`,JP=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include <common> #include <uv_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { vLineDistance = scale * lineDistance; #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> }`,eL=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include <common> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> }`,tL=`#include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #endif #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <worldpos_vertex> #include <envmap_vertex> #include <fog_vertex> }`,nL=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include <common> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> 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 <aomap_fragment> reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,iL=`#define LAMBERT varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <envmap_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,sL=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_lambert_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_lambert_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,rL=`#define MATCAP varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <color_pars_vertex> #include <displacementmap_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> vViewPosition = - mvPosition.xyz; }`,oL=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include <common> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <normal_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> 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 <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,aL=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,lL=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include <packing> #include <uv_pars_fragment> #include <normal_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include <clipping_planes_fragment> #include <logdepthbuf_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,cL=`#define PHONG varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <envmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <envmap_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,hL=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <envmap_common_pars_fragment> #include <envmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_phong_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <specularmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <specularmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_phong_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include <envmap_fragment> #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,uL=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,dL=`#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 <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <iridescence_fragment> #include <cube_uv_reflection_fragment> #include <envmap_common_pars_fragment> #include <envmap_physical_pars_fragment> #include <fog_pars_fragment> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_physical_pars_fragment> #include <transmission_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <clearcoat_pars_fragment> #include <iridescence_pars_fragment> #include <roughnessmap_pars_fragment> #include <metalnessmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <roughnessmap_fragment> #include <metalnessmap_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <clearcoat_normal_fragment_begin> #include <clearcoat_normal_fragment_maps> #include <emissivemap_fragment> #include <lights_physical_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include <transmission_fragment> vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,fL=`#define TOON varying vec3 vViewPosition; #include <common> #include <batching_pars_vertex> #include <uv_pars_vertex> #include <displacementmap_pars_vertex> #include <color_pars_vertex> #include <fog_pars_vertex> #include <normal_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> #include <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <batching_vertex> #include <beginnormal_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <normal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <displacementmap_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <clipping_planes_vertex> vViewPosition = - mvPosition.xyz; #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,pL=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include <common> #include <packing> #include <dithering_pars_fragment> #include <color_pars_fragment> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <aomap_pars_fragment> #include <lightmap_pars_fragment> #include <emissivemap_pars_fragment> #include <gradientmap_pars_fragment> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <normal_pars_fragment> #include <lights_toon_pars_fragment> #include <shadowmap_pars_fragment> #include <bumpmap_pars_fragment> #include <normalmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include <logdepthbuf_fragment> #include <map_fragment> #include <color_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> #include <normal_fragment_begin> #include <normal_fragment_maps> #include <emissivemap_fragment> #include <lights_toon_fragment> #include <lights_fragment_begin> #include <lights_fragment_maps> #include <lights_fragment_end> #include <aomap_fragment> vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> #include <dithering_fragment> }`,mL=`uniform float size; uniform float scale; #include <common> #include <color_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> #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 <color_vertex> #include <morphinstance_vertex> #include <morphcolor_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <project_vertex> gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <worldpos_vertex> #include <fog_vertex> }`,_L=`uniform vec3 diffuse; uniform float opacity; #include <common> #include <color_pars_fragment> #include <map_particle_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_particle_fragment> #include <color_fragment> #include <alphatest_fragment> #include <alphahash_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> #include <premultiplied_alpha_fragment> }`,gL=`#include <common> #include <batching_pars_vertex> #include <fog_pars_vertex> #include <morphtarget_pars_vertex> #include <skinning_pars_vertex> #include <logdepthbuf_pars_vertex> #include <shadowmap_pars_vertex> void main() { #include <batching_vertex> #include <beginnormal_vertex> #include <morphinstance_vertex> #include <morphnormal_vertex> #include <skinbase_vertex> #include <skinnormal_vertex> #include <defaultnormal_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <project_vertex> #include <logdepthbuf_vertex> #include <worldpos_vertex> #include <shadowmap_vertex> #include <fog_vertex> }`,vL=`uniform vec3 color; uniform float opacity; #include <common> #include <packing> #include <fog_pars_fragment> #include <bsdfs> #include <lights_pars_begin> #include <logdepthbuf_pars_fragment> #include <shadowmap_pars_fragment> #include <shadowmask_pars_fragment> void main() { #include <logdepthbuf_fragment> gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> }`,xL=`uniform float rotation; uniform vec2 center; #include <common> #include <uv_pars_vertex> #include <fog_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> void main() { #include <uv_vertex> 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 <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <fog_vertex> }`,ML=`uniform vec3 diffuse; uniform float opacity; #include <common> #include <uv_pars_fragment> #include <map_pars_fragment> #include <alphamap_pars_fragment> #include <alphatest_pars_fragment> #include <alphahash_pars_fragment> #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment> void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include <clipping_planes_fragment> vec3 outgoingLight = vec3( 0.0 ); #include <logdepthbuf_fragment> #include <map_fragment> #include <alphamap_fragment> #include <alphatest_fragment> #include <alphahash_fragment> outgoingLight = diffuseColor.rgb; #include <opaque_fragment> #include <tonemapping_fragment> #include <colorspace_fragment> #include <fog_fragment> }`,ft={alphahash_fragment:VC,alphahash_pars_fragment:GC,alphamap_fragment:WC,alphamap_pars_fragment:$C,alphatest_fragment:qC,alphatest_pars_fragment:XC,aomap_fragment:YC,aomap_pars_fragment:QC,batching_pars_vertex:jC,batching_vertex:ZC,begin_vertex:KC,beginnormal_vertex:JC,bsdfs:eR,iridescence_fragment:tR,bumpmap_pars_fragment:nR,clipping_planes_fragment:iR,clipping_planes_pars_fragment:sR,clipping_planes_pars_vertex:rR,clipping_planes_vertex:oR,color_fragment:aR,color_pars_fragment:lR,color_pars_vertex:cR,color_vertex:hR,common:uR,cube_uv_reflection_fragment:dR,defaultnormal_vertex:fR,displacementmap_pars_vertex:pR,displacementmap_vertex:mR,emissivemap_fragment:_R,emissivemap_pars_fragment:gR,colorspace_fragment:vR,colorspace_pars_fragment:xR,envmap_fragment:MR,envmap_common_pars_fragment:ER,envmap_pars_fragment:yR,envmap_pars_vertex:SR,envmap_physical_pars_fragment:UR,envmap_vertex:bR,fog_vertex:wR,fog_pars_vertex:TR,fog_fragment:AR,fog_pars_fragment:CR,gradientmap_pars_fragment:RR,lightmap_pars_fragment:PR,lights_lambert_fragment:LR,lights_lambert_pars_fragment:DR,lights_pars_begin:IR,lights_toon_fragment:NR,lights_toon_pars_fragment:FR,lights_phong_fragment:OR,lights_phong_pars_fragment:zR,lights_physical_fragment:kR,lights_physical_pars_fragment:BR,lights_fragment_begin:HR,lights_fragment_maps:VR,lights_fragment_end:GR,logdepthbuf_fragment:WR,logdepthbuf_pars_fragment:$R,logdepthbuf_pars_vertex:qR,logdepthbuf_vertex:XR,map_fragment:YR,map_pars_fragment:QR,map_particle_fragment:jR,map_particle_pars_fragment:ZR,metalnessmap_fragment:KR,metalnessmap_pars_fragment:JR,morphinstance_vertex:eP,morphcolor_vertex:tP,morphnormal_vertex:nP,morphtarget_pars_vertex:iP,morphtarget_vertex:sP,normal_fragment_begin:rP,normal_fragment_maps:oP,normal_pars_fragment:aP,normal_pars_vertex:lP,normal_vertex:cP,normalmap_pars_fragment:hP,clearcoat_normal_fragment_begin:uP,clearcoat_normal_fragment_maps:dP,clearcoat_pars_fragment:fP,iridescence_pars_fragment:pP,opaque_fragment:mP,packing:_P,premultiplied_alpha_fragment:gP,project_vertex:vP,dithering_fragment:xP,dithering_pars_fragment:MP,roughnessmap_fragment:EP,roughnessmap_pars_fragment:yP,shadowmap_pars_fragment:SP,shadowmap_pars_vertex:bP,shadowmap_vertex:wP,shadowmask_pars_fragment:TP,skinbase_vertex:AP,skinning_pars_vertex:CP,skinning_vertex:RP,skinnormal_vertex:PP,specularmap_fragment:LP,specularmap_pars_fragment:DP,tonemapping_fragment:IP,tonemapping_pars_fragment:UP,transmission_fragment:NP,transmission_pars_fragment:FP,uv_pars_fragment:OP,uv_pars_vertex:zP,uv_vertex:kP,worldpos_vertex:BP,background_vert:HP,background_frag:VP,backgroundCube_vert:GP,backgroundCube_frag:WP,cube_vert:$P,cube_frag:qP,depth_vert:XP,depth_frag:YP,distanceRGBA_vert:QP,distanceRGBA_frag:jP,equirect_vert:ZP,equirect_frag:KP,linedashed_vert:JP,linedashed_frag:eL,meshbasic_vert:tL,meshbasic_frag:nL,meshlambert_vert:iL,meshlambert_frag:sL,meshmatcap_vert:rL,meshmatcap_frag:oL,meshnormal_vert:aL,meshnormal_frag:lL,meshphong_vert:cL,meshphong_frag:hL,meshphysical_vert:uL,meshphysical_frag:dL,meshtoon_vert:fL,meshtoon_frag:pL,points_vert:mL,points_frag:_L,shadow_vert:gL,shadow_frag:vL,sprite_vert:xL,sprite_frag:ML},ke={common:{diffuse:{value:new bt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ht}},envmap:{envMap:{value:null},envMapRotation:{value:new ht},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ht}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ht}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ht},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ht},normalScale:{value:new at(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ht},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ht}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ht}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ht}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new bt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new bt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0},uvTransform:{value:new ht}},sprite:{diffuse:{value:new bt(16777215)},opacity:{value:1},center:{value:new at(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}}},mi={basic:{uniforms:gn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.fog]),vertexShader:ft.meshbasic_vert,fragmentShader:ft.meshbasic_frag},lambert:{uniforms:gn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new bt(0)}}]),vertexShader:ft.meshlambert_vert,fragmentShader:ft.meshlambert_frag},phong:{uniforms:gn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new bt(0)},specular:{value:new bt(1118481)},shininess:{value:30}}]),vertexShader:ft.meshphong_vert,fragmentShader:ft.meshphong_frag},standard:{uniforms:gn([ke.common,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.roughnessmap,ke.metalnessmap,ke.fog,ke.lights,{emissive:{value:new bt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ft.meshphysical_vert,fragmentShader:ft.meshphysical_frag},toon:{uniforms:gn([ke.common,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.gradientmap,ke.fog,ke.lights,{emissive:{value:new bt(0)}}]),vertexShader:ft.meshtoon_vert,fragmentShader:ft.meshtoon_frag},matcap:{uniforms:gn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,{matcap:{value:null}}]),vertexShader:ft.meshmatcap_vert,fragmentShader:ft.meshmatcap_frag},points:{uniforms:gn([ke.points,ke.fog]),vertexShader:ft.points_vert,fragmentShader:ft.points_frag},dashed:{uniforms:gn([ke.common,ke.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ft.linedashed_vert,fragmentShader:ft.linedashed_frag},depth:{uniforms:gn([ke.common,ke.displacementmap]),vertexShader:ft.depth_vert,fragmentShader:ft.depth_frag},normal:{uniforms:gn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,{opacity:{value:1}}]),vertexShader:ft.meshnormal_vert,fragmentShader:ft.meshnormal_frag},sprite:{uniforms:gn([ke.sprite,ke.fog]),vertexShader:ft.sprite_vert,fragmentShader:ft.sprite_frag},background:{uniforms:{uvTransform:{value:new ht},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ft.background_vert,fragmentShader:ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ht}},vertexShader:ft.backgroundCube_vert,fragmentShader:ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ft.cube_vert,fragmentShader:ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ft.equirect_vert,fragmentShader:ft.equirect_frag},distanceRGBA:{uniforms:gn([ke.common,ke.displacementmap,{referencePosition:{value:new re},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ft.distanceRGBA_vert,fragmentShader:ft.distanceRGBA_frag},shadow:{uniforms:gn([ke.lights,ke.fog,{color:{value:new bt(0)},opacity:{value:1}}]),vertexShader:ft.shadow_vert,fragmentShader:ft.shadow_frag}};mi.physical={uniforms:gn([mi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ht},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ht},clearcoatNormalScale:{value:new at(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ht},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ht},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ht},sheen:{value:0},sheenColor:{value:new bt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ht},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ht},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ht},transmissionSamplerSize:{value:new at},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ht},attenuationDistance:{value:0},attenuationColor:{value:new bt(0)},specularColor:{value:new bt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ht},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ht},anisotropyVector:{value:new at},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ht}}]),vertexShader:ft.meshphysical_vert,fragmentShader:ft.meshphysical_frag};const _l={r:0,b:0,g:0},Vs=new bi,EL=new Ft;function yL(n,e,t,i,s,r,o){const a=new bt(0);let l=r===!0?0:1,c,h,f=null,p=0,m=null;function g(w){let M=w.isScene===!0?w.background:null;return M&&M.isTexture&&(M=(w.backgroundBlurriness>0?t:e).get(M)),M}function x(w){let M=!1;const E=g(w);E===null?u(a,l):E&&E.isColor&&(u(E,1),M=!0);const N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||M)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function d(w,M){const E=g(M);E&&(E.isCubeTexture||E.mapping===uc)?(h===void 0&&(h=new Gn(new wo(1,1,1),new Xi({name:"BackgroundCubeMaterial",uniforms:mo(mi.backgroundCube.uniforms),vertexShader:mi.backgroundCube.vertexShader,fragmentShader:mi.backgroundCube.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(N,A,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),Vs.copy(M.backgroundRotation),Vs.x*=-1,Vs.y*=-1,Vs.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Vs.y*=-1,Vs.z*=-1),h.material.uniforms.envMap.value=E,h.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(EL.makeRotationFromEuler(Vs)),h.material.toneMapped=Et.getTransfer(E.colorSpace)!==At,(f!==E||p!==E.version||m!==n.toneMapping)&&(h.material.needsUpdate=!0,f=E,p=E.version,m=n.toneMapping),h.layers.enableAll(),w.unshift(h,h.geometry,h.material,0,0,null)):E&&E.isTexture&&(c===void 0&&(c=new Gn(new Ta(2,2),new Xi({name:"BackgroundMaterial",uniforms:mo(mi.background.uniforms),vertexShader:mi.background.vertexShader,fragmentShader:mi.background.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=E,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.toneMapped=Et.getTransfer(E.colorSpace)!==At,E.matrixAutoUpdate===!0&&E.updateMatrix(),c.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||p!==E.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,f=E,p=E.version,m=n.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function u(w,M){w.getRGB(_l,s0(n)),i.buffers.color.setClear(_l.r,_l.g,_l.b,M,o)}return{getClearColor:function(){return a},setClearColor:function(w,M=1){a.set(w),l=M,u(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,u(a,l)},render:x,addToRenderList:d}}function SL(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=p(null);let r=s,o=!1;function a(_,b,W,z,G){let K=!1;const H=f(z,W,b);r!==H&&(r=H,c(r.object)),K=m(_,z,W,G),K&&g(_,z,W,G),G!==null&&e.update(G,n.ELEMENT_ARRAY_BUFFER),(K||o)&&(o=!1,E(_,b,W,z),G!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(G).buffer))}function l(){return n.createVertexArray()}function c(_){return n.bindVertexArray(_)}function h(_){return n.deleteVertexArray(_)}function f(_,b,W){const z=W.wireframe===!0;let G=i[_.id];G===void 0&&(G={},i[_.id]=G);let K=G[b.id];K===void 0&&(K={},G[b.id]=K);let H=K[z];return H===void 0&&(H=p(l()),K[z]=H),H}function p(_){const b=[],W=[],z=[];for(let G=0;G<t;G++)b[G]=0,W[G]=0,z[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:W,attributeDivisors:z,object:_,attributes:{},index:null}}function m(_,b,W,z){const G=r.attributes,K=b.attributes;let H=0;const ie=W.getAttributes();for(const B in ie)if(ie[B].location>=0){const me=G[B];let Me=K[B];if(Me===void 0&&(B==="instanceMatrix"&&_.instanceMatrix&&(Me=_.instanceMatrix),B==="instanceColor"&&_.instanceColor&&(Me=_.instanceColor)),me===void 0||me.attribute!==Me||Me&&me.data!==Me.data)return!0;H++}return r.attributesNum!==H||r.index!==z}function g(_,b,W,z){const G={},K=b.attributes;let H=0;const ie=W.getAttributes();for(const B in ie)if(ie[B].location>=0){let me=K[B];me===void 0&&(B==="instanceMatrix"&&_.instanceMatrix&&(me=_.instanceMatrix),B==="instanceColor"&&_.instanceColor&&(me=_.instanceColor));const Me={};Me.attribute=me,me&&me.data&&(Me.data=me.data),G[B]=Me,H++}r.attributes=G,r.attributesNum=H,r.index=z}function x(){const _=r.newAttributes;for(let b=0,W=_.length;b<W;b++)_[b]=0}function d(_){u(_,0)}function u(_,b){const W=r.newAttributes,z=r.enabledAttributes,G=r.attributeDivisors;W[_]=1,z[_]===0&&(n.enableVertexAttribArray(_),z[_]=1),G[_]!==b&&(n.vertexAttribDivisor(_,b),G[_]=b)}function w(){const _=r.newAttributes,b=r.enabledAttributes;for(let W=0,z=b.length;W<z;W++)b[W]!==_[W]&&(n.disableVertexAttribArray(W),b[W]=0)}function M(_,b,W,z,G,K,H){H===!0?n.vertexAttribIPointer(_,b,W,G,K):n.vertexAttribPointer(_,b,W,z,G,K)}function E(_,b,W,z){x();const G=z.attributes,K=W.getAttributes(),H=b.defaultAttributeValues;for(const ie in K){const B=K[ie];if(B.location>=0){let ue=G[ie];if(ue===void 0&&(ie==="instanceMatrix"&&_.instanceMatrix&&(ue=_.instanceMatrix),ie==="instanceColor"&&_.instanceColor&&(ue=_.instanceColor)),ue!==void 0){const me=ue.normalized,Me=ue.itemSize,Ge=e.get(ue);if(Ge===void 0)continue;const Qe=Ge.buffer,$=Ge.type,te=Ge.bytesPerElement,ve=$===n.INT||$===n.UNSIGNED_INT||ue.gpuType===Xd;if(ue.isInterleavedBufferAttribute){const de=ue.data,Pe=de.stride,Le=ue.offset;if(de.isInstancedInterleavedBuffer){for(let He=0;He<B.locationSize;He++)u(B.location+He,de.meshPerAttribute);_.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let He=0;He<B.locationSize;He++)d(B.location+He);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let He=0;He<B.locationSize;He++)M(B.location+He,Me/B.locationSize,$,me,Pe*te,(Le+Me/B.locationSize*He)*te,ve)}else{if(ue.isInstancedBufferAttribute){for(let de=0;de<B.locationSize;de++)u(B.location+de,ue.meshPerAttribute);_.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let de=0;de<B.locationSize;de++)d(B.location+de);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let de=0;de<B.locationSize;de++)M(B.location+de,Me/B.locationSize,$,me,Me*te,Me/B.locationSize*de*te,ve)}}else if(H!==void 0){const me=H[ie];if(me!==void 0)switch(me.length){case 2:n.vertexAttrib2fv(B.location,me);break;case 3:n.vertexAttrib3fv(B.location,me);break;case 4:n.vertexAttrib4fv(B.location,me);break;default:n.vertexAttrib1fv(B.location,me)}}}}w()}function N(){I();for(const _ in i){const b=i[_];for(const W in b){const z=b[W];for(const G in z)h(z[G].object),delete z[G];delete b[W]}delete i[_]}}function A(_){if(i[_.id]===void 0)return;const b=i[_.id];for(const W in b){const z=b[W];for(const G in z)h(z[G].object),delete z[G];delete b[W]}delete i[_.id]}function T(_){for(const b in i){const W=i[b];if(W[_.id]===void 0)continue;const z=W[_.id];for(const G in z)h(z[G].object),delete z[G];delete W[_.id]}}function I(){C(),o=!0,r!==s&&(r=s,c(r.object))}function C(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:I,resetDefaultState:C,dispose:N,releaseStatesOfGeometry:A,releaseStatesOfProgram:T,initAttributes:x,enableAttribute:d,disableUnusedAttributes:w}}function bL(n,e,t){let i;function s(c){i=c}function r(c,h){n.drawArrays(i,c,h),t.update(h,i,1)}function o(c,h,f){f!==0&&(n.drawArraysInstanced(i,c,h,f),t.update(h,i,f))}function a(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,f);let m=0;for(let g=0;g<f;g++)m+=h[g];t.update(m,i,1)}function l(c,h,f,p){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<c.length;g++)o(c[g],h[g],p[g]);else{m.multiDrawArraysInstancedWEBGL(i,c,0,h,0,p,0,f);let g=0;for(let x=0;x<f;x++)g+=h[x]*p[x];t.update(g,i,1)}}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function wL(n,e,t,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");s=n.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(T){return!(T!==ni&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(T){const I=T===Sa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==qi&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Bi&&!I)}function l(T){if(T==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,p=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),d=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),u=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),M=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=g>0,A=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reverseDepthBuffer:p,maxTextures:m,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:d,maxAttributes:u,maxVertexUniforms:w,maxVaryings:M,maxFragmentUniforms:E,vertexTextures:N,maxSamples:A}}function TL(n){const e=this;let t=null,i=0,s=!1,r=!1;const o=new ls,a=new ht,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||i!==0||s;return s=p,i=f.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,p){t=h(f,p,0)},this.setState=function(f,p,m){const g=f.clippingPlanes,x=f.clipIntersection,d=f.clipShadows,u=n.get(f);if(!s||g===null||g.length===0||r&&!d)r?h(null):c();else{const w=r?0:i,M=w*4;let E=u.clippingState||null;l.value=E,E=h(g,p,M,m);for(let N=0;N!==M;++N)E[N]=t[N];u.clippingState=E,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(f,p,m,g){const x=f!==null?f.length:0;let d=null;if(x!==0){if(d=l.value,g!==!0||d===null){const u=m+x*4,w=p.matrixWorldInverse;a.getNormalMatrix(w),(d===null||d.length<u)&&(d=new Float32Array(u));for(let M=0,E=m;M!==x;++M,E+=4)o.copy(f[M]).applyMatrix4(w,a),o.normal.toArray(d,E),d[E+3]=o.constant}l.value=d,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,d}}function AL(n){let e=new WeakMap;function t(o,a){return a===Nu?o.mapping=ho:a===Fu&&(o.mapping=uo),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Nu||a===Fu)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new zC(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){const a=o.target;a.removeEventListener("dispose",s);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}class CL extends r0{constructor(e=-1,t=1,i=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const qr=4,Xp=[.125,.215,.35,.446,.526,.582],js=20,mh=new CL,Yp=new bt;let _h=null,gh=0,vh=0,xh=!1;const qs=(1+Math.sqrt(5))/2,Nr=1/qs,Qp=[new re(-qs,Nr,0),new re(qs,Nr,0),new re(-Nr,0,qs),new re(Nr,0,qs),new re(0,qs,-Nr),new re(0,qs,Nr),new re(-1,1,-1),new re(1,1,-1),new re(-1,1,1),new re(1,1,1)];class jp{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,s=100){_h=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),xh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Jp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Kp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(_h,gh,vh),this._renderer.xr.enabled=xh,e.scissorTest=!1,gl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ho||e.mapping===uo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_h=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),xh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Vn,minFilter:Vn,generateMipmaps:!1,type:Sa,format:ni,colorSpace:So,depthBuffer:!1},s=Zp(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Zp(e,t,i);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=RL(r)),this._blurMaterial=PL(r,e,t)}return s}_compileMaterial(e){const t=new Gn(this._lodPlanes[0],e);this._renderer.compile(t,mh)}_sceneToCubeUV(e,t,i,s){const a=new zn(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(Yp),h.toneMapping=vs,h.autoClear=!1;const m=new sf({name:"PMREM.Background",side:wn,depthWrite:!1,depthTest:!1}),g=new Gn(new wo,m);let x=!1;const d=e.background;d?d.isColor&&(m.color.copy(d),e.background=null,x=!0):(m.color.copy(Yp),x=!0);for(let u=0;u<6;u++){const w=u%3;w===0?(a.up.set(0,l[u],0),a.lookAt(c[u],0,0)):w===1?(a.up.set(0,0,l[u]),a.lookAt(0,c[u],0)):(a.up.set(0,l[u],0),a.lookAt(0,0,c[u]));const M=this._cubeSize;gl(s,w*M,u>2?M:0,M,M),h.setRenderTarget(s),x&&h.render(g,a),h.render(e,a)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=p,h.autoClear=f,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ho||e.mapping===uo;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Jp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Kp());const r=s?this._cubemapMaterial:this._equirectMaterial,o=new Gn(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;gl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,mh)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Qp[(s-r-1)%Qp.length];this._blur(e,r-1,r,o,a)}t.autoClear=i}_blur(e,t,i,s,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,s,"latitudinal",r),this._halfBlur(o,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new Gn(this._lodPlanes[s],c),p=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*js-1),x=r/g,d=isFinite(r)?1+Math.floor(h*x):js;d>js&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${js}`);const u=[];let w=0;for(let T=0;T<js;++T){const I=T/x,C=Math.exp(-I*I/2);u.push(C),T===0?w+=C:T<d&&(w+=2*C)}for(let T=0;T<u.length;T++)u[T]=u[T]/w;p.envMap.value=e.texture,p.samples.value=d,p.weights.value=u,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:M}=this;p.dTheta.value=g,p.mipInt.value=M-i;const E=this._sizeLods[s],N=3*E*(s>M-qr?s-M+qr:0),A=4*(this._cubeSize-E);gl(t,N,A,3*E,2*E),l.setRenderTarget(t),l.render(f,mh)}}function RL(n){const e=[],t=[],i=[];let s=n;const r=n-qr+1+Xp.length;for(let o=0;o<r;o++){const a=Math.pow(2,s);t.push(a);let l=1/a;o>n-qr?l=Xp[o-n+qr-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),h=-c,f=1+c,p=[h,h,f,h,f,f,h,h,f,f,h,f],m=6,g=6,x=3,d=2,u=1,w=new Float32Array(x*g*m),M=new Float32Array(d*g*m),E=new Float32Array(u*g*m);for(let A=0;A<m;A++){const T=A%3*2/3-1,I=A>2?0:-1,C=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];w.set(C,x*g*A),M.set(p,d*g*A);const _=[A,A,A,A,A,A];E.set(_,u*g*A)}const N=new As;N.setAttribute("position",new Ei(w,x)),N.setAttribute("uv",new Ei(M,d)),N.setAttribute("faceIndex",new Ei(E,u)),e.push(N),s>qr&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Zp(n,e,t){const i=new sr(n,e,t);return i.texture.mapping=uc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function gl(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function PL(n,e,t){const i=new Float32Array(js),s=new re(0,1,0);return new Xi({name:"SphericalGaussianBlur",defines:{n:js,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:rf(),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 <cube_uv_reflection_fragment> 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:gs,depthTest:!1,depthWrite:!1})}function Kp(){return new Xi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:rf(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include <common> void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:gs,depthTest:!1,depthWrite:!1})}function Jp(){return new Xi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:rf(),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:gs,depthTest:!1,depthWrite:!1})}function rf(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function LL(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===Nu||l===Fu,h=l===ho||l===uo;if(c||h){let f=e.get(a);const p=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==p)return t===null&&(t=new jp(n)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),f.texture;if(f!==void 0)return f.texture;{const m=a.image;return c&&m&&m.height>0||h&&m&&s(m)?(t===null&&(t=new jp(n)),f=c?t.fromEquirectangular(a):t.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),a.addEventListener("dispose",r),f.texture):null}}}return a}function s(a){let l=0;const c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function DL(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let s;switch(i){case"WEBGL_depth_texture":s=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=n.getExtension(i)}return e[i]=s,s}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const s=t(i);return s===null&&Wo("THREE.WebGLRenderer: "+i+" extension not supported."),s}}}function IL(n,e,t,i){const s={},r=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const g in p.attributes)e.remove(p.attributes[g]);for(const g in p.morphAttributes){const x=p.morphAttributes[g];for(let d=0,u=x.length;d<u;d++)e.remove(x[d])}p.removeEventListener("dispose",o),delete s[p.id];const m=r.get(p);m&&(e.remove(m),r.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function a(f,p){return s[p.id]===!0||(p.addEventListener("dispose",o),s[p.id]=!0,t.memory.geometries++),p}function l(f){const p=f.attributes;for(const g in p)e.update(p[g],n.ARRAY_BUFFER);const m=f.morphAttributes;for(const g in m){const x=m[g];for(let d=0,u=x.length;d<u;d++)e.update(x[d],n.ARRAY_BUFFER)}}function c(f){const p=[],m=f.index,g=f.attributes.position;let x=0;if(m!==null){const w=m.array;x=m.version;for(let M=0,E=w.length;M<E;M+=3){const N=w[M+0],A=w[M+1],T=w[M+2];p.push(N,A,A,T,T,N)}}else if(g!==void 0){const w=g.array;x=g.version;for(let M=0,E=w.length/3-1;M<E;M+=3){const N=M+0,A=M+1,T=M+2;p.push(N,A,A,T,T,N)}}else return;const d=new(Kv(p)?i0:n0)(p,1);d.version=x;const u=r.get(f);u&&e.remove(u),r.set(f,d)}function h(f){const p=r.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&c(f)}else c(f);return r.get(f)}return{get:a,update:l,getWireframeAttribute:h}}function UL(n,e,t){let i;function s(p){i=p}let r,o;function a(p){r=p.type,o=p.bytesPerElement}function l(p,m){n.drawElements(i,m,r,p*o),t.update(m,i,1)}function c(p,m,g){g!==0&&(n.drawElementsInstanced(i,m,r,p*o,g),t.update(m,i,g))}function h(p,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,m,0,r,p,0,g);let d=0;for(let u=0;u<g;u++)d+=m[u];t.update(d,i,1)}function f(p,m,g,x){if(g===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let u=0;u<p.length;u++)c(p[u]/o,m[u],x[u]);else{d.multiDrawElementsInstancedWEBGL(i,m,0,r,p,0,x,0,g);let u=0;for(let w=0;w<g;w++)u+=m[w]*x[w];t.update(u,i,1)}}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function NL(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(r/3);break;case n.LINES:t.lines+=a*(r/2);break;case n.LINE_STRIP:t.lines+=a*(r-1);break;case n.LINE_LOOP:t.lines+=a*r;break;case n.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:i}}function FL(n,e,t){const i=new WeakMap,s=new zt;function r(o,a,l){const c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=h!==void 0?h.length:0;let p=i.get(a);if(p===void 0||p.count!==f){let C=function(){T.dispose(),i.delete(a),a.removeEventListener("dispose",C)};p!==void 0&&p.texture.dispose();const m=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,d=a.morphAttributes.position||[],u=a.morphAttributes.normal||[],w=a.morphAttributes.color||[];let M=0;m===!0&&(M=1),g===!0&&(M=2),x===!0&&(M=3);let E=a.attributes.position.count*M,N=1;E>e.maxTextureSize&&(N=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*N*4*f),T=new e0(A,E,N,f);T.type=Bi,T.needsUpdate=!0;const I=M*4;for(let _=0;_<f;_++){const b=d[_],W=u[_],z=w[_],G=E*N*4*_;for(let K=0;K<b.count;K++){const H=K*I;m===!0&&(s.fromBufferAttribute(b,K),A[G+H+0]=s.x,A[G+H+1]=s.y,A[G+H+2]=s.z,A[G+H+3]=0),g===!0&&(s.fromBufferAttribute(W,K),A[G+H+4]=s.x,A[G+H+5]=s.y,A[G+H+6]=s.z,A[G+H+7]=0),x===!0&&(s.fromBufferAttribute(z,K),A[G+H+8]=s.x,A[G+H+9]=s.y,A[G+H+10]=s.z,A[G+H+11]=z.itemSize===4?s.w:1)}}p={count:f,texture:T,size:new at(E,N)},i.set(a,p),a.addEventListener("dispose",C)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let m=0;for(let x=0;x<c.length;x++)m+=c[x];const g=a.morphTargetsRelative?1:1-m;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",p.size)}return{update:r}}function OL(n,e,t,i){let s=new WeakMap;function r(l){const c=i.render.frame,h=l.geometry,f=e.get(l,h);if(s.get(f)!==c&&(e.update(f),s.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),s.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;s.get(p)!==c&&(p.update(),s.set(p,c))}return f}function o(){s=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}class c0 extends dn{constructor(e,t,i,s,r,o,a,l,c,h=eo){if(h!==eo&&h!==po)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===eo&&(i=ir),i===void 0&&h===po&&(i=fo),super(null,s,r,o,a,l,h,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:ii,this.minFilter=l!==void 0?l:ii,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const h0=new dn,em=new c0(1,1),u0=new e0,d0=new yC,f0=new o0,tm=[],nm=[],im=new Float32Array(16),sm=new Float32Array(9),rm=new Float32Array(4);function To(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=tm[s];if(r===void 0&&(r=new Float32Array(s),tm[s]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(r,a)}return r}function Qt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function jt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function fc(n,e){let t=nm[e];t===void 0&&(t=new Int32Array(e),nm[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function zL(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function kL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;n.uniform2fv(this.addr,e),jt(t,e)}}function BL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Qt(t,e))return;n.uniform3fv(this.addr,e),jt(t,e)}}function HL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;n.uniform4fv(this.addr,e),jt(t,e)}}function VL(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Qt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),jt(t,e)}else{if(Qt(t,i))return;rm.set(i),n.uniformMatrix2fv(this.addr,!1,rm),jt(t,i)}}function GL(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Qt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),jt(t,e)}else{if(Qt(t,i))return;sm.set(i),n.uniformMatrix3fv(this.addr,!1,sm),jt(t,i)}}function WL(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Qt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),jt(t,e)}else{if(Qt(t,i))return;im.set(i),n.uniformMatrix4fv(this.addr,!1,im),jt(t,i)}}function $L(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function qL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;n.uniform2iv(this.addr,e),jt(t,e)}}function XL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Qt(t,e))return;n.uniform3iv(this.addr,e),jt(t,e)}}function YL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;n.uniform4iv(this.addr,e),jt(t,e)}}function QL(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function jL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;n.uniform2uiv(this.addr,e),jt(t,e)}}function ZL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Qt(t,e))return;n.uniform3uiv(this.addr,e),jt(t,e)}}function KL(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;n.uniform4uiv(this.addr,e),jt(t,e)}}function JL(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s);let r;this.type===n.SAMPLER_2D_SHADOW?(em.compareFunction=Zv,r=em):r=h0,t.setTexture2D(e||r,s)}function e2(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture3D(e||d0,s)}function t2(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTextureCube(e||f0,s)}function n2(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture2DArray(e||u0,s)}function i2(n){switch(n){case 5126:return zL;case 35664:return kL;case 35665:return BL;case 35666:return HL;case 35674:return VL;case 35675:return GL;case 35676:return WL;case 5124:case 35670:return $L;case 35667:case 35671:return qL;case 35668:case 35672:return XL;case 35669:case 35673:return YL;case 5125:return QL;case 36294:return jL;case 36295:return ZL;case 36296:return KL;case 35678:case 36198:case 36298:case 36306:case 35682:return JL;case 35679:case 36299:case 36307:return e2;case 35680:case 36300:case 36308:case 36293:return t2;case 36289:case 36303:case 36311:case 36292:return n2}}function s2(n,e){n.uniform1fv(this.addr,e)}function r2(n,e){const t=To(e,this.size,2);n.uniform2fv(this.addr,t)}function o2(n,e){const t=To(e,this.size,3);n.uniform3fv(this.addr,t)}function a2(n,e){const t=To(e,this.size,4);n.uniform4fv(this.addr,t)}function l2(n,e){const t=To(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function c2(n,e){const t=To(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function h2(n,e){const t=To(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function u2(n,e){n.uniform1iv(this.addr,e)}function d2(n,e){n.uniform2iv(this.addr,e)}function f2(n,e){n.uniform3iv(this.addr,e)}function p2(n,e){n.uniform4iv(this.addr,e)}function m2(n,e){n.uniform1uiv(this.addr,e)}function _2(n,e){n.uniform2uiv(this.addr,e)}function g2(n,e){n.uniform3uiv(this.addr,e)}function v2(n,e){n.uniform4uiv(this.addr,e)}function x2(n,e,t){const i=this.cache,s=e.length,r=fc(t,s);Qt(i,r)||(n.uniform1iv(this.addr,r),jt(i,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||h0,r[o])}function M2(n,e,t){const i=this.cache,s=e.length,r=fc(t,s);Qt(i,r)||(n.uniform1iv(this.addr,r),jt(i,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||d0,r[o])}function E2(n,e,t){const i=this.cache,s=e.length,r=fc(t,s);Qt(i,r)||(n.uniform1iv(this.addr,r),jt(i,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||f0,r[o])}function y2(n,e,t){const i=this.cache,s=e.length,r=fc(t,s);Qt(i,r)||(n.uniform1iv(this.addr,r),jt(i,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||u0,r[o])}function S2(n){switch(n){case 5126:return s2;case 35664:return r2;case 35665:return o2;case 35666:return a2;case 35674:return l2;case 35675:return c2;case 35676:return h2;case 5124:case 35670:return u2;case 35667:case 35671:return d2;case 35668:case 35672:return f2;case 35669:case 35673:return p2;case 5125:return m2;case 36294:return _2;case 36295:return g2;case 36296:return v2;case 35678:case 36198:case 36298:case 36306:case 35682:return x2;case 35679:case 36299:case 36307:return M2;case 35680:case 36300:case 36308:case 36293:return E2;case 36289:case 36303:case 36311:case 36292:return y2}}class b2{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=i2(t.type)}}class w2{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=S2(t.type)}}class T2{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const s=this.seq;for(let r=0,o=s.length;r!==o;++r){const a=s[r];a.setValue(e,t[a.id],i)}}}const Mh=/(\w+)(\])?(\[|\.)?/g;function om(n,e){n.seq.push(e),n.map[e.id]=e}function A2(n,e,t){const i=n.name,s=i.length;for(Mh.lastIndex=0;;){const r=Mh.exec(i),o=Mh.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){om(t,c===void 0?new b2(a,n,e):new w2(a,n,e));break}else{let f=t.map[a];f===void 0&&(f=new T2(a),om(t,f)),t=f}}}class Ol{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){const r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);A2(r,o,this)}}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const o=e[s];o.id in t&&i.push(o)}return i}}function am(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const C2=37297;let R2=0;function P2(n,e){const t=n.split(` `),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(` `)}const lm=new ht;function L2(n){Et._getMatrix(lm,Et.workingColorSpace,n);const e=`mat3( ${lm.elements.map(t=>t.toFixed(4))} )`;switch(Et.getTransfer(n)){case dc:return[e,"LinearTransferOETF"];case At:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function cm(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=n.getShaderInfoLog(e).trim();if(i&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const o=parseInt(r[1]);return t.toUpperCase()+` `+s+` `+P2(n.getShaderSource(e),o)}else return s}function D2(n,e){const t=L2(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}function I2(n,e){let t;switch(e){case UA:t="Linear";break;case NA:t="Reinhard";break;case FA:t="Cineon";break;case OA:t="ACESFilmic";break;case kA:t="AgX";break;case BA:t="Neutral";break;case zA:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const vl=new re;function U2(){Et.getLuminanceCoefficients(vl);const n=vl.x.toFixed(4),e=vl.y.toFixed(4),t=vl.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function N2(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter($o).join(` `)}function F2(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function O2(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const r=n.getActiveAttrib(e,s),o=r.name;let a=1;r.type===n.FLOAT_MAT2&&(a=2),r.type===n.FLOAT_MAT3&&(a=3),r.type===n.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function $o(n){return n!==""}function hm(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function um(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const z2=/^[ \t]*#include +<([\w\d./]+)>/gm;function dd(n){return n.replace(z2,B2)}const k2=new Map;function B2(n,e){let t=ft[e];if(t===void 0){const i=k2.get(e);if(i!==void 0)t=ft[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return dd(t)}const H2=/#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 dm(n){return n.replace(H2,V2)}function V2(n,e,t,i){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function fm(n){let e=`precision ${n.precision} float; precision ${n.precision} int; precision ${n.precision} sampler2D; precision ${n.precision} samplerCube; precision ${n.precision} sampler3D; precision ${n.precision} sampler2DArray; precision ${n.precision} sampler2DShadow; precision ${n.precision} samplerCubeShadow; precision ${n.precision} sampler2DArrayShadow; precision ${n.precision} isampler2D; precision ${n.precision} isampler3D; precision ${n.precision} isamplerCube; precision ${n.precision} isampler2DArray; precision ${n.precision} usampler2D; precision ${n.precision} usampler3D; precision ${n.precision} usamplerCube; precision ${n.precision} usampler2DArray; `;return n.precision==="highp"?e+=` #define HIGH_PRECISION`:n.precision==="mediump"?e+=` #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=` #define LOW_PRECISION`),e}function G2(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Ov?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===fA?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Fi&&(e="SHADOWMAP_TYPE_VSM"),e}function W2(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case ho:case uo:e="ENVMAP_TYPE_CUBE";break;case uc:e="ENVMAP_TYPE_CUBE_UV";break}return e}function $2(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case uo:e="ENVMAP_MODE_REFRACTION";break}return e}function q2(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case zv:e="ENVMAP_BLENDING_MULTIPLY";break;case DA:e="ENVMAP_BLENDING_MIX";break;case IA:e="ENVMAP_BLENDING_ADD";break}return e}function X2(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function Y2(n,e,t,i){const s=n.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=G2(t),c=W2(t),h=$2(t),f=q2(t),p=X2(t),m=N2(t),g=F2(r),x=s.createProgram();let d,u,w=t.glslVersion?"#version "+t.glslVersion+` `:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter($o).join(` `),d.length>0&&(d+=` `),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter($o).join(` `),u.length>0&&(u+=` `)):(d=[fm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter($o).join(` `),u=[fm(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==vs?"#define TONE_MAPPING":"",t.toneMapping!==vs?ft.tonemapping_pars_fragment:"",t.toneMapping!==vs?I2("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ft.colorspace_pars_fragment,D2("linearToOutputTexel",t.outputColorSpace),U2(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter($o).join(` `)),o=dd(o),o=hm(o,t),o=um(o,t),a=dd(a),a=hm(a,t),a=um(a,t),o=dm(o),a=dm(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es `,d=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+d,u=["#define varying in",t.glslVersion===wp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===wp?"":"#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(` `)+` `+u);const M=w+d+o,E=w+u+a,N=am(s,s.VERTEX_SHADER,M),A=am(s,s.FRAGMENT_SHADER,E);s.attachShader(x,N),s.attachShader(x,A),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function T(b){if(n.debug.checkShaderErrors){const W=s.getProgramInfoLog(x).trim(),z=s.getShaderInfoLog(N).trim(),G=s.getShaderInfoLog(A).trim();let K=!0,H=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(K=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,x,N,A);else{const ie=cm(s,N,"vertex"),B=cm(s,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+` Material Name: `+b.name+` Material Type: `+b.type+` Program Info Log: `+W+` `+ie+` `+B)}else W!==""?console.warn("THREE.WebGLProgram: Program Info Log:",W):(z===""||G==="")&&(H=!1);H&&(b.diagnostics={runnable:K,programLog:W,vertexShader:{log:z,prefix:d},fragmentShader:{log:G,prefix:u}})}s.deleteShader(N),s.deleteShader(A),I=new Ol(s,x),C=O2(s,x)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let C;this.getAttributes=function(){return C===void 0&&T(this),C};let _=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return _===!1&&(_=s.getProgramParameter(x,C2)),_},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=R2++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=N,this.fragmentShader=A,this}let Q2=0;class j2{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new Z2(e),t.set(e,i)),i}}class Z2{constructor(e){this.id=Q2++,this.code=e,this.usedTimes=0}}function K2(n,e,t,i,s,r,o){const a=new nf,l=new j2,c=new Set,h=[],f=s.logarithmicDepthBuffer,p=s.vertexTextures;let m=s.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(C){return c.add(C),C===0?"uv":`uv${C}`}function d(C,_,b,W,z){const G=W.fog,K=z.geometry,H=C.isMeshStandardMaterial?W.environment:null,ie=(C.isMeshStandardMaterial?t:e).get(C.envMap||H),B=ie&&ie.mapping===uc?ie.image.height:null,ue=g[C.type];C.precision!==null&&(m=s.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const me=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,Me=me!==void 0?me.length:0;let Ge=0;K.morphAttributes.position!==void 0&&(Ge=1),K.morphAttributes.normal!==void 0&&(Ge=2),K.morphAttributes.color!==void 0&&(Ge=3);let Qe,$,te,ve;if(ue){const st=mi[ue];Qe=st.vertexShader,$=st.fragmentShader}else Qe=C.vertexShader,$=C.fragmentShader,l.update(C),te=l.getVertexShaderID(C),ve=l.getFragmentShaderID(C);const de=n.getRenderTarget(),Pe=n.state.buffers.depth.getReversed(),Le=z.isInstancedMesh===!0,He=z.isBatchedMesh===!0,je=!!C.map,We=!!C.matcap,q=!!ie,Z=!!C.aoMap,et=!!C.lightMap,$e=!!C.bumpMap,Ue=!!C.normalMap,Oe=!!C.displacementMap,Ve=!!C.emissiveMap,D=!!C.metalnessMap,v=!!C.roughnessMap,S=C.anisotropy>0,F=C.clearcoat>0,Q=C.dispersion>0,X=C.iridescence>0,ne=C.sheen>0,_e=C.transmission>0,fe=S&&!!C.anisotropyMap,Ae=F&&!!C.clearcoatMap,ge=F&&!!C.clearcoatNormalMap,le=F&&!!C.clearcoatRoughnessMap,Ee=X&&!!C.iridescenceMap,Ce=X&&!!C.iridescenceThicknessMap,ye=ne&&!!C.sheenColorMap,we=ne&&!!C.sheenRoughnessMap,Fe=!!C.specularMap,qe=!!C.specularColorMap,Y=!!C.specularIntensityMap,k=_e&&!!C.transmissionMap,j=_e&&!!C.thicknessMap,V=!!C.gradientMap,ee=!!C.alphaMap,he=C.alphaTest>0,be=!!C.alphaHash,Xe=!!C.extensions;let xt=vs;C.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(xt=n.toneMapping);const Je={shaderID:ue,shaderType:C.type,shaderName:C.name,vertexShader:Qe,fragmentShader:$,defines:C.defines,customVertexShaderID:te,customFragmentShaderID:ve,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:He,batchingColor:He&&z._colorsTexture!==null,instancing:Le,instancingColor:Le&&z.instanceColor!==null,instancingMorph:Le&&z.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:de===null?n.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:So,alphaToCoverage:!!C.alphaToCoverage,map:je,matcap:We,envMap:q,envMapMode:q&&ie.mapping,envMapCubeUVHeight:B,aoMap:Z,lightMap:et,bumpMap:$e,normalMap:Ue,displacementMap:p&&Oe,emissiveMap:Ve,normalMapObjectSpace:Ue&&C.normalMapType===WA,normalMapTangentSpace:Ue&&C.normalMapType===jv,metalnessMap:D,roughnessMap:v,anisotropy:S,anisotropyMap:fe,clearcoat:F,clearcoatMap:Ae,clearcoatNormalMap:ge,clearcoatRoughnessMap:le,dispersion:Q,iridescence:X,iridescenceMap:Ee,iridescenceThicknessMap:Ce,sheen:ne,sheenColorMap:ye,sheenRoughnessMap:we,specularMap:Fe,specularColorMap:qe,specularIntensityMap:Y,transmission:_e,transmissionMap:k,thicknessMap:j,gradientMap:V,opaque:C.transparent===!1&&C.blending===Jr&&C.alphaToCoverage===!1,alphaMap:ee,alphaTest:he,alphaHash:be,combine:C.combine,mapUv:je&&x(C.map.channel),aoMapUv:Z&&x(C.aoMap.channel),lightMapUv:et&&x(C.lightMap.channel),bumpMapUv:$e&&x(C.bumpMap.channel),normalMapUv:Ue&&x(C.normalMap.channel),displacementMapUv:Oe&&x(C.displacementMap.channel),emissiveMapUv:Ve&&x(C.emissiveMap.channel),metalnessMapUv:D&&x(C.metalnessMap.channel),roughnessMapUv:v&&x(C.roughnessMap.channel),anisotropyMapUv:fe&&x(C.anisotropyMap.channel),clearcoatMapUv:Ae&&x(C.clearcoatMap.channel),clearcoatNormalMapUv:ge&&x(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&x(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&x(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ce&&x(C.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&x(C.sheenColorMap.channel),sheenRoughnessMapUv:we&&x(C.sheenRoughnessMap.channel),specularMapUv:Fe&&x(C.specularMap.channel),specularColorMapUv:qe&&x(C.specularColorMap.channel),specularIntensityMapUv:Y&&x(C.specularIntensityMap.channel),transmissionMapUv:k&&x(C.transmissionMap.channel),thicknessMapUv:j&&x(C.thicknessMap.channel),alphaMapUv:ee&&x(C.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(Ue||S),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!K.attributes.uv&&(je||ee),fog:!!G,useFog:C.fog===!0,fogExp2:!!G&&G.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reverseDepthBuffer:Pe,skinning:z.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Ge,numDirLights:_.directional.length,numPointLights:_.point.length,numSpotLights:_.spot.length,numSpotLightMaps:_.spotLightMap.length,numRectAreaLights:_.rectArea.length,numHemiLights:_.hemi.length,numDirLightShadows:_.directionalShadowMap.length,numPointLightShadows:_.pointShadowMap.length,numSpotLightShadows:_.spotShadowMap.length,numSpotLightShadowsWithMaps:_.numSpotLightShadowsWithMaps,numLightProbes:_.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:n.shadowMap.enabled&&b.length>0,shadowMapType:n.shadowMap.type,toneMapping:xt,decodeVideoTexture:je&&C.map.isVideoTexture===!0&&Et.getTransfer(C.map.colorSpace)===At,decodeVideoTextureEmissive:Ve&&C.emissiveMap.isVideoTexture===!0&&Et.getTransfer(C.emissiveMap.colorSpace)===At,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===_i,flipSided:C.side===wn,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:Xe&&C.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Xe&&C.extensions.multiDraw===!0||He)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return Je.vertexUv1s=c.has(1),Je.vertexUv2s=c.has(2),Je.vertexUv3s=c.has(3),c.clear(),Je}function u(C){const _=[];if(C.shaderID?_.push(C.shaderID):(_.push(C.customVertexShaderID),_.push(C.customFragmentShaderID)),C.defines!==void 0)for(const b in C.defines)_.push(b),_.push(C.defines[b]);return C.isRawShaderMaterial===!1&&(w(_,C),M(_,C),_.push(n.outputColorSpace)),_.push(C.customProgramCacheKey),_.join()}function w(C,_){C.push(_.precision),C.push(_.outputColorSpace),C.push(_.envMapMode),C.push(_.envMapCubeUVHeight),C.push(_.mapUv),C.push(_.alphaMapUv),C.push(_.lightMapUv),C.push(_.aoMapUv),C.push(_.bumpMapUv),C.push(_.normalMapUv),C.push(_.displacementMapUv),C.push(_.emissiveMapUv),C.push(_.metalnessMapUv),C.push(_.roughnessMapUv),C.push(_.anisotropyMapUv),C.push(_.clearcoatMapUv),C.push(_.clearcoatNormalMapUv),C.push(_.clearcoatRoughnessMapUv),C.push(_.iridescenceMapUv),C.push(_.iridescenceThicknessMapUv),C.push(_.sheenColorMapUv),C.push(_.sheenRoughnessMapUv),C.push(_.specularMapUv),C.push(_.specularColorMapUv),C.push(_.specularIntensityMapUv),C.push(_.transmissionMapUv),C.push(_.thicknessMapUv),C.push(_.combine),C.push(_.fogExp2),C.push(_.sizeAttenuation),C.push(_.morphTargetsCount),C.push(_.morphAttributeCount),C.push(_.numDirLights),C.push(_.numPointLights),C.push(_.numSpotLights),C.push(_.numSpotLightMaps),C.push(_.numHemiLights),C.push(_.numRectAreaLights),C.push(_.numDirLightShadows),C.push(_.numPointLightShadows),C.push(_.numSpotLightShadows),C.push(_.numSpotLightShadowsWithMaps),C.push(_.numLightProbes),C.push(_.shadowMapType),C.push(_.toneMapping),C.push(_.numClippingPlanes),C.push(_.numClipIntersection),C.push(_.depthPacking)}function M(C,_){a.disableAll(),_.supportsVertexTextures&&a.enable(0),_.instancing&&a.enable(1),_.instancingColor&&a.enable(2),_.instancingMorph&&a.enable(3),_.matcap&&a.enable(4),_.envMap&&a.enable(5),_.normalMapObjectSpace&&a.enable(6),_.normalMapTangentSpace&&a.enable(7),_.clearcoat&&a.enable(8),_.iridescence&&a.enable(9),_.alphaTest&&a.enable(10),_.vertexColors&&a.enable(11),_.vertexAlphas&&a.enable(12),_.vertexUv1s&&a.enable(13),_.vertexUv2s&&a.enable(14),_.vertexUv3s&&a.enable(15),_.vertexTangents&&a.enable(16),_.anisotropy&&a.enable(17),_.alphaHash&&a.enable(18),_.batching&&a.enable(19),_.dispersion&&a.enable(20),_.batchingColor&&a.enable(21),C.push(a.mask),a.disableAll(),_.fog&&a.enable(0),_.useFog&&a.enable(1),_.flatShading&&a.enable(2),_.logarithmicDepthBuffer&&a.enable(3),_.reverseDepthBuffer&&a.enable(4),_.skinning&&a.enable(5),_.morphTargets&&a.enable(6),_.morphNormals&&a.enable(7),_.morphColors&&a.enable(8),_.premultipliedAlpha&&a.enable(9),_.shadowMapEnabled&&a.enable(10),_.doubleSided&&a.enable(11),_.flipSided&&a.enable(12),_.useDepthPacking&&a.enable(13),_.dithering&&a.enable(14),_.transmission&&a.enable(15),_.sheen&&a.enable(16),_.opaque&&a.enable(17),_.pointsUvs&&a.enable(18),_.decodeVideoTexture&&a.enable(19),_.decodeVideoTextureEmissive&&a.enable(20),_.alphaToCoverage&&a.enable(21),C.push(a.mask)}function E(C){const _=g[C.type];let b;if(_){const W=mi[_];b=UC.clone(W.uniforms)}else b=C.uniforms;return b}function N(C,_){let b;for(let W=0,z=h.length;W<z;W++){const G=h[W];if(G.cacheKey===_){b=G,++b.usedTimes;break}}return b===void 0&&(b=new Y2(n,_,C,r),h.push(b)),b}function A(C){if(--C.usedTimes===0){const _=h.indexOf(C);h[_]=h[h.length-1],h.pop(),C.destroy()}}function T(C){l.remove(C)}function I(){l.dispose()}return{getParameters:d,getProgramCacheKey:u,getUniforms:E,acquireProgram:N,releaseProgram:A,releaseShaderCache:T,programs:h,dispose:I}}function J2(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function s(o,a,l){n.get(o)[a]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function eD(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function pm(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function mm(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function o(f,p,m,g,x,d){let u=n[e];return u===void 0?(u={id:f.id,object:f,geometry:p,material:m,groupOrder:g,renderOrder:f.renderOrder,z:x,group:d},n[e]=u):(u.id=f.id,u.object=f,u.geometry=p,u.material=m,u.groupOrder=g,u.renderOrder=f.renderOrder,u.z=x,u.group=d),e++,u}function a(f,p,m,g,x,d){const u=o(f,p,m,g,x,d);m.transmission>0?i.push(u):m.transparent===!0?s.push(u):t.push(u)}function l(f,p,m,g,x,d){const u=o(f,p,m,g,x,d);m.transmission>0?i.unshift(u):m.transparent===!0?s.unshift(u):t.unshift(u)}function c(f,p){t.length>1&&t.sort(f||eD),i.length>1&&i.sort(p||pm),s.length>1&&s.sort(p||pm)}function h(){for(let f=e,p=n.length;f<p;f++){const m=n[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:s,init:r,push:a,unshift:l,finish:h,sort:c}}function tD(){let n=new WeakMap;function e(i,s){const r=n.get(i);let o;return r===void 0?(o=new mm,n.set(i,[o])):s>=r.length?(o=new mm,r.push(o)):o=r[s],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function nD(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new re,color:new bt};break;case"SpotLight":t={position:new re,direction:new re,color:new bt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new re,color:new bt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new re,skyColor:new bt,groundColor:new bt};break;case"RectAreaLight":t={color:new bt,position:new re,halfWidth:new re,halfHeight:new re};break}return n[e.id]=t,t}}}function iD(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let sD=0;function rD(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function oD(n){const e=new nD,t=iD(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new re);const s=new re,r=new Ft,o=new Ft;function a(c){let h=0,f=0,p=0;for(let C=0;C<9;C++)i.probe[C].set(0,0,0);let m=0,g=0,x=0,d=0,u=0,w=0,M=0,E=0,N=0,A=0,T=0;c.sort(rD);for(let C=0,_=c.length;C<_;C++){const b=c[C],W=b.color,z=b.intensity,G=b.distance,K=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=W.r*z,f+=W.g*z,p+=W.b*z;else if(b.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(b.sh.coefficients[H],z);T++}else if(b.isDirectionalLight){const H=e.get(b);if(H.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const ie=b.shadow,B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,i.directionalShadow[m]=B,i.directionalShadowMap[m]=K,i.directionalShadowMatrix[m]=b.shadow.matrix,w++}i.directional[m]=H,m++}else if(b.isSpotLight){const H=e.get(b);H.position.setFromMatrixPosition(b.matrixWorld),H.color.copy(W).multiplyScalar(z),H.distance=G,H.coneCos=Math.cos(b.angle),H.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),H.decay=b.decay,i.spot[x]=H;const ie=b.shadow;if(b.map&&(i.spotLightMap[N]=b.map,N++,ie.updateMatrices(b),b.castShadow&&A++),i.spotLightMatrix[x]=ie.matrix,b.castShadow){const B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,i.spotShadow[x]=B,i.spotShadowMap[x]=K,E++}x++}else if(b.isRectAreaLight){const H=e.get(b);H.color.copy(W).multiplyScalar(z),H.halfWidth.set(b.width*.5,0,0),H.halfHeight.set(0,b.height*.5,0),i.rectArea[d]=H,d++}else if(b.isPointLight){const H=e.get(b);if(H.color.copy(b.color).multiplyScalar(b.intensity),H.distance=b.distance,H.decay=b.decay,b.castShadow){const ie=b.shadow,B=t.get(b);B.shadowIntensity=ie.intensity,B.shadowBias=ie.bias,B.shadowNormalBias=ie.normalBias,B.shadowRadius=ie.radius,B.shadowMapSize=ie.mapSize,B.shadowCameraNear=ie.camera.near,B.shadowCameraFar=ie.camera.far,i.pointShadow[g]=B,i.pointShadowMap[g]=K,i.pointShadowMatrix[g]=b.shadow.matrix,M++}i.point[g]=H,g++}else if(b.isHemisphereLight){const H=e.get(b);H.skyColor.copy(b.color).multiplyScalar(z),H.groundColor.copy(b.groundColor).multiplyScalar(z),i.hemi[u]=H,u++}}d>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ke.LTC_FLOAT_1,i.rectAreaLTC2=ke.LTC_FLOAT_2):(i.rectAreaLTC1=ke.LTC_HALF_1,i.rectAreaLTC2=ke.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=f,i.ambient[2]=p;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==x||I.rectAreaLength!==d||I.hemiLength!==u||I.numDirectionalShadows!==w||I.numPointShadows!==M||I.numSpotShadows!==E||I.numSpotMaps!==N||I.numLightProbes!==T)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=d,i.point.length=g,i.hemi.length=u,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=E+N-A,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=T,I.directionalLength=m,I.pointLength=g,I.spotLength=x,I.rectAreaLength=d,I.hemiLength=u,I.numDirectionalShadows=w,I.numPointShadows=M,I.numSpotShadows=E,I.numSpotMaps=N,I.numLightProbes=T,i.version=sD++)}function l(c,h){let f=0,p=0,m=0,g=0,x=0;const d=h.matrixWorldInverse;for(let u=0,w=c.length;u<w;u++){const M=c[u];if(M.isDirectionalLight){const E=i.directional[f];E.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),f++}else if(M.isSpotLight){const E=i.spot[m];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),E.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),m++}else if(M.isRectAreaLight){const E=i.rectArea[g];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),o.identity(),r.copy(M.matrixWorld),r.premultiply(d),o.extractRotation(r),E.halfWidth.set(M.width*.5,0,0),E.halfHeight.set(0,M.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),g++}else if(M.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(d),p++}else if(M.isHemisphereLight){const E=i.hemi[x];E.direction.setFromMatrixPosition(M.matrixWorld),E.direction.transformDirection(d),x++}}}return{setup:a,setupView:l,state:i}}function _m(n){const e=new oD(n),t=[],i=[];function s(h){c.camera=h,t.length=0,i.length=0}function r(h){t.push(h)}function o(h){i.push(h)}function a(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function aD(n){let e=new WeakMap;function t(s,r=0){const o=e.get(s);let a;return o===void 0?(a=new _m(n),e.set(s,[a])):r>=o.length?(a=new _m(n),o.push(a)):a=o[r],a}function i(){e=new WeakMap}return{get:t,dispose:i}}class lD extends wa{static get type(){return"MeshDepthMaterial"}constructor(e){super(),this.isMeshDepthMaterial=!0,this.depthPacking=VA,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class cD extends wa{static get type(){return"MeshDistanceMaterial"}constructor(e){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const hD=`void main() { gl_Position = vec4( position, 1.0 ); }`,uD=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include <packing> void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function dD(n,e,t){let i=new a0;const s=new at,r=new at,o=new zt,a=new lD({depthPacking:GA}),l=new cD,c={},h=t.maxTextureSize,f={[ws]:wn,[wn]:ws,[_i]:_i},p=new Xi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new at},radius:{value:4}},vertexShader:hD,fragmentShader:uD}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const g=new As;g.setAttribute("position",new Ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Gn(g,p),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ov;let u=this.type;this.render=function(A,T,I){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||A.length===0)return;const C=n.getRenderTarget(),_=n.getActiveCubeFace(),b=n.getActiveMipmapLevel(),W=n.state;W.setBlending(gs),W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const z=u!==Fi&&this.type===Fi,G=u===Fi&&this.type!==Fi;for(let K=0,H=A.length;K<H;K++){const ie=A[K],B=ie.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",ie,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);const ue=B.getFrameExtents();if(s.multiply(ue),r.copy(B.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ue.x),s.x=r.x*ue.x,B.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ue.y),s.y=r.y*ue.y,B.mapSize.y=r.y)),B.map===null||z===!0||G===!0){const Me=this.type!==Fi?{minFilter:ii,magFilter:ii}:{};B.map!==null&&B.map.dispose(),B.map=new sr(s.x,s.y,Me),B.map.texture.name=ie.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const me=B.getViewportCount();for(let Me=0;Me<me;Me++){const Ge=B.getViewport(Me);o.set(r.x*Ge.x,r.y*Ge.y,r.x*Ge.z,r.y*Ge.w),W.viewport(o),B.updateMatrices(ie,Me),i=B.getFrustum(),E(T,I,B.camera,ie,this.type)}B.isPointLightShadow!==!0&&this.type===Fi&&w(B,I),B.needsUpdate=!1}u=this.type,d.needsUpdate=!1,n.setRenderTarget(C,_,b)};function w(A,T){const I=e.update(x);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,m.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new sr(s.x,s.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(T,null,I,p,x,null),m.uniforms.shadow_pass.value=A.mapPass.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(T,null,I,m,x,null)}function M(A,T,I,C){let _=null;const b=I.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(b!==void 0)_=b;else if(_=I.isPointLight===!0?l:a,n.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){const W=_.uuid,z=T.uuid;let G=c[W];G===void 0&&(G={},c[W]=G);let K=G[z];K===void 0&&(K=_.clone(),G[z]=K,T.addEventListener("dispose",N)),_=K}if(_.visible=T.visible,_.wireframe=T.wireframe,C===Fi?_.side=T.shadowSide!==null?T.shadowSide:T.side:_.side=T.shadowSide!==null?T.shadowSide:f[T.side],_.alphaMap=T.alphaMap,_.alphaTest=T.alphaTest,_.map=T.map,_.clipShadows=T.clipShadows,_.clippingPlanes=T.clippingPlanes,_.clipIntersection=T.clipIntersection,_.displacementMap=T.displacementMap,_.displacementScale=T.displacementScale,_.displacementBias=T.displacementBias,_.wireframeLinewidth=T.wireframeLinewidth,_.linewidth=T.linewidth,I.isPointLight===!0&&_.isMeshDistanceMaterial===!0){const W=n.properties.get(_);W.light=I}return _}function E(A,T,I,C,_){if(A.visible===!1)return;if(A.layers.test(T.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&_===Fi)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,A.matrixWorld);const z=e.update(A),G=A.material;if(Array.isArray(G)){const K=z.groups;for(let H=0,ie=K.length;H<ie;H++){const B=K[H],ue=G[B.materialIndex];if(ue&&ue.visible){const me=M(A,ue,C,_);A.onBeforeShadow(n,A,T,I,z,me,B),n.renderBufferDirect(I,null,z,me,A,B),A.onAfterShadow(n,A,T,I,z,me,B)}}}else if(G.visible){const K=M(A,G,C,_);A.onBeforeShadow(n,A,T,I,z,K,null),n.renderBufferDirect(I,null,z,K,A,null),A.onAfterShadow(n,A,T,I,z,K,null)}}const W=A.children;for(let z=0,G=W.length;z<G;z++)E(W[z],T,I,C,_)}function N(A){A.target.removeEventListener("dispose",N);for(const I in c){const C=c[I],_=A.target.uuid;_ in C&&(C[_].dispose(),delete C[_])}}}const fD={[Cu]:Ru,[Pu]:Iu,[Lu]:Uu,[co]:Du,[Ru]:Cu,[Iu]:Pu,[Uu]:Lu,[Du]:co};function pD(n,e){function t(){let k=!1;const j=new zt;let V=null;const ee=new zt(0,0,0,0);return{setMask:function(he){V!==he&&!k&&(n.colorMask(he,he,he,he),V=he)},setLocked:function(he){k=he},setClear:function(he,be,Xe,xt,Je){Je===!0&&(he*=xt,be*=xt,Xe*=xt),j.set(he,be,Xe,xt),ee.equals(j)===!1&&(n.clearColor(he,be,Xe,xt),ee.copy(j))},reset:function(){k=!1,V=null,ee.set(-1,0,0,0)}}}function i(){let k=!1,j=!1,V=null,ee=null,he=null;return{setReversed:function(be){if(j!==be){const Xe=e.get("EXT_clip_control");j?Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.ZERO_TO_ONE_EXT):Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.NEGATIVE_ONE_TO_ONE_EXT);const xt=he;he=null,this.setClear(xt)}j=be},getReversed:function(){return j},setTest:function(be){be?de(n.DEPTH_TEST):Pe(n.DEPTH_TEST)},setMask:function(be){V!==be&&!k&&(n.depthMask(be),V=be)},setFunc:function(be){if(j&&(be=fD[be]),ee!==be){switch(be){case Cu:n.depthFunc(n.NEVER);break;case Ru:n.depthFunc(n.ALWAYS);break;case Pu:n.depthFunc(n.LESS);break;case co:n.depthFunc(n.LEQUAL);break;case Lu:n.depthFunc(n.EQUAL);break;case Du:n.depthFunc(n.GEQUAL);break;case Iu:n.depthFunc(n.GREATER);break;case Uu:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ee=be}},setLocked:function(be){k=be},setClear:function(be){he!==be&&(j&&(be=1-be),n.clearDepth(be),he=be)},reset:function(){k=!1,V=null,ee=null,he=null,j=!1}}}function s(){let k=!1,j=null,V=null,ee=null,he=null,be=null,Xe=null,xt=null,Je=null;return{setTest:function(st){k||(st?de(n.STENCIL_TEST):Pe(n.STENCIL_TEST))},setMask:function(st){j!==st&&!k&&(n.stencilMask(st),j=st)},setFunc:function(st,Ot,In){(V!==st||ee!==Ot||he!==In)&&(n.stencilFunc(st,Ot,In),V=st,ee=Ot,he=In)},setOp:function(st,Ot,In){(be!==st||Xe!==Ot||xt!==In)&&(n.stencilOp(st,Ot,In),be=st,Xe=Ot,xt=In)},setLocked:function(st){k=st},setClear:function(st){Je!==st&&(n.clearStencil(st),Je=st)},reset:function(){k=!1,j=null,V=null,ee=null,he=null,be=null,Xe=null,xt=null,Je=null}}}const r=new t,o=new i,a=new s,l=new WeakMap,c=new WeakMap;let h={},f={},p=new WeakMap,m=[],g=null,x=!1,d=null,u=null,w=null,M=null,E=null,N=null,A=null,T=new bt(0,0,0),I=0,C=!1,_=null,b=null,W=null,z=null,G=null;const K=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,ie=0;const B=n.getParameter(n.VERSION);B.indexOf("WebGL")!==-1?(ie=parseFloat(/^WebGL (\d)/.exec(B)[1]),H=ie>=1):B.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),H=ie>=2);let ue=null,me={};const Me=n.getParameter(n.SCISSOR_BOX),Ge=n.getParameter(n.VIEWPORT),Qe=new zt().fromArray(Me),$=new zt().fromArray(Ge);function te(k,j,V,ee){const he=new Uint8Array(4),be=n.createTexture();n.bindTexture(k,be),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Xe=0;Xe<V;Xe++)k===n.TEXTURE_3D||k===n.TEXTURE_2D_ARRAY?n.texImage3D(j,0,n.RGBA,1,1,ee,0,n.RGBA,n.UNSIGNED_BYTE,he):n.texImage2D(j+Xe,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,he);return be}const ve={};ve[n.TEXTURE_2D]=te(n.TEXTURE_2D,n.TEXTURE_2D,1),ve[n.TEXTURE_CUBE_MAP]=te(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ve[n.TEXTURE_2D_ARRAY]=te(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ve[n.TEXTURE_3D]=te(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),de(n.DEPTH_TEST),o.setFunc(co),$e(!1),Ue(xp),de(n.CULL_FACE),Z(gs);function de(k){h[k]!==!0&&(n.enable(k),h[k]=!0)}function Pe(k){h[k]!==!1&&(n.disable(k),h[k]=!1)}function Le(k,j){return f[k]!==j?(n.bindFramebuffer(k,j),f[k]=j,k===n.DRAW_FRAMEBUFFER&&(f[n.FRAMEBUFFER]=j),k===n.FRAMEBUFFER&&(f[n.DRAW_FRAMEBUFFER]=j),!0):!1}function He(k,j){let V=m,ee=!1;if(k){V=p.get(j),V===void 0&&(V=[],p.set(j,V));const he=k.textures;if(V.length!==he.length||V[0]!==n.COLOR_ATTACHMENT0){for(let be=0,Xe=he.length;be<Xe;be++)V[be]=n.COLOR_ATTACHMENT0+be;V.length=he.length,ee=!0}}else V[0]!==n.BACK&&(V[0]=n.BACK,ee=!0);ee&&n.drawBuffers(V)}function je(k){return g!==k?(n.useProgram(k),g=k,!0):!1}const We={[Qs]:n.FUNC_ADD,[mA]:n.FUNC_SUBTRACT,[_A]:n.FUNC_REVERSE_SUBTRACT};We[gA]=n.MIN,We[vA]=n.MAX;const q={[xA]:n.ZERO,[MA]:n.ONE,[EA]:n.SRC_COLOR,[Tu]:n.SRC_ALPHA,[AA]:n.SRC_ALPHA_SATURATE,[wA]:n.DST_COLOR,[SA]:n.DST_ALPHA,[yA]:n.ONE_MINUS_SRC_COLOR,[Au]:n.ONE_MINUS_SRC_ALPHA,[TA]:n.ONE_MINUS_DST_COLOR,[bA]:n.ONE_MINUS_DST_ALPHA,[CA]:n.CONSTANT_COLOR,[RA]:n.ONE_MINUS_CONSTANT_COLOR,[PA]:n.CONSTANT_ALPHA,[LA]:n.ONE_MINUS_CONSTANT_ALPHA};function Z(k,j,V,ee,he,be,Xe,xt,Je,st){if(k===gs){x===!0&&(Pe(n.BLEND),x=!1);return}if(x===!1&&(de(n.BLEND),x=!0),k!==pA){if(k!==d||st!==C){if((u!==Qs||E!==Qs)&&(n.blendEquation(n.FUNC_ADD),u=Qs,E=Qs),st)switch(k){case Jr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Mp:n.blendFunc(n.ONE,n.ONE);break;case Ep:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case yp:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}else switch(k){case Jr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Mp:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Ep:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case yp:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}w=null,M=null,N=null,A=null,T.set(0,0,0),I=0,d=k,C=st}return}he=he||j,be=be||V,Xe=Xe||ee,(j!==u||he!==E)&&(n.blendEquationSeparate(We[j],We[he]),u=j,E=he),(V!==w||ee!==M||be!==N||Xe!==A)&&(n.blendFuncSeparate(q[V],q[ee],q[be],q[Xe]),w=V,M=ee,N=be,A=Xe),(xt.equals(T)===!1||Je!==I)&&(n.blendColor(xt.r,xt.g,xt.b,Je),T.copy(xt),I=Je),d=k,C=!1}function et(k,j){k.side===_i?Pe(n.CULL_FACE):de(n.CULL_FACE);let V=k.side===wn;j&&(V=!V),$e(V),k.blending===Jr&&k.transparent===!1?Z(gs):Z(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.blendColor,k.blendAlpha,k.premultipliedAlpha),o.setFunc(k.depthFunc),o.setTest(k.depthTest),o.setMask(k.depthWrite),r.setMask(k.colorWrite);const ee=k.stencilWrite;a.setTest(ee),ee&&(a.setMask(k.stencilWriteMask),a.setFunc(k.stencilFunc,k.stencilRef,k.stencilFuncMask),a.setOp(k.stencilFail,k.stencilZFail,k.stencilZPass)),Ve(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits),k.alphaToCoverage===!0?de(n.SAMPLE_ALPHA_TO_COVERAGE):Pe(n.SAMPLE_ALPHA_TO_COVERAGE)}function $e(k){_!==k&&(k?n.frontFace(n.CW):n.frontFace(n.CCW),_=k)}function Ue(k){k!==uA?(de(n.CULL_FACE),k!==b&&(k===xp?n.cullFace(n.BACK):k===dA?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Pe(n.CULL_FACE),b=k}function Oe(k){k!==W&&(H&&n.lineWidth(k),W=k)}function Ve(k,j,V){k?(de(n.POLYGON_OFFSET_FILL),(z!==j||G!==V)&&(n.polygonOffset(j,V),z=j,G=V)):Pe(n.POLYGON_OFFSET_FILL)}function D(k){k?de(n.SCISSOR_TEST):Pe(n.SCISSOR_TEST)}function v(k){k===void 0&&(k=n.TEXTURE0+K-1),ue!==k&&(n.activeTexture(k),ue=k)}function S(k,j,V){V===void 0&&(ue===null?V=n.TEXTURE0+K-1:V=ue);let ee=me[V];ee===void 0&&(ee={type:void 0,texture:void 0},me[V]=ee),(ee.type!==k||ee.texture!==j)&&(ue!==V&&(n.activeTexture(V),ue=V),n.bindTexture(k,j||ve[k]),ee.type=k,ee.texture=j)}function F(){const k=me[ue];k!==void 0&&k.type!==void 0&&(n.bindTexture(k.type,null),k.type=void 0,k.texture=void 0)}function Q(){try{n.compressedTexImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function X(){try{n.compressedTexImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function ne(){try{n.texSubImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function _e(){try{n.texSubImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function fe(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ae(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function ge(){try{n.texStorage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function le(){try{n.texStorage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ee(){try{n.texImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ce(){try{n.texImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function ye(k){Qe.equals(k)===!1&&(n.scissor(k.x,k.y,k.z,k.w),Qe.copy(k))}function we(k){$.equals(k)===!1&&(n.viewport(k.x,k.y,k.z,k.w),$.copy(k))}function Fe(k,j){let V=c.get(j);V===void 0&&(V=new WeakMap,c.set(j,V));let ee=V.get(k);ee===void 0&&(ee=n.getUniformBlockIndex(j,k.name),V.set(k,ee))}function qe(k,j){const ee=c.get(j).get(k);l.get(j)!==ee&&(n.uniformBlockBinding(j,ee,k.__bindingPointIndex),l.set(j,ee))}function Y(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},ue=null,me={},f={},p=new WeakMap,m=[],g=null,x=!1,d=null,u=null,w=null,M=null,E=null,N=null,A=null,T=new bt(0,0,0),I=0,C=!1,_=null,b=null,W=null,z=null,G=null,Qe.set(0,0,n.canvas.width,n.canvas.height),$.set(0,0,n.canvas.width,n.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:de,disable:Pe,bindFramebuffer:Le,drawBuffers:He,useProgram:je,setBlending:Z,setMaterial:et,setFlipSided:$e,setCullFace:Ue,setLineWidth:Oe,setPolygonOffset:Ve,setScissorTest:D,activeTexture:v,bindTexture:S,unbindTexture:F,compressedTexImage2D:Q,compressedTexImage3D:X,texImage2D:Ee,texImage3D:Ce,updateUBOMapping:Fe,uniformBlockBinding:qe,texStorage2D:ge,texStorage3D:le,texSubImage2D:ne,texSubImage3D:_e,compressedTexSubImage2D:fe,compressedTexSubImage3D:Ae,scissor:ye,viewport:we,reset:Y}}function gm(n,e,t,i){const s=mD(i);switch(t){case Gv:return n*e;case $v:return n*e;case qv:return n*e*2;case Xv:return n*e/s.components*s.byteLength;case jd:return n*e/s.components*s.byteLength;case Yv:return n*e*2/s.components*s.byteLength;case Zd:return n*e*2/s.components*s.byteLength;case Wv:return n*e*3/s.components*s.byteLength;case ni:return n*e*4/s.components*s.byteLength;case Kd:return n*e*4/s.components*s.byteLength;case Dl:case Il:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ul:case Nl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bu:case Vu:return Math.max(n,16)*Math.max(e,8)/4;case ku:case Hu:return Math.max(n,8)*Math.max(e,8)/2;case Gu:case Wu:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case $u:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case qu:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Xu:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Yu:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Qu:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case ju:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Zu:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ku:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ju:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case ed:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case td:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case nd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case id:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case sd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case rd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Fl:case od:case ad:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Qv:case ld:return Math.ceil(n/4)*Math.ceil(e/4)*8;case cd:case hd:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function mD(n){switch(n){case qi:case Bv:return{byteLength:1,components:1};case pa:case Hv:case Sa:return{byteLength:2,components:1};case Yd:case Qd:return{byteLength:2,components:4};case ir:case Xd:case Bi:return{byteLength:4,components:1};case Vv:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}function _D(n,e,t,i,s,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new at,h=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(v,S){return m?new OffscreenCanvas(v,S):Zl("canvas")}function x(v,S,F){let Q=1;const X=D(v);if((X.width>F||X.height>F)&&(Q=F/Math.max(X.width,X.height)),Q<1)if(typeof HTMLImageElement<"u"&&v instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&v instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&v instanceof ImageBitmap||typeof VideoFrame<"u"&&v instanceof VideoFrame){const ne=Math.floor(Q*X.width),_e=Math.floor(Q*X.height);f===void 0&&(f=g(ne,_e));const fe=S?g(ne,_e):f;return fe.width=ne,fe.height=_e,fe.getContext("2d").drawImage(v,0,0,ne,_e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+X.width+"x"+X.height+") to ("+ne+"x"+_e+")."),fe}else return"data"in v&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+X.width+"x"+X.height+")."),v;return v}function d(v){return v.generateMipmaps}function u(v){n.generateMipmap(v)}function w(v){return v.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:v.isWebGL3DRenderTarget?n.TEXTURE_3D:v.isWebGLArrayRenderTarget||v.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function M(v,S,F,Q,X=!1){if(v!==null){if(n[v]!==void 0)return n[v];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+v+"'")}let ne=S;if(S===n.RED&&(F===n.FLOAT&&(ne=n.R32F),F===n.HALF_FLOAT&&(ne=n.R16F),F===n.UNSIGNED_BYTE&&(ne=n.R8)),S===n.RED_INTEGER&&(F===n.UNSIGNED_BYTE&&(ne=n.R8UI),F===n.UNSIGNED_SHORT&&(ne=n.R16UI),F===n.UNSIGNED_INT&&(ne=n.R32UI),F===n.BYTE&&(ne=n.R8I),F===n.SHORT&&(ne=n.R16I),F===n.INT&&(ne=n.R32I)),S===n.RG&&(F===n.FLOAT&&(ne=n.RG32F),F===n.HALF_FLOAT&&(ne=n.RG16F),F===n.UNSIGNED_BYTE&&(ne=n.RG8)),S===n.RG_INTEGER&&(F===n.UNSIGNED_BYTE&&(ne=n.RG8UI),F===n.UNSIGNED_SHORT&&(ne=n.RG16UI),F===n.UNSIGNED_INT&&(ne=n.RG32UI),F===n.BYTE&&(ne=n.RG8I),F===n.SHORT&&(ne=n.RG16I),F===n.INT&&(ne=n.RG32I)),S===n.RGB_INTEGER&&(F===n.UNSIGNED_BYTE&&(ne=n.RGB8UI),F===n.UNSIGNED_SHORT&&(ne=n.RGB16UI),F===n.UNSIGNED_INT&&(ne=n.RGB32UI),F===n.BYTE&&(ne=n.RGB8I),F===n.SHORT&&(ne=n.RGB16I),F===n.INT&&(ne=n.RGB32I)),S===n.RGBA_INTEGER&&(F===n.UNSIGNED_BYTE&&(ne=n.RGBA8UI),F===n.UNSIGNED_SHORT&&(ne=n.RGBA16UI),F===n.UNSIGNED_INT&&(ne=n.RGBA32UI),F===n.BYTE&&(ne=n.RGBA8I),F===n.SHORT&&(ne=n.RGBA16I),F===n.INT&&(ne=n.RGBA32I)),S===n.RGB&&F===n.UNSIGNED_INT_5_9_9_9_REV&&(ne=n.RGB9_E5),S===n.RGBA){const _e=X?dc:Et.getTransfer(Q);F===n.FLOAT&&(ne=n.RGBA32F),F===n.HALF_FLOAT&&(ne=n.RGBA16F),F===n.UNSIGNED_BYTE&&(ne=_e===At?n.SRGB8_ALPHA8:n.RGBA8),F===n.UNSIGNED_SHORT_4_4_4_4&&(ne=n.RGBA4),F===n.UNSIGNED_SHORT_5_5_5_1&&(ne=n.RGB5_A1)}return(ne===n.R16F||ne===n.R32F||ne===n.RG16F||ne===n.RG32F||ne===n.RGBA16F||ne===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function E(v,S){let F;return v?S===null||S===ir||S===fo?F=n.DEPTH24_STENCIL8:S===Bi?F=n.DEPTH32F_STENCIL8:S===pa&&(F=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===ir||S===fo?F=n.DEPTH_COMPONENT24:S===Bi?F=n.DEPTH_COMPONENT32F:S===pa&&(F=n.DEPTH_COMPONENT16),F}function N(v,S){return d(v)===!0||v.isFramebufferTexture&&v.minFilter!==ii&&v.minFilter!==Vn?Math.log2(Math.max(S.width,S.height))+1:v.mipmaps!==void 0&&v.mipmaps.length>0?v.mipmaps.length:v.isCompressedTexture&&Array.isArray(v.image)?S.mipmaps.length:1}function A(v){const S=v.target;S.removeEventListener("dispose",A),I(S),S.isVideoTexture&&h.delete(S)}function T(v){const S=v.target;S.removeEventListener("dispose",T),_(S)}function I(v){const S=i.get(v);if(S.__webglInit===void 0)return;const F=v.source,Q=p.get(F);if(Q){const X=Q[S.__cacheKey];X.usedTimes--,X.usedTimes===0&&C(v),Object.keys(Q).length===0&&p.delete(F)}i.remove(v)}function C(v){const S=i.get(v);n.deleteTexture(S.__webglTexture);const F=v.source,Q=p.get(F);delete Q[S.__cacheKey],o.memory.textures--}function _(v){const S=i.get(v);if(v.depthTexture&&(v.depthTexture.dispose(),i.remove(v.depthTexture)),v.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(S.__webglFramebuffer[Q]))for(let X=0;X<S.__webglFramebuffer[Q].length;X++)n.deleteFramebuffer(S.__webglFramebuffer[Q][X]);else n.deleteFramebuffer(S.__webglFramebuffer[Q]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[Q])}else{if(Array.isArray(S.__webglFramebuffer))for(let Q=0;Q<S.__webglFramebuffer.length;Q++)n.deleteFramebuffer(S.__webglFramebuffer[Q]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let Q=0;Q<S.__webglColorRenderbuffer.length;Q++)S.__webglColorRenderbuffer[Q]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[Q]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const F=v.textures;for(let Q=0,X=F.length;Q<X;Q++){const ne=i.get(F[Q]);ne.__webglTexture&&(n.deleteTexture(ne.__webglTexture),o.memory.textures--),i.remove(F[Q])}i.remove(v)}let b=0;function W(){b=0}function z(){const v=b;return v>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+v+" texture units while this GPU supports only "+s.maxTextures),b+=1,v}function G(v){const S=[];return S.push(v.wrapS),S.push(v.wrapT),S.push(v.wrapR||0),S.push(v.magFilter),S.push(v.minFilter),S.push(v.anisotropy),S.push(v.internalFormat),S.push(v.format),S.push(v.type),S.push(v.generateMipmaps),S.push(v.premultiplyAlpha),S.push(v.flipY),S.push(v.unpackAlignment),S.push(v.colorSpace),S.join()}function K(v,S){const F=i.get(v);if(v.isVideoTexture&&Oe(v),v.isRenderTargetTexture===!1&&v.version>0&&F.__version!==v.version){const Q=v.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{$(F,v,S);return}}t.bindTexture(n.TEXTURE_2D,F.__webglTexture,n.TEXTURE0+S)}function H(v,S){const F=i.get(v);if(v.version>0&&F.__version!==v.version){$(F,v,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,F.__webglTexture,n.TEXTURE0+S)}function ie(v,S){const F=i.get(v);if(v.version>0&&F.__version!==v.version){$(F,v,S);return}t.bindTexture(n.TEXTURE_3D,F.__webglTexture,n.TEXTURE0+S)}function B(v,S){const F=i.get(v);if(v.version>0&&F.__version!==v.version){te(F,v,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,F.__webglTexture,n.TEXTURE0+S)}const ue={[Ou]:n.REPEAT,[Ks]:n.CLAMP_TO_EDGE,[zu]:n.MIRRORED_REPEAT},me={[ii]:n.NEAREST,[HA]:n.NEAREST_MIPMAP_NEAREST,[Ka]:n.NEAREST_MIPMAP_LINEAR,[Vn]:n.LINEAR,[Yc]:n.LINEAR_MIPMAP_NEAREST,[Js]:n.LINEAR_MIPMAP_LINEAR},Me={[$A]:n.NEVER,[ZA]:n.ALWAYS,[qA]:n.LESS,[Zv]:n.LEQUAL,[XA]:n.EQUAL,[jA]:n.GEQUAL,[YA]:n.GREATER,[QA]:n.NOTEQUAL};function Ge(v,S){if(S.type===Bi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Vn||S.magFilter===Yc||S.magFilter===Ka||S.magFilter===Js||S.minFilter===Vn||S.minFilter===Yc||S.minFilter===Ka||S.minFilter===Js)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(v,n.TEXTURE_WRAP_S,ue[S.wrapS]),n.texParameteri(v,n.TEXTURE_WRAP_T,ue[S.wrapT]),(v===n.TEXTURE_3D||v===n.TEXTURE_2D_ARRAY)&&n.texParameteri(v,n.TEXTURE_WRAP_R,ue[S.wrapR]),n.texParameteri(v,n.TEXTURE_MAG_FILTER,me[S.magFilter]),n.texParameteri(v,n.TEXTURE_MIN_FILTER,me[S.minFilter]),S.compareFunction&&(n.texParameteri(v,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(v,n.TEXTURE_COMPARE_FUNC,Me[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===ii||S.minFilter!==Ka&&S.minFilter!==Js||S.type===Bi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");n.texParameterf(v,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,s.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function Qe(v,S){let F=!1;v.__webglInit===void 0&&(v.__webglInit=!0,S.addEventListener("dispose",A));const Q=S.source;let X=p.get(Q);X===void 0&&(X={},p.set(Q,X));const ne=G(S);if(ne!==v.__cacheKey){X[ne]===void 0&&(X[ne]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,F=!0),X[ne].usedTimes++;const _e=X[v.__cacheKey];_e!==void 0&&(X[v.__cacheKey].usedTimes--,_e.usedTimes===0&&C(S)),v.__cacheKey=ne,v.__webglTexture=X[ne].texture}return F}function $(v,S,F){let Q=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Q=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Q=n.TEXTURE_3D);const X=Qe(v,S),ne=S.source;t.bindTexture(Q,v.__webglTexture,n.TEXTURE0+F);const _e=i.get(ne);if(ne.version!==_e.__version||X===!0){t.activeTexture(n.TEXTURE0+F);const fe=Et.getPrimaries(Et.workingColorSpace),Ae=S.colorSpace===hs?null:Et.getPrimaries(S.colorSpace),ge=S.colorSpace===hs||fe===Ae?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge);let le=x(S.image,!1,s.maxTextureSize);le=Ve(S,le);const Ee=r.convert(S.format,S.colorSpace),Ce=r.convert(S.type);let ye=M(S.internalFormat,Ee,Ce,S.colorSpace,S.isVideoTexture);Ge(Q,S);let we;const Fe=S.mipmaps,qe=S.isVideoTexture!==!0,Y=_e.__version===void 0||X===!0,k=ne.dataReady,j=N(S,le);if(S.isDepthTexture)ye=E(S.format===po,S.type),Y&&(qe?t.texStorage2D(n.TEXTURE_2D,1,ye,le.width,le.height):t.texImage2D(n.TEXTURE_2D,0,ye,le.width,le.height,0,Ee,Ce,null));else if(S.isDataTexture)if(Fe.length>0){qe&&Y&&t.texStorage2D(n.TEXTURE_2D,j,ye,Fe[0].width,Fe[0].height);for(let V=0,ee=Fe.length;V<ee;V++)we=Fe[V],qe?k&&t.texSubImage2D(n.TEXTURE_2D,V,0,0,we.width,we.height,Ee,Ce,we.data):t.texImage2D(n.TEXTURE_2D,V,ye,we.width,we.height,0,Ee,Ce,we.data);S.generateMipmaps=!1}else qe?(Y&&t.texStorage2D(n.TEXTURE_2D,j,ye,le.width,le.height),k&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,le.width,le.height,Ee,Ce,le.data)):t.texImage2D(n.TEXTURE_2D,0,ye,le.width,le.height,0,Ee,Ce,le.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){qe&&Y&&t.texStorage3D(n.TEXTURE_2D_ARRAY,j,ye,Fe[0].width,Fe[0].height,le.depth);for(let V=0,ee=Fe.length;V<ee;V++)if(we=Fe[V],S.format!==ni)if(Ee!==null)if(qe){if(k)if(S.layerUpdates.size>0){const he=gm(we.width,we.height,S.format,S.type);for(const be of S.layerUpdates){const Xe=we.data.subarray(be*he/we.data.BYTES_PER_ELEMENT,(be+1)*he/we.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,V,0,0,be,we.width,we.height,1,Ee,Xe)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,V,0,0,0,we.width,we.height,le.depth,Ee,we.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,V,ye,we.width,we.height,le.depth,0,we.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else qe?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,V,0,0,0,we.width,we.height,le.depth,Ee,Ce,we.data):t.texImage3D(n.TEXTURE_2D_ARRAY,V,ye,we.width,we.height,le.depth,0,Ee,Ce,we.data)}else{qe&&Y&&t.texStorage2D(n.TEXTURE_2D,j,ye,Fe[0].width,Fe[0].height);for(let V=0,ee=Fe.length;V<ee;V++)we=Fe[V],S.format!==ni?Ee!==null?qe?k&&t.compressedTexSubImage2D(n.TEXTURE_2D,V,0,0,we.width,we.height,Ee,we.data):t.compressedTexImage2D(n.TEXTURE_2D,V,ye,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?k&&t.texSubImage2D(n.TEXTURE_2D,V,0,0,we.width,we.height,Ee,Ce,we.data):t.texImage2D(n.TEXTURE_2D,V,ye,we.width,we.height,0,Ee,Ce,we.data)}else if(S.isDataArrayTexture)if(qe){if(Y&&t.texStorage3D(n.TEXTURE_2D_ARRAY,j,ye,le.width,le.height,le.depth),k)if(S.layerUpdates.size>0){const V=gm(le.width,le.height,S.format,S.type);for(const ee of S.layerUpdates){const he=le.data.subarray(ee*V/le.data.BYTES_PER_ELEMENT,(ee+1)*V/le.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ee,le.width,le.height,1,Ee,Ce,he)}S.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,le.width,le.height,le.depth,Ee,Ce,le.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ye,le.width,le.height,le.depth,0,Ee,Ce,le.data);else if(S.isData3DTexture)qe?(Y&&t.texStorage3D(n.TEXTURE_3D,j,ye,le.width,le.height,le.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,le.width,le.height,le.depth,Ee,Ce,le.data)):t.texImage3D(n.TEXTURE_3D,0,ye,le.width,le.height,le.depth,0,Ee,Ce,le.data);else if(S.isFramebufferTexture){if(Y)if(qe)t.texStorage2D(n.TEXTURE_2D,j,ye,le.width,le.height);else{let V=le.width,ee=le.height;for(let he=0;he<j;he++)t.texImage2D(n.TEXTURE_2D,he,ye,V,ee,0,Ee,Ce,null),V>>=1,ee>>=1}}else if(Fe.length>0){if(qe&&Y){const V=D(Fe[0]);t.texStorage2D(n.TEXTURE_2D,j,ye,V.width,V.height)}for(let V=0,ee=Fe.length;V<ee;V++)we=Fe[V],qe?k&&t.texSubImage2D(n.TEXTURE_2D,V,0,0,Ee,Ce,we):t.texImage2D(n.TEXTURE_2D,V,ye,Ee,Ce,we);S.generateMipmaps=!1}else if(qe){if(Y){const V=D(le);t.texStorage2D(n.TEXTURE_2D,j,ye,V.width,V.height)}k&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ee,Ce,le)}else t.texImage2D(n.TEXTURE_2D,0,ye,Ee,Ce,le);d(S)&&u(Q),_e.__version=ne.version,S.onUpdate&&S.onUpdate(S)}v.__version=S.version}function te(v,S,F){if(S.image.length!==6)return;const Q=Qe(v,S),X=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,v.__webglTexture,n.TEXTURE0+F);const ne=i.get(X);if(X.version!==ne.__version||Q===!0){t.activeTexture(n.TEXTURE0+F);const _e=Et.getPrimaries(Et.workingColorSpace),fe=S.colorSpace===hs?null:Et.getPrimaries(S.colorSpace),Ae=S.colorSpace===hs||_e===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);const ge=S.isCompressedTexture||S.image[0].isCompressedTexture,le=S.image[0]&&S.image[0].isDataTexture,Ee=[];for(let ee=0;ee<6;ee++)!ge&&!le?Ee[ee]=x(S.image[ee],!0,s.maxCubemapSize):Ee[ee]=le?S.image[ee].image:S.image[ee],Ee[ee]=Ve(S,Ee[ee]);const Ce=Ee[0],ye=r.convert(S.format,S.colorSpace),we=r.convert(S.type),Fe=M(S.internalFormat,ye,we,S.colorSpace),qe=S.isVideoTexture!==!0,Y=ne.__version===void 0||Q===!0,k=X.dataReady;let j=N(S,Ce);Ge(n.TEXTURE_CUBE_MAP,S);let V;if(ge){qe&&Y&&t.texStorage2D(n.TEXTURE_CUBE_MAP,j,Fe,Ce.width,Ce.height);for(let ee=0;ee<6;ee++){V=Ee[ee].mipmaps;for(let he=0;he<V.length;he++){const be=V[he];S.format!==ni?ye!==null?qe?k&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he,0,0,be.width,be.height,ye,be.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he,Fe,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qe?k&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he,0,0,be.width,be.height,ye,we,be.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he,Fe,be.width,be.height,0,ye,we,be.data)}}}else{if(V=S.mipmaps,qe&&Y){V.length>0&&j++;const ee=D(Ee[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,j,Fe,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(le){qe?k&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Ee[ee].width,Ee[ee].height,ye,we,Ee[ee].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Fe,Ee[ee].width,Ee[ee].height,0,ye,we,Ee[ee].data);for(let he=0;he<V.length;he++){const Xe=V[he].image[ee].image;qe?k&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he+1,0,0,Xe.width,Xe.height,ye,we,Xe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he+1,Fe,Xe.width,Xe.height,0,ye,we,Xe.data)}}else{qe?k&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ye,we,Ee[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Fe,ye,we,Ee[ee]);for(let he=0;he<V.length;he++){const be=V[he];qe?k&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he+1,0,0,ye,we,be.image[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,he+1,Fe,ye,we,be.image[ee])}}}d(S)&&u(n.TEXTURE_CUBE_MAP),ne.__version=X.version,S.onUpdate&&S.onUpdate(S)}v.__version=S.version}function ve(v,S,F,Q,X,ne){const _e=r.convert(F.format,F.colorSpace),fe=r.convert(F.type),Ae=M(F.internalFormat,_e,fe,F.colorSpace),ge=i.get(S),le=i.get(F);if(le.__renderTarget=S,!ge.__hasExternalTextures){const Ee=Math.max(1,S.width>>ne),Ce=Math.max(1,S.height>>ne);X===n.TEXTURE_3D||X===n.TEXTURE_2D_ARRAY?t.texImage3D(X,ne,Ae,Ee,Ce,S.depth,0,_e,fe,null):t.texImage2D(X,ne,Ae,Ee,Ce,0,_e,fe,null)}t.bindFramebuffer(n.FRAMEBUFFER,v),Ue(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Q,X,le.__webglTexture,0,$e(S)):(X===n.TEXTURE_2D||X>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&X<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Q,X,le.__webglTexture,ne),t.bindFramebuffer(n.FRAMEBUFFER,null)}function de(v,S,F){if(n.bindRenderbuffer(n.RENDERBUFFER,v),S.depthBuffer){const Q=S.depthTexture,X=Q&&Q.isDepthTexture?Q.type:null,ne=E(S.stencilBuffer,X),_e=S.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=$e(S);Ue(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,fe,ne,S.width,S.height):F?n.renderbufferStorageMultisample(n.RENDERBUFFER,fe,ne,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,ne,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,_e,n.RENDERBUFFER,v)}else{const Q=S.textures;for(let X=0;X<Q.length;X++){const ne=Q[X],_e=r.convert(ne.format,ne.colorSpace),fe=r.convert(ne.type),Ae=M(ne.internalFormat,_e,fe,ne.colorSpace),ge=$e(S);F&&Ue(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ge,Ae,S.width,S.height):Ue(S)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ge,Ae,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,Ae,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Pe(v,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,v),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Q=i.get(S.depthTexture);Q.__renderTarget=S,(!Q.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),K(S.depthTexture,0);const X=Q.__webglTexture,ne=$e(S);if(S.depthTexture.format===eo)Ue(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,X,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,X,0);else if(S.depthTexture.format===po)Ue(S)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,X,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,X,0);else throw new Error("Unknown depthTexture format")}function Le(v){const S=i.get(v),F=v.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==v.depthTexture){const Q=v.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),Q){const X=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,Q.removeEventListener("dispose",X)};Q.addEventListener("dispose",X),S.__depthDisposeCallback=X}S.__boundDepthTexture=Q}if(v.depthTexture&&!S.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");Pe(S.__webglFramebuffer,v)}else if(F){S.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[Q]),S.__webglDepthbuffer[Q]===void 0)S.__webglDepthbuffer[Q]=n.createRenderbuffer(),de(S.__webglDepthbuffer[Q],v,!1);else{const X=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ne=S.__webglDepthbuffer[Q];n.bindRenderbuffer(n.RENDERBUFFER,ne),n.framebufferRenderbuffer(n.FRAMEBUFFER,X,n.RENDERBUFFER,ne)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=n.createRenderbuffer(),de(S.__webglDepthbuffer,v,!1);else{const Q=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,X=S.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,X),n.framebufferRenderbuffer(n.FRAMEBUFFER,Q,n.RENDERBUFFER,X)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function He(v,S,F){const Q=i.get(v);S!==void 0&&ve(Q.__webglFramebuffer,v,v.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),F!==void 0&&Le(v)}function je(v){const S=v.texture,F=i.get(v),Q=i.get(S);v.addEventListener("dispose",T);const X=v.textures,ne=v.isWebGLCubeRenderTarget===!0,_e=X.length>1;if(_e||(Q.__webglTexture===void 0&&(Q.__webglTexture=n.createTexture()),Q.__version=S.version,o.memory.textures++),ne){F.__webglFramebuffer=[];for(let fe=0;fe<6;fe++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[fe]=[];for(let Ae=0;Ae<S.mipmaps.length;Ae++)F.__webglFramebuffer[fe][Ae]=n.createFramebuffer()}else F.__webglFramebuffer[fe]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer=[];for(let fe=0;fe<S.mipmaps.length;fe++)F.__webglFramebuffer[fe]=n.createFramebuffer()}else F.__webglFramebuffer=n.createFramebuffer();if(_e)for(let fe=0,Ae=X.length;fe<Ae;fe++){const ge=i.get(X[fe]);ge.__webglTexture===void 0&&(ge.__webglTexture=n.createTexture(),o.memory.textures++)}if(v.samples>0&&Ue(v)===!1){F.__webglMultisampledFramebuffer=n.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let fe=0;fe<X.length;fe++){const Ae=X[fe];F.__webglColorRenderbuffer[fe]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,F.__webglColorRenderbuffer[fe]);const ge=r.convert(Ae.format,Ae.colorSpace),le=r.convert(Ae.type),Ee=M(Ae.internalFormat,ge,le,Ae.colorSpace,v.isXRRenderTarget===!0),Ce=$e(v);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ce,Ee,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,F.__webglColorRenderbuffer[fe])}n.bindRenderbuffer(n.RENDERBUFFER,null),v.depthBuffer&&(F.__webglDepthRenderbuffer=n.createRenderbuffer(),de(F.__webglDepthRenderbuffer,v,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ne){t.bindTexture(n.TEXTURE_CUBE_MAP,Q.__webglTexture),Ge(n.TEXTURE_CUBE_MAP,S);for(let fe=0;fe<6;fe++)if(S.mipmaps&&S.mipmaps.length>0)for(let Ae=0;Ae<S.mipmaps.length;Ae++)ve(F.__webglFramebuffer[fe][Ae],v,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae);else ve(F.__webglFramebuffer[fe],v,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0);d(S)&&u(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let fe=0,Ae=X.length;fe<Ae;fe++){const ge=X[fe],le=i.get(ge);t.bindTexture(n.TEXTURE_2D,le.__webglTexture),Ge(n.TEXTURE_2D,ge),ve(F.__webglFramebuffer,v,ge,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,0),d(ge)&&u(n.TEXTURE_2D)}t.unbindTexture()}else{let fe=n.TEXTURE_2D;if((v.isWebGL3DRenderTarget||v.isWebGLArrayRenderTarget)&&(fe=v.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(fe,Q.__webglTexture),Ge(fe,S),S.mipmaps&&S.mipmaps.length>0)for(let Ae=0;Ae<S.mipmaps.length;Ae++)ve(F.__webglFramebuffer[Ae],v,S,n.COLOR_ATTACHMENT0,fe,Ae);else ve(F.__webglFramebuffer,v,S,n.COLOR_ATTACHMENT0,fe,0);d(S)&&u(fe),t.unbindTexture()}v.depthBuffer&&Le(v)}function We(v){const S=v.textures;for(let F=0,Q=S.length;F<Q;F++){const X=S[F];if(d(X)){const ne=w(v),_e=i.get(X).__webglTexture;t.bindTexture(ne,_e),u(ne),t.unbindTexture()}}}const q=[],Z=[];function et(v){if(v.samples>0){if(Ue(v)===!1){const S=v.textures,F=v.width,Q=v.height;let X=n.COLOR_BUFFER_BIT;const ne=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=i.get(v),fe=S.length>1;if(fe)for(let Ae=0;Ae<S.length;Ae++)t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let Ae=0;Ae<S.length;Ae++){if(v.resolveDepthBuffer&&(v.depthBuffer&&(X|=n.DEPTH_BUFFER_BIT),v.stencilBuffer&&v.resolveStencilBuffer&&(X|=n.STENCIL_BUFFER_BIT)),fe){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Ae]);const ge=i.get(S[Ae]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ge,0)}n.blitFramebuffer(0,0,F,Q,0,0,F,Q,X,n.NEAREST),l===!0&&(q.length=0,Z.length=0,q.push(n.COLOR_ATTACHMENT0+Ae),v.depthBuffer&&v.resolveDepthBuffer===!1&&(q.push(ne),Z.push(ne),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Z)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,q))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),fe)for(let Ae=0;Ae<S.length;Ae++){t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Ae]);const ge=i.get(S[Ae]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.TEXTURE_2D,ge,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(v.depthBuffer&&v.resolveDepthBuffer===!1&&l){const S=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function $e(v){return Math.min(s.maxSamples,v.samples)}function Ue(v){const S=i.get(v);return v.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Oe(v){const S=o.render.frame;h.get(v)!==S&&(h.set(v,S),v.update())}function Ve(v,S){const F=v.colorSpace,Q=v.format,X=v.type;return v.isCompressedTexture===!0||v.isVideoTexture===!0||F!==So&&F!==hs&&(Et.getTransfer(F)===At?(Q!==ni||X!==qi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),S}function D(v){return typeof HTMLImageElement<"u"&&v instanceof HTMLImageElement?(c.width=v.naturalWidth||v.width,c.height=v.naturalHeight||v.height):typeof VideoFrame<"u"&&v instanceof VideoFrame?(c.width=v.displayWidth,c.height=v.displayHeight):(c.width=v.width,c.height=v.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=W,this.setTexture2D=K,this.setTexture2DArray=H,this.setTexture3D=ie,this.setTextureCube=B,this.rebindTextures=He,this.setupRenderTarget=je,this.updateRenderTargetMipmap=We,this.updateMultisampleRenderTarget=et,this.setupDepthRenderbuffer=Le,this.setupFrameBufferTexture=ve,this.useMultisampledRTT=Ue}function gD(n,e){function t(i,s=hs){let r;const o=Et.getTransfer(s);if(i===qi)return n.UNSIGNED_BYTE;if(i===Yd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Qd)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Vv)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Bv)return n.BYTE;if(i===Hv)return n.SHORT;if(i===pa)return n.UNSIGNED_SHORT;if(i===Xd)return n.INT;if(i===ir)return n.UNSIGNED_INT;if(i===Bi)return n.FLOAT;if(i===Sa)return n.HALF_FLOAT;if(i===Gv)return n.ALPHA;if(i===Wv)return n.RGB;if(i===ni)return n.RGBA;if(i===$v)return n.LUMINANCE;if(i===qv)return n.LUMINANCE_ALPHA;if(i===eo)return n.DEPTH_COMPONENT;if(i===po)return n.DEPTH_STENCIL;if(i===Xv)return n.RED;if(i===jd)return n.RED_INTEGER;if(i===Yv)return n.RG;if(i===Zd)return n.RG_INTEGER;if(i===Kd)return n.RGBA_INTEGER;if(i===Dl||i===Il||i===Ul||i===Nl)if(o===At)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Dl)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Il)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ul)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Nl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Dl)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Il)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ul)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Nl)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ku||i===Bu||i===Hu||i===Vu)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===ku)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Bu)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Hu)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Vu)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Gu||i===Wu||i===$u)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Gu||i===Wu)return o===At?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===$u)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===qu||i===Xu||i===Yu||i===Qu||i===ju||i===Zu||i===Ku||i===Ju||i===ed||i===td||i===nd||i===id||i===sd||i===rd)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===qu)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Xu)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Yu)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qu)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ju)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Zu)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ku)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ju)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ed)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===td)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nd)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===id)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===sd)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===rd)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fl||i===od||i===ad)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Fl)return o===At?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===od)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ad)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Qv||i===ld||i===cd||i===hd)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Fl)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ld)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===cd)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hd)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===fo?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class vD extends zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Xr extends Tn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xD={type:"move"};class Eh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Xr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new re,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new re),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new re,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new re),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let s=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const x of e.hand.values()){const d=t.getJointPose(x,i),u=this._getHandJoint(c,x);d!==null&&(u.matrix.fromArray(d.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=d.radius),u.visible=d!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=h.position.distanceTo(f.position),m=.02,g=.005;c.inputState.pinching&&p>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(xD)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Xr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const MD=` void main() { gl_Position = vec4( position, 1.0 ); }`,ED=` 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 yD{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const s=new dn,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Xi({vertexShader:MD,fragmentShader:ED,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Gn(new Ta(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class SD extends or{constructor(e,t){super();const i=this;let s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,f=null,p=null,m=null,g=null;const x=new yD,d=t.getContextAttributes();let u=null,w=null;const M=[],E=[],N=new at;let A=null;const T=new zn;T.viewport=new zt;const I=new zn;I.viewport=new zt;const C=[T,I],_=new vD;let b=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let te=M[$];return te===void 0&&(te=new Eh,M[$]=te),te.getTargetRaySpace()},this.getControllerGrip=function($){let te=M[$];return te===void 0&&(te=new Eh,M[$]=te),te.getGripSpace()},this.getHand=function($){let te=M[$];return te===void 0&&(te=new Eh,M[$]=te),te.getHandSpace()};function z($){const te=E.indexOf($.inputSource);if(te===-1)return;const ve=M[te];ve!==void 0&&(ve.update($.inputSource,$.frame,c||o),ve.dispatchEvent({type:$.type,data:$.inputSource}))}function G(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",G),s.removeEventListener("inputsourceschange",K);for(let $=0;$<M.length;$++){const te=E[$];te!==null&&(E[$]=null,M[$].disconnect(te))}b=null,W=null,x.reset(),e.setRenderTarget(u),m=null,p=null,f=null,s=null,w=null,Qe.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function($){if(s=$,s!==null){if(u=e.getRenderTarget(),s.addEventListener("select",z),s.addEventListener("selectstart",z),s.addEventListener("selectend",z),s.addEventListener("squeeze",z),s.addEventListener("squeezestart",z),s.addEventListener("squeezeend",z),s.addEventListener("end",G),s.addEventListener("inputsourceschange",K),d.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),s.renderState.layers===void 0){const te={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,t,te),s.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),w=new sr(m.framebufferWidth,m.framebufferHeight,{format:ni,type:qi,colorSpace:e.outputColorSpace,stencilBuffer:d.stencil})}else{let te=null,ve=null,de=null;d.depth&&(de=d.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,te=d.stencil?po:eo,ve=d.stencil?fo:ir);const Pe={colorFormat:t.RGBA8,depthFormat:de,scaleFactor:r};f=new XRWebGLBinding(s,t),p=f.createProjectionLayer(Pe),s.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),w=new sr(p.textureWidth,p.textureHeight,{format:ni,type:qi,depthTexture:new c0(p.textureWidth,p.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:d.stencil,colorSpace:e.outputColorSpace,samples:d.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),Qe.setContext(s),Qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function K($){for(let te=0;te<$.removed.length;te++){const ve=$.removed[te],de=E.indexOf(ve);de>=0&&(E[de]=null,M[de].disconnect(ve))}for(let te=0;te<$.added.length;te++){const ve=$.added[te];let de=E.indexOf(ve);if(de===-1){for(let Le=0;Le<M.length;Le++)if(Le>=E.length){E.push(ve),de=Le;break}else if(E[Le]===null){E[Le]=ve,de=Le;break}if(de===-1)break}const Pe=M[de];Pe&&Pe.connect(ve)}}const H=new re,ie=new re;function B($,te,ve){H.setFromMatrixPosition(te.matrixWorld),ie.setFromMatrixPosition(ve.matrixWorld);const de=H.distanceTo(ie),Pe=te.projectionMatrix.elements,Le=ve.projectionMatrix.elements,He=Pe[14]/(Pe[10]-1),je=Pe[14]/(Pe[10]+1),We=(Pe[9]+1)/Pe[5],q=(Pe[9]-1)/Pe[5],Z=(Pe[8]-1)/Pe[0],et=(Le[8]+1)/Le[0],$e=He*Z,Ue=He*et,Oe=de/(-Z+et),Ve=Oe*-Z;if(te.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Ve),$.translateZ(Oe),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Pe[10]===-1)$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{const D=He+Oe,v=je+Oe,S=$e-Ve,F=Ue+(de-Ve),Q=We*je/v*D,X=q*je/v*D;$.projectionMatrix.makePerspective(S,F,Q,X,D,v),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function ue($,te){te===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(te.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let te=$.near,ve=$.far;x.texture!==null&&(x.depthNear>0&&(te=x.depthNear),x.depthFar>0&&(ve=x.depthFar)),_.near=I.near=T.near=te,_.far=I.far=T.far=ve,(b!==_.near||W!==_.far)&&(s.updateRenderState({depthNear:_.near,depthFar:_.far}),b=_.near,W=_.far),T.layers.mask=$.layers.mask|2,I.layers.mask=$.layers.mask|4,_.layers.mask=T.layers.mask|I.layers.mask;const de=$.parent,Pe=_.cameras;ue(_,de);for(let Le=0;Le<Pe.length;Le++)ue(Pe[Le],de);Pe.length===2?B(_,T,I):_.projectionMatrix.copy(T.projectionMatrix),me($,_,de)};function me($,te,ve){ve===null?$.matrix.copy(te.matrixWorld):($.matrix.copy(ve.matrixWorld),$.matrix.invert(),$.matrix.multiply(te.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=ma*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return _},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function($){l=$,p!==null&&(p.fixedFoveation=$),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=$)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(_)};let Me=null;function Ge($,te){if(h=te.getViewerPose(c||o),g=te,h!==null){const ve=h.views;m!==null&&(e.setRenderTargetFramebuffer(w,m.framebuffer),e.setRenderTarget(w));let de=!1;ve.length!==_.cameras.length&&(_.cameras.length=0,de=!0);for(let Le=0;Le<ve.length;Le++){const He=ve[Le];let je=null;if(m!==null)je=m.getViewport(He);else{const q=f.getViewSubImage(p,He);je=q.viewport,Le===0&&(e.setRenderTargetTextures(w,q.colorTexture,p.ignoreDepthValues?void 0:q.depthStencilTexture),e.setRenderTarget(w))}let We=C[Le];We===void 0&&(We=new zn,We.layers.enable(Le),We.viewport=new zt,C[Le]=We),We.matrix.fromArray(He.transform.matrix),We.matrix.decompose(We.position,We.quaternion,We.scale),We.projectionMatrix.fromArray(He.projectionMatrix),We.projectionMatrixInverse.copy(We.projectionMatrix).invert(),We.viewport.set(je.x,je.y,je.width,je.height),Le===0&&(_.matrix.copy(We.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale)),de===!0&&_.cameras.push(We)}const Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")){const Le=f.getDepthInformation(ve[0]);Le&&Le.isValid&&Le.texture&&x.init(e,Le,s.renderState)}}for(let ve=0;ve<M.length;ve++){const de=E[ve],Pe=M[ve];de!==null&&Pe!==void 0&&Pe.update(de,te,c||o)}Me&&Me($,te),te.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:te}),g=null}const Qe=new l0;Qe.setAnimationLoop(Ge),this.setAnimationLoop=function($){Me=$},this.dispose=function(){}}}const Gs=new bi,bD=new Ft;function wD(n,e){function t(d,u){d.matrixAutoUpdate===!0&&d.updateMatrix(),u.value.copy(d.matrix)}function i(d,u){u.color.getRGB(d.fogColor.value,s0(n)),u.isFog?(d.fogNear.value=u.near,d.fogFar.value=u.far):u.isFogExp2&&(d.fogDensity.value=u.density)}function s(d,u,w,M,E){u.isMeshBasicMaterial||u.isMeshLambertMaterial?r(d,u):u.isMeshToonMaterial?(r(d,u),f(d,u)):u.isMeshPhongMaterial?(r(d,u),h(d,u)):u.isMeshStandardMaterial?(r(d,u),p(d,u),u.isMeshPhysicalMaterial&&m(d,u,E)):u.isMeshMatcapMaterial?(r(d,u),g(d,u)):u.isMeshDepthMaterial?r(d,u):u.isMeshDistanceMaterial?(r(d,u),x(d,u)):u.isMeshNormalMaterial?r(d,u):u.isLineBasicMaterial?(o(d,u),u.isLineDashedMaterial&&a(d,u)):u.isPointsMaterial?l(d,u,w,M):u.isSpriteMaterial?c(d,u):u.isShadowMaterial?(d.color.value.copy(u.color),d.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function r(d,u){d.opacity.value=u.opacity,u.color&&d.diffuse.value.copy(u.color),u.emissive&&d.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.bumpMap&&(d.bumpMap.value=u.bumpMap,t(u.bumpMap,d.bumpMapTransform),d.bumpScale.value=u.bumpScale,u.side===wn&&(d.bumpScale.value*=-1)),u.normalMap&&(d.normalMap.value=u.normalMap,t(u.normalMap,d.normalMapTransform),d.normalScale.value.copy(u.normalScale),u.side===wn&&d.normalScale.value.negate()),u.displacementMap&&(d.displacementMap.value=u.displacementMap,t(u.displacementMap,d.displacementMapTransform),d.displacementScale.value=u.displacementScale,d.displacementBias.value=u.displacementBias),u.emissiveMap&&(d.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,d.emissiveMapTransform)),u.specularMap&&(d.specularMap.value=u.specularMap,t(u.specularMap,d.specularMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest);const w=e.get(u),M=w.envMap,E=w.envMapRotation;M&&(d.envMap.value=M,Gs.copy(E),Gs.x*=-1,Gs.y*=-1,Gs.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Gs.y*=-1,Gs.z*=-1),d.envMapRotation.value.setFromMatrix4(bD.makeRotationFromEuler(Gs)),d.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=u.reflectivity,d.ior.value=u.ior,d.refractionRatio.value=u.refractionRatio),u.lightMap&&(d.lightMap.value=u.lightMap,d.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,d.lightMapTransform)),u.aoMap&&(d.aoMap.value=u.aoMap,d.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,d.aoMapTransform))}function o(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform))}function a(d,u){d.dashSize.value=u.dashSize,d.totalSize.value=u.dashSize+u.gapSize,d.scale.value=u.scale}function l(d,u,w,M){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.size.value=u.size*w,d.scale.value=M*.5,u.map&&(d.map.value=u.map,t(u.map,d.uvTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function c(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.rotation.value=u.rotation,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function h(d,u){d.specular.value.copy(u.specular),d.shininess.value=Math.max(u.shininess,1e-4)}function f(d,u){u.gradientMap&&(d.gradientMap.value=u.gradientMap)}function p(d,u){d.metalness.value=u.metalness,u.metalnessMap&&(d.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,d.metalnessMapTransform)),d.roughness.value=u.roughness,u.roughnessMap&&(d.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,d.roughnessMapTransform)),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)}function m(d,u,w){d.ior.value=u.ior,u.sheen>0&&(d.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),d.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(d.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,d.sheenColorMapTransform)),u.sheenRoughnessMap&&(d.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,d.sheenRoughnessMapTransform))),u.clearcoat>0&&(d.clearcoat.value=u.clearcoat,d.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(d.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,d.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(d.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===wn&&d.clearcoatNormalScale.value.negate())),u.dispersion>0&&(d.dispersion.value=u.dispersion),u.iridescence>0&&(d.iridescence.value=u.iridescence,d.iridescenceIOR.value=u.iridescenceIOR,d.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(d.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,d.iridescenceMapTransform)),u.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),u.transmission>0&&(d.transmission.value=u.transmission,d.transmissionSamplerMap.value=w.texture,d.transmissionSamplerSize.value.set(w.width,w.height),u.transmissionMap&&(d.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,d.transmissionMapTransform)),d.thickness.value=u.thickness,u.thicknessMap&&(d.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=u.attenuationDistance,d.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(d.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(d.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=u.specularIntensity,d.specularColor.value.copy(u.specularColor),u.specularColorMap&&(d.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,d.specularColorMapTransform)),u.specularIntensityMap&&(d.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,u){u.matcap&&(d.matcap.value=u.matcap)}function x(d,u){const w=e.get(u).light;d.referencePosition.value.setFromMatrixPosition(w.matrixWorld),d.nearDistance.value=w.shadow.camera.near,d.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function TD(n,e,t,i){let s={},r={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,M){const E=M.program;i.uniformBlockBinding(w,E)}function c(w,M){let E=s[w.id];E===void 0&&(g(w),E=h(w),s[w.id]=E,w.addEventListener("dispose",d));const N=M.program;i.updateUBOMapping(w,N);const A=e.render.frame;r[w.id]!==A&&(p(w),r[w.id]=A)}function h(w){const M=f();w.__bindingPointIndex=M;const E=n.createBuffer(),N=w.__size,A=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,N,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,M,E),E}function f(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(w){const M=s[w.id],E=w.uniforms,N=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,M);for(let A=0,T=E.length;A<T;A++){const I=Array.isArray(E[A])?E[A]:[E[A]];for(let C=0,_=I.length;C<_;C++){const b=I[C];if(m(b,A,C,N)===!0){const W=b.__offset,z=Array.isArray(b.value)?b.value:[b.value];let G=0;for(let K=0;K<z.length;K++){const H=z[K],ie=x(H);typeof H=="number"||typeof H=="boolean"?(b.__data[0]=H,n.bufferSubData(n.UNIFORM_BUFFER,W+G,b.__data)):H.isMatrix3?(b.__data[0]=H.elements[0],b.__data[1]=H.elements[1],b.__data[2]=H.elements[2],b.__data[3]=0,b.__data[4]=H.elements[3],b.__data[5]=H.elements[4],b.__data[6]=H.elements[5],b.__data[7]=0,b.__data[8]=H.elements[6],b.__data[9]=H.elements[7],b.__data[10]=H.elements[8],b.__data[11]=0):(H.toArray(b.__data,G),G+=ie.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,W,b.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(w,M,E,N){const A=w.value,T=M+"_"+E;if(N[T]===void 0)return typeof A=="number"||typeof A=="boolean"?N[T]=A:N[T]=A.clone(),!0;{const I=N[T];if(typeof A=="number"||typeof A=="boolean"){if(I!==A)return N[T]=A,!0}else if(I.equals(A)===!1)return I.copy(A),!0}return!1}function g(w){const M=w.uniforms;let E=0;const N=16;for(let T=0,I=M.length;T<I;T++){const C=Array.isArray(M[T])?M[T]:[M[T]];for(let _=0,b=C.length;_<b;_++){const W=C[_],z=Array.isArray(W.value)?W.value:[W.value];for(let G=0,K=z.length;G<K;G++){const H=z[G],ie=x(H),B=E%N,ue=B%ie.boundary,me=B+ue;E+=ue,me!==0&&N-me<ie.storage&&(E+=N-me),W.__data=new Float32Array(ie.storage/Float32Array.BYTES_PER_ELEMENT),W.__offset=E,E+=ie.storage}}}const A=E%N;return A>0&&(E+=N-A),w.__size=E,w.__cache={},this}function x(w){const M={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(M.boundary=4,M.storage=4):w.isVector2?(M.boundary=8,M.storage=8):w.isVector3||w.isColor?(M.boundary=16,M.storage=12):w.isVector4?(M.boundary=16,M.storage=16):w.isMatrix3?(M.boundary=48,M.storage=48):w.isMatrix4?(M.boundary=64,M.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),M}function d(w){const M=w.target;M.removeEventListener("dispose",d);const E=o.indexOf(M.__bindingPointIndex);o.splice(E,1),n.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function u(){for(const w in s)n.deleteBuffer(s[w]);o=[],s={},r={}}return{bind:l,update:c,dispose:u}}class AD{constructor(e={}){const{canvas:t=pC(),context:i=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reverseDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=o;const g=new Uint32Array(4),x=new Int32Array(4);let d=null,u=null;const w=[],M=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Dn,this.toneMapping=vs,this.toneMappingExposure=1;const E=this;let N=!1,A=0,T=0,I=null,C=-1,_=null;const b=new zt,W=new zt;let z=null;const G=new bt(0);let K=0,H=t.width,ie=t.height,B=1,ue=null,me=null;const Me=new zt(0,0,H,ie),Ge=new zt(0,0,H,ie);let Qe=!1;const $=new a0;let te=!1,ve=!1;const de=new Ft,Pe=new Ft,Le=new re,He=new zt,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function q(){return I===null?B:1}let Z=i;function et(y,R){return t.getContext(y,R)}try{const y={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${qd}`),t.addEventListener("webglcontextlost",ee,!1),t.addEventListener("webglcontextrestored",he,!1),t.addEventListener("webglcontextcreationerror",be,!1),Z===null){const R="webgl2";if(Z=et(R,y),Z===null)throw et(R)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let $e,Ue,Oe,Ve,D,v,S,F,Q,X,ne,_e,fe,Ae,ge,le,Ee,Ce,ye,we,Fe,qe,Y,k;function j(){$e=new DL(Z),$e.init(),qe=new gD(Z,$e),Ue=new wL(Z,$e,e,qe),Oe=new pD(Z,$e),Ue.reverseDepthBuffer&&p&&Oe.buffers.depth.setReversed(!0),Ve=new NL(Z),D=new J2,v=new _D(Z,$e,Oe,D,Ue,qe,Ve),S=new AL(E),F=new LL(E),Q=new HC(Z),Y=new SL(Z,Q),X=new IL(Z,Q,Ve,Y),ne=new OL(Z,X,Q,Ve),ye=new FL(Z,Ue,v),le=new TL(D),_e=new K2(E,S,F,$e,Ue,Y,le),fe=new wD(E,D),Ae=new tD,ge=new aD($e),Ce=new yL(E,S,F,Oe,ne,m,l),Ee=new dD(E,ne,Ue),k=new TD(Z,Ve,Ue,Oe),we=new bL(Z,$e,Ve),Fe=new UL(Z,$e,Ve),Ve.programs=_e.programs,E.capabilities=Ue,E.extensions=$e,E.properties=D,E.renderLists=Ae,E.shadowMap=Ee,E.state=Oe,E.info=Ve}j();const V=new SD(E,Z);this.xr=V,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){const y=$e.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=$e.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(y){y!==void 0&&(B=y,this.setSize(H,ie,!1))},this.getSize=function(y){return y.set(H,ie)},this.setSize=function(y,R,U=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=y,ie=R,t.width=Math.floor(y*B),t.height=Math.floor(R*B),U===!0&&(t.style.width=y+"px",t.style.height=R+"px"),this.setViewport(0,0,y,R)},this.getDrawingBufferSize=function(y){return y.set(H*B,ie*B).floor()},this.setDrawingBufferSize=function(y,R,U){H=y,ie=R,B=U,t.width=Math.floor(y*U),t.height=Math.floor(R*U),this.setViewport(0,0,y,R)},this.getCurrentViewport=function(y){return y.copy(b)},this.getViewport=function(y){return y.copy(Me)},this.setViewport=function(y,R,U,L){y.isVector4?Me.set(y.x,y.y,y.z,y.w):Me.set(y,R,U,L),Oe.viewport(b.copy(Me).multiplyScalar(B).round())},this.getScissor=function(y){return y.copy(Ge)},this.setScissor=function(y,R,U,L){y.isVector4?Ge.set(y.x,y.y,y.z,y.w):Ge.set(y,R,U,L),Oe.scissor(W.copy(Ge).multiplyScalar(B).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(y){Oe.setScissorTest(Qe=y)},this.setOpaqueSort=function(y){ue=y},this.setTransparentSort=function(y){me=y},this.getClearColor=function(y){return y.copy(Ce.getClearColor())},this.setClearColor=function(){Ce.setClearColor.apply(Ce,arguments)},this.getClearAlpha=function(){return Ce.getClearAlpha()},this.setClearAlpha=function(){Ce.setClearAlpha.apply(Ce,arguments)},this.clear=function(y=!0,R=!0,U=!0){let L=0;if(y){let O=!1;if(I!==null){const oe=I.texture.format;O=oe===Kd||oe===Zd||oe===jd}if(O){const oe=I.texture.type,pe=oe===qi||oe===ir||oe===pa||oe===fo||oe===Yd||oe===Qd,xe=Ce.getClearColor(),Se=Ce.getClearAlpha(),Re=xe.r,Te=xe.g,De=xe.b;pe?(g[0]=Re,g[1]=Te,g[2]=De,g[3]=Se,Z.clearBufferuiv(Z.COLOR,0,g)):(x[0]=Re,x[1]=Te,x[2]=De,x[3]=Se,Z.clearBufferiv(Z.COLOR,0,x))}else L|=Z.COLOR_BUFFER_BIT}R&&(L|=Z.DEPTH_BUFFER_BIT),U&&(L|=Z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Z.clear(L)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ee,!1),t.removeEventListener("webglcontextrestored",he,!1),t.removeEventListener("webglcontextcreationerror",be,!1),Ae.dispose(),ge.dispose(),D.dispose(),S.dispose(),F.dispose(),ne.dispose(),Y.dispose(),k.dispose(),_e.dispose(),V.dispose(),V.removeEventListener("sessionstart",Ao),V.removeEventListener("sessionend",li),$n.stop()};function ee(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function he(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const y=Ve.autoReset,R=Ee.enabled,U=Ee.autoUpdate,L=Ee.needsUpdate,O=Ee.type;j(),Ve.autoReset=y,Ee.enabled=R,Ee.autoUpdate=U,Ee.needsUpdate=L,Ee.type=O}function be(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Xe(y){const R=y.target;R.removeEventListener("dispose",Xe),xt(R)}function xt(y){Je(y),D.remove(y)}function Je(y){const R=D.get(y).programs;R!==void 0&&(R.forEach(function(U){_e.releaseProgram(U)}),y.isShaderMaterial&&_e.releaseShaderCache(y))}this.renderBufferDirect=function(y,R,U,L,O,oe){R===null&&(R=je);const pe=O.isMesh&&O.matrixWorld.determinant()<0,xe=mc(y,R,U,L,O);Oe.setMaterial(L,pe);let Se=U.index,Re=1;if(L.wireframe===!0){if(Se=X.getWireframeAttribute(U),Se===void 0)return;Re=2}const Te=U.drawRange,De=U.attributes.position;let Ye=Te.start*Re,Ze=(Te.start+Te.count)*Re;oe!==null&&(Ye=Math.max(Ye,oe.start*Re),Ze=Math.min(Ze,(oe.start+oe.count)*Re)),Se!==null?(Ye=Math.max(Ye,0),Ze=Math.min(Ze,Se.count)):De!=null&&(Ye=Math.max(Ye,0),Ze=Math.min(Ze,De.count));const _t=Ze-Ye;if(_t<0||_t===1/0)return;Y.setup(O,L,xe,U,Se);let tt,Ie=we;if(Se!==null&&(tt=Q.get(Se),Ie=Fe,Ie.setIndex(tt)),O.isMesh)L.wireframe===!0?(Oe.setLineWidth(L.wireframeLinewidth*q()),Ie.setMode(Z.LINES)):Ie.setMode(Z.TRIANGLES);else if(O.isLine){let Be=L.linewidth;Be===void 0&&(Be=1),Oe.setLineWidth(Be*q()),O.isLineSegments?Ie.setMode(Z.LINES):O.isLineLoop?Ie.setMode(Z.LINE_LOOP):Ie.setMode(Z.LINE_STRIP)}else O.isPoints?Ie.setMode(Z.POINTS):O.isSprite&&Ie.setMode(Z.TRIANGLES);if(O.isBatchedMesh)if(O._multiDrawInstances!==null)Ie.renderMultiDrawInstances(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount,O._multiDrawInstances);else if($e.get("WEBGL_multi_draw"))Ie.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else{const Be=O._multiDrawStarts,ut=O._multiDrawCounts,ot=O._multiDrawCount,Zt=Se?Q.get(Se).bytesPerElement:1,kt=D.get(L).currentProgram.getUniforms();for(let sn=0;sn<ot;sn++)kt.setValue(Z,"_gl_DrawID",sn),Ie.render(Be[sn]/Zt,ut[sn])}else if(O.isInstancedMesh)Ie.renderInstances(Ye,_t,O.count);else if(U.isInstancedBufferGeometry){const Be=U._maxInstanceCount!==void 0?U._maxInstanceCount:1/0,ut=Math.min(U.instanceCount,Be);Ie.renderInstances(Ye,_t,ut)}else Ie.render(Ye,_t)};function st(y,R,U){y.transparent===!0&&y.side===_i&&y.forceSinglePass===!1?(y.side=wn,y.needsUpdate=!0,Ls(y,R,U),y.side=ws,y.needsUpdate=!0,Ls(y,R,U),y.side=_i):Ls(y,R,U)}this.compile=function(y,R,U=null){U===null&&(U=y),u=ge.get(U),u.init(R),M.push(u),U.traverseVisible(function(O){O.isLight&&O.layers.test(R.layers)&&(u.pushLight(O),O.castShadow&&u.pushShadow(O))}),y!==U&&y.traverseVisible(function(O){O.isLight&&O.layers.test(R.layers)&&(u.pushLight(O),O.castShadow&&u.pushShadow(O))}),u.setupLights();const L=new Set;return y.traverse(function(O){if(!(O.isMesh||O.isPoints||O.isLine||O.isSprite))return;const oe=O.material;if(oe)if(Array.isArray(oe))for(let pe=0;pe<oe.length;pe++){const xe=oe[pe];st(xe,U,O),L.add(xe)}else st(oe,U,O),L.add(oe)}),M.pop(),u=null,L},this.compileAsync=function(y,R,U=null){const L=this.compile(y,R,U);return new Promise(O=>{function oe(){if(L.forEach(function(pe){D.get(pe).currentProgram.isReady()&&L.delete(pe)}),L.size===0){O(y);return}setTimeout(oe,10)}$e.get("KHR_parallel_shader_compile")!==null?oe():setTimeout(oe,10)})};let Ot=null;function In(y){Ot&&Ot(y)}function Ao(){$n.stop()}function li(){$n.start()}const $n=new l0;$n.setAnimationLoop(In),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(y){Ot=y,V.setAnimationLoop(y),y===null?$n.stop():$n.start()},V.addEventListener("sessionstart",Ao),V.addEventListener("sessionend",li),this.render=function(y,R){if(R!==void 0&&R.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),R.parent===null&&R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(R),R=V.getCamera()),y.isScene===!0&&y.onBeforeRender(E,y,R,I),u=ge.get(y,M.length),u.init(R),M.push(u),Pe.multiplyMatrices(R.projectionMatrix,R.matrixWorldInverse),$.setFromProjectionMatrix(Pe),ve=this.localClippingEnabled,te=le.init(this.clippingPlanes,ve),d=Ae.get(y,w.length),d.init(),w.push(d),V.enabled===!0&&V.isPresenting===!0){const oe=E.xr.getDepthSensingMesh();oe!==null&&ar(oe,R,-1/0,E.sortObjects)}ar(y,R,0,E.sortObjects),d.finish(),E.sortObjects===!0&&d.sort(ue,me),We=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,We&&Ce.addToRenderList(d,y),this.info.render.frame++,te===!0&&le.beginShadows();const U=u.state.shadowsArray;Ee.render(U,y,R),te===!0&&le.endShadows(),this.info.autoReset===!0&&this.info.reset();const L=d.opaque,O=d.transmissive;if(u.setupLights(),R.isArrayCamera){const oe=R.cameras;if(O.length>0)for(let pe=0,xe=oe.length;pe<xe;pe++){const Se=oe[pe];Cs(L,O,y,Se)}We&&Ce.render(y);for(let pe=0,xe=oe.length;pe<xe;pe++){const Se=oe[pe];Co(d,y,Se,Se.viewport)}}else O.length>0&&Cs(L,O,y,R),We&&Ce.render(y),Co(d,y,R);I!==null&&(v.updateMultisampleRenderTarget(I),v.updateRenderTargetMipmap(I)),y.isScene===!0&&y.onAfterRender(E,y,R),Y.resetDefaultState(),C=-1,_=null,M.pop(),M.length>0?(u=M[M.length-1],te===!0&&le.setGlobalState(E.clippingPlanes,u.state.camera)):u=null,w.pop(),w.length>0?d=w[w.length-1]:d=null};function ar(y,R,U,L){if(y.visible===!1)return;if(y.layers.test(R.layers)){if(y.isGroup)U=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(R);else if(y.isLight)u.pushLight(y),y.castShadow&&u.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||$.intersectsSprite(y)){L&&He.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Pe);const pe=ne.update(y),xe=y.material;xe.visible&&d.push(y,pe,xe,U,He.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||$.intersectsObject(y))){const pe=ne.update(y),xe=y.material;if(L&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),He.copy(y.boundingSphere.center)):(pe.boundingSphere===null&&pe.computeBoundingSphere(),He.copy(pe.boundingSphere.center)),He.applyMatrix4(y.matrixWorld).applyMatrix4(Pe)),Array.isArray(xe)){const Se=pe.groups;for(let Re=0,Te=Se.length;Re<Te;Re++){const De=Se[Re],Ye=xe[De.materialIndex];Ye&&Ye.visible&&d.push(y,pe,Ye,U,He.z,De)}}else xe.visible&&d.push(y,pe,xe,U,He.z,null)}}const oe=y.children;for(let pe=0,xe=oe.length;pe<xe;pe++)ar(oe[pe],R,U,L)}function Co(y,R,U,L){const O=y.opaque,oe=y.transmissive,pe=y.transparent;u.setupLightsView(U),te===!0&&le.setGlobalState(E.clippingPlanes,U),L&&Oe.viewport(b.copy(L)),O.length>0&&Rs(O,R,U),oe.length>0&&Rs(oe,R,U),pe.length>0&&Rs(pe,R,U),Oe.buffers.depth.setTest(!0),Oe.buffers.depth.setMask(!0),Oe.buffers.color.setMask(!0),Oe.setPolygonOffset(!1)}function Cs(y,R,U,L){if((U.isScene===!0?U.overrideMaterial:null)!==null)return;u.state.transmissionRenderTarget[L.id]===void 0&&(u.state.transmissionRenderTarget[L.id]=new sr(1,1,{generateMipmaps:!0,type:$e.has("EXT_color_buffer_half_float")||$e.has("EXT_color_buffer_float")?Sa:qi,minFilter:Js,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Et.workingColorSpace}));const oe=u.state.transmissionRenderTarget[L.id],pe=L.viewport||b;oe.setSize(pe.z,pe.w);const xe=E.getRenderTarget();E.setRenderTarget(oe),E.getClearColor(G),K=E.getClearAlpha(),K<1&&E.setClearColor(16777215,.5),E.clear(),We&&Ce.render(U);const Se=E.toneMapping;E.toneMapping=vs;const Re=L.viewport;if(L.viewport!==void 0&&(L.viewport=void 0),u.setupLightsView(L),te===!0&&le.setGlobalState(E.clippingPlanes,L),Rs(y,U,L),v.updateMultisampleRenderTarget(oe),v.updateRenderTargetMipmap(oe),$e.has("WEBGL_multisampled_render_to_texture")===!1){let Te=!1;for(let De=0,Ye=R.length;De<Ye;De++){const Ze=R[De],_t=Ze.object,tt=Ze.geometry,Ie=Ze.material,Be=Ze.group;if(Ie.side===_i&&_t.layers.test(L.layers)){const ut=Ie.side;Ie.side=wn,Ie.needsUpdate=!0,Ps(_t,U,L,tt,Ie,Be),Ie.side=ut,Ie.needsUpdate=!0,Te=!0}}Te===!0&&(v.updateMultisampleRenderTarget(oe),v.updateRenderTargetMipmap(oe))}E.setRenderTarget(xe),E.setClearColor(G,K),Re!==void 0&&(L.viewport=Re),E.toneMapping=Se}function Rs(y,R,U){const L=R.isScene===!0?R.overrideMaterial:null;for(let O=0,oe=y.length;O<oe;O++){const pe=y[O],xe=pe.object,Se=pe.geometry,Re=L===null?pe.material:L,Te=pe.group;xe.layers.test(U.layers)&&Ps(xe,R,U,Se,Re,Te)}}function Ps(y,R,U,L,O,oe){y.onBeforeRender(E,R,U,L,O,oe),y.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),O.onBeforeRender(E,R,U,L,y,oe),O.transparent===!0&&O.side===_i&&O.forceSinglePass===!1?(O.side=wn,O.needsUpdate=!0,E.renderBufferDirect(U,R,L,O,y,oe),O.side=ws,O.needsUpdate=!0,E.renderBufferDirect(U,R,L,O,y,oe),O.side=_i):E.renderBufferDirect(U,R,L,O,y,oe),y.onAfterRender(E,R,U,L,O,oe)}function Ls(y,R,U){R.isScene!==!0&&(R=je);const L=D.get(y),O=u.state.lights,oe=u.state.shadowsArray,pe=O.state.version,xe=_e.getParameters(y,O.state,oe,R,U),Se=_e.getProgramCacheKey(xe);let Re=L.programs;L.environment=y.isMeshStandardMaterial?R.environment:null,L.fog=R.fog,L.envMap=(y.isMeshStandardMaterial?F:S).get(y.envMap||L.environment),L.envMapRotation=L.environment!==null&&y.envMap===null?R.environmentRotation:y.envMapRotation,Re===void 0&&(y.addEventListener("dispose",Xe),Re=new Map,L.programs=Re);let Te=Re.get(Se);if(Te!==void 0){if(L.currentProgram===Te&&L.lightsStateVersion===pe)return Aa(y,xe),Te}else xe.uniforms=_e.getUniforms(y),y.onBeforeCompile(xe,E),Te=_e.acquireProgram(xe,Se),Re.set(Se,Te),L.uniforms=xe.uniforms;const De=L.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(De.clippingPlanes=le.uniform),Aa(y,xe),L.needsLights=P(y),L.lightsStateVersion=pe,L.needsLights&&(De.ambientLightColor.value=O.state.ambient,De.lightProbe.value=O.state.probe,De.directionalLights.value=O.state.directional,De.directionalLightShadows.value=O.state.directionalShadow,De.spotLights.value=O.state.spot,De.spotLightShadows.value=O.state.spotShadow,De.rectAreaLights.value=O.state.rectArea,De.ltc_1.value=O.state.rectAreaLTC1,De.ltc_2.value=O.state.rectAreaLTC2,De.pointLights.value=O.state.point,De.pointLightShadows.value=O.state.pointShadow,De.hemisphereLights.value=O.state.hemi,De.directionalShadowMap.value=O.state.directionalShadowMap,De.directionalShadowMatrix.value=O.state.directionalShadowMatrix,De.spotShadowMap.value=O.state.spotShadowMap,De.spotLightMatrix.value=O.state.spotLightMatrix,De.spotLightMap.value=O.state.spotLightMap,De.pointShadowMap.value=O.state.pointShadowMap,De.pointShadowMatrix.value=O.state.pointShadowMatrix),L.currentProgram=Te,L.uniformsList=null,Te}function Ro(y){if(y.uniformsList===null){const R=y.currentProgram.getUniforms();y.uniformsList=Ol.seqWithValue(R.seq,y.uniforms)}return y.uniformsList}function Aa(y,R){const U=D.get(y);U.outputColorSpace=R.outputColorSpace,U.batching=R.batching,U.batchingColor=R.batchingColor,U.instancing=R.instancing,U.instancingColor=R.instancingColor,U.instancingMorph=R.instancingMorph,U.skinning=R.skinning,U.morphTargets=R.morphTargets,U.morphNormals=R.morphNormals,U.morphColors=R.morphColors,U.morphTargetsCount=R.morphTargetsCount,U.numClippingPlanes=R.numClippingPlanes,U.numIntersection=R.numClipIntersection,U.vertexAlphas=R.vertexAlphas,U.vertexTangents=R.vertexTangents,U.toneMapping=R.toneMapping}function mc(y,R,U,L,O){R.isScene!==!0&&(R=je),v.resetTextureUnits();const oe=R.fog,pe=L.isMeshStandardMaterial?R.environment:null,xe=I===null?E.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:So,Se=(L.isMeshStandardMaterial?F:S).get(L.envMap||pe),Re=L.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,Te=!!U.attributes.tangent&&(!!L.normalMap||L.anisotropy>0),De=!!U.morphAttributes.position,Ye=!!U.morphAttributes.normal,Ze=!!U.morphAttributes.color;let _t=vs;L.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(_t=E.toneMapping);const tt=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,Ie=tt!==void 0?tt.length:0,Be=D.get(L),ut=u.state.lights;if(te===!0&&(ve===!0||y!==_)){const on=y===_&&L.id===C;le.setState(L,y,on)}let ot=!1;L.version===Be.__version?(Be.needsLights&&Be.lightsStateVersion!==ut.state.version||Be.outputColorSpace!==xe||O.isBatchedMesh&&Be.batching===!1||!O.isBatchedMesh&&Be.batching===!0||O.isBatchedMesh&&Be.batchingColor===!0&&O.colorTexture===null||O.isBatchedMesh&&Be.batchingColor===!1&&O.colorTexture!==null||O.isInstancedMesh&&Be.instancing===!1||!O.isInstancedMesh&&Be.instancing===!0||O.isSkinnedMesh&&Be.skinning===!1||!O.isSkinnedMesh&&Be.skinning===!0||O.isInstancedMesh&&Be.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Be.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Be.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Be.instancingMorph===!1&&O.morphTexture!==null||Be.envMap!==Se||L.fog===!0&&Be.fog!==oe||Be.numClippingPlanes!==void 0&&(Be.numClippingPlanes!==le.numPlanes||Be.numIntersection!==le.numIntersection)||Be.vertexAlphas!==Re||Be.vertexTangents!==Te||Be.morphTargets!==De||Be.morphNormals!==Ye||Be.morphColors!==Ze||Be.toneMapping!==_t||Be.morphTargetsCount!==Ie)&&(ot=!0):(ot=!0,Be.__version=L.version);let Zt=Be.currentProgram;ot===!0&&(Zt=Ls(L,R,O));let kt=!1,sn=!1,Pt=!1;const Mt=Zt.getUniforms(),En=Be.uniforms;if(Oe.useProgram(Zt.program)&&(kt=!0,sn=!0,Pt=!0),L.id!==C&&(C=L.id,sn=!0),kt||_!==y){Oe.buffers.depth.getReversed()?(de.copy(y.projectionMatrix),_C(de),gC(de),Mt.setValue(Z,"projectionMatrix",de)):Mt.setValue(Z,"projectionMatrix",y.projectionMatrix),Mt.setValue(Z,"viewMatrix",y.matrixWorldInverse);const ci=Mt.map.cameraPosition;ci!==void 0&&ci.setValue(Z,Le.setFromMatrixPosition(y.matrixWorld)),Ue.logarithmicDepthBuffer&&Mt.setValue(Z,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(L.isMeshPhongMaterial||L.isMeshToonMaterial||L.isMeshLambertMaterial||L.isMeshBasicMaterial||L.isMeshStandardMaterial||L.isShaderMaterial)&&Mt.setValue(Z,"isOrthographic",y.isOrthographicCamera===!0),_!==y&&(_=y,sn=!0,Pt=!0)}if(O.isSkinnedMesh){Mt.setOptional(Z,O,"bindMatrix"),Mt.setOptional(Z,O,"bindMatrixInverse");const on=O.skeleton;on&&(on.boneTexture===null&&on.computeBoneTexture(),Mt.setValue(Z,"boneTexture",on.boneTexture,v))}O.isBatchedMesh&&(Mt.setOptional(Z,O,"batchingTexture"),Mt.setValue(Z,"batchingTexture",O._matricesTexture,v),Mt.setOptional(Z,O,"batchingIdTexture"),Mt.setValue(Z,"batchingIdTexture",O._indirectTexture,v),Mt.setOptional(Z,O,"batchingColorTexture"),O._colorsTexture!==null&&Mt.setValue(Z,"batchingColorTexture",O._colorsTexture,v));const Kt=U.morphAttributes;if((Kt.position!==void 0||Kt.normal!==void 0||Kt.color!==void 0)&&ye.update(O,U,Zt),(sn||Be.receiveShadow!==O.receiveShadow)&&(Be.receiveShadow=O.receiveShadow,Mt.setValue(Z,"receiveShadow",O.receiveShadow)),L.isMeshGouraudMaterial&&L.envMap!==null&&(En.envMap.value=Se,En.flipEnvMap.value=Se.isCubeTexture&&Se.isRenderTargetTexture===!1?-1:1),L.isMeshStandardMaterial&&L.envMap===null&&R.environment!==null&&(En.envMapIntensity.value=R.environmentIntensity),sn&&(Mt.setValue(Z,"toneMappingExposure",E.toneMappingExposure),Be.needsLights&&_c(En,Pt),oe&&L.fog===!0&&fe.refreshFogUniforms(En,oe),fe.refreshMaterialUniforms(En,L,B,ie,u.state.transmissionRenderTarget[y.id]),Ol.upload(Z,Ro(Be),En,v)),L.isShaderMaterial&&L.uniformsNeedUpdate===!0&&(Ol.upload(Z,Ro(Be),En,v),L.uniformsNeedUpdate=!1),L.isSpriteMaterial&&Mt.setValue(Z,"center",O.center),Mt.setValue(Z,"modelViewMatrix",O.modelViewMatrix),Mt.setValue(Z,"normalMatrix",O.normalMatrix),Mt.setValue(Z,"modelMatrix",O.matrixWorld),L.isShaderMaterial||L.isRawShaderMaterial){const on=L.uniformsGroups;for(let ci=0,qn=on.length;ci<qn;ci++){const hf=on[ci];k.update(hf,Zt),k.bind(hf,Zt)}}return Zt}function _c(y,R){y.ambientLightColor.needsUpdate=R,y.lightProbe.needsUpdate=R,y.directionalLights.needsUpdate=R,y.directionalLightShadows.needsUpdate=R,y.pointLights.needsUpdate=R,y.pointLightShadows.needsUpdate=R,y.spotLights.needsUpdate=R,y.spotLightShadows.needsUpdate=R,y.rectAreaLights.needsUpdate=R,y.hemisphereLights.needsUpdate=R}function P(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(y,R,U){D.get(y.texture).__webglTexture=R,D.get(y.depthTexture).__webglTexture=U;const L=D.get(y);L.__hasExternalTextures=!0,L.__autoAllocateDepthBuffer=U===void 0,L.__autoAllocateDepthBuffer||$e.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),L.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(y,R){const U=D.get(y);U.__webglFramebuffer=R,U.__useDefaultFramebuffer=R===void 0},this.setRenderTarget=function(y,R=0,U=0){I=y,A=R,T=U;let L=!0,O=null,oe=!1,pe=!1;if(y){const Se=D.get(y);if(Se.__useDefaultFramebuffer!==void 0)Oe.bindFramebuffer(Z.FRAMEBUFFER,null),L=!1;else if(Se.__webglFramebuffer===void 0)v.setupRenderTarget(y);else if(Se.__hasExternalTextures)v.rebindTextures(y,D.get(y.texture).__webglTexture,D.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const De=y.depthTexture;if(Se.__boundDepthTexture!==De){if(De!==null&&D.has(De)&&(y.width!==De.image.width||y.height!==De.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");v.setupDepthRenderbuffer(y)}}const Re=y.texture;(Re.isData3DTexture||Re.isDataArrayTexture||Re.isCompressedArrayTexture)&&(pe=!0);const Te=D.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Te[R])?O=Te[R][U]:O=Te[R],oe=!0):y.samples>0&&v.useMultisampledRTT(y)===!1?O=D.get(y).__webglMultisampledFramebuffer:Array.isArray(Te)?O=Te[U]:O=Te,b.copy(y.viewport),W.copy(y.scissor),z=y.scissorTest}else b.copy(Me).multiplyScalar(B).floor(),W.copy(Ge).multiplyScalar(B).floor(),z=Qe;if(Oe.bindFramebuffer(Z.FRAMEBUFFER,O)&&L&&Oe.drawBuffers(y,O),Oe.viewport(b),Oe.scissor(W),Oe.setScissorTest(z),oe){const Se=D.get(y.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_CUBE_MAP_POSITIVE_X+R,Se.__webglTexture,U)}else if(pe){const Se=D.get(y.texture),Re=R||0;Z.framebufferTextureLayer(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Se.__webglTexture,U||0,Re)}C=-1},this.readRenderTargetPixels=function(y,R,U,L,O,oe,pe){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xe=D.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&pe!==void 0&&(xe=xe[pe]),xe){Oe.bindFramebuffer(Z.FRAMEBUFFER,xe);try{const Se=y.texture,Re=Se.format,Te=Se.type;if(!Ue.textureFormatReadable(Re)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Te)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}R>=0&&R<=y.width-L&&U>=0&&U<=y.height-O&&Z.readPixels(R,U,L,O,qe.convert(Re),qe.convert(Te),oe)}finally{const Se=I!==null?D.get(I).__webglFramebuffer:null;Oe.bindFramebuffer(Z.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(y,R,U,L,O,oe,pe){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xe=D.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&pe!==void 0&&(xe=xe[pe]),xe){const Se=y.texture,Re=Se.format,Te=Se.type;if(!Ue.textureFormatReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Te))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(R>=0&&R<=y.width-L&&U>=0&&U<=y.height-O){Oe.bindFramebuffer(Z.FRAMEBUFFER,xe);const De=Z.createBuffer();Z.bindBuffer(Z.PIXEL_PACK_BUFFER,De),Z.bufferData(Z.PIXEL_PACK_BUFFER,oe.byteLength,Z.STREAM_READ),Z.readPixels(R,U,L,O,qe.convert(Re),qe.convert(Te),0);const Ye=I!==null?D.get(I).__webglFramebuffer:null;Oe.bindFramebuffer(Z.FRAMEBUFFER,Ye);const Ze=Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE,0);return Z.flush(),await mC(Z,Ze,4),Z.bindBuffer(Z.PIXEL_PACK_BUFFER,De),Z.getBufferSubData(Z.PIXEL_PACK_BUFFER,0,oe),Z.deleteBuffer(De),Z.deleteSync(Ze),oe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(y,R=null,U=0){y.isTexture!==!0&&(Wo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),R=arguments[0]||null,y=arguments[1]);const L=Math.pow(2,-U),O=Math.floor(y.image.width*L),oe=Math.floor(y.image.height*L),pe=R!==null?R.x:0,xe=R!==null?R.y:0;v.setTexture2D(y,0),Z.copyTexSubImage2D(Z.TEXTURE_2D,U,0,0,pe,xe,O,oe),Oe.unbindTexture()},this.copyTextureToTexture=function(y,R,U=null,L=null,O=0){y.isTexture!==!0&&(Wo("WebGLRenderer: copyTextureToTexture function signature has changed."),L=arguments[0]||null,y=arguments[1],R=arguments[2],O=arguments[3]||0,U=null);let oe,pe,xe,Se,Re,Te,De,Ye,Ze;const _t=y.isCompressedTexture?y.mipmaps[O]:y.image;U!==null?(oe=U.max.x-U.min.x,pe=U.max.y-U.min.y,xe=U.isBox3?U.max.z-U.min.z:1,Se=U.min.x,Re=U.min.y,Te=U.isBox3?U.min.z:0):(oe=_t.width,pe=_t.height,xe=_t.depth||1,Se=0,Re=0,Te=0),L!==null?(De=L.x,Ye=L.y,Ze=L.z):(De=0,Ye=0,Ze=0);const tt=qe.convert(R.format),Ie=qe.convert(R.type);let Be;R.isData3DTexture?(v.setTexture3D(R,0),Be=Z.TEXTURE_3D):R.isDataArrayTexture||R.isCompressedArrayTexture?(v.setTexture2DArray(R,0),Be=Z.TEXTURE_2D_ARRAY):(v.setTexture2D(R,0),Be=Z.TEXTURE_2D),Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,R.flipY),Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),Z.pixelStorei(Z.UNPACK_ALIGNMENT,R.unpackAlignment);const ut=Z.getParameter(Z.UNPACK_ROW_LENGTH),ot=Z.getParameter(Z.UNPACK_IMAGE_HEIGHT),Zt=Z.getParameter(Z.UNPACK_SKIP_PIXELS),kt=Z.getParameter(Z.UNPACK_SKIP_ROWS),sn=Z.getParameter(Z.UNPACK_SKIP_IMAGES);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,_t.width),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,_t.height),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,Se),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,Re),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,Te);const Pt=y.isDataArrayTexture||y.isData3DTexture,Mt=R.isDataArrayTexture||R.isData3DTexture;if(y.isRenderTargetTexture||y.isDepthTexture){const En=D.get(y),Kt=D.get(R),on=D.get(En.__renderTarget),ci=D.get(Kt.__renderTarget);Oe.bindFramebuffer(Z.READ_FRAMEBUFFER,on.__webglFramebuffer),Oe.bindFramebuffer(Z.DRAW_FRAMEBUFFER,ci.__webglFramebuffer);for(let qn=0;qn<xe;qn++)Pt&&Z.framebufferTextureLayer(Z.READ_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,D.get(y).__webglTexture,O,Te+qn),y.isDepthTexture?(Mt&&Z.framebufferTextureLayer(Z.DRAW_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,D.get(R).__webglTexture,O,Ze+qn),Z.blitFramebuffer(Se,Re,oe,pe,De,Ye,oe,pe,Z.DEPTH_BUFFER_BIT,Z.NEAREST)):Mt?Z.copyTexSubImage3D(Be,O,De,Ye,Ze+qn,Se,Re,oe,pe):Z.copyTexSubImage2D(Be,O,De,Ye,Ze+qn,Se,Re,oe,pe);Oe.bindFramebuffer(Z.READ_FRAMEBUFFER,null),Oe.bindFramebuffer(Z.DRAW_FRAMEBUFFER,null)}else Mt?y.isDataTexture||y.isData3DTexture?Z.texSubImage3D(Be,O,De,Ye,Ze,oe,pe,xe,tt,Ie,_t.data):R.isCompressedArrayTexture?Z.compressedTexSubImage3D(Be,O,De,Ye,Ze,oe,pe,xe,tt,_t.data):Z.texSubImage3D(Be,O,De,Ye,Ze,oe,pe,xe,tt,Ie,_t):y.isDataTexture?Z.texSubImage2D(Z.TEXTURE_2D,O,De,Ye,oe,pe,tt,Ie,_t.data):y.isCompressedTexture?Z.compressedTexSubImage2D(Z.TEXTURE_2D,O,De,Ye,_t.width,_t.height,tt,_t.data):Z.texSubImage2D(Z.TEXTURE_2D,O,De,Ye,oe,pe,tt,Ie,_t);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,ut),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,ot),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,Zt),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,kt),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,sn),O===0&&R.generateMipmaps&&Z.generateMipmap(Be),Oe.unbindTexture()},this.copyTextureToTexture3D=function(y,R,U=null,L=null,O=0){return y.isTexture!==!0&&(Wo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),U=arguments[0]||null,L=arguments[1]||null,y=arguments[2],R=arguments[3],O=arguments[4]||0),Wo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(y,R,U,L,O)},this.initRenderTarget=function(y){D.get(y).__webglFramebuffer===void 0&&v.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?v.setTextureCube(y,0):y.isData3DTexture?v.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?v.setTexture2DArray(y,0):v.setTexture2D(y,0),Oe.unbindTexture()},this.resetState=function(){A=0,T=0,I=null,Oe.reset(),Y.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=Et._getDrawingBufferColorSpace(e),t.unpackColorSpace=Et._getUnpackColorSpace()}}class p0 extends Tn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new bi,this.environmentIntensity=1,this.environmentRotation=new bi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class m0 extends dn{constructor(e,t,i,s,r,o,a,l,c){super(e,t,i,s,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Vn,this.magFilter=r!==void 0?r:Vn,this.generateMipmaps=!1;const h=this;function f(){h.needsUpdate=!0,e.requestVideoFrameCallback(f)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(f)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class of extends As{constructor(e=1,t=32,i=16,s=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:s,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const h=[],f=new re,p=new re,m=[],g=[],x=[],d=[];for(let u=0;u<=i;u++){const w=[],M=u/i;let E=0;u===0&&o===0?E=.5/t:u===i&&l===Math.PI&&(E=-.5/t);for(let N=0;N<=t;N++){const A=N/t;f.x=-e*Math.cos(s+A*r)*Math.sin(o+M*a),f.y=e*Math.cos(o+M*a),f.z=e*Math.sin(s+A*r)*Math.sin(o+M*a),g.push(f.x,f.y,f.z),p.copy(f).normalize(),x.push(p.x,p.y,p.z),d.push(A+E,1-M),w.push(c++)}h.push(w)}for(let u=0;u<i;u++)for(let w=0;w<t;w++){const M=h[u][w+1],E=h[u][w],N=h[u+1][w],A=h[u+1][w+1];(u!==0||o>0)&&m.push(M,E,A),(u!==i-1||l<Math.PI)&&m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new yi(g,3)),this.setAttribute("normal",new yi(x,3)),this.setAttribute("uv",new yi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new of(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class CD extends wa{static get type(){return"MeshStandardMaterial"}constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new bt(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 bt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jv,this.normalScale=new at(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 bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}const vm=new Ft;class RD{constructor(e,t,i=0,s=1/0){this.ray=new tf(e,t),this.near=i,this.far=s,this.camera=null,this.layers=new nf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return vm.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(vm),this}intersectObject(e,t=!0,i=[]){return fd(e,this,i,t),i.sort(xm),i}intersectObjects(e,t=!0,i=[]){for(let s=0,r=e.length;s<r;s++)fd(e[s],this,i,t);return i.sort(xm),i}}function xm(n,e){return n.distance-e.distance}function fd(n,e,t,i){let s=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(s=!1),s===!0&&i===!0){const r=n.children;for(let o=0,a=r.length;o<a;o++)fd(r[o],e,t,!0)}}class Mm{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(un(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class PD extends or{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qd);/*! * Photo Sphere Viewer / Markers Plugin 5.11.1 * @copyright 2015-2024 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) */var LD=Object.defineProperty,DD=(n,e)=>{for(var t in e)LD(n,t,{get:e[t],enumerable:!0})},ID={};DD(ID,{EnterMarkerEvent:()=>T0,GotoMarkerDoneEvent:()=>pd,HideMarkersEvent:()=>aa,LeaveMarkerEvent:()=>S0,MarkerVisibilityEvent:()=>v0,MarkersPluginEvent:()=>Wn,RenderMarkersListEvent:()=>$0,SelectMarkerEvent:()=>R0,SelectMarkerListEvent:()=>D0,SetMarkersEvent:()=>B0,ShowMarkersEvent:()=>la,UnselectMarkerEvent:()=>N0});var Wn=class extends eg{},_0=class g0 extends Wn{constructor(e,t){super(g0.type),this.marker=e,this.visible=t}};_0.type="marker-visibility";var v0=_0,x0=class M0 extends Wn{constructor(e){super(M0.type),this.marker=e}};x0.type="goto-marker-done";var pd=x0,E0=class y0 extends Wn{constructor(e){super(y0.type),this.marker=e}};E0.type="leave-marker";var S0=E0,b0=class w0 extends Wn{constructor(e){super(w0.type),this.marker=e}};b0.type="enter-marker";var T0=b0,A0=class C0 extends Wn{constructor(e,t,i){super(C0.type),this.marker=e,this.doubleClick=t,this.rightClick=i}};A0.type="select-marker";var R0=A0,P0=class L0 extends Wn{constructor(e){super(L0.type),this.marker=e}};P0.type="select-marker-list";var D0=P0,I0=class U0 extends Wn{constructor(e){super(U0.type),this.marker=e}};I0.type="unselect-marker";var N0=I0,F0=class O0 extends Wn{constructor(){super(O0.type)}};F0.type="hide-markers";var aa=F0,z0=class k0 extends Wn{constructor(e){super(k0.type),this.markers=e}};z0.type="set-markers";var B0=z0,H0=class V0 extends Wn{constructor(){super(V0.type)}};H0.type="show-markers";var la=H0,G0=class W0 extends Wn{constructor(e){super(W0.type),this.markers=e}};G0.type="render-markers-list";var $0=G0,UD=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 9 81 81"><path fill="currentColor" d="M50.5 90S22.9 51.9 22.9 36.6 35.2 9 50.5 9s27.6 12.4 27.6 27.6S50.5 90 50.5 90zm0-66.3c-6.1 0-11 4.9-11 11s4.9 11 11 11 11-4.9 11-11-4.9-11-11-11z"/><!--Created by Rohith M S from the Noun Project--></svg> `,_a=class extends Mn{constructor(n){super(n,{className:"psv-markers-button",icon:UD,hoverScale:!0,collapsable:!0,tabbable:!0}),this.plugin=this.viewer.getPlugin("markers"),this.plugin&&(this.plugin.addEventListener(la.type,this),this.plugin.addEventListener(aa.type,this),this.toggleActive(!0))}destroy(){this.plugin&&(this.plugin.removeEventListener(la.type,this),this.plugin.removeEventListener(aa.type,this)),super.destroy()}isSupported(){return!!this.plugin}handleEvent(n){n instanceof la?this.toggleActive(!0):n instanceof aa&&this.toggleActive(!1)}onClick(){this.plugin.toggleAllMarkers()}};_a.id="markers";var q0=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="9 9 81 81"><path fill="currentColor" d="M37.5 90S9.9 51.9 9.9 36.6 22.2 9 37.5 9s27.6 12.4 27.6 27.6S37.5 90 37.5 90zm0-66.3c-6.1 0-11 4.9-11 11s4.9 11 11 11 11-4.9 11-11-4.9-11-11-11zM86.7 55H70c-1.8 0-3.3-1.5-3.3-3.3s1.5-3.3 3.3-3.3h16.7c1.8 0 3.3 1.5 3.3 3.3S88.5 55 86.7 55zm0-25h-15a3.3 3.3 0 0 1-3.3-3.3c0-1.8 1.5-3.3 3.3-3.3h15c1.8 0 3.3 1.5 3.3 3.3 0 1.8-1.5 3.3-3.3 3.3zM56.5 73h30c1.8 0 3.3 1.5 3.3 3.3 0 1.8-1.5 3.3-3.3 3.3h-30a3.3 3.3 0 0 1-3.3-3.3 3.2 3.2 0 0 1 3.3-3.3z"/><!--Created by Rohith M S from the Noun Project--></svg> `,Kl="http://www.w3.org/2000/svg",Nt="psvMarker",ND=rt.dasherize(Nt),Ho="marker",Br="markersList",md={amount:2,duration:100,easing:"linear"},FD=(n,e)=>` <div class="psv-panel-menu psv-panel-menu--stripped"> <h1 class="psv-panel-menu-title">${q0} ${e}</h1> <ul class="psv-panel-menu-list"> ${n.map(t=>` <li data-${ND}="${t.id}" class="psv-panel-menu-item" tabindex="0"> ${t.type==="image"?`<span class="psv-panel-menu-item-icon"><img src="${t.definition}"/></span>`:""} <span class="psv-panel-menu-item-label">${t.getListContent()}</span> </li> `).join("")} </ul> </div> `,pc=class extends Mn{constructor(n){super(n,{className:" psv-markers-list-button",icon:q0,hoverScale:!0,collapsable:!0,tabbable:!0}),this.plugin=this.viewer.getPlugin("markers"),this.plugin&&(this.viewer.addEventListener(ct.ShowPanelEvent.type,this),this.viewer.addEventListener(ct.HidePanelEvent.type,this))}destroy(){this.viewer.removeEventListener(ct.ShowPanelEvent.type,this),this.viewer.removeEventListener(ct.HidePanelEvent.type,this),super.destroy()}isSupported(){return!!this.plugin}handleEvent(n){n instanceof ct.ShowPanelEvent?this.toggleActive(n.panelId===Br):n instanceof ct.HidePanelEvent&&this.toggleActive(!1)}onClick(){this.plugin.toggleMarkersList()}};pc.id="markersList";var Em=new re,OD=new Ts,ym=new re,zD=class extends Tn{constructor(n=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=n,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(e){e.element instanceof Element&&e.element.parentNode!==null&&e.element.parentNode.removeChild(e.element)})})}copy(n,e){return super.copy(n,e),this.element=n.element.cloneNode(!0),this}},hi=new Ft,kD=new Ft,BD=class{constructor(n={}){const e=this;let t,i,s,r;const o={camera:{style:""},objects:new WeakMap},a=n.element!==void 0?n.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",a.appendChild(l);const c=document.createElement("div");c.style.transformStyle="preserve-3d",l.appendChild(c),this.getSize=function(){return{width:t,height:i}},this.render=function(x,d){const u=d.projectionMatrix.elements[5]*r;d.view&&d.view.enabled?(l.style.transform=`translate( ${-d.view.offsetX*(t/d.view.width)}px, ${-d.view.offsetY*(i/d.view.height)}px )`,l.style.transform+=`scale( ${d.view.fullWidth/d.view.width}, ${d.view.fullHeight/d.view.height} )`):l.style.transform="",x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),d.parent===null&&d.matrixWorldAutoUpdate===!0&&d.updateMatrixWorld();let w,M;d.isOrthographicCamera&&(w=-(d.right+d.left)/2,M=(d.top+d.bottom)/2);const E=d.view&&d.view.enabled?d.view.height/d.view.fullHeight:1,N=d.isOrthographicCamera?`scale( ${E} )scale(`+u+")translate("+h(w)+"px,"+h(M)+"px)"+f(d.matrixWorldInverse):`scale( ${E} )translateZ(`+u+"px)"+f(d.matrixWorldInverse),T=(d.isPerspectiveCamera?"perspective("+u+"px) ":"")+N+"translate("+s+"px,"+r+"px)";o.camera.style!==T&&(c.style.transform=T,o.camera.style=T),g(x,x,d)},this.setSize=function(x,d){t=x,i=d,s=t/2,r=i/2,a.style.width=x+"px",a.style.height=d+"px",l.style.width=x+"px",l.style.height=d+"px",c.style.width=x+"px",c.style.height=d+"px"};function h(x){return Math.abs(x)<1e-10?0:x}function f(x){const d=x.elements;return"matrix3d("+h(d[0])+","+h(-d[1])+","+h(d[2])+","+h(d[3])+","+h(d[4])+","+h(-d[5])+","+h(d[6])+","+h(d[7])+","+h(d[8])+","+h(-d[9])+","+h(d[10])+","+h(d[11])+","+h(d[12])+","+h(-d[13])+","+h(d[14])+","+h(d[15])+")"}function p(x){const d=x.elements;return"translate(-50%,-50%)"+("matrix3d("+h(d[0])+","+h(d[1])+","+h(d[2])+","+h(d[3])+","+h(-d[4])+","+h(-d[5])+","+h(-d[6])+","+h(-d[7])+","+h(d[8])+","+h(d[9])+","+h(d[10])+","+h(d[11])+","+h(d[12])+","+h(d[13])+","+h(d[14])+","+h(d[15])+")")}function m(x){x.isCSS3DObject&&(x.element.style.display="none");for(let d=0,u=x.children.length;d<u;d++)m(x.children[d])}function g(x,d,u,w){if(x.visible===!1){m(x);return}if(x.isCSS3DObject){const M=x.layers.test(u.layers)===!0,E=x.element;if(E.style.display=M===!0?"":"none",M===!0){x.onBeforeRender(e,d,u);let N;x.isCSS3DSprite?(hi.copy(u.matrixWorldInverse),hi.transpose(),x.rotation2D!==0&&hi.multiply(kD.makeRotationZ(x.rotation2D)),x.matrixWorld.decompose(Em,OD,ym),hi.setPosition(Em),hi.scale(ym),hi.elements[3]=0,hi.elements[7]=0,hi.elements[11]=0,hi.elements[15]=1,N=p(hi)):N=p(x.matrixWorld);const A=o.objects.get(x);if(A===void 0||A.style!==N){E.style.transform=N;const T={style:N};o.objects.set(x,T)}E.parentNode!==c&&c.appendChild(E),x.onAfterRender(e,d,u)}}for(let M=0,E=x.children.length;M<E;M++)g(x.children[M],d,u)}}},HD=class{constructor(n){this.viewer=n,this.element=document.createElement("div"),this.element.className="psv-markers-css3d-container",this.renderer=new BD({element:this.element}),this.scene=new p0,this.intersectionObserver=new IntersectionObserver(e=>{e.forEach(t=>{const i=t.target[Nt];i.config.visible&&(i.viewportIntersection=t.isIntersecting)})},{root:this.element}),n.addEventListener(ct.ReadyEvent.type,this,{once:!0}),n.addEventListener(ct.SizeUpdatedEvent.type,this),n.addEventListener(ct.RenderEvent.type,this)}handleEvent(n){switch(n.type){case ct.ReadyEvent.type:case ct.SizeUpdatedEvent.type:this.updateSize();break;case ct.RenderEvent.type:this.render();break}}destroy(){this.viewer.removeEventListener(ct.ReadyEvent.type,this),this.viewer.removeEventListener(ct.SizeUpdatedEvent.type,this),this.viewer.removeEventListener(ct.RenderEvent.type,this),this.intersectionObserver.disconnect()}updateSize(){const n=this.viewer.getSize();this.renderer.setSize(n.width,n.height)}render(){this.renderer.render(this.scene,this.viewer.renderer.camera)}addObject(n){this.scene.add(n.threeElement),this.intersectionObserver.observe(n.domElement)}removeObject(n){this.scene.remove(n.threeElement),this.intersectionObserver.unobserve(n.domElement)}},zl=(n=>(n.image="image",n.html="html",n.element="element",n.imageLayer="imageLayer",n.videoLayer="videoLayer",n.elementLayer="elementLayer",n.polygon="polygon",n.polygonPixels="polygonPixels",n.polyline="polyline",n.polylinePixels="polylinePixels",n.square="square",n.rect="rect",n.circle="circle",n.ellipse="ellipse",n.path="path",n))(zl||{});function _d(n,e=!1){const t=[];if(Object.keys(zl).forEach(i=>{n[i]&&t.push(i)}),t.length===0&&!e)throw new Ke(`missing marker content, either ${Object.keys(zl).join(", ")}`);if(t.length>1)throw new Ke(`multiple marker content, either ${Object.keys(zl).join(", ")}`);return t[0]}var X0=class{constructor(n,e,t){if(this.viewer=n,this.plugin=e,this.state={anchor:null,visible:!1,staticTooltip:!1,position:null,position2D:null,positions3D:null,size:null},!t.id)throw new Ke("missing marker id");this.type=_d(t),this.createElement(),this.update(t)}get id(){return this.config.id}get data(){return this.config.data}get domElement(){return null}get threeElement(){return null}get video(){return null}destroy(){delete this.viewer,delete this.plugin,delete this.element,this.hideTooltip()}is3d(){return!1}isNormal(){return!1}isPoly(){return!1}isSvg(){return!1}isCss3d(){return!1}update(n){const e=_d(n,!0);if(e!==void 0&&e!==this.type)throw new Ke(`cannot change marker ${n.id} type`);if(rt.isExtendedPosition(n)&&(rt.logWarn('Use the "position" property to configure the position of a marker'),n.position=this.viewer.dataHelper.cleanPosition(n)),"width"in n&&"height"in n&&(rt.logWarn('Use the "size" property to configure the size of a marker'),n.size={width:n.width,height:n.height}),this.config=rt.deepmerge(this.config,n),typeof this.config.tooltip=="string"&&(this.config.tooltip={content:this.config.tooltip}),this.config.tooltip&&!this.config.tooltip.trigger&&(this.config.tooltip.trigger="hover"),rt.isNil(this.config.visible)&&(this.config.visible=!0),rt.isNil(this.config.zIndex)&&(this.config.zIndex=1),rt.isNil(this.config.opacity)&&(this.config.opacity=1),this.config.rotation){const t=this.config.rotation;typeof t=="object"?this.config.rotation={yaw:t.yaw?rt.parseAngle(t.yaw,!0,!1):0,pitch:t.pitch?rt.parseAngle(t.pitch,!0,!1):0,roll:t.roll?rt.parseAngle(t.roll,!0,!1):0}:this.config.rotation={yaw:0,pitch:0,roll:rt.parseAngle(t,!0,!1)}}else this.config.rotation={yaw:0,pitch:0,roll:0};this.state.anchor=rt.parsePoint(this.config.anchor)}getListContent(){var n;return this.config.listContent?this.config.listContent:(n=this.config.tooltip)!=null&&n.content?this.config.tooltip.content:this.config.html?this.config.html:this.id}showTooltip(n,e,t=!1){var i;if(this.state.visible&&((i=this.config.tooltip)!=null&&i.content)&&this.state.position2D){const s={...this.config.tooltip,style:{pointerEvents:this.state.staticTooltip?"auto":"none"},data:this,top:0,left:0};if(this.isPoly()||this.is3d()||this.isCss3d())if(n||e){const r=rt.getPosition(this.viewer.container);s.top=e-r.y+10,s.left=n-r.x,s.box={width:20,height:20}}else s.top=this.state.position2D.y,s.left=this.state.position2D.x;else{const r=this.viewer.dataHelper.vector3ToViewerCoords(this.state.positions3D[0]);let o=this.state.size.width,a=this.state.size.height;this.config.hoverScale&&!this.state.staticTooltip&&(o*=this.config.hoverScale.amount,a*=this.config.hoverScale.amount),s.top=r.y-a*this.state.anchor.y+a/2,s.left=r.x-o*this.state.anchor.x+o/2,s.box={width:o,height:a}}this.tooltip?t?this.tooltip.update(this.config.tooltip.content,s):this.tooltip.move(s):this.tooltip=this.viewer.createTooltip(s)}}hideTooltip(){this.tooltip&&(this.tooltip.hide(),this.tooltip=null)}},af=class extends X0{get domElement(){return this.element}constructor(n,e,t){super(n,e,t)}afterCreateElement(){this.element[Nt]=this}destroy(){delete this.element[Nt],super.destroy()}update(n){super.update(n);const e=this.domElement;e.id=`psv-marker-${this.config.id}`,e.setAttribute("class","psv-marker"),this.state.visible&&e.classList.add("psv-marker--visible"),this.config.tooltip&&e.classList.add("psv-marker--has-tooltip"),this.config.content&&e.classList.add("psv-marker--has-content"),this.config.className&&rt.addClasses(e,this.config.className),e.style.opacity=`${this.config.opacity}`,e.style.zIndex=`${30+this.config.zIndex}`,this.config.style&&Object.assign(e.style,this.config.style)}},Jl=class extends af{constructor(n,e,t){super(n,e,t)}afterCreateElement(){super.afterCreateElement(),this.domElement.addEventListener("transitionend",()=>{this.domElement.style.transition=""})}render({viewerPosition:n,zoomLevel:e,hoveringMarker:t}){this.__updateSize();const i=this.viewer.dataHelper.vector3ToViewerCoords(this.state.positions3D[0]);return i.x-=this.state.size.width*this.state.anchor.x,i.y-=this.state.size.height*this.state.anchor.y,this.state.positions3D[0].dot(this.viewer.state.direction)>0&&i.x+this.state.size.width>=0&&i.x-this.state.size.width<=this.viewer.state.size.width&&i.y+this.state.size.height>=0&&i.y-this.state.size.height<=this.viewer.state.size.height?(this.domElement.style.translate=`${i.x}px ${i.y}px 0px`,this.applyScale({zoomLevel:e,viewerPosition:n,mouseover:this===t}),i):null}update(n){if(super.update(n),!rt.isExtendedPosition(this.config.position))throw new Ke(`missing marker ${this.id} position`);try{this.state.position=this.viewer.dataHelper.cleanPosition(this.config.position)}catch(t){throw new Ke(`invalid marker ${this.id} position`,t)}this.state.positions3D=[this.viewer.dataHelper.sphericalCoordsToVector3(this.state.position)];const e=this.domElement;e.classList.add("psv-marker--normal"),this.config.scale&&Array.isArray(this.config.scale)&&(this.config.scale={zoom:this.config.scale}),typeof this.config.hoverScale=="boolean"?this.config.hoverScale=this.config.hoverScale?this.plugin.config.defaultHoverScale||md:null:typeof this.config.hoverScale=="number"?this.config.hoverScale={amount:this.config.hoverScale}:this.config.hoverScale||(this.config.hoverScale=this.plugin.config.defaultHoverScale),this.config.hoverScale&&(this.config.hoverScale={...this.plugin.config.defaultHoverScale,...this.config.hoverScale}),e.style.rotate=this.config.rotation.roll!==0?ud.radToDeg(this.config.rotation.roll)+"deg":null,e.style.transformOrigin=`${this.state.anchor.x*100}% ${this.state.anchor.y*100}%`}__updateSize(){if(!this.needsUpdateSize)return;const n=this.domElement,e=!this.state.visible||!this.state.size;if(e&&n.classList.add("psv-marker--transparent"),this.isSvg()){const t=n.firstElementChild.getBoundingClientRect();this.state.size={width:t.width,height:t.height}}else this.state.size={width:n.offsetWidth,height:n.offsetHeight};e&&n.classList.remove("psv-marker--transparent"),this.isSvg()&&(n.style.width=this.state.size.width+"px",n.style.height=this.state.size.height+"px"),this.type!=="element"&&(this.needsUpdateSize=!1)}applyScale({zoomLevel:n,viewerPosition:e,mouseover:t}){t!==null&&this.config.hoverScale&&(this.domElement.style.transition=`scale ${this.config.hoverScale.duration}ms ${this.config.hoverScale.easing}`);let i=1;if(typeof this.config.scale=="function")i=this.config.scale(n,e);else if(this.config.scale){if(Array.isArray(this.config.scale.zoom)){const[s,r]=this.config.scale.zoom;i*=s+(r-s)*da.EASINGS.inQuad(n/100)}if(Array.isArray(this.config.scale.yaw)){const[s,r]=this.config.scale.yaw,o=ud.degToRad(this.viewer.state.hFov)/2,a=Math.abs(rt.getShortestArc(this.state.position.yaw,e.yaw));i*=r+(s-r)*da.EASINGS.outQuad(Math.max(0,(o-a)/o))}}t&&this.config.hoverScale&&(i*=this.config.hoverScale.amount),this.domElement.style.scale=`${i}`}},VD=`// https://www.8thwall.com/playground/chromakey-threejs uniform sampler2D map; uniform float alpha; uniform bool keying; uniform vec3 color; uniform float similarity; uniform float smoothness; uniform float spill; varying vec2 vUv; vec2 RGBtoUV(vec3 rgb) { return vec2( rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5, rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5 ); } void main(void) { gl_FragColor = texture2D(map, vUv); if (keying) { float chromaDist = distance(RGBtoUV(gl_FragColor.rgb), RGBtoUV(color)); float baseMask = chromaDist - similarity; float fullMask = pow(clamp(baseMask / smoothness, 0., 1.), 1.5); gl_FragColor.a *= fullMask * alpha; float spillVal = pow(clamp(baseMask / spill, 0., 1.), 1.5); float desat = clamp(gl_FragColor.r * 0.2126 + gl_FragColor.g * 0.7152 + gl_FragColor.b * 0.0722, 0., 1.); gl_FragColor.rgb = mix(vec3(desat, desat, desat), gl_FragColor.rgb, spillVal); } else { gl_FragColor.a *= alpha; } } `,GD=`varying vec2 vUv; uniform vec2 repeat; uniform vec2 offset; void main() { vUv = uv * repeat + offset; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } `,WD=class extends Xi{get map(){return this.uniforms.map.value}set map(n){this.uniforms.map.value=n}set alpha(n){this.uniforms.alpha.value=n}get offset(){return this.uniforms.offset.value}get repeat(){return this.uniforms.repeat.value}set chromaKey(n){this.uniforms.keying.value=(n==null?void 0:n.enabled)===!0,n!=null&&n.enabled&&(typeof n.color=="object"&&"r"in n.color?this.uniforms.color.value.set(n.color.r/255,n.color.g/255,n.color.b/255):this.uniforms.color.value.set(n.color??65280),this.uniforms.similarity.value=n.similarity??.2,this.uniforms.smoothness.value=n.smoothness??.2)}constructor(n){super({transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{map:{value:n==null?void 0:n.map},repeat:{value:new at(1,1)},offset:{value:new at(0,0)},alpha:{value:(n==null?void 0:n.alpha)??1},keying:{value:!1},color:{value:new bt(65280)},similarity:{value:.2},smoothness:{value:.2},spill:{value:.1}},vertexShader:GD,fragmentShader:VD}),this.chromaKey=n==null?void 0:n.chromaKey}};function $D({src:n,withCredentials:e,muted:t,autoplay:i}){const s=document.createElement("video");return s.crossOrigin=e?"use-credentials":"anonymous",s.loop=!0,s.playsInline=!0,s.autoplay=i,s.muted=t,s.preload="metadata",n instanceof MediaStream?s.srcObject=n:s.src=n,s}function qD(n,e,t){const[i,s]=n,[r,o]=e,a=rt.greatArcDistance(n,e),l=Math.sin((1-t)*a)/Math.sin(a),c=Math.sin(t*a)/Math.sin(a),h=l*Math.cos(s)*Math.cos(i)+c*Math.cos(o)*Math.cos(r),f=l*Math.cos(s)*Math.sin(i)+c*Math.cos(o)*Math.sin(r),p=l*Math.sin(s)+c*Math.sin(o);return[Math.atan2(f,h),Math.atan2(p,Math.sqrt(h*h+f*f))]}function Y0(n){const e=[n[0]];let t=0;for(let i=1;i<n.length;i++){const s=n[i-1][0]-n[i][0];s>Math.PI?t+=1:s<-Math.PI&&(t-=1),e.push([n[i][0]+t*2*Math.PI,n[i][1]])}return e}function Q0(n){const t=Y0(n).reduce((i,s)=>[i[0]+s[0],i[1]+s[1]]);return[rt.parseAngle(t[0]/n.length),t[1]/n.length]}function XD(n){const e=Y0(n);let t=0;const i=[];for(let r=0;r<e.length-1;r++){const o=rt.greatArcDistance(e[r],e[r+1])*da.SPHERE_RADIUS;i.push(o),t+=o}let s=0;for(let r=0;r<e.length-1;r++){if(s+i[r]>t/2){const o=(t/2-s)/i[r];return qD(e[r],e[r+1],o)}s+=i[r]}return e[Math.round(e.length/2)]}var xl=new re,Sm=new re,yh=new re,bm=new re,wm=new re,Tm=new re;function YD(n,e,t){xl.copy(t).normalize(),Sm.crossVectors(n,e).normalize(),yh.crossVectors(Sm,n).normalize(),bm.copy(n).multiplyScalar(-xl.dot(yh)),wm.copy(yh).multiplyScalar(xl.dot(n));const i=new re().addVectors(bm,wm).normalize();return Tm.crossVectors(i,xl),i.applyAxisAngle(Tm,.01).multiplyScalar(da.SPHERE_RADIUS)}var QD=class extends X0{get threeElement(){return this.element}get threeMesh(){return this.threeElement.children[0]}get video(){return this.type==="videoLayer"?this.threeMesh.material.map.image:null}constructor(n,e,t){super(n,e,t)}is3d(){return!0}createElement(){const n=new WD({alpha:0}),e=new Ta(1,1),t=new Gn(e,n);t.userData={[Nt]:this},Object.defineProperty(t,"visible",{enumerable:!0,get:function(){return this.userData[Nt].config.visible},set:function(i){this.userData[Nt].config.visible=i}}),this.element=new Xr().add(t),this.type==="videoLayer"&&this.viewer.needsContinuousUpdate(!0)}destroy(){delete this.threeMesh.userData[Nt],this.type==="videoLayer"&&(this.video.pause(),this.viewer.needsContinuousUpdate(!1)),super.destroy()}render(){return this.viewer.renderer.isObjectVisible(this.threeMesh)?this.viewer.dataHelper.sphericalCoordsToViewerCoords(this.state.position):null}update(n){var s,r,o;super.update(n);const e=this.threeMesh,t=e.parent,i=e.material;if(rt.isExtendedPosition(this.config.position)){try{this.state.position=this.viewer.dataHelper.cleanPosition(this.config.position)}catch(l){throw new Ke(`invalid marker ${this.id} position`,l)}if(!this.config.size)throw new Ke(`missing marker ${this.id} size`);if(this.state.size=this.config.size,e.scale.set(this.config.size.width/100,this.config.size.height/100,1),e.position.set(e.scale.x*(.5-this.state.anchor.x),e.scale.y*(this.state.anchor.y-.5),0),e.rotation.set(0,0,0),this.viewer.dataHelper.sphericalCoordsToVector3(this.state.position,t.position),t.lookAt(0,t.position.y,0),this.config.orientation)switch(rt.logWarn('Marker#orientation is deprecated, use "rotation.yaw" or "rotation.pitch" instead'),e.rotateZ(-this.config.rotation.roll),this.config.orientation){case"horizontal":t.rotateX(this.state.position.pitch<0?-Math.PI/2:Math.PI/2);break;case"vertical-left":t.rotateY(-Math.PI*.4);break;case"vertical-right":t.rotateY(Math.PI*.4);break}else e.rotateY(-this.config.rotation.yaw),e.rotateX(-this.config.rotation.pitch),e.rotateZ(-this.config.rotation.roll);const a=e.geometry.getAttribute("position");this.state.positions3D=[0,1,3,2].map(l=>{const c=new re;return c.fromBufferAttribute(a,l),e.localToWorld(c)})}else{if(((s=this.config.position)==null?void 0:s.length)!==4)throw new Ke(`missing marker ${this.id} position`);let a;try{a=this.config.position.map(f=>this.viewer.dataHelper.cleanPosition(f))}catch(f){throw new Ke(`invalid marker ${this.id} position`,f)}const l=a.map(f=>this.viewer.dataHelper.sphericalCoordsToVector3(f)),c=Q0(a.map(({yaw:f,pitch:p})=>[f,p]));this.state.position={yaw:c[0],pitch:c[1]},this.state.positions3D=l;const h=e.geometry.getAttribute("position");[l[0],l[1],l[3],l[2]].forEach((f,p)=>{h.setX(p,f.x),h.setY(p,f.y),h.setZ(p,f.z)}),h.needsUpdate=!0,this.__setTextureWrap(i)}switch(this.type){case"videoLayer":if(this.definition!==this.config.videoLayer){(r=i.map)==null||r.dispose();const a=$D({src:this.config.videoLayer,withCredentials:this.viewer.config.withCredentials,muted:!0,autoplay:this.config.autoplay??!0}),l=new m0(a);i.map=l,i.alpha=0,a.addEventListener("loadedmetadata",()=>{this.viewer&&(i.alpha=this.config.opacity,rt.isExtendedPosition(this.config.position)||(e.material.userData[Nt]={width:a.videoWidth,height:a.videoHeight},this.__setTextureWrap(i)))},{once:!0}),a.autoplay&&a.play(),this.definition=this.config.videoLayer}else i.alpha=this.config.opacity;break;case"imageLayer":if(this.definition!==this.config.imageLayer){(o=i.map)==null||o.dispose();const a=new dn;i.map=a,i.alpha=0,this.viewer.textureLoader.loadImage(this.config.imageLayer).then(l=>{this.viewer&&(rt.isExtendedPosition(this.config.position)||(e.material.userData[Nt]={width:l.width,height:l.height},this.__setTextureWrap(i)),a.image=l,a.anisotropy=4,a.needsUpdate=!0,i.alpha=this.config.opacity,this.viewer.needsUpdate())}),this.definition=this.config.imageLayer}else i.alpha=this.config.opacity;break}i.chromaKey=this.config.chromaKey,e.renderOrder=1e3+this.config.zIndex,e.geometry.boundingBox=null}__setTextureWrap(n){const e=n.userData[Nt];if(!e||!e.height||!e.width){n.repeat.set(1,1),n.offset.set(0,0);return}const t=this.config.position.map(f=>this.viewer.dataHelper.cleanPosition(f)),i=rt.greatArcDistance([t[0].yaw,t[0].pitch],[t[1].yaw,t[1].pitch]),s=rt.greatArcDistance([t[3].yaw,t[3].pitch],[t[2].yaw,t[2].pitch]),r=rt.greatArcDistance([t[1].yaw,t[1].pitch],[t[2].yaw,t[2].pitch]),o=rt.greatArcDistance([t[0].yaw,t[0].pitch],[t[3].yaw,t[3].pitch]),a=(i+s)/(r+o),l=e.width/e.height;let c=0,h=0;a<l?c=l-a:h=1/l-1/a,n.repeat.set(1-c,1-h),n.offset.set(c/2,h/2)}},jD=class extends af{constructor(n,e,t){super(n,e,t),this.viewportIntersection=!1}get threeElement(){return this.object}isCss3d(){return!0}createElement(){this.element=document.createElement("div"),this.object=new zD(this.element),this.object.userData={[Nt]:this},Object.defineProperty(this.object,"visible",{enumerable:!0,get:function(){return this.userData[Nt].config.visible},set:function(n){this.userData[Nt].config.visible=n}}),this.afterCreateElement()}destroy(){delete this.object.userData[Nt],delete this.object,super.destroy()}render({viewerPosition:n,zoomLevel:e}){var s,r;const t=this.domElement;if(this.state.size={width:t.offsetWidth,height:t.offsetHeight},this.state.positions3D[0].dot(this.viewer.state.direction)>0&&this.viewportIntersection){const o=this.viewer.dataHelper.sphericalCoordsToViewerCoords(this.state.position);return(r=(s=this.config.elementLayer).updateMarker)==null||r.call(s,{marker:this,position:o,viewerPosition:n,zoomLevel:e,viewerSize:this.viewer.state.size}),o}else return null}update(n){if(super.update(n),!rt.isExtendedPosition(this.config.position))throw new Ke(`missing marker ${this.id} position`);try{this.state.position=this.viewer.dataHelper.cleanPosition(this.config.position)}catch(i){throw new Ke(`invalid marker ${this.id} position`,i)}this.state.positions3D=[this.viewer.dataHelper.sphericalCoordsToVector3(this.state.position)];const e=this.threeElement,t=this.domElement;t.classList.add("psv-marker--css3d"),t.childNodes.forEach(i=>i.remove()),t.appendChild(this.config.elementLayer),this.config.elementLayer.style.display="block",e.position.copy(this.state.positions3D[0]).multiplyScalar(100),e.lookAt(0,this.state.positions3D[0].y*100,0),e.rotateY(-this.config.rotation.yaw),e.rotateX(-this.config.rotation.pitch),e.rotateZ(-this.config.rotation.roll)}},ZD=class extends Jl{constructor(n,e,t){super(n,e,t)}isNormal(){return!0}createElement(){this.element=document.createElement("div"),this.afterCreateElement()}render(n){var t,i;const e=super.render(n);return e&&this.type==="element"&&((i=(t=this.config.element).updateMarker)==null||i.call(t,{marker:this,position:e,viewerPosition:n.viewerPosition,zoomLevel:n.zoomLevel,viewerSize:this.viewer.state.size})),e}update(n){super.update(n);const e=this.domElement;if(this.config.image&&!this.config.size)throw new Ke(`missing marker ${this.id} size`);switch(this.config.size?(this.needsUpdateSize=!1,this.state.size=this.config.size,e.style.width=this.config.size.width+"px",e.style.height=this.config.size.height+"px"):this.needsUpdateSize=!0,this.type){case"image":this.definition=this.config.image,e.style.backgroundImage=`url("${this.config.image}")`;break;case"html":this.definition=this.config.html,e.innerHTML=this.config.html;break;case"element":this.definition!==this.config.element&&(this.definition=this.config.element,e.childNodes.forEach(t=>t.remove()),e.appendChild(this.config.element),this.config.element.style.display="block");break}}},KD=class extends af{constructor(n,e,t){super(n,e,t)}createElement(){this.element=document.createElementNS(Kl,"path"),this.element[Nt]=this}isPoly(){return!0}get isPixels(){return this.type==="polygonPixels"||this.type==="polylinePixels"}get isPolygon(){return this.type==="polygon"||this.type==="polygonPixels"}get isPolyline(){return this.type==="polyline"||this.type==="polylinePixels"}get coords(){return this.definition}render(){const n=this.__getAllPolyPositions();if(n[0].length>(this.isPolygon?2:1)){const t=this.viewer.dataHelper.sphericalCoordsToViewerCoords(this.state.position),i=n.filter(s=>s.length>0).map(s=>{let r="M";return r+=s.map(o=>`${o.x-t.x},${o.y-t.y}`).join("L"),this.isPolygon&&(r+="Z"),r}).join(" ");return this.domElement.setAttributeNS(null,"d",i),this.domElement.setAttributeNS(null,"transform",`translate(${t.x} ${t.y})`),t}else return null}update(n){super.update(n);const e=this.domElement;e.classList.add("psv-marker--poly"),this.config.svgStyle?(Object.entries(this.config.svgStyle).forEach(([i,s])=>{e.setAttributeNS(null,rt.dasherize(i),s)}),this.isPolyline&&!this.config.svgStyle.fill&&e.setAttributeNS(null,"fill","none")):this.isPolygon?e.setAttributeNS(null,"fill","rgba(0,0,0,0.5)"):this.isPolyline&&(e.setAttributeNS(null,"fill","none"),e.setAttributeNS(null,"stroke","rgb(0,0,0)"));try{let i=this.config[this.type];if(!Array.isArray(i[0]))for(let s=0;s<i.length;s++)i.splice(s,2,[i[s],i[s+1]]);if(Array.isArray(i[0][0])||(i=[i]),this.isPolyline&&i.length>1)throw new Ke("polylines cannot have holes");this.isPixels?this.definition=i.map(s=>s.map(r=>{const o=this.viewer.dataHelper.textureCoordsToSphericalCoords({textureX:r[0],textureY:r[1]});return[o.yaw,o.pitch]})):this.definition=i.map(s=>s.map(r=>[rt.parseAngle(r[0]),rt.parseAngle(r[1],!0)]))}catch(i){throw new Ke(`invalid marker ${this.id} position`,i)}const t=this.isPolygon?Q0(this.coords[0]):XD(this.coords[0]);this.state.position={yaw:t[0],pitch:t[1]},this.positions3D=this.coords.map(i=>i.map(s=>this.viewer.dataHelper.sphericalCoordsToVector3({yaw:s[0],pitch:s[1]}))),this.state.positions3D=this.positions3D[0]}__getAllPolyPositions(){return this.positions3D.map(n=>this.__getPolyPositions(n))}__getPolyPositions(n){const e=n.length,t=n.map(s=>({vector:s,visible:s.dot(this.viewer.state.direction)>0})),i=[];return t.forEach((s,r)=>{s.visible||[r===0?t[e-1]:t[r-1],r===e-1?t[0]:t[r+1]].forEach(a=>{a.visible&&i.push({visible:a.vector,invisible:s.vector,index:r})})}),i.reverse().forEach(s=>{t.splice(s.index,0,{vector:YD(s.visible,s.invisible,this.viewer.state.direction),visible:!0})}),t.filter(s=>s.visible).map(s=>this.viewer.dataHelper.vector3ToViewerCoords(s.vector))}},JD=class extends Jl{get svgElement(){return this.domElement.firstElementChild}constructor(n,e,t){super(n,e,t)}isSvg(){return!0}createElement(){const n=this.type==="square"?"rect":this.type,e=document.createElementNS(Kl,n);this.element=document.createElementNS(Kl,"svg"),this.element.appendChild(e),this.afterCreateElement()}update(n){super.update(n);const e=this.svgElement;switch(this.needsUpdateSize=!0,this.type){case"square":this.definition={x:0,y:0,width:this.config.square,height:this.config.square};break;case"rect":Array.isArray(this.config.rect)?this.definition={x:0,y:0,width:this.config.rect[0],height:this.config.rect[1]}:this.definition={x:0,y:0,width:this.config.rect.width,height:this.config.rect.height};break;case"circle":this.definition={cx:this.config.circle,cy:this.config.circle,r:this.config.circle};break;case"ellipse":Array.isArray(this.config.ellipse)?this.definition={cx:this.config.ellipse[0],cy:this.config.ellipse[1],rx:this.config.ellipse[0],ry:this.config.ellipse[1]}:this.definition={cx:this.config.ellipse.rx,cy:this.config.ellipse.ry,rx:this.config.ellipse.rx,ry:this.config.ellipse.ry};break;case"path":this.definition={d:this.config.path};break}Object.entries(this.definition).forEach(([t,i])=>{e.setAttributeNS(null,t,i)}),this.config.svgStyle?Object.entries(this.config.svgStyle).forEach(([t,i])=>{e.setAttributeNS(null,rt.dasherize(t),i)}):e.setAttributeNS(null,"fill","rgba(0,0,0,0.5)")}},eI=rt.getConfigParser({clickEventOnMarker:!1,gotoMarkerSpeed:"8rpm",markers:null,defaultHoverScale:null},{defaultHoverScale(n){return n?(n===!0&&(n=md),typeof n=="number"&&(n={amount:n}),{...md,...n}):null}});function tI(n){switch(_d(n,!1)){case"image":case"html":case"element":return ZD;case"imageLayer":case"videoLayer":return QD;case"elementLayer":return jD;case"polygon":case"polyline":case"polygonPixels":case"polylinePixels":return KD;case"square":case"rect":case"circle":case"ellipse":case"path":return JD;default:throw new Ke("invalid marker type")}}var _o=class extends Nv{constructor(n,e){super(n,e),this.markers={},this.state={allVisible:!0,showAllTooltips:!1,currentMarker:null,hoveringMarker:null,needsReRender:!1,lastClientX:null,lastClientY:null},this.container=document.createElement("div"),this.container.className="psv-markers",this.viewer.container.appendChild(this.container),this.svgContainer=document.createElementNS(Kl,"svg"),this.svgContainer.setAttribute("class","psv-markers-svg-container"),this.container.appendChild(this.svgContainer),this.css3DContainer=new HD(n),this.container.appendChild(this.css3DContainer.element),this.container.addEventListener("mouseenter",this,!0),this.container.addEventListener("mouseleave",this,!0),this.container.addEventListener("mousemove",this,!0),this.container.addEventListener("contextmenu",this)}init(){super.init(),rt.checkStylesheet(this.viewer.container,"markers-plugin"),this.viewer.addEventListener(ct.ClickEvent.type,this),this.viewer.addEventListener(ct.DoubleClickEvent.type,this),this.viewer.addEventListener(ct.RenderEvent.type,this),this.viewer.addEventListener(ct.ConfigChangedEvent.type,this),this.viewer.addEventListener(ct.ObjectEnterEvent.type,this),this.viewer.addEventListener(ct.ObjectHoverEvent.type,this),this.viewer.addEventListener(ct.ObjectLeaveEvent.type,this),this.viewer.addEventListener(ct.ReadyEvent.type,this,{once:!0})}destroy(){this.clearMarkers(!1),this.viewer.unobserveObjects(Nt),this.viewer.removeEventListener(ct.ClickEvent.type,this),this.viewer.removeEventListener(ct.DoubleClickEvent.type,this),this.viewer.removeEventListener(ct.RenderEvent.type,this),this.viewer.removeEventListener(ct.ObjectEnterEvent.type,this),this.viewer.removeEventListener(ct.ObjectHoverEvent.type,this),this.viewer.removeEventListener(ct.ObjectLeaveEvent.type,this),this.viewer.removeEventListener(ct.ReadyEvent.type,this),this.css3DContainer.destroy(),this.viewer.container.removeChild(this.container),super.destroy()}handleEvent(n){var e;switch(n.type){case ct.ReadyEvent.type:this.config.markers&&(this.setMarkers(this.config.markers),delete this.config.markers);break;case ct.RenderEvent.type:this.renderMarkers();break;case ct.ClickEvent.type:this.__onClick(n,!1);break;case ct.DoubleClickEvent.type:this.__onClick(n,!0);break;case ct.ObjectEnterEvent.type:case ct.ObjectLeaveEvent.type:case ct.ObjectHoverEvent.type:if(n.userDataKey===Nt){const t=n.originalEvent,i=n.object.userData[Nt];switch(n.type){case ct.ObjectEnterEvent.type:(e=i.config.style)!=null&&e.cursor?this.viewer.setCursor(i.config.style.cursor):(i.config.tooltip||i.config.content)&&this.viewer.setCursor("pointer"),this.__onEnterMarker(t,i);break;case ct.ObjectLeaveEvent.type:this.viewer.setCursor(null),this.__onLeaveMarker(i);break;case ct.ObjectHoverEvent.type:this.__onHoverMarker(t,i);break}}break;case"mouseenter":{const t=this.__getTargetMarker(rt.getEventTarget(n));this.__onEnterMarker(n,t);break}case"mouseleave":{const t=this.__getTargetMarker(rt.getEventTarget(n));this.__onLeaveMarker(t);break}case"mousemove":{const t=this.__getTargetMarker(rt.getEventTarget(n),!0);this.__onHoverMarker(n,t);break}case"contextmenu":n.preventDefault();break}}toggleAllMarkers(){this.state.allVisible?this.hideAllMarkers():this.showAllMarkers()}showAllMarkers(){this.state.allVisible=!0,Object.values(this.markers).forEach(n=>{n.config.visible=!0}),this.renderMarkers(),this.dispatchEvent(new la)}hideAllMarkers(){this.state.allVisible=!1,Object.values(this.markers).forEach(n=>{n.config.visible=!1}),this.renderMarkers(),this.dispatchEvent(new aa)}toggleAllTooltips(){this.state.showAllTooltips?this.hideAllTooltips():this.showAllTooltips()}showAllTooltips(){this.state.showAllTooltips=!0,Object.values(this.markers).forEach(n=>{n.state.staticTooltip=!0,n.showTooltip()})}hideAllTooltips(){this.state.showAllTooltips=!1,Object.values(this.markers).forEach(n=>{n.state.staticTooltip=!1,n.hideTooltip()})}getNbMarkers(){return Object.keys(this.markers).length}getMarkers(){return Object.values(this.markers)}addMarker(n,e=!0){if(this.markers[n.id])throw new Ke(`marker "${n.id}" already exists`);const t=new(tI(n))(this.viewer,this,n);t.isPoly()?this.svgContainer.appendChild(t.domElement):t.isCss3d()?this.css3DContainer.addObject(t):t.is3d()?this.viewer.renderer.addObject(t.threeElement):this.container.appendChild(t.domElement),this.markers[t.id]=t,this.state.showAllTooltips&&(t.state.staticTooltip=!0),e&&this.__afterChangeMarkers()}getMarker(n){const e=typeof n=="object"?n.id:n;if(!this.markers[e])throw new Ke(`cannot find marker "${e}"`);return this.markers[e]}getCurrentMarker(){return this.state.currentMarker}updateMarker(n,e=!0){var i;const t=this.getMarker(n.id);t.update(n),e&&(this.__afterChangeMarkers(),(t===this.state.hoveringMarker&&((i=t.config.tooltip)==null?void 0:i.trigger)==="hover"||t.state.staticTooltip)&&t.showTooltip(this.state.lastClientX,this.state.lastClientY,!0))}removeMarker(n,e=!0){const t=this.getMarker(n);t.isPoly()?this.svgContainer.removeChild(t.domElement):t.isCss3d()?this.css3DContainer.removeObject(t):t.is3d()?this.viewer.renderer.removeObject(t.threeElement):this.container.removeChild(t.domElement),this.state.hoveringMarker===t&&(this.state.hoveringMarker=null),this.state.currentMarker===t&&(this.state.currentMarker=null),t.destroy(),delete this.markers[t.id],e&&this.__afterChangeMarkers()}removeMarkers(n,e=!0){n.forEach(t=>this.removeMarker(t,!1)),e&&this.__afterChangeMarkers()}setMarkers(n,e=!0){this.clearMarkers(!1),n==null||n.forEach(t=>{this.addMarker(t,!1)}),e&&this.__afterChangeMarkers()}clearMarkers(n=!0){Object.keys(this.markers).forEach(e=>{this.removeMarker(e,!1)}),n&&this.__afterChangeMarkers()}gotoMarker(n,e=this.config.gotoMarkerSpeed){const t=this.getMarker(n);return e?this.viewer.animate({...t.state.position,zoom:t.config.zoomLvl,speed:e}).then(()=>{this.dispatchEvent(new pd(t))}):(this.viewer.rotate(t.state.position),rt.isNil(t.config.zoomLvl)||this.viewer.zoom(t.config.zoomLvl),this.dispatchEvent(new pd(t)),Promise.resolve())}hideMarker(n){this.toggleMarker(n,!1)}showMarker(n){this.toggleMarker(n,!0)}showMarkerTooltip(n){const e=this.getMarker(n);e.state.staticTooltip=!0,e.showTooltip()}hideMarkerTooltip(n){const e=this.getMarker(n);e.state.staticTooltip=!1,e.hideTooltip()}toggleMarker(n,e){const t=this.getMarker(n);t.config.visible=rt.isNil(e)?!t.config.visible:e,this.renderMarkers()}showMarkerPanel(n){const e=this.getMarker(n);e.config.content?this.viewer.panel.show({id:Ho,content:e.config.content}):this.hideMarkerPanel()}hideMarkerPanel(){this.viewer.panel.hide(Ho)}toggleMarkersList(){this.viewer.panel.isVisible(Br)?this.hideMarkersList():this.showMarkersList()}showMarkersList(){let n=[];Object.values(this.markers).forEach(t=>{t.config.visible&&!t.config.hideList&&n.push(t)});const e=new $0(n);this.dispatchEvent(e),n=e.markers,this.viewer.panel.show({id:Br,content:FD(n,this.viewer.config.lang[_a.id]),noMargin:!0,clickHandler:t=>{const i=rt.getClosest(t,".psv-panel-menu-item"),s=i?i.dataset[Nt]:void 0;if(s){const r=this.getMarker(s);this.dispatchEvent(new D0(r)),this.gotoMarker(r.id),this.hideMarkersList()}}})}hideMarkersList(){this.viewer.panel.hide(Br)}renderMarkers(){if(this.state.needsReRender){this.state.needsReRender=!1;return}const n=this.viewer.getZoomLevel(),e=this.viewer.getPosition(),t=this.state.hoveringMarker;Object.values(this.markers).forEach(i=>{let s=i.config.visible,r=!1,o=null;s&&(o=i.render({viewerPosition:e,zoomLevel:n,hoveringMarker:t}),s=!!o),r=i.state.visible!==s,i.state.visible=s,i.state.position2D=o,i.domElement&&rt.toggleClass(i.domElement,"psv-marker--visible",s),s?i.state.staticTooltip?i.showTooltip():i!==this.state.hoveringMarker&&i.hideTooltip():i.hideTooltip(),r&&(this.dispatchEvent(new v0(i,s)),(i.is3d()||i.isCss3d())&&(this.state.needsReRender=!0))}),this.state.needsReRender&&this.viewer.needsUpdate()}__getTargetMarker(n,e=!1){if(n instanceof Node){const t=e?rt.getClosest(n,".psv-marker"):n;return t?t[Nt]:void 0}else return Array.isArray(n)?n.map(t=>t.userData[Nt]).filter(t=>!!t).sort((t,i)=>i.config.zIndex-t.config.zIndex)[0]:null}__onEnterMarker(n,e){var t;e&&(this.state.hoveringMarker=e,this.state.lastClientX=n.clientX,this.state.lastClientY=n.clientY,this.dispatchEvent(new T0(e)),e instanceof Jl&&e.applyScale({zoomLevel:this.viewer.getZoomLevel(),viewerPosition:this.viewer.getPosition(),mouseover:!0}),!e.state.staticTooltip&&((t=e.config.tooltip)==null?void 0:t.trigger)==="hover"&&e.showTooltip(n.clientX,n.clientY))}__onLeaveMarker(n){var e;n&&(this.dispatchEvent(new S0(n)),n instanceof Jl&&n.applyScale({zoomLevel:this.viewer.getZoomLevel(),viewerPosition:this.viewer.getPosition(),mouseover:!1}),this.state.hoveringMarker=null,!n.state.staticTooltip&&((e=n.config.tooltip)==null?void 0:e.trigger)==="hover"?n.hideTooltip():n.state.staticTooltip&&n.showTooltip())}__onHoverMarker(n,e){var t;e&&(this.state.lastClientX=n.clientX,this.state.lastClientY=n.clientY,(e.isPoly()||e.is3d()||e.isCss3d())&&((t=e.config.tooltip)==null?void 0:t.trigger)==="hover"&&e.showTooltip(n.clientX,n.clientY))}__onClick(n,e){var r,o;const t=this.__getTargetMarker(n.data.objects),s=this.__getTargetMarker(n.data.target,!0)||t;this.state.currentMarker&&this.state.currentMarker!==s&&(this.dispatchEvent(new N0(this.state.currentMarker)),this.viewer.panel.hide(Ho),!this.state.showAllTooltips&&((r=this.state.currentMarker.config.tooltip)==null?void 0:r.trigger)==="click"&&this.hideMarkerTooltip(this.state.currentMarker.id),this.state.currentMarker=null),s&&(this.state.currentMarker=s,this.dispatchEvent(new R0(s,e,n.data.rightclick)),this.config.clickEventOnMarker?n.data.marker=s:n.stopImmediatePropagation(),this.markers[s.id]&&!n.data.rightclick&&(((o=s.config.tooltip)==null?void 0:o.trigger)==="click"?s.tooltip?this.hideMarkerTooltip(s.id):this.showMarkerTooltip(s.id):this.showMarkerPanel(s.id)))}__afterChangeMarkers(){this.__refreshUi(),this.__checkObjectsObserver(),this.viewer.needsUpdate(),this.dispatchEvent(new B0(this.getMarkers()))}__refreshUi(){var e,t;const n=Object.values(this.markers).filter(i=>!i.config.hideList).length;n===0?(this.viewer.panel.isVisible(Br)||this.viewer.panel.isVisible(Ho))&&this.viewer.panel.hide():this.viewer.panel.isVisible(Br)?this.showMarkersList():this.viewer.panel.isVisible(Ho)&&(this.state.currentMarker?this.showMarkerPanel(this.state.currentMarker.id):this.viewer.panel.hide()),(e=this.viewer.navbar.getButton(_a.id,!1))==null||e.toggle(n>0),(t=this.viewer.navbar.getButton(pc.id,!1))==null||t.toggle(n>0)}__checkObjectsObserver(){Object.values(this.markers).some(e=>e.is3d())?this.viewer.observeObjects(Nt):this.viewer.unobserveObjects(Nt)}};_o.id="markers";_o.VERSION="5.11.1";_o.configParser=eI;_o.readonlyOptions=["markers"];bs.lang[_a.id]="Markers";bs.lang[pc.id]="Markers list";$d(_a,"caption:left");$d(pc,"caption:left");const nI={name:"QuizTypePanorama",data(){return{hotspots:[],currentQuestion:null}},computed:{...ri(["questions","questionsNumber","unansweredQuestions","unansweredQuestionsNumber","isPlaymitQuiz","isFoxQuiz"]),quiz(){return this.$store.getters.currentQuiz},panoramaImage(){return this.$store.getters.currentQuiz.panoramaImage},questionType(){if(this.currentQuestion)return`question-${this.currentQuestion.type}`},hasError(){return!lt.isEmpty(this.$store.state.base.error)},cancelUrl(){return`/quiz-modus/abbrechen/${this.$store.state.gameRound.hash}`},ad(){return this.$store.getters.hasQuizAd?{id:this.$store.state.ads.quiz.adZoneId,item:this.$store.state.ads.quiz.list[0]}:null}},created(){window.addEventListener("keyup",this.handleKeyup),this.nextUnansweredQuestionsIdx=0},mounted(){this.addClassesToBodyElem(),this.setUpPanorama()},beforeUnmount(){this.destroyPanorama(),window.removeEventListener("keyup",this.handleKeyup)},unmounted(){this.removeClassesFromBodyElem()},methods:{addClassesToBodyElem(){const n=document.querySelector("body");n.classList.add("l-body--quiz-mode-playing"),n.classList.add("l-body--quiz-mode-panorama")},removeClassesFromBodyElem(){const n=document.querySelector("body");n.classList.remove("l-body--quiz-mode-playing"),n.classList.remove("l-body--quiz-mode-panorama")},setUpPanorama(){this.buildHotSpots(),this.buildPanorama()},buildHotSpots(){const n=[];for(let e=0;e<this.unansweredQuestionsNumber;e+=1)if(this.questionHasCoordinates(this.questions[e])){const t={id:this.unansweredQuestions[e].hash,html:"<div></div>",className:"c-panorama-hotspot c-panorama-hotspot--animated",size:{width:32,height:32},position:{textureX:this.unansweredQuestions[e].coordinates.x,textureY:this.unansweredQuestions[e].coordinates.y}};n.push(t)}this.hotspots=n},buildPanorama(){this.PSV=new Wr({container:this.$refs.panoramaContainer,panorama:this.panoramaImage,defaultZoomLvl:17,navbar:!1,plugins:[[_o,{markers:this.hotspots}]]}),this.markersPlugin=this.PSV.getPlugin(_o),this.markersPlugin.addEventListener("select-marker",({marker:n})=>{this.handleHotspotClick(n)})},questionHasCoordinates(n){return lt.has(n,"coordinates.x")&<.has(n,"coordinates.y")},destroyPanorama(){this.hotspots=[],this.markersPlugin.removeEventListener("select-marker")},handleHotspotClick(n){this.hotspot=n,this.setCurrentQuestion(n.id)},setCurrentQuestion(n){const e=lt.find(this.questions,{hash:n});this.currentQuestion=e||null},closeQuestion(){this.currentQuestion=null},handleKeyup(n){n.keyCode===27&&this.currentQuestion&&this.closeQuestion()},handleAnswerClicked(){this.closeQuestion(),this.removeHotspot(),this.resetUnansweredQuestionIdx()},removeHotspot(){this.markersPlugin.removeMarker(this.hotspot.id),this.hotspot=void 0},findNextHotspot(){const n=this.findNextUnansweredQuestion();n&&this.PSV.animate({textureX:n.coordinates.x,textureY:n.coordinates.y,speed:500})},findNextUnansweredQuestion(){const n=this.unansweredQuestions[this.nextUnansweredQuestionsIdx];return this.nextUnansweredQuestionsIdx===this.unansweredQuestionsNumber-1?this.nextUnansweredQuestionsIdx=0:this.nextUnansweredQuestionsIdx+=1,n},resetUnansweredQuestionIdx(){this.nextUnansweredQuestionsIdx=0}}},iI={class:"l-quiz-type-panorama"},sI={class:"l-quiz-type-panorama__brand"},rI={class:"l-quiz-type-panorama__exit"},oI=["href"],aI={key:1,class:"l-quiz-type-panorama__ad-container"},lI={class:"c-promo-single c-promo-single--vertical"},cI=["href"],hI=["src"],uI=["src"],dI={key:0,class:"l-quiz-type-panorama__panorama-overlay"},fI={class:"l-quiz-type-panorama__panorama-container",ref:"panoramaContainer"},pI={class:"l-quiz-type-panorama__modal"},mI={class:"l-quiz-type-panorama__hotspot-finder"},_I={key:2,class:"l-quiz-type-panorama__progress-bar"};function gI(n,e,t,i,s,r){const o=it("quiz-branding-playmit"),a=it("quiz-branding-fox"),l=it("quiz-header-points"),c=it("quiz-textual-progress"),h=it("quiz-progress-bar");return J(),ae("div",iI,[se("div",sI,[n.isPlaymitQuiz?(J(),yt(o,{key:0,light:!0})):Ne("",!0),n.isFoxQuiz?(J(),yt(a,{key:1,light:!0})):Ne("",!0),n.isPlaymitQuiz?(J(),yt(l,{key:2,class:"c-quiz-header__possible-points--panorama"})):Ne("",!0)]),r.hasError?Ne("",!0):(J(),yt(c,{key:0,class:"l-quiz-type-panorama__textual-progress"})),se("div",rI,[se("a",{class:"l-quiz-type-panorama__exit-link",href:r.cancelUrl},"Quiz beenden",8,oI)]),r.ad?(J(),ae("div",aI,[se("div",lI,[e[2]||(e[2]=se("span",{class:"c-promo-single__powered"},"Unterstützt von",-1)),r.ad.item.url?(J(),ae("a",{key:0,href:r.ad.item.url,target:"blank"},[se("img",{class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,hI)],8,cI)):(J(),ae("img",{key:1,class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,uI))])])):Ne("",!0),Tt(qo,{name:"fade-in"},{default:Yr(()=>[s.currentQuestion?(J(),ae("div",dI)):Ne("",!0)]),_:1}),se("div",fI,null,512),Tt(qo,{name:"slide-up"},{default:Yr(()=>[s.currentQuestion?(J(),ae("div",{key:0,class:fn(["l-quiz-type-panorama__modal-wrapper",{"l-quiz-type-panorama__modal-wrapper--visible":s.currentQuestion}])},[se("div",pI,[(J(),yt(Wi(r.questionType),{question:s.currentQuestion,key:s.currentQuestion.hash,onAnswerClicked:r.handleAnswerClicked},null,40,["question","onAnswerClicked"])),se("a",{href:"",class:"l-quiz-type-panorama__modal-close",onClick:e[0]||(e[0]=er((...f)=>r.closeQuestion&&r.closeQuestion(...f),["prevent"]))},"×")])],2)):Ne("",!0)]),_:1}),se("div",mI,[n.unansweredQuestions.length?(J(),ae("button",{key:0,class:"l-quiz-type-panorama__hotspot-finder-button",type:"button",onClick:e[1]||(e[1]=(...f)=>r.findNextHotspot&&r.findNextHotspot(...f))},"Hotspot finden")):Ne("",!0)]),r.hasError?Ne("",!0):(J(),ae("div",_I,[Tt(h,{class:"c-progress--transparent"})]))])}const vI=mt(nI,[["render",gI]]),Am={type:"change"},lf={type:"start"},j0={type:"end"},Ml=new tf,Cm=new ls,xI=Math.cos(70*ud.DEG2RAD),Gt=new re,yn=2*Math.PI,Ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Sh=1e-6;class MI extends PD{constructor(e,t=null){super(e,t),this.state=Ct.NONE,this.enabled=!0,this.target=new re,this.cursor=new re,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Kr.ROTATE,MIDDLE:Kr.DOLLY,RIGHT:Kr.PAN},this.touches={ONE:$r.ROTATE,TWO:$r.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new re,this._lastQuaternion=new Ts,this._lastTargetPosition=new re,this._quat=new Ts().setFromUnitVectors(e.up,new re(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Mm,this._sphericalDelta=new Mm,this._scale=1,this._panOffset=new re,this._rotateStart=new at,this._rotateEnd=new at,this._rotateDelta=new at,this._panStart=new at,this._panEnd=new at,this._panDelta=new at,this._dollyStart=new at,this._dollyEnd=new at,this._dollyDelta=new at,this._dollyDirection=new re,this._mouse=new at,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=yI.bind(this),this._onPointerDown=EI.bind(this),this._onPointerUp=SI.bind(this),this._onContextMenu=PI.bind(this),this._onMouseWheel=TI.bind(this),this._onKeyDown=AI.bind(this),this._onTouchStart=CI.bind(this),this._onTouchMove=RI.bind(this),this._onMouseDown=bI.bind(this),this._onMouseMove=wI.bind(this),this._interceptControlDown=LI.bind(this),this._interceptControlUp=DI.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){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(Am),this.update(),this.state=Ct.NONE}update(e=null){const t=this.object.position;Gt.copy(t).sub(this.target),Gt.applyQuaternion(this._quat),this._spherical.setFromVector3(Gt),this.autoRotate&&this.state===Ct.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=yn:i>Math.PI&&(i-=yn),s<-Math.PI?s+=yn:s>Math.PI&&(s-=yn),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),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):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Gt.setFromSpherical(this._spherical),Gt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Gt),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)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Gt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new re(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new re(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Gt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Ml.origin.copy(this.object.position),Ml.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ml.direction))<xI?this.object.lookAt(this.target):(Cm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ml.intersectPlane(Cm,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Sh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Sh||this._lastTargetPosition.distanceToSquared(this.target)>Sh?(this.dispatchEvent(Am),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?yn/60*this.autoRotateSpeed*e:yn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Gt.setFromMatrixColumn(t,0),Gt.multiplyScalar(-e),this._panOffset.add(Gt)}_panUp(e,t){this.screenSpacePanning===!0?Gt.setFromMatrixColumn(t,1):(Gt.setFromMatrixColumn(t,0),Gt.crossVectors(this.object.up,Gt)),Gt.multiplyScalar(e),this._panOffset.add(Gt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Gt.copy(s).sub(this.target);let r=Gt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.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(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(yn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-yn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(yn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-yn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new at,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function EI(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function yI(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function SI(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(j0),this.state=Ct.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function bI(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Kr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=Ct.DOLLY;break;case Kr.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=Ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=Ct.ROTATE}break;case Kr.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=Ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=Ct.PAN}break;default:this.state=Ct.NONE}this.state!==Ct.NONE&&this.dispatchEvent(lf)}function wI(n){switch(this.state){case Ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case Ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case Ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function TI(n){this.enabled===!1||this.enableZoom===!1||this.state!==Ct.NONE||(n.preventDefault(),this.dispatchEvent(lf),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(j0))}function AI(n){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(n)}function CI(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case $r.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=Ct.TOUCH_ROTATE;break;case $r.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=Ct.TOUCH_PAN;break;default:this.state=Ct.NONE}break;case 2:switch(this.touches.TWO){case $r.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=Ct.TOUCH_DOLLY_PAN;break;case $r.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=Ct.TOUCH_DOLLY_ROTATE;break;default:this.state=Ct.NONE}break;default:this.state=Ct.NONE}this.state!==Ct.NONE&&this.dispatchEvent(lf)}function RI(n){switch(this._trackPointer(n),this.state){case Ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case Ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case Ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case Ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=Ct.NONE}}function PI(n){this.enabled!==!1&&n.preventDefault()}function LI(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function DI(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const bh=(n,e)=>Math.round(n*10**e)/10**e,II={name:"QuizTypePanoramavideo",mixins:[ax],data(){return{currentQuestion:null,showBrowserNotice:!1}},computed:{...ri(["questions","questionsNumber","unansweredQuestions","unansweredQuestionsNumber","isPlaymitQuiz","isFoxQuiz"]),quiz(){return this.$store.getters.currentQuiz},panoramaVideoUrl(){return this.$store.getters.currentQuiz.panoramaVideo},questionType(){if(this.currentQuestion)return"question-"+this.currentQuestion.type},hasError(){return!lt.isEmpty(this.$store.state.base.error)},cancelUrl(){return`/quiz-modus/abbrechen/${this.$store.state.gameRound.hash}`},ad(){return this.$store.getters.hasQuizAd?{id:this.$store.state.ads.quiz.adZoneId,item:this.$store.state.ads.quiz.list[0]}:null}},created(){window.addEventListener("keyup",this.handleKeyup),this.nextUnansweredQuestionsIdx=0,this.hotspots=[]},mounted(){this.addClassesToBodyElem(),this.addEventListenersForPanoramaVideo(),this.setUpPanoramaVideo()},beforeUnmount(){this.destroyPanoramaVideo(),window.removeEventListener("keyup",this.handleKeyup),this.removeEventListenersForPanoramaVideo()},unmounted(){this.removeClassesFromBodyElem()},methods:{addClassesToBodyElem(){const n=document.querySelector("body");n.classList.add("l-body--quiz-mode-playing"),n.classList.add("l-body--quiz-mode-panorama")},removeClassesFromBodyElem(){const n=document.querySelector("body");n.classList.remove("l-body--quiz-mode-playing"),n.classList.remove("l-body--quiz-mode-panorama")},addEventListenersForPanoramaVideo(){document.addEventListener("click",this.handleMouseClicksForVideo),document.addEventListener("mousedown",this.handleMouseClicksForVideo),window.addEventListener("resize",this.onWindowResize),this.$refs.panoramaContainer.addEventListener("click",this.logCoordinates)},removeEventListenersForPanoramaVideo(){document.removeEventListener("click",this.handleMouseClicksForVideo),document.removeEventListener("mousedown",this.handleMouseClicksForVideo),window.removeEventListener("resize",this.onWindowResize),this.$refs.panoramaContainer.removeEventListener("click",this.logCoordinates)},showBrowserNoticeModal(){this.showBrowserNotice=!0},hideBrowserNoticeModal(){this.showBrowserNotice=!1,this.resumeMotion()},setUpPanoramaVideo(){this.buildScene(),this.buildHotSpots(),this.animate()},buildScene(){const{innerWidth:n,innerHeight:e}=window;this.panoramaDistance=100,this.scene=new p0,this.camera=new zn(80,n/e,.1,1e3),this.camera.position.set(0,0,1),this.video=this.$refs.videoContainer,this.video.play(),this.texture=new m0(this.video),this.texture.colorSpace=Dn,this.material=new sf({map:this.texture,side:_i}),this.geometry=new of(this.panoramaDistance,128,128),this.geometry.scale(-1,1,1),this.sphere=new Gn(this.geometry,this.material),this.scene.add(this.sphere),this.hotspots=new Xr,this.scene.add(this.hotspots),this.renderer=new AD,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(n,e),this.$refs.panoramaContainer.appendChild(this.renderer.domElement),this.controls=new MI(this.camera,this.renderer.domElement),this.controls.enablePan=!1,this.controls.enableZoom=!1,this.controls.rotateSpeed=.6,this.controls.autoRotate=!0,this.controls.autoRotateSpeed=.3,this.templateGeo=new wo(3,3,3),this.templateMaterial=new CD({color:255,transparent:!0,opacity:0}),this.templateMesh=new Gn(this.templateGeo,this.templateMaterial)},buildHotSpots(){this.unansweredQuestions.forEach((n,e)=>{if(this.questionHasCoordinates(n)){const t=`hotspot-${e+1}`,i=this.templateMesh.clone();i.position.set(n.coordinates.x,n.coordinates.y,n.coordinates.z),i.hotspotId=t,this.hotspots.add(i);const s=document.createElement("div"),r=document.createElement("div");s.appendChild(r),s.classList.add("l-quiz-type-panorama__hotspot","c-panorama-hotspot","c-panorama-hotspot--animated"),s.id=t,s.addEventListener("click",o=>{this.handleHotspotClick(o.target.closest(".l-quiz-type-panorama__hotspot"),n.hash)}),this.$refs.panoramaContainer.appendChild(s)}})},setHotspotPositions(){this.hotspots.children.forEach(n=>{const{x:e,y:t}=this.get2DPosition(n),i=document.getElementById(n.hotspotId),s=this.getDistance(this.camera.position,n.position,!0);i&&(s>this.panoramaDistance?(i.style.top=`${t-10}px`,i.style.left=`${e-10}px`,i.style.display="block",i.style.transform="scale(1.1)"):i.style.display="none")})},handleMouseClicksForVideo(){this.video.muted=!1,this.controls.autoRotate=!1},onWindowResize(){this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)},animate(){requestAnimationFrame(()=>{this.animate()}),this.updateAnimation()},updateAnimation(){this.setHotspotPositions(),this.controls.update(),this.renderer.render(this.scene,this.camera)},logCoordinates(n){if(n.shiftKey){const e=this.getClickInfo(n,this.sphere)[0],{point:t}=e;console.log(`${bh(t.x,6)}, ${bh(t.y,6)}, ${bh(t.z,6)}`)}},getClickInfo(n,e){const{clientX:t,clientY:i}=n,s=new at,r=new RD;return s.x=t/window.innerWidth*2-1,s.y=-(i/window.innerHeight)*2+1,r.setFromCamera(s,this.camera),r.intersectObject(e,!1)},get2DPosition(n){const e=new re,t=.5*window.innerWidth,i=.5*window.innerHeight;return n.updateMatrixWorld(),e.setFromMatrixPosition(n.matrixWorld),e.project(this.camera),e.x=e.x*t+t,e.y=-(e.y*i)+i,{x:e.x,y:e.y}},getDistance(n,e,t=!1){const i=n.x-e.x,s=n.y-e.y,r=n.z-e.z;return Math.sqrt(t?i*i+s*s+r*r:i*i+r*r)},questionHasCoordinates(n){return lt.has(n,"coordinates.x")&<.has(n,"coordinates.y")&<.has(n,"coordinates.z")},destroyPanoramaVideo(){this.texture.dispose(),this.material.dispose(),this.geometry.dispose(),this.templateGeo.dispose(),this.templateMaterial.dispose(),this.hotspots.children.forEach(n=>{n.geometry.dispose(),n.material.dispose()})},pauseMotion(){this.video.pause(),this.controls.autoRotate=!1},resumeMotion(){this.video.play()},handleHotspotClick(n,e){this.hotspot=n,this.setCurrentQuestion(e),this.pauseMotion()},setCurrentQuestion(n){const e=lt.find(this.questions,{hash:n});this.currentQuestion=e||null},closeQuestion(){this.currentQuestion=null,this.resumeMotion()},handleKeyup(n){n.keyCode===27&&this.currentQuestion&&this.closeQuestion(),n.keyCode===80&&this.video.play()},handleAnswerClicked(){this.closeQuestion(),this.removeHotspot(),this.resetUnansweredQuestionIdx()},removeHotspot(){const n=this.hotspot.id,e=this.hotspots.children.find(t=>t.hotspotId===n);this.$refs.panoramaContainer.removeChild(this.hotspot),this.hotspots.remove(e),this.hotspot=void 0},findNextHotspot(){const n=this.findNextUnansweredQuestion();n&&this.questionHasCoordinates(n)&&this.moveCameraToNextHotspot(n.coordinates)},findNextUnansweredQuestion(){const n=this.unansweredQuestions[this.nextUnansweredQuestionsIdx];return this.nextUnansweredQuestionsIdx===this.unansweredQuestionsNumber-1?this.nextUnansweredQuestionsIdx=0:this.nextUnansweredQuestionsIdx+=1,n},resetUnansweredQuestionIdx(){this.nextUnansweredQuestionsIdx=0},moveCameraToNextHotspot(n){const i={x:-n.x/100,y:-n.y/100,z:-n.z/100},s={x:i.x-this.camera.position.x,y:i.y-this.camera.position.y,z:i.z-this.camera.position.z},r={x:s.x/40,y:s.y/40,z:s.z/40};for(let o=0;o<40;o++)setTimeout(()=>{this.camera.position.set(this.camera.position.x+r.x,this.camera.position.y+r.y,this.camera.position.z+r.z)},o*10)}}},UI={class:"l-quiz-type-panorama"},NI={class:"l-quiz-type-panorama__brand"},FI={class:"l-quiz-type-panorama__exit"},OI=["href"],zI={key:1,class:"l-quiz-type-panorama__ad-container"},kI={class:"c-promo-single c-promo-single--vertical"},BI=["href"],HI=["src"],VI=["src"],GI={key:0,class:"l-quiz-type-panorama__panorama-overlay"},WI={class:"l-quiz-type-panorama__panorama-container",ref:"panoramaContainer"},$I={ref:"videoContainer",loop:"",muted:"",playsinline:"",style:{display:"none"}},qI=["src"],XI={class:"l-quiz-type-panorama__modal"},YI={key:0,class:"l-quiz-type-panorama__browser-notice"},QI={class:"l-quiz-type-panorama__hotspot-finder"},jI={key:2,class:"l-quiz-type-panorama__progress-bar"};function ZI(n,e,t,i,s,r){const o=it("quiz-branding-playmit"),a=it("quiz-branding-fox"),l=it("quiz-header-points"),c=it("quiz-textual-progress"),h=it("quiz-progress-bar");return J(),ae("div",UI,[se("div",NI,[n.isPlaymitQuiz?(J(),yt(o,{key:0,light:!0})):Ne("",!0),n.isFoxQuiz?(J(),yt(a,{key:1,light:!0})):Ne("",!0),n.isPlaymitQuiz?(J(),yt(l,{key:2,class:"c-quiz-header__possible-points--panorama"})):Ne("",!0)]),r.hasError?Ne("",!0):(J(),yt(c,{key:0,class:"l-quiz-type-panorama__textual-progress"})),se("div",FI,[se("a",{class:"l-quiz-type-panorama__exit-link",href:r.cancelUrl},"Quiz beenden",8,OI)]),r.ad?(J(),ae("div",zI,[se("div",kI,[e[3]||(e[3]=se("span",{class:"c-promo-single__powered"},"Unterstützt von",-1)),r.ad.item.url?(J(),ae("a",{key:0,href:r.ad.item.url,target:"blank"},[se("img",{class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,HI)],8,BI)):(J(),ae("img",{key:1,class:"c-promo-single__ad",src:r.ad.item.logoUrl},null,8,VI))])])):Ne("",!0),Tt(qo,{name:"fade-in"},{default:Yr(()=>[s.currentQuestion?(J(),ae("div",GI)):Ne("",!0)]),_:1}),se("div",WI,null,512),se("video",$I,[se("source",{src:r.panoramaVideoUrl},null,8,qI)],512),Tt(qo,{name:"slide-up"},{default:Yr(()=>[s.currentQuestion?(J(),ae("div",{key:0,class:fn(["l-quiz-type-panorama__modal-wrapper",{"l-quiz-type-panorama__modal-wrapper--visible":s.currentQuestion}])},[se("div",XI,[(J(),yt(Wi(r.questionType),{question:s.currentQuestion,key:s.currentQuestion.hash,onAnswerClicked:r.handleAnswerClicked},null,40,["question","onAnswerClicked"])),se("a",{href:"",class:"l-quiz-type-panorama__modal-close",onClick:e[0]||(e[0]=er((...f)=>r.closeQuestion&&r.closeQuestion(...f),["prevent"]))},"×")])],2)):Ne("",!0)]),_:1}),Tt(qo,{name:"fade-in"},{default:Yr(()=>[s.showBrowserNotice?(J(),ae("div",YI,[se("a",{href:"",class:"l-quiz-type-panorama__modal-close l-quiz-type-panorama__browser-notice-close",onClick:e[1]||(e[1]=er((...f)=>r.hideBrowserNoticeModal&&r.hideBrowserNoticeModal(...f),["prevent"]))},"×"),e[4]||(e[4]=se("p",null,[se("span",{class:"u-text-bold"},"Hinweis"),pt(": Es handelt sich bei diesem Video-Panorama-Quiz um ein experimentelles Feature."),se("br"),pt(" Die besten Ergebnisse erzielst du mit einem der folgenden Browser: "),se("br"),se("strong",null,"Brave"),pt(", "),se("strong",null,"Opera"),pt(", "),se("strong",null,"Microsoft Edge"),pt(", "),se("strong",null,"Google Chrome"),pt(". ")],-1))])):Ne("",!0)]),_:1}),se("div",QI,[n.unansweredQuestions.length?(J(),ae("button",{key:0,class:"l-quiz-type-panorama__hotspot-finder-button",type:"button",onClick:e[2]||(e[2]=(...f)=>r.findNextHotspot&&r.findNextHotspot(...f))},"Hotspot finden")):Ne("",!0)]),r.hasError?Ne("",!0):(J(),ae("div",jI,[Tt(h,{class:"c-progress--transparent"})]))])}const KI=mt(II,[["render",ZI]]),JI={name:"QuizIntro",props:{quizType:{type:String}},computed:{...oi({currentIntroIndex:n=>n.gameRound.currentQuizIndex}),...ri({intro:"currentQuizIntro"}),introFileName(){return this.intro.file?this.intro.file_name?this.intro.file_name:this.intro.file.url.split("/").pop():""},introFileIcon(){if(!this.intro.file)return null;switch(this.intro.file.url.substr(this.intro.file.url.lastIndexOf(".")+1)){case"pdf":return"icon-file-pdf-o";case"doc":return"icon-file-word-o";case"docx":return"icon-file-word-o";default:return"icon-file-o"}},quizTypeClass(){if(this.quizType==="berufsvideo")return"l-quiz-intro__intro--profession-video"}},mounted(){this.addBodyClasses()},unmounted(){this.removeBodyClasses()},methods:{addBodyClasses(){this.bodyElem=document.querySelector(".l-body"),this.bodyElem&&this.bodyElem.classList.add("l-body--quiz-mode-playing")},removeBodyClasses(){this.bodyElem&&this.bodyElem.classList.remove("l-body--quiz-mode-playing")},startQuiz(){this.$store.dispatch("handleIntroSeen",this.currentIntroIndex)}}},eU={class:"l-quiz-intro"},tU={class:"l-quiz-intro__content"},nU={key:0,class:"l-quiz-intro__headline"},iU={key:1,class:"l-quiz-intro__video-container"},sU={key:2,class:"l-quiz-intro__image-container"},rU=["src"],oU={class:"l-quiz-intro__main"},aU=["innerHTML"],lU={key:1,class:"l-quiz-intro__file__container"},cU=["href"],hU={class:"l-quiz-intro__start-container u-text-center u-margin-t-lg"};function uU(n,e,t,i,s,r){const o=it("quiz-header"),a=it("embed-video");return J(),ae("div",eU,[Tt(o),se("div",{class:fn(["l-quiz-intro__intro",r.quizTypeClass])},[se("div",tU,[n.intro.headline?(J(),ae("h1",nU,nt(n.intro.headline),1)):Ne("",!0),n.intro.video_url?(J(),ae("div",iU,[Tt(a,{url:n.intro.video_url},null,8,["url"])])):Ne("",!0),n.intro.image?(J(),ae("div",sU,[se("img",{src:n.intro.image.url,class:"l-quiz-intro__image"},null,8,rU)])):Ne("",!0),se("div",oU,[n.intro.text?(J(),ae("div",{key:0,class:"l-quiz-intro__text c-content-text",innerHTML:n.intro.text},null,8,aU)):Ne("",!0),n.intro.file?(J(),ae("div",lU,[se("a",{href:n.intro.file.url,title:"introFileName",target:"_blank",class:"c-button c-button--with-border"},[se("span",{class:fn(r.introFileIcon)},null,2),pt(" "+nt(r.introFileName),1)],8,cU)])):Ne("",!0),se("div",hU,[se("button",{type:"button",class:"c-button c-button--blue c-button--large",onClick:e[0]||(e[0]=(...l)=>r.startQuiz&&r.startQuiz(...l))},"Starte Quiz")])])])],2)])}const dU=mt(JI,[["render",uU]]),fU={name:"QuizBrandingPlaymit",props:{light:{type:Boolean,default:!1}},computed:{baseUrl(){return this.$store.state.base.url},logoUrl(){return`/images/logo${this.light?"-white":""}.svg`}}},pU=["href"],mU=["src"],_U=["src"];function gU(n,e,t,i,s,r){return J(),ae("div",{class:fn(["c-quiz-mode-branding",{"c-quiz-mode-branding--light":t.light}])},[r.baseUrl?(J(),ae("a",{key:0,class:"c-quiz-mode-branding__logo-link",href:r.baseUrl},[se("img",{class:"c-quiz-mode-branding__logo",src:r.logoUrl,alt:"Playmit"},null,8,mU)],8,pU)):(J(),ae("img",{key:1,class:"c-quiz-mode-branding__logo",src:r.logoUrl,alt:"Playmit"},null,8,_U)),e[0]||(e[0]=se("span",{class:"c-quiz-mode-branding__logo-subline"},"/ quiz-modus",-1))],2)}const vU=mt(fU,[["render",gU]]),xU={name:"QuizBrandingFox",props:{light:{type:Boolean,default:!1}},components:{"logo-fox":rx}};function MU(n,e,t,i,s,r){const o=it("logo-fox");return J(),ae("div",{class:fn(["c-quiz-mode-branding c-quiz-mode-branding--fox",{"c-quiz-mode-branding--light":t.light}])},[Tt(o,{name:"Foxmit",size:"small",light:t.light,class:"mr-4"},null,8,["light"]),e[0]||(e[0]=se("span",{class:"c-quiz-mode-branding__logo-subline"},"/ quiz-modus",-1))],2)}const EU=mt(xU,[["render",MU]]),yU={name:"QuizHeader",computed:{...oi({points:n=>n.gameRound.points,hash:n=>n.gameRound.hash}),...ri(["quizAbortUrl","isPlaymitQuiz","isFoxQuiz","isFoxTest"]),cancelUrl(){return this.quizAbortUrl(this.hash)}}},SU={class:"c-quiz-header"},bU={class:"c-quiz-header__container"},wU={class:"c-quiz-header__slot-container"},TU=["href"];function AU(n,e,t,i,s,r){const o=it("quiz-branding-playmit"),a=it("quiz-branding-fox"),l=it("quiz-header-points");return J(),ae("header",SU,[se("div",bU,[n.isPlaymitQuiz?(J(),yt(o,{key:0})):Ne("",!0),n.isFoxQuiz?(J(),yt(a,{key:1})):Ne("",!0),se("div",wU,[n.isPlaymitQuiz?(J(),yt(l,{key:0})):Ne("",!0),K0(n.$slots,"default",{},()=>[n.isFoxTest?Ne("",!0):(J(),ae("a",{key:0,href:r.cancelUrl,title:"Quiz beenden"},"Quiz beenden",8,TU))])])])])}const CU=mt(yU,[["render",AU]]),RU={name:"QuizHeaderPoints",mounted(){this.$nextTick(()=>{this.setUpTooltips()})},computed:{...oi({points:n=>n.gameRound.points}),...ri(["isExhibitionQuiz"]),exceptionsInfoText(){let n=this.points.exceptions[0];if(n==="QuizLimitDailyException")return this.isExhibitionQuiz?"Du hast das Quiz dieses Aussteller heute schon zu oft gespielt. Um wieder Punkte zu erhalten, probiere ein Quiz eines anderen Ausstellers.":"Du hast dieses Quiz heute schon zu oft gespielt. Versuche es doch morgen wieder!";if(n==="QuizLimitMonthlyException")return"Du hast dieses Quiz in diesem Monat bereits zu oft gespielt. Probiere doch ein Anderes!";if(n==="QuizLimit30DaysException")return"Du hast dieses Quiz in den letzten 30 Tagen bereits zu oft gespielt. Probiere doch ein Anderes!";if(n==="QuizLimitTotalException")return"Du hast dieses Quiz bereits zu oft gespielt. Probiere doch ein Anderes!"}},methods:{setUpTooltips(){const n=this.$refs.pointsExceptions;if(n){const e=lt.merge(cx,{content:n.dataset.tooltip});lx(n,e)}}}},PU={class:"c-quiz-header__possible-points"},LU={class:"c-quiz-header__possible-points-number"},DU=["data-tooltip"];function IU(n,e,t,i,s,r){return J(),ae("div",PU,[n.points.possible?(J(),ae(vt,{key:0},[se("span",LU,nt(n.points.possible)+" Punkte",1),e[0]||(e[0]=pt(" möglich "))],64)):Ne("",!0),n.points.exceptions.length?(J(),ae(vt,{key:1},[e[2]||(e[2]=pt(" Keine Punkte mehr ")),se("span",{ref:"pointsExceptions",class:"c-quiz-header__possible-points-info-icon","data-tooltip":r.exceptionsInfoText},e[1]||(e[1]=[se("span",{class:"icon-info-circle"},null,-1)]),8,DU)],64)):Ne("",!0)])}const UU=mt(RU,[["render",IU]]),NU={name:"QuizProgressBar",computed:{isLoading(){return this.$store.state.base.isLoading},all(){return this.$store.getters.questionsFilteredFromRemember.length},progress(){var n=this.$store.getters.currentQuestionNumber-this.$store.getters.rememberQuestionsSeen;return n=n<1?1:n,ca.isEmpty(this.$store.state.result.hasResult)?(n-1)/this.all*100:100}}},FU={class:"c-progress"};function OU(n,e,t,i,s,r){return J(),ae("div",FU,[se("div",{class:"c-progress__bar",style:no({width:r.progress+"%"})},null,4)])}const zU=mt(NU,[["render",OU]]),kU={name:"QuizTextualProgress",computed:{isLoading(){return this.$store.state.base.isLoading},all(){return this.$store.getters.questionsFilteredFromRemember.length},current(){let n=this.$store.getters.currentQuestionNumber-this.$store.getters.rememberQuestionsSeen;return n>0?n:1}}};function BU(n,e,t,i,s,r){return J(),ae("div",null,[r.isLoading?Ne("",!0):(J(),ae(vt,{key:0},[pt(" Frage "+nt(r.current)+" von "+nt(r.all),1)],64))])}const HU=mt(kU,[["render",BU]]),VU={name:"QuestionMC",emits:["answer-clicked"],props:{question:{type:Object,required:!0}},data(){return{clickedAnswers:[]}},computed:{hasAttachment(){return!!this.question.attachment},multiSelectHint(){return this.clickedAnswers.length>0&&this.clickedAnswers.length<this.question.answersNumber?"Bitte wähle eine weitere Antwort aus!":null}},watch:{clickedAnswers:{handler(n,e){this.question.answersNumber===n.length&&this.dispatchAnswer()},deep:!0}},mounted(){this.$store.dispatch("submitViewing",{hash:this.question.hash})},methods:{handleAnswerClick(n){let e=this.clickedAnswers.indexOf(n);e>-1?this.clickedAnswers.splice(e,1):this.clickedAnswers.push(n)},answerSelected(n){return this.clickedAnswers.indexOf(n)>-1},dispatchAnswer(){this.handleBotCheck(),this.$store.dispatch("submitAnswer",{questionHash:this.question.hash,answer:this.clickedAnswers}),this.$emit("answer-clicked")},handleBotCheck(){this.$store.getters.currentQuestionShouldBeChecked&&this.$store.dispatch("executeRecaptcha",{questionHash:this.question.hash,action:"quiz_mode_question_mc"})}}},GU={class:"l-question-mc__question"},WU={class:"l-question-mc__main-container"},$U={class:"l-question-mc__answers js-question-mc-answers"},qU=["onClick"],XU={key:0,class:"l-question-mc__attachment-container"},YU={key:0,class:"l-question-mc__hint js-question-multi-select-hint"};function QU(n,e,t,i,s,r){const o=it("attachment");return J(),ae("div",{class:fn(["l-question-mc",{"l-question-mc--has-attachment":r.hasAttachment}])},[se("div",GU,nt(t.question.name),1),se("div",WU,[se("ul",$U,[(J(!0),ae(vt,null,Si(t.question.answers,(a,l)=>(J(),ae("li",{class:fn(["l-question-mc__answer js-question-mc-answer",{"l-question-mc__answer--selected":r.answerSelected(l)}]),key:l,onClick:er(c=>r.handleAnswerClick(l),["prevent"])},[pt(nt(a.value)+" ",1),a.attachment?(J(),yt(o,{key:0,class:"l-question-mc__answer-attachment",attachment:a.attachment,"alt-text":"Bild wird geladen"},null,8,["attachment"])):Ne("",!0)],10,qU))),128))]),r.hasAttachment?(J(),ae("div",XU,[Tt(o,{attachment:t.question.attachment,class:"l-question-mc__attachment"},null,8,["attachment"])])):Ne("",!0)]),r.multiSelectHint?(J(),ae("div",YU,nt(r.multiSelectHint),1)):Ne("",!0)],2)}const jU=mt(VU,[["render",QU]]),ZU={name:"QuestionInput",emits:["answer-clicked"],props:{question:{type:Object,required:!0}},computed:{hasAttachment(){return!!this.question.attachment}},data(){return{answer:""}},mounted(){this.$store.dispatch("submitViewing",{hash:this.question.hash}),this.$refs.input.focus()},methods:{dispatchAnswer(){this.handleBotCheck(),this.answer&&this.answer!==""&&(this.$store.dispatch("submitAnswer",{questionHash:this.question.hash,answer:this.answer}),this.$emit("answer-clicked"))},handleBotCheck(){this.$store.getters.currentQuestionShouldBeChecked&&this.$store.dispatch("executeRecaptcha",{questionHash:this.question.hash,action:"quiz_mode_question_input"})}}},KU={class:"l-question-input"},JU={class:"l-question-input__question"},e3={key:0,class:"l-question-input__attachment-container"},t3={class:"l-question-input__answer-container"},n3=["disabled"];function i3(n,e,t,i,s,r){const o=it("attachment");return J(),ae("div",KU,[se("div",JU,nt(t.question.name),1),r.hasAttachment?(J(),ae("div",e3,[Tt(o,{attachment:t.question.attachment,class:"l-question-input__attachment"},null,8,["attachment"])])):Ne("",!0),se("div",t3,[Rm(se("input",{class:"l-question-input__input",type:"text",placeholder:"Deine Antwort","onUpdate:modelValue":e[0]||(e[0]=a=>s.answer=a),onKeyup:e[1]||(e[1]=ex((...a)=>r.dispatchAnswer&&r.dispatchAnswer(...a),["enter"])),ref:"input"},null,544),[[J0,s.answer]]),se("button",{type:"button",class:"l-question-input__button",onClick:e[2]||(e[2]=(...a)=>r.dispatchAnswer&&r.dispatchAnswer(...a)),disabled:!s.answer&&s.answer===""},"Absenden",8,n3)])])}const s3=mt(ZU,[["render",i3]]),r3={name:"QuestionGraphical",emits:["answer-clicked"],props:{question:{type:Object,required:!0}},data(){return{markerUrl:"/images/marker.png",clickedPositions:[],viewportTooSmall:!1}},computed:{image(){return this.question.attachment},answerFormatted(){return this.question.answersNumber===1?this.clickedPositions[0]:this.clickedPositions},cancelUrl(){return`/quiz-modus/abbrechen/${this.$store.state.gameRound.hash}`}},watch:{clickedPositions:{handler(n,e){this.question.answersNumber===n.length&&this.dispatchAnswer()},deep:!0}},beforeMount(){this.$nextTick(()=>{this.setUpSmallViewportHandling()})},mounted(){this.$store.dispatch("submitViewing",{hash:this.question.hash})},beforeUnmount(){this.teardownSmallViewportHandling()},methods:{getMarkerPosition(n){return{top:`${n.y}px`,left:`${n.x}px`}},removeClickedPosition(n){this.question.type!=="order_preferenc"&&this.clickedPositions.splice(n,1)},processAnswer(n){this.clickedPositions.push(this.calculateClickPosition(n))},dispatchAnswer(){this.handleBotCheck(),this.$store.dispatch("submitAnswer",{questionHash:this.question.hash,answer:this.answerFormatted}),this.$emit("answer-clicked")},handleBotCheck(){this.$store.getters.currentQuestionShouldBeChecked&&this.$store.dispatch("executeRecaptcha",{questionHash:this.question.hash,action:"quiz_mode_question_graphical"})},calculateClickPosition(n){let e=this.$refs.image.getBoundingClientRect(),t=Math.round(n.clientX-e.left),i=Math.round(n.clientY-e.top);return{x:t,y:i}},setUpSmallViewportHandling(){this.checkViewportWidth(),window.addEventListener("resize",this.checkViewportWidth)},checkViewportWidth(){Lm().width<Pm.graphicalQuestionBreakpoint?(this.viewportTooSmall=!0,document.querySelector(".l-quiz-type-standard").classList.add("l-quiz-type-standard--viewport-too-small")):(this.viewportTooSmall=!1,document.querySelector(".l-quiz-type-standard").classList.remove("l-quiz-type-standard--viewport-too-small"))},teardownSmallViewportHandling(){window.removeEventListener("resize",this.checkViewportWidth)}}},o3={class:"l-question-graphical"},a3={class:"l-question-graphical__question"},l3={class:"l-question-graphical__image-container"},c3={class:"l-question-graphical__overlays-position-container"},h3=["src","alt"],u3=["src","onClick"],d3={key:1,class:"l-question-graphical__viewport-info"};function f3(n,e,t,i,s,r){return J(),ae("div",o3,[s.viewportTooSmall?(J(),ae("div",d3,e[1]||(e[1]=[se("h5",{class:"l-question-graphical__viewport-info-headline"},"Um das grafische Quiz zu spielen, drehe bitte dein Smartphone oder spiele auf einem größeren Bildschirm weiter.",-1),se("div",{class:"l-question-graphical__viewport-info-phone"},[se("div",{class:"l-question-graphical__viewport-info-phone-display"}),se("div",{class:"l-question-graphical__viewport-info-phone-button"})],-1)]))):(J(),ae(vt,{key:0},[se("div",a3,nt(t.question.name),1),se("div",l3,[se("div",c3,[se("img",{class:"l-question-graphical__image",src:r.image.url,alt:t.question.name,ref:"image",onClick:e[0]||(e[0]=(...o)=>r.processAnswer&&r.processAnswer(...o))},null,8,h3),(J(!0),ae(vt,null,Si(s.clickedPositions,(o,a)=>(J(),ae("img",{key:a,src:s.markerUrl,alt:"Gewählte Antwort",class:"l-question-graphical__marker",style:no(r.getMarkerPosition(o)),onClick:l=>r.removeClickedPosition(a)},null,12,u3))),128))])])],64))])}const p3=mt(r3,[["render",f3]]),m3={name:"QuestionRemember",emits:["answer-clicked"],props:{question:{type:Object,required:!0}},computed:{hasAttachment(){return!!this.question.attachment}},mounted(){this.$store.dispatch("submitViewing",{hash:this.question.hash})},methods:{showQuestion(){this.handleBotCheck(),this.$store.dispatch("submitAnswer",{questionHash:this.question.hash}),this.$emit("answer-clicked")},handleBotCheck(){this.$store.getters.currentQuestionShouldBeChecked&&this.$store.dispatch("executeRecaptcha",{questionHash:this.question.hash,action:"quiz_mode_question_remember"})}}},_3={class:"l-question-remember"},g3={class:"l-question-remember__question"},v3={key:0,class:"l-question-remember__add-text"},x3={key:1,class:"l-question-remember__attachment"},M3={class:"l-question-remember__actions"};function E3(n,e,t,i,s,r){const o=it("attachment");return J(),ae("div",_3,[se("div",g3,nt(t.question.name),1),t.question.additional_text.length?(J(),ae("div",v3,nt(t.question.additional_text),1)):Ne("",!0),r.hasAttachment?(J(),ae("div",x3,[Tt(o,{attachment:t.question.attachment},null,8,["attachment"])])):Ne("",!0),se("div",M3,[se("button",{class:"l-question-remember__button",type:"button",onClick:e[0]||(e[0]=er((...a)=>r.showQuestion&&r.showQuestion(...a),["prevent"]))},"Weiter")])])}const y3=mt(m3,[["render",E3]]),cf={props:{ad:{type:Object,default:null}},data(){return{reviewMode:!1,reviewed:!1}},computed:{...oi({guest:n=>n.gameRound.guest,wrongQuestions:n=>n.result.wrongQuestions}),reviewAvailable(){return!!this.wrongQuestions.length&&!this.reviewed&&!this.guest}},methods:{changeMode(){this.reviewMode=!this.reviewMode,this.reviewed=!0}}},S3={name:"QuizResultPlaymit",mixins:[hx,cf],data(){return{adsTracked:!1}},computed:{...oi({ads:n=>n.ads.result.list,adZoneId:n=>n.ads.result.adZoneId,isCompanyQuiz:n=>n.gameRound.quizzes[0].company,ranking:n=>n.result.ranking}),currentUrlPath(){const n=document.head.querySelector('meta[name="current-url"]');return n?n.content:""},tracking(){return{container:"adsContainer",ads:this.ads,name:`ad_zone_${this.adZoneId}`}}},created(){this.$store.dispatch("fetchRanking"),this.isCompanyQuiz||this.$store.dispatch("fetchResultAds")},mounted(){this.$nextTick(()=>{this.trackAdsShown(),this.setupTrackAdClicks()})},updated(){this.$nextTick(()=>{this.trackAdsShown(),this.setupTrackAdClicks(),this.updateMonthlyChallengePositionOnHeader()})},beforeUnmount(){this.tearDownTrackAdClicks()},methods:{isEmpty(n){return ca.isEmpty(n)},trackAdsShown(){this.ads.length&&window.matomoEnabled&&this.adsTracked===!1&&this.$refs.adsContainer&&(this.ads.forEach(n=>{_paq.push(["trackContentImpression",`ad_zone_${this.adZoneId}`,`company_${n.companyId}`,this.currentUrlPath])}),this.adsTracked=!0)},updateMonthlyChallengePositionOnHeader(){if(!this.isEmpty(this.ranking)){const n=document.querySelector(".js-monthly-challenge-count-header");n&&(n.innerText=`#${this.ranking.position}`)}}}},b3={class:"l-quiz-result"},w3={key:0,class:"l-quiz-result__result"},T3={class:"l-quiz-result__top-companies",ref:"adsContainer"},A3=["href","data-company-id"],C3={class:"c-image-card__image-centerer"},R3={class:"c-image-card__image-container"},P3=["src","alt"],L3={key:1,class:"c-image-card"},D3={class:"c-image-card__image-centerer"},I3={class:"c-image-card__image-container"},U3=["src","alt"];function N3(n,e,t,i,s,r){const o=it("quiz-result-headline"),a=it("quiz-result-text"),l=it("quiz-result-actions"),c=it("quiz-result-further-links"),h=it("wrong-questions-review");return J(),ae("div",b3,[n.reviewMode?(J(),yt(h,{key:1,"review-mode":n.reviewMode,"review-available":n.reviewAvailable,ad:n.ad,onChangeMode:n.changeMode},null,8,["review-mode","review-available","ad","onChangeMode"])):(J(),ae("div",w3,[Tt(o,{class:"l-quiz-result__headline-container"}),Tt(a,{class:"l-quiz-result__text"}),Tt(l,{class:"l-quiz-result__actions","review-mode":n.reviewMode,"review-available":n.reviewAvailable,onChangeMode:n.changeMode},null,8,["review-mode","review-available","onChangeMode"]),Tt(c),n.ads.length?(J(),ae(vt,{key:0},[e[0]||(e[0]=se("h4",{class:"l-quiz-result__top-companies-headline"},"Diese Top-Arbeitgeber empfehlen playmit.com und freuen sich auf deine Playmit-Urkunde:",-1)),se("ul",T3,[(J(!0),ae(vt,null,Si(n.ads,(f,p)=>(J(),ae("li",{key:p},[f.url.length?(J(),ae("a",{key:0,class:"c-image-card",href:f.url,target:"_blank","data-company-id":f.companyId},[se("div",C3,[se("div",R3,[se("img",{class:"c-image-card__image",src:f.logoUrl,alt:f.name},null,8,P3)])])],8,A3)):(J(),ae("div",L3,[se("div",D3,[se("div",I3,[se("img",{class:"c-image-card__image",src:f.logoUrl,alt:f.name},null,8,U3)])])]))]))),128))],512)],64)):Ne("",!0)]))])}const F3=mt(S3,[["render",N3]]),O3={name:"QuizResultFurtherLinks",data(){return{furtherLinksTracked:!1}},computed:{...oi({furtherLinks:n=>n.result.furtherLinks}),furtherLinksHasCompanyDetail(){return!1},furtherLinksHasCertificate(){return this.furtherLinks.length?lt.findIndex(this.furtherLinks,{type:"Certificate"})>-1:!1},furtherLinksCompanyDetail(){return lt.find(this.furtherLinks,{type:"CompanyDetail"})},furtherLinksCertificate(){return lt.find(this.furtherLinks,{type:"Certificate"})},companyDetailFacts(){if(this.furtherLinksCompanyDetail){let n,e;if(this.furtherLinksCompanyDetail.benefits.length)n="Vorteile",e=this.furtherLinksCompanyDetail.benefits;else if(this.furtherLinksCompanyDetail.professions.length)n="Berufe",e=this.furtherLinksCompanyDetail.professions;else return null;return{label:n,facts:e}}return null},currentUrlPath(){const n=document.head.querySelector('meta[name="current-url"]');return n?n.content:""}},created(){this.$store.dispatch("fetchFurtherLinks")},mounted(){this.trackFurtherLinksShown(),this.setupTrackFurtherLinkClicks()},updated(){this.$nextTick(()=>{this.trackFurtherLinksShown(),this.setupTrackFurtherLinkClicks()})},beforeUnmount(){this.tearDownTrackFurtherLinkClicks()},methods:{getBackgroundImageForFurtherLink(n){const e=n.backgroundImage||null;return e?{backgroundImage:`url("${e}")`}:!1},trackFurtherLinksShown(){this.furtherLinks.length&&window.matomoEnabled&&this.furtherLinksTracked===!1&&this.$refs.furtherLinksContainer&&this.furtherLinks.forEach(n=>{lt.has(n,"trackingName")&<.has(n,"trackingPiece")&&_paq.push(["trackContentImpression",n.trackingName,n.trackingPiece,this.currentUrlPath])})},setupTrackFurtherLinkClicks(){this.furtherLinks.length&&this.$refs.furtherLinksContainer&&this.$refs.furtherLinksContainer.addEventListener("click",this.fireTrackFurtherLinkClick)},fireTrackFurtherLinkClick(n){if(!window.matomoEnabled)return;const e=n.target.closest("a");if(e){const{href:t}=e,i=e.dataset.tname,s=e.dataset.tpiece;i&&s&&_paq.push(["trackContentInteraction","click",i,s,t])}},tearDownTrackFurtherLinkClicks(){this.furtherLinks.length&&this.$refs.furtherLinksContainer&&this.$refs.furtherLinksContainer.removeEventListener("click",this.fireTrackFurtherLinkClick)}}},z3={key:0,class:"l-quiz-result__further-quizzes-company-bar"},k3={key:0,class:"l-quiz-result__certificate-button c-centered-button-container"},B3=["href"],H3={class:"l-quiz-result__further-quizzes-headline l-quiz-result__further-quizzes-headline--thin"},V3={class:"c-company-bar-big c-company-bar-big__further-quizzes",ref:"furtherLinksContainer"},G3=["href","data-tname","data-tpiece"],W3={class:"c-company-bar-big__body"},$3={key:0,class:"c-company-bar-big__facts"},q3={class:"c-company-bar-big__facts-label"},X3={class:"c-company-bar-big__facts-list"},Y3=["href","data-tname","data-tpiece"],Q3={class:"c-company-bar-big__logo-container"},j3=["src","alt"],Z3={class:"l-quiz-result__further-quizzes",ref:"furtherLinksContainer"},K3=["href","data-tname","data-tpiece"],J3=["src"],eN={key:1,class:"c-media-card__badge c-badge c-badge--light-orange"},tN={class:"c-media-card__content c-media-card__content--dark"},nN={class:"c-media-card__text"};function iN(n,e,t,i,s,r){return n.furtherLinks.length?(J(),ae("div",z3,[r.furtherLinksHasCompanyDetail?(J(),ae(vt,{key:0},[r.furtherLinksHasCertificate?(J(),ae("div",k3,[se("a",{href:r.furtherLinksCertificate.url,class:"c-button c-button--blue c-button--block"},nt(r.furtherLinksCertificate.title),9,B3)])):Ne("",!0),se("h3",H3,[e[0]||(e[0]=pt(" Nähere Informationen über ")),se("strong",null,nt(r.furtherLinksCompanyDetail.title),1)]),se("div",V3,[se("div",{class:fn(["c-company-bar-big__video-container",{"c-media-card__image-container--image-centered":r.furtherLinksCompanyDetail.image}]),style:no(r.getBackgroundImageForFurtherLink(r.furtherLinksCompanyDetail))},[r.furtherLinksCompanyDetail.hasVideo?(J(),ae("a",{key:0,class:"c-media-card__play-button",href:r.furtherLinksCompanyDetail.url+"?openVideo=1","data-tname":r.furtherLinksCompanyDetail.trackingName,"data-tpiece":r.furtherLinksCompanyDetail.trackingPiece},null,8,G3)):Ne("",!0)],6),se("div",W3,[r.companyDetailFacts?(J(),ae("div",$3,[se("p",q3,nt(r.companyDetailFacts.label)+":",1),se("ul",X3,[(J(!0),ae(vt,null,Si(r.companyDetailFacts.facts,o=>(J(),ae("li",null,nt(o),1))),256))])])):Ne("",!0),se("a",{class:"c-button c-button--orange c-button--block",href:r.furtherLinksCompanyDetail.url,"data-tname":r.furtherLinksCompanyDetail.trackingName,"data-tpiece":r.furtherLinksCompanyDetail.trackingPiece}," Mehr erfahren und Job finden ",8,Y3)]),se("div",Q3,[se("img",{class:"c-company-bar-big__logo",src:r.furtherLinksCompanyDetail.logo||"",alt:r.furtherLinksCompanyDetail.title+" Logo"},null,8,j3)])],512)],64)):(J(),ae(vt,{key:1},[e[1]||(e[1]=se("h3",{class:"l-quiz-result__further-quizzes-headline"},"So geht es weiter",-1)),se("ul",Z3,[(J(!0),ae(vt,null,Si(n.furtherLinks,(o,a)=>(J(),ae("li",{key:a},[se("a",{class:"c-media-card",href:o.url,"data-tname":o.trackingName,"data-tpiece":o.trackingPiece},[se("div",{class:fn(["c-media-card__image-container",{"c-media-card__image-container--image-centered":o.image}]),style:no(r.getBackgroundImageForFurtherLink(o))},[o.image?(J(),ae("img",{key:0,class:"c-media-card__image",src:o.image},null,8,J3)):Ne("",!0),o.badge?(J(),ae("span",eN,nt(o.badge),1)):Ne("",!0)],6),se("div",tN,[se("div",nN,nt(o.title),1)])],8,K3)]))),128))],512)],64))])):Ne("",!0)}const sN=mt(O3,[["render",iN]]),rN={name:"QuestionInterests",mixins:[Dm],props:{question:{type:Object,required:!0}},data(){return{formData:{type:"interests",interests:[]},isLoading:!1}},computed:{bonusPointsAvailable(){return this.question.bonusPoints>0},exhibition(){return this.$store.state.base.exhibition},companyId(){return this.$store.state.base.exhibitionInfoQuestions.companyId}},created(){this.preparePreSelectedInterests()},methods:{preparePreSelectedInterests(){this.question.options.forEach(n=>{n.selected===!0&&this.formData.interests.push(n.value)})},submit(){this.isLoading=!0,vi.post(this.route("playmit.portal.exhibitions.user-infos",this.exhibition.slug),{...this.formData,company_id:this.companyId}).then(n=>{this.$store.commit("exhibitionInfoQuestions",n.data)}).catch(n=>{this.setValidationErrors(n.response)}).then(()=>{this.isLoading=!1})}}},oN={class:"u-margin-b-xs"},aN={class:"u-text-center u-text-xl u-text-blue"},lN={class:"u-text-center"},cN={class:"u-margin-t-xs u-margin-b-xs u-text-lg"},hN={class:"max-w-sm mx-auto u-margin-t-2xl"},uN={class:"c-form-checkbox"},dN=["value"],fN={class:"c-form-checkbox__label"},pN={key:0,class:"c-alert c-alert--error u-margin-t-xl u-text-sm u-text-left u-text-normal"};function mN(n,e,t,i,s,r){return J(),ae("div",{class:fn({"c-loading-animation":this.isLoading})},[se("div",oN,[se("h3",aN,[e[2]||(e[2]=pt(" Bonusfrage ")),r.bonusPointsAvailable?(J(),ae(vt,{key:0},[pt(" ("+nt(this.question.bonusPoints)+" Bonuspunkte) ",1)],64)):Ne("",!0)])]),se("div",lN,[se("h5",cN,"Willkommen auf der Messe "+nt(this.question.exhibition)+"!",1),e[3]||(e[3]=se("p",{class:"u-text-normal"},"An welchen Ausbildungsmöglichkeiten bist du interessiert?",-1))]),se("div",hN,[(J(!0),ae(vt,null,Si(t.question.options,(o,a)=>(J(),ae("div",{key:a,class:"c-form-group u-margin-b-xs"},[se("label",uN,[Rm(se("input",{class:"c-form-checkbox__input",type:"checkbox",value:o.value,"onUpdate:modelValue":e[0]||(e[0]=l=>s.formData.interests=l)},null,8,dN),[[tx,s.formData.interests]]),se("div",fN,nt(o.label),1)])]))),128)),se("button",{class:"c-button c-button--blue-large-block u-margin-t-lg",type:"button",onClick:e[1]||(e[1]=(...o)=>r.submit&&r.submit(...o))},"Absenden und Bonuspunkte erhalten"),n.hasErrors?(J(),ae("div",pN,[n.hasValidationError("company_id")||n.hasValidationError("type")?(J(),ae(vt,{key:0},[pt("Es gab einen Fehler. Bitte versuche es nochmals oder lade die Seite neu!")],64)):(J(),ae(vt,{key:1},[pt(nt(n.validationError("interests")),1)],64))])):Ne("",!0)])],2)}const _N=mt(rN,[["render",mN]]),gN={name:"QuestionAllowContacting",mixins:[Dm],props:{question:{type:Object,required:!0}},data(){return{isLoading:!1}},computed:{bonusPointsAvailable(){return this.question.bonusPoints>0},exhibition(){return this.$store.state.base.exhibition},companyId(){return this.$store.state.base.exhibitionInfoQuestions.companyId}},methods:{submit(n){this.isLoading=!0,vi.post(this.route("playmit.portal.exhibitions.user-infos",this.exhibition.slug),{type:"allow_contacting",company_id:this.companyId,allow_contacting:n}).then(e=>{this.$store.commit("exhibitionInfoQuestions",e.data)}).catch(e=>{this.setValidationErrors(e.response)}).then(()=>{this.isLoading=!1})}}},vN={class:"u-margin-b-xs"},xN={class:"u-text-center u-text-xl u-text-blue"},MN={class:"u-text-center"},EN=["innerHTML"],yN={class:"max-w-sm mx-auto u-margin-t-2xl"},SN={class:"u-margin-b-3xs"},bN={key:0,class:"c-alert c-alert--error u-margin-t-xl u-text-sm u-text-left u-text-normal"};function wN(n,e,t,i,s,r){return J(),ae("div",{class:fn(["max-w-md mx-auto",{"c-loading-animation":this.isLoading}])},[se("div",vN,[se("h3",xN,[e[2]||(e[2]=pt(" Bonusfrage ")),r.bonusPointsAvailable?(J(),ae(vt,{key:0},[pt(" ("+nt(this.question.bonusPoints)+" Bonuspunkte) ",1)],64)):Ne("",!0)])]),se("div",MN,[se("div",{class:"u-text-normal",innerHTML:t.question.question},null,8,EN)]),se("div",yN,[se("ul",null,[se("li",SN,[se("a",{href:"#",class:"c-answer block",onClick:e[0]||(e[0]=er(o=>r.submit(!0),["prevent"]))},"Ja")]),se("li",null,[se("a",{href:"#",class:"c-answer c-answer--white block",onClick:e[1]||(e[1]=er(o=>r.submit(!1),["prevent"]))},"Nein")])])]),n.hasErrors?(J(),ae("div",bN,[n.hasValidationError("company_id")||n.hasValidationError("type")?(J(),ae(vt,{key:0},[pt("Es gab einen Fehler. Bitte versuche es nochmals oder lade die Seite neu!")],64)):(J(),ae(vt,{key:1},[pt(nt(n.validationError("allow_contacting")),1)],64))])):Ne("",!0)],2)}const TN=mt(gN,[["render",wN]]),AN={name:"ExhibitionInfoQuestionsManager",components:{"question-interests":_N,"question-allow-contacting":TN},computed:{questions(){return this.$store.state.base.exhibitionInfoQuestions.questions},currentQuestion(){return lt.head(this.questions)},currentQuestionComponent(){return`question-${lt.kebabCase(this.currentQuestion.type)}`}}};function CN(n,e,t,i,s,r){return J(),ae("div",null,[(J(),yt(Wi(r.currentQuestionComponent),{question:r.currentQuestion},null,8,["question"]))])}const RN=mt(AN,[["render",CN]]),PN={name:"QuizResultPlaymitExhibition",components:{"exhibition-info-questions-manager":RN},mixins:[cf],computed:{needsToAnswerQuestions(){return this.$store.state.base.exhibitionInfoQuestions.questions.length>0}}},LN={class:"l-quiz-result"},DN={key:0,class:"l-quiz-result__result"};function IN(n,e,t,i,s,r){const o=it("exhibition-info-questions-manager"),a=it("quiz-result-headline"),l=it("quiz-result-text"),c=it("quiz-result-actions"),h=it("wrong-questions-review");return J(),ae("div",LN,[r.needsToAnswerQuestions?(J(),yt(o,{key:0})):(J(),ae(vt,{key:1},[n.reviewMode?(J(),yt(h,{key:1,"review-mode":n.reviewMode,"review-available":n.reviewAvailable,"new-game-round-button-text":"Neue Runde dieses Ausstellers spielen",onChangeMode:n.changeMode},null,8,["review-mode","review-available","onChangeMode"])):(J(),ae("div",DN,[Tt(a,{class:"l-quiz-result__headline-container"}),Tt(l,{class:"l-quiz-result__text"}),Tt(c,{class:"l-quiz-result__actions","review-mode":n.reviewMode,"review-available":n.reviewAvailable,"new-game-round-button-text":"Neue Runde dieses Ausstellers spielen",onChangeMode:n.changeMode},null,8,["review-mode","review-available","onChangeMode"]),e[0]||(e[0]=se("div",{class:"l-quiz-result__exhibition-tips"},[se("p",null,[se("span",{class:"l-quiz-result__exhibition-tips-tip"},"Tipp:"),pt(" Spiele viele weitere Quiz von unterschiedlichen Ausstellern, um möglichst viele Punkte zu sammeln. Für jeden neuen Aussteller bekommst du zusätzliche Bonuspunkte. Pro Aussteller-Quiz erhält man nur für max. 5 Spielrunden Punkte. ")])],-1))]))],64))])}const UN=mt(PN,[["render",IN]]),NN={name:"QuizResultFox",mixins:[cf],computed:{companyLogo(){return this.$store.state.ads.quiz.list[0].logoUrl}}},FN={class:"l-quiz-result l-quiz-result--fox"},ON=["href"],zN={class:"l-quiz-result__content"},kN={key:0,class:"l-quiz-result__result"},BN={key:0,class:"l-quiz-type-standard__ad-container"},HN={class:"c-promo-single"},VN=["src"];function GN(n,e,t,i,s,r){const o=it("quiz-header"),a=it("quiz-result-headline"),l=it("quiz-result-text"),c=it("quiz-result-actions"),h=it("wrong-questions-review");return J(),ae("div",FN,[Tt(o,{class:"l-quiz-result__header"},{default:Yr(()=>[se("a",{href:n.route("fox.portal.dashboard"),title:"Zum Dashboard"},"Zur Übersicht",8,ON)]),_:1}),se("div",zN,[n.reviewMode?(J(),yt(h,{key:1,"review-mode":n.reviewMode,"review-available":n.reviewAvailable,ad:n.ad,onChangeMode:n.changeMode},null,8,["review-mode","review-available","ad","onChangeMode"])):(J(),ae("div",kN,[Tt(a,{class:"l-quiz-result__headline-container"}),Tt(l,{class:"l-quiz-result__text"}),Tt(c,{class:"l-quiz-result__actions","review-mode":n.reviewMode,"review-available":n.reviewAvailable,onChangeMode:n.changeMode},null,8,["review-mode","review-available","onChangeMode"])]))]),r.companyLogo?(J(),ae("div",BN,[se("div",HN,[se("img",{class:"c-promo-single__ad",src:r.companyLogo},null,8,VN)])])):Ne("",!0)])}const WN=mt(NN,[["render",GN]]),$N="Gratuliere",qN="Schade",XN="Gut gemacht,",YN={name:"QuizResultHeadline",computed:{...oi({correctAnswersNumber:n=>n.result.answersStatus.correct,points:n=>n.result.points,wrongAnswersNumber:n=>n.result.answersStatus.wrong,username:n=>n.result.username}),...ri(["isPlaymitQuiz","isFoxQuiz","isCharacteristicQuiz"]),headline(){if(this.isFoxQuiz)return"Quiz-Runde abgeschlossen";let n;return this.isCharacteristicQuiz?n=XN:n=this.correctAnswersNumber>=this.points.requiredCorrectAnswers?$N:qN,this.username?`${n} ${this.username}`:n},questionsTotal(){return this.correctAnswersNumber+this.wrongAnswersNumber}}},QN={class:"c-quiz-result-headline"},jN={key:0,class:"c-quiz-result-headline__headline"},ZN={key:1,class:"c-quiz-result-headline__headline c-quiz-result-headline__headline--thin"};function KN(n,e,t,i,s,r){return J(),ae("div",QN,[r.headline?(J(),ae("h2",jN,nt(r.headline)+"!",1)):Ne("",!0),n.isCharacteristicQuiz?Ne("",!0):(J(),ae("h2",ZN,nt(n.correctAnswersNumber)+" von "+nt(r.questionsTotal)+" Fragen richtig beantwortet. ",1))])}const JN=mt(YN,[["render",KN]]),eF={name:"QuizResultText",computed:{...oi({points:n=>n.result.points,notices:n=>n.base.notices,ranking:n=>n.result.ranking}),...ri(["isPlaymitQuiz","isFoxQuiz","isCharacteristicQuiz","questionsNumber"]),questionsString(){return this.questionsNumber===1?"Frage":"Fragen"}},methods:{isEmpty(n){return ca.isEmpty(n)}}},tF={class:"c-quiz-result-text"},nF={key:2,class:"c-quiz-result-text__notices"};function iF(n,e,t,i,s,r){const o=it("notice");return J(),ae("div",tF,[n.isPlaymitQuiz&&n.isCharacteristicQuiz?(J(),ae(vt,{key:0},[e[0]||(e[0]=pt(" Du hast ")),se("strong",null,nt(n.questionsNumber)+" "+nt(r.questionsString),1),e[1]||(e[1]=pt(" zu deinen persönlichen Eigenschaften beantwortet. "))],64)):n.isPlaymitQuiz&&!n.isCharacteristicQuiz?(J(),ae(vt,{key:1},[n.points.exceptions.length?(J(),ae(vt,{key:0},[pt(" Für diese Runde hast du keine Punkte erhalten. ")],64)):(J(),ae(vt,{key:1},[e[2]||(e[2]=pt(" Du hast ")),se("strong",null,nt(n.points.earned)+" Punkte",1),e[3]||(e[3]=pt(" erspielt. "))],64)),r.isEmpty(n.ranking)?Ne("",!0):(J(),ae(vt,{key:2},[e[4]||(e[4]=pt(" Du bist ")),n.points.exceptions.length?Ne("",!0):(J(),ae(vt,{key:0},[pt("nun")],64)),e[5]||(e[5]=pt(" auf ")),se("strong",null,"Platz "+nt(n.ranking.position)+" in der "+nt(n.ranking.name),1),e[6]||(e[6]=pt(". "))],64))],64)):Ne("",!0),n.notices.length?(J(),ae("div",nF,[(J(!0),ae(vt,null,Si(n.notices,(a,l)=>(J(),yt(o,{key:l,notice:a},null,8,["notice"]))),128))])):Ne("",!0)])}const sF=mt(eF,[["render",iF]]),rF={name:"QuizResultActions",emits:["change-mode"],props:{reviewMode:{type:Boolean,required:!0},reviewAvailable:{type:Boolean,required:!0},newGameRoundButtonText:{type:String,default:"Neue Runde spielen"}},computed:{...oi({exhibition:n=>n.base.exhibition}),...ri(["isPlaymitQuiz","isFoxQuiz","isExhibitionQuiz"])},methods:{reset(n){this.$store.dispatch("resetQuiz")}}},oF={class:"c-result-actions"},aF={class:"c-result-actions__container"},lF=["href"],cF=["href"],hF={key:0,class:"u-text-center"};function uF(n,e,t,i,s,r){return J(),ae("div",oF,[se("div",aF,[n.isPlaymitQuiz&&!n.isExhibitionQuiz?(J(),ae(vt,{key:0},[t.reviewAvailable&&!t.reviewMode?(J(),ae("button",{key:0,class:"c-result-actions__button c-button c-button--with-border",type:"button",onClick:e[0]||(e[0]=o=>n.$emit("change-mode"))},"Falsche Antworten anzeigen")):Ne("",!0),t.reviewMode?(J(),ae("button",{key:1,class:"c-result-actions__button c-button c-button--with-border",type:"button",onClick:e[1]||(e[1]=o=>n.$emit("change-mode"))},"Resultat anzeigen")):Ne("",!0)],64)):Ne("",!0),n.isPlaymitQuiz&&n.isExhibitionQuiz?(J(),ae("a",{key:1,class:"c-result-actions__button c-button c-button--blue hover:text-white",href:n.route("playmit.portal.exhibitions.show",this.exhibition.slug)},"Zurück zur Messe-Rallye-Challenge",8,lF)):Ne("",!0),n.isFoxQuiz?(J(),ae("a",{key:2,class:"c-result-actions__button c-button c-button--blue hover:text-white",href:n.route("fox.portal.dashboard")},"Zur Übersicht",8,cF)):Ne("",!0),se("button",{class:"c-result-actions__button c-button c-button--with-border",onClick:e[2]||(e[2]=(...o)=>r.reset&&r.reset(...o))},nt(t.newGameRoundButtonText),1)]),n.isFoxQuiz||n.isExhibitionQuiz?(J(),ae("div",hF,[t.reviewAvailable&&!t.reviewMode?(J(),ae("button",{key:0,class:"c-result-actions__button c-result-actions__button--additional c-button c-button--link c-button--small",type:"button",onClick:e[3]||(e[3]=o=>n.$emit("change-mode"))},"Falsche Antworten anzeigen")):Ne("",!0),t.reviewMode?(J(),ae("button",{key:1,class:"c-result-actions__button c-result-actions__button--additional c-button c-button--link c-button--small",type:"button",onClick:e[4]||(e[4]=o=>n.$emit("change-mode"))},"Resultat anzeigen")):Ne("",!0)])):Ne("",!0)])}const dF=mt(rF,[["render",uF]]),fF={name:"WrongQuestionsReview",emits:["change-mode"],props:{reviewMode:{type:Boolean,required:!0},reviewAvailable:{type:Boolean,required:!0},ad:{type:Object,default:null},newGameRoundButtonText:{type:String,default:"Neue Runde spielen"}},computed:{...oi({currentWrongQuestionNumber:n=>n.result.currentWrongQuestionNumber}),...ri(["currentWrongQuestion","isFirstWrongQuestion","isLastWrongQuestion"]),wrongQuestionType(){return"wrong-question-"+this.currentWrongQuestion.question.type}},methods:{showNextWrongQuestion(){this.$store.commit("setCurrentWrongQuestionNumber")},showPrevWrongQuestion(){this.isFirstWrongQuestion||this.$store.commit("setCurrentWrongQuestionNumber",this.currentWrongQuestionNumber-1)}}},pF={class:"l-quiz-result__wrong-questions-container"},mF={class:"l-quiz-result__wrong-questions"},_F={class:"l-quiz-result__wrong-question-stage"},gF={class:"l-quiz-result__wrong-question-nav"},vF={key:0,class:"l-quiz-result__ad-container"},xF={class:"c-promo-single"},MF=["src"];function EF(n,e,t,i,s,r){const o=it("quiz-result-actions");return J(),ae("div",pF,[se("div",mF,[se("div",_F,[(J(),yt(Wi(r.wrongQuestionType),{"wrong-question":n.currentWrongQuestion,key:n.currentWrongQuestionNumber},null,8,["wrong-question"]))]),se("div",gF,[n.isFirstWrongQuestion?Ne("",!0):(J(),ae("button",{key:0,class:"l-quiz-result__wrong-question-prev",type:"button",onClick:e[0]||(e[0]=(...a)=>r.showPrevWrongQuestion&&r.showPrevWrongQuestion(...a))},e[3]||(e[3]=[pt(" ← "),se("span",{class:"l-quiz-result__wrong-question-nav-text"},"Vorige falsch beantwortete Frage anzeigen",-1)]))),n.isLastWrongQuestion?Ne("",!0):(J(),ae("button",{key:1,class:"l-quiz-result__wrong-question-next",type:"button",onClick:e[1]||(e[1]=(...a)=>r.showNextWrongQuestion&&r.showNextWrongQuestion(...a))},e[4]||(e[4]=[se("span",{class:"l-quiz-result__wrong-question-nav-text"},"Nächste falsch beantwortete Frage anzeigen",-1),pt(" → ")])))]),Tt(o,{class:"l-quiz-result__actions l-quiz-result__actions--review","review-mode":t.reviewMode,"review-available":t.reviewAvailable,"new-game-round-button-text":t.newGameRoundButtonText,onChangeMode:e[2]||(e[2]=a=>n.$emit("change-mode"))},null,8,["review-mode","review-available","new-game-round-button-text"])]),t.ad?(J(),ae("div",vF,[se("div",xF,[e[5]||(e[5]=se("span",{class:"c-promo-single__powered"},"Unterstützt von",-1)),se("img",{class:"c-promo-single__ad",src:t.ad.item.logoUrl},null,8,MF)])])):Ne("",!0)])}const yF=mt(fF,[["render",EF]]),SF={name:"WrongQuestionGraphical",props:{wrongQuestion:{type:Object,required:!0}},data(){return{markerUrl:"/images/marker.png",viewportTooSmall:!1}},computed:{question(){return this.wrongQuestion.question},name(){return this.wrongQuestion.question.name},attachment(){return this.question.attachment},givenAnswers(){let n=JSON.parse(this.wrongQuestion.answers.givenAnswer);return lt.isArray(n)?n:[n]},rightAnswers(){return this.wrongQuestion.answers.rightAnswers},isOrderPreferenceQuestion(){return this.question.mode==="order_preference"}},beforeMount(){this.$nextTick(()=>{this.setUpSmallViewportHandling()})},beforeUnmount(){this.teardownSmallViewportHandling()},methods:{getMarkerPosition(n){return{top:`${n.y}px`,left:`${n.x}px`}},getRightAnswerStyle(n){let e=JSON.parse(n.value);return{top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`}},getRightAnswerInfo(n){return this.isOrderPreferenceQuestion?JSON.parse(n.value).precedence:null},setUpSmallViewportHandling(){this.checkViewportWidth(),window.addEventListener("resize",this.checkViewportWidth)},checkViewportWidth(){Lm().width<Pm.graphicalQuestionBreakpoint?this.viewportTooSmall=!0:this.viewportTooSmall=!1},teardownSmallViewportHandling(){window.removeEventListener("resize",this.checkViewportWidth)}}},bF={class:"l-question-graphical"},wF={class:"l-question-graphical__question"},TF={class:"l-question-graphical__image-container"},AF={class:"l-question-graphical__overlays-position-container"},CF=["src"],RF=["textContent"],PF=["src"],LF={class:"l-question-graphical__right-answer-area-info"},DF={key:1,class:"l-question-graphical__viewport-info"};function IF(n,e,t,i,s,r){return J(),ae("div",bF,[s.viewportTooSmall?(J(),ae("div",DF,e[0]||(e[0]=[se("h5",{class:"l-question-graphical__viewport-info-headline"},"Um das grafische Quiz zu spielen, drehe bitte dein Smartphone oder spiele auf einem größeren Bildschirm weiter.",-1),se("div",{class:"l-question-graphical__viewport-info-phone"},[se("div",{class:"l-question-graphical__viewport-info-phone-display"}),se("div",{class:"l-question-graphical__viewport-info-phone-button"})],-1)]))):(J(),ae(vt,{key:0},[se("div",wF,nt(r.name),1),se("div",TF,[se("div",AF,[se("img",{class:"l-question-graphical__image",src:r.attachment.url},null,8,CF),(J(!0),ae(vt,null,Si(r.givenAnswers,(o,a)=>(J(),ae("div",{key:`marker${a}`,class:"l-question-graphical__marker",style:no(r.getMarkerPosition(o))},[r.isOrderPreferenceQuestion?(J(),ae("span",{key:0,class:"l-question-graphical__marker-info",textContent:nt(a+1)},null,8,RF)):Ne("",!0),se("img",{class:"l-question-graphical__marker-image",src:s.markerUrl},null,8,PF)],4))),128)),(J(!0),ae(vt,null,Si(r.rightAnswers,(o,a)=>(J(),ae("div",{key:a,class:"l-question-graphical__right-answer-area",style:no(r.getRightAnswerStyle(o))},[se("span",LF,nt(r.getRightAnswerInfo(o)),1)],4))),128))])])],64))])}const UF=mt(SF,[["render",IF]]),NF={name:"WrongQuestionMC",props:{wrongQuestion:{type:Object,required:!0}},computed:{question(){return this.wrongQuestion.question},hasAttachment(){return!!this.wrongQuestion.question.attachment},rightAnswer(){return this.wrongQuestion.answers.rightAnswers[0].value},givenAnswer(){return this.wrongQuestion.answers.givenAnswer}}},FF={class:"l-question-input"},OF={class:"l-question-input__question"},zF={key:0,class:"l-question-input__attachment-container"},kF={class:"l-question-input__answer-container"},BF={class:"l-question-input__answer l-question-input__answer--given"},HF={class:"l-question-input__answer l-question-input__answer--right"};function VF(n,e,t,i,s,r){const o=it("attachment");return J(),ae("div",FF,[se("div",OF,nt(r.question.name),1),r.hasAttachment?(J(),ae("div",zF,[Tt(o,{attachment:r.question.attachment,class:"l-question-input__attachment"},null,8,["attachment"])])):Ne("",!0),se("div",kF,[se("div",BF,[e[0]||(e[0]=pt(" Antwort gegeben: ")),se("strong",null,nt(r.givenAnswer),1)]),se("div",HF,[e[1]||(e[1]=pt(" Richtige Antwort: ")),se("strong",null,nt(r.rightAnswer),1)])])])}const GF=mt(NF,[["render",VF]]),WF={name:"WrongQuestionMC",props:{wrongQuestion:{type:Object,required:!0}},computed:{question(){return this.wrongQuestion.question},hasAttachment(){return!!this.wrongQuestion.question.attachment},rightAnswers(){return this.wrongQuestion.answers.rightAnswers},givenAnswer(){return this.wrongQuestion.answers.givenAnswer}},methods:{getCssClasses(n,e){return{"l-question-mc__answer--given":this.isGivenAnswer(e),"l-question-mc__answer--right":this.isCorrectAnswer(n)}},isGivenAnswer(n){return this.givenAnswer.indexOf(n)>-1},isCorrectAnswer(n){return n.attachment?lt.findIndex(this.rightAnswers,e=>e.attachment.url===n.attachment.url)>=0:lt.findIndex(this.rightAnswers,e=>e.value===n.value)>=0}}},$F={class:"l-question-mc__question"},qF={class:"l-question-mc__main-container"},XF={class:"l-question-mc__answers js-wrong-question-mc-answers"},YF={key:0,class:"l-question-mc__attachment-container"};function QF(n,e,t,i,s,r){const o=it("attachment");return J(),ae("div",{class:fn(["l-question-mc",{"l-question-mc--has-attachment":r.hasAttachment}])},[se("div",$F,nt(r.question.name),1),se("div",qF,[se("ul",XF,[(J(!0),ae(vt,null,Si(r.question.answers,(a,l)=>(J(),ae("li",{class:fn(["l-question-mc__answer l-question-mc__answer--review js-wrong-question-mc-answer",r.getCssClasses(a,l)]),key:l},[pt(nt(a.value)+" ",1),a.attachment?(J(),yt(o,{key:0,class:"l-question-mc__answer-attachment",attachment:a.attachment},null,8,["attachment"])):Ne("",!0)],2))),128))]),r.hasAttachment?(J(),ae("div",YF,[Tt(o,{attachment:r.question.attachment,class:"l-question-mc__attachment"},null,8,["attachment"])])):Ne("",!0)])],2)}const jF=mt(WF,[["render",QF]]),Z0=nx({});Z0.component("EmbedVideo",Wx).component("LoadingIndicator",sx).component("Attachment",ox).component("Notice",Zx).component("Error",LM).component("Quiz",UM).component("QuizTypeStandard",KM).component("QuizTypePanorama",vI).component("QuizTypePanoramavideo",KI).component("QuizIntro",dU).component("QuizBrandingPlaymit",vU).component("QuizBrandingFox",EU).component("QuizHeader",CU).component("QuizHeaderPoints",UU).component("QuizProgressBar",zU).component("QuizTextualProgress",HU).component("QuestionMc",jU).component("QuestionInput",s3).component("QuestionGraphical",p3).component("QuestionRemember",y3).component("QuizResultPlaymit",F3).component("QuizResultFurtherLinks",sN).component("QuizResultPlaymitExhibition",UN).component("QuizResultFox",WN).component("QuizResultHeadline",JN).component("QuizResultText",sF).component("QuizResultActions",dF).component("WrongQuestionsReview",yF).component("WrongQuestionGraphical",UF).component("WrongQuestionInput",GF).component("WrongQuestionMc",jF).mixin({methods:{route:Wt,optional:ux}}).use(kx);document.querySelector("#vue-quiz-app")&&Z0.mount("#vue-quiz-app");