From 71278954e1f9a3064a64bf59694ee37f27405efc Mon Sep 17 00:00:00 2001 From: Simon Stucki Date: Fri, 9 Aug 2024 13:52:43 +0200 Subject: [PATCH] Deploy website - based on 06439e255cd80a819b415dac7422afb61776c87e --- 404.html | 4 ++-- assets/js/1122199e.41470f52.js | 1 - ...93b7f.487614cf.js => 1df93b7f.2fc294ab.js} | 4 ++-- ...E.txt => 1df93b7f.2fc294ab.js.LICENSE.txt} | 0 assets/js/45d3dc74.92480abd.js | 1 + assets/js/45d3dc74.ed6dbd05.js | 1 - assets/js/4ad98c9f.eca53698.js | 1 + assets/js/4c15fca4.1ed6b0ad.js | 1 + assets/js/4c15fca4.328bf988.js | 1 - assets/js/4d780be7.5b134119.js | 1 + assets/js/4d780be7.79413078.js | 1 - assets/js/860ff063.179d9684.js | 1 + assets/js/main.6129305b.js | 2 -- assets/js/main.9da18800.js | 2 ++ ...CENSE.txt => main.9da18800.js.LICENSE.txt} | 0 assets/js/runtime~main.b3dc4539.js | 1 - assets/js/runtime~main.bc1ab999.js | 1 + blog/archive/index.html | 4 ++-- blog/index.html | 4 ++-- blog/welcome/index.html | 4 ++-- docs/advanced/destruction/index.html | 10 +++++---- docs/advanced/environment-light/index.html | 22 +++++++++++++++++++ docs/advanced/exception-handling/index.html | 8 +++---- docs/advanced/theory/index.html | 6 ++--- docs/advanced/view-projection/index.html | 6 ++--- docs/category/advanced/index.html | 6 ++--- docs/intro/index.html | 4 ++-- docs/tutorial-basic/index.html | 16 ++++++++++---- index.html | 6 ++--- sitemap.xml | 2 +- 30 files changed, 77 insertions(+), 44 deletions(-) delete mode 100644 assets/js/1122199e.41470f52.js rename assets/js/{1df93b7f.487614cf.js => 1df93b7f.2fc294ab.js} (99%) rename assets/js/{1df93b7f.487614cf.js.LICENSE.txt => 1df93b7f.2fc294ab.js.LICENSE.txt} (100%) create mode 100644 assets/js/45d3dc74.92480abd.js delete mode 100644 assets/js/45d3dc74.ed6dbd05.js create mode 100644 assets/js/4ad98c9f.eca53698.js create mode 100644 assets/js/4c15fca4.1ed6b0ad.js delete mode 100644 assets/js/4c15fca4.328bf988.js create mode 100644 assets/js/4d780be7.5b134119.js delete mode 100644 assets/js/4d780be7.79413078.js create mode 100644 assets/js/860ff063.179d9684.js delete mode 100644 assets/js/main.6129305b.js create mode 100644 assets/js/main.9da18800.js rename assets/js/{main.6129305b.js.LICENSE.txt => main.9da18800.js.LICENSE.txt} (100%) delete mode 100644 assets/js/runtime~main.b3dc4539.js create mode 100644 assets/js/runtime~main.bc1ab999.js create mode 100644 docs/advanced/environment-light/index.html diff --git a/404.html b/404.html index 2d50876..cc52db9 100644 --- a/404.html +++ b/404.html @@ -5,8 +5,8 @@ Page Not Found | strahl - - + +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/assets/js/1122199e.41470f52.js b/assets/js/1122199e.41470f52.js deleted file mode 100644 index 711194f..0000000 --- a/assets/js/1122199e.41470f52.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[85],{132:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>s,default:()=>h,frontMatter:()=>r,metadata:()=>d,toc:()=>o});var a=t(4848),i=t(8453);const r={sidebar_position:2},s="Getting Started",d={id:"tutorial-basic",title:"Getting Started",description:"Installation",source:"@site/docs/tutorial-basic.mdx",sourceDirName:".",slug:"/tutorial-basic",permalink:"/strahl/docs/tutorial-basic",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2},sidebar:"tutorialSidebar",previous:{title:"strahl Documentation",permalink:"/strahl/docs/intro"},next:{title:"Advanced",permalink:"/strahl/docs/category/advanced"}},l={},o=[{value:"Installation",id:"installation",level:2},{value:"Setup",id:"setup",level:2},{value:"Define canvas",id:"define-canvas",level:3},{value:"Prepare 3D data",id:"prepare-3d-data",level:3},{value:"Initialize strahl",id:"initialize-strahl",level:3},{value:"What's next?",id:"whats-next",level:3}];function c(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.h1,{id:"getting-started",children:"Getting Started"}),"\n",(0,a.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsx)(n.p,{children:"The library is available in the npm registry. To install it using npm, run:"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"npm install --save strahl\n"})}),"\n",(0,a.jsx)(n.h2,{id:"setup",children:"Setup"}),"\n",(0,a.jsx)(n.h3,{id:"define-canvas",children:"Define canvas"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-html",metastring:'title="index.html"',children:'\n\n \n \n \n \n \n \n \n\n'})}),"\n",(0,a.jsx)(n.admonition,{type:"warning",children:(0,a.jsxs)(n.p,{children:["Make sure that the ",(0,a.jsx)(n.code,{children:"canvas"})," is present in the ",(0,a.jsx)(n.code,{children:"DOM"})," before calling ",(0,a.jsx)(n.code,{children:"strahl"}),"."]})}),"\n",(0,a.jsx)(n.h3,{id:"prepare-3d-data",children:"Prepare 3D data"}),"\n",(0,a.jsxs)(n.p,{children:["Load 3D models using ",(0,a.jsx)(n.code,{children:"three"})," loaders."]}),"\n",(0,a.jsxs)(n.p,{children:["Make sure to assign ",(0,a.jsx)(n.code,{children:"OpenPBRMaterial"})," to all materials within the scene."]}),"\n",(0,a.jsxs)(n.h3,{id:"initialize-strahl",children:["Initialize ",(0,a.jsx)(n.code,{children:"strahl"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-js",children:'await runPathTracer("render-target", model);\n'})}),"\n",(0,a.jsx)(n.admonition,{type:"info",children:(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.code,{children:"runPathTracer"})," accepts a third parameter for additional configuration. See the advanced guides for more information."]})}),"\n",(0,a.jsx)(n.h3,{id:"whats-next",children:"What's next?"}),"\n",(0,a.jsxs)(n.p,{children:["Check out the ",(0,a.jsx)(n.a,{href:"/docs/category/advanced",children:"advanced guides"})," for more information on how to configure the path tracer."]})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>d});var a=t(6540);const i={},r=a.createContext(i);function s(e){const n=a.useContext(r);return a.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),a.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1df93b7f.487614cf.js b/assets/js/1df93b7f.2fc294ab.js similarity index 99% rename from assets/js/1df93b7f.487614cf.js rename to assets/js/1df93b7f.2fc294ab.js index 69118a8..3472616 100644 --- a/assets/js/1df93b7f.487614cf.js +++ b/assets/js/1df93b7f.2fc294ab.js @@ -1,2 +1,2 @@ -/*! For license information please see 1df93b7f.487614cf.js.LICENSE.txt */ -"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[583],{9269:(t,e,n)=>{n.r(e),n.d(e,{default:()=>Eo});var s=n(4164),i=n(4586),r=n(781),a=n(1107);const o={features:"features_t9lD"};var l=n(4848);const h=[{title:"Modern Technology",description:(0,l.jsx)(l.Fragment,{children:"Strahl leverages WebGPU, the latest web graphics API built for years to come."})},{title:"Fully Open-Source",description:(0,l.jsx)(l.Fragment,{children:"Strahl is built out in public under MIT license, your feedback is welcome."})},{title:"Using OpenPBR",description:(0,l.jsx)(l.Fragment,{children:"Strahl supports Physically-based Rendering based on the OpenPBR surface shading model."})}];function u(t){let{title:e,description:n}=t;return(0,l.jsx)("div",{className:(0,s.A)("col col--4"),children:(0,l.jsxs)("div",{className:"text--center padding-horiz--md",children:[(0,l.jsx)(a.A,{as:"h3",children:e}),(0,l.jsx)("p",{children:n})]})})}function c(){return(0,l.jsx)("section",{className:o.features,children:(0,l.jsx)("div",{className:"container",children:(0,l.jsx)("div",{className:"row",children:h.map(((t,e)=>(0,l.jsx)(u,{...t},e)))})})})}var d=n(7875);const p={heroBanner:"heroBanner_qdFl",heroTitle:"heroTitle_qg2I",heroMark:"heroMark_V22N",typewriterContainer:"typewriterContainer_MUFz",heroTypewriter:"heroTypewriter_T0w2",cursorContainer:"cursorContainer_gtpg",cursor:"cursor_m5HY",opacityFade:"opacityFade_eRto",heroText:"heroText_ryRM",buttons:"buttons_AeoN"};var m=n(8774),f=n(3914);const y={icon:"icon_FiRX"};function g(t){let{to:e,children:n,icon:i,variant:r="primary"}=t;return(0,l.jsxs)(m.A,{to:e,className:`button button--${r} button--lg`,children:[i?(0,l.jsx)(f.g,{icon:i,className:(0,s.A)("margin-right--sm",y.icon)}):null,n]})}var _=n(6540);const x=function(t){const e=(0,_.useRef)(null);(0,_.useLayoutEffect)((()=>{e.current=t}));return(0,_.useCallback)((function(){if(!e.current)throw new Error("event called before initialization");return(0,e.current)(...arguments)}),[])};const b=function(t){return x(((e,n)=>{let s,i="write",r=0;const a=()=>{"write"===i?r+=1:r-=1;const o=n.currentText.substring(0,r);if(t.current&&(0===o.length?t.current.innerHTML=" ":t.current.textContent=o),"write"===i&&r===n?.currentText.length)i="shift";else if("delete"===i&&0===r){i="write";const t=(n.currentTextIndex+1)%e.length;n.currentText=e[t],n.currentTextIndex=t}"write"===i?s=setTimeout(a,100+80*Math.random()):"delete"===i?s=setTimeout(a,40+20*Math.random()):"shift"===i&&(i="delete",s=setTimeout(a,1400))};return a(),()=>{clearTimeout(s)}}))};var w=n(5348),v=Object.defineProperty,k=(t,e,n)=>((t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const M=0,S=1,T=2,A=0,E=1,R=2,B=3,z=1,P=2,L=1001,I=1026,C="srgb",D="srgb-linear",N="display-p3",F="display-p3-linear",O="linear",W="srgb",U="rec709",q=7680,j=2e3;class V{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,s=n.length;e>8&255]+G[t>>16&255]+G[t>>24&255]+"-"+G[255&e]+G[e>>8&255]+"-"+G[e>>16&15|64]+G[e>>24&255]+"-"+G[63&n|128]+G[n>>8&255]+"-"+G[n>>16&255]+G[n>>24&255]+G[255&s]+G[s>>8&255]+G[s>>16&255]+G[s>>24&255]).toLowerCase()}function Z(t,e,n){return Math.max(e,Math.min(n,t))}function J(t,e){return(t%e+e)%e}function $(t,e,n){return(1-n)*t+n*e}function K(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Q(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const tt=H;class et{constructor(t,e){void 0===t&&(t=0),void 0===e&&(e=0),et.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Z(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),i=this.x-t.x,r=this.y-t.y;return this.x=i*n-r*s+t.x,this.y=i*s+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class nt{constructor(t,e,n,s,i,r,a,o,l){nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,s,i,r,a,o,l)}set(t,e,n,s,i,r,a,o,l){const h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=i,h[5]=o,h[6]=n,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,i=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],h=n[4],u=n[7],c=n[2],d=n[5],p=n[8],m=s[0],f=s[3],y=s[6],g=s[1],_=s[4],x=s[7],b=s[2],w=s[5],v=s[8];return i[0]=r*m+a*g+o*b,i[3]=r*f+a*_+o*w,i[6]=r*y+a*x+o*v,i[1]=l*m+h*g+u*b,i[4]=l*f+h*_+u*w,i[7]=l*y+h*x+u*v,i[2]=c*m+d*g+p*b,i[5]=c*f+d*_+p*w,i[8]=c*y+d*x+p*v,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*r*h-e*a*l-n*i*h+n*a*o+s*i*l-s*r*o}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],u=h*r-a*l,c=a*o-h*i,d=l*i-r*o,p=e*u+n*c+s*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=u*m,t[1]=(s*l-h*n)*m,t[2]=(a*n-s*r)*m,t[3]=c*m,t[4]=(h*e-s*o)*m,t[5]=(s*i-a*e)*m,t[6]=d*m,t[7]=(n*o-l*e)*m,t[8]=(r*e-n*i)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,i,r,a){const o=Math.cos(i),l=Math.sin(i);return this.set(n*o,n*l,-n*(o*r+l*a)+r+t,-s*l,s*o,-s*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(st.makeScale(t,e)),this}rotate(t){return this.premultiply(st.makeRotation(-t)),this}translate(t,e){return this.premultiply(st.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e){void 0===e&&(e=0);for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const st=new nt;function it(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const rt={};const at=(new nt).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ot=(new nt).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),lt={[D]:{transfer:O,primaries:U,toReference:t=>t,fromReference:t=>t},[C]:{transfer:W,primaries:U,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[F]:{transfer:O,primaries:"p3",toReference:t=>t.applyMatrix3(ot),fromReference:t=>t.applyMatrix3(at)},[N]:{transfer:W,primaries:"p3",toReference:t=>t.convertSRGBToLinear().applyMatrix3(ot),fromReference:t=>t.applyMatrix3(at).convertLinearToSRGB()}},ht=new Set([D,F]),ut={enabled:!0,_workingColorSpace:D,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!ht.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;const s=lt[e].toReference;return(0,lt[n].fromReference)(s(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return lt[t].primaries},getTransfer:function(t){return""===t?O:lt[t].transfer}};function ct(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function dt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let pt;class mt{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===pt&&(pt=it("canvas")),pt.width=t.width,pt.height=t.height;const n=pt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=pt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=it("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),i=s.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case L:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case L:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}xt.DEFAULT_IMAGE=null,xt.DEFAULT_MAPPING=300,xt.DEFAULT_ANISOTROPY=1;class bt{constructor(t,e,n,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=1),this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,i,r,a){let o=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3];const c=i[r+0],d=i[r+1],p=i[r+2],m=i[r+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=u);if(1===a)return t[e+0]=c,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(u!==m||o!==c||l!==d||h!==p){let t=1-a;const e=o*c+l*d+h*p+u*m,n=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const i=Math.sqrt(s),r=Math.atan2(i,e*n);t=Math.sin(t*r)/i,a=Math.sin(a*r)/i}const i=a*n;if(o=o*t+c*i,l=l*t+d*i,h=h*t+p*i,u=u*t+m*i,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=t,l*=t,h*=t,u*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,i,r){const a=n[s],o=n[s+1],l=n[s+2],h=n[s+3],u=i[r],c=i[r+1],d=i[r+2],p=i[r+3];return t[e]=a*p+h*u+o*d-l*c,t[e+1]=o*p+h*c+l*u-a*d,t[e+2]=l*p+h*d+a*c-o*u,t[e+3]=h*p-a*u-o*c-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){void 0===e&&(e=!0);const n=t._x,s=t._y,i=t._z,r=t._order,a=Math.cos,o=Math.sin,l=a(n/2),h=a(s/2),u=a(i/2),c=o(n/2),d=o(s/2),p=o(i/2);switch(r){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],h=e[6],u=e[10],c=n+a+u;if(c>0){const t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(h-o)*t,this._y=(i-l)*t,this._z=(r-s)*t}else if(n>a&&n>u){const t=2*Math.sqrt(1+n-a-u);this._w=(h-o)/t,this._x=.25*t,this._y=(s+r)/t,this._z=(i+l)/t}else if(a>u){const t=2*Math.sqrt(1+a-n-u);this._w=(i-l)/t,this._x=(s+r)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+u-n-a);this._w=(r-s)/t,this._x=(i+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Z(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const s=Math.min(1,e/n);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,i=t._z,r=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=n*h+r*a+s*l-i*o,this._y=s*h+r*o+i*a-n*l,this._z=i*h+r*l+n*o-s*a,this._w=r*h-n*a-s*o-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,s=this._y,i=this._z,r=this._w;let a=r*t._w+n*t._x+s*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=n,this._y=s,this._z=i,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*n+e*this._x,this._y=t*s+e*this._y,this._z=t*i+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-e)*h)/l,c=Math.sin(e*h)/l;return this._w=r*u+this._w*c,this._x=n*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class wt{constructor(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),wt.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(kt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(kt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*s,this.y=i[1]*e+i[4]*n+i[7]*s,this.z=i[2]*e+i[5]*n+i[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,i=t.elements,r=1/(i[3]*e+i[7]*n+i[11]*s+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*s+i[12])*r,this.y=(i[1]*e+i[5]*n+i[9]*s+i[13])*r,this.z=(i[2]*e+i[6]*n+i[10]*s+i[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,i=t.x,r=t.y,a=t.z,o=t.w,l=2*(r*s-a*n),h=2*(a*e-i*s),u=2*(i*n-r*e);return this.x=e+o*l+r*u-a*h,this.y=n+o*h+a*l-i*u,this.z=s+o*u+i*h-r*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*s,this.y=i[1]*e+i[5]*n+i[9]*s,this.z=i[2]*e+i[6]*n+i[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,i=t.z,r=e.x,a=e.y,o=e.z;return this.x=s*o-i*a,this.y=i*r-n*o,this.z=n*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return vt.copy(this).projectOnVector(t),this.sub(vt)}reflect(t){return this.sub(vt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Z(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vt=new wt,kt=new bt;class Mt{constructor(t,e){void 0===t&&(t=new wt(1/0,1/0,1/0)),void 0===e&&(e=new wt(-1/0,-1/0,-1/0)),this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Tt),Tt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(It),Ct.subVectors(this.max,It),Et.subVectors(t.a,It),Rt.subVectors(t.b,It),Bt.subVectors(t.c,It),zt.subVectors(Rt,Et),Pt.subVectors(Bt,Rt),Lt.subVectors(Et,Bt);let e=[0,-zt.z,zt.y,0,-Pt.z,Pt.y,0,-Lt.z,Lt.y,zt.z,0,-zt.x,Pt.z,0,-Pt.x,Lt.z,0,-Lt.x,-zt.y,zt.x,0,-Pt.y,Pt.x,0,-Lt.y,Lt.x,0];return!(!Ft(e,Et,Rt,Bt,Ct)||(e=[1,0,0,0,1,0,0,0,1],!Ft(e,Et,Rt,Bt,Ct)))&&(Dt.crossVectors(zt,Pt),e=[Dt.x,Dt.y,Dt.z],Ft(e,Et,Rt,Bt,Ct))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Tt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Tt).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(St[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),St[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),St[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),St[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),St[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),St[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),St[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),St[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(St)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const St=[new wt,new wt,new wt,new wt,new wt,new wt,new wt,new wt],Tt=new wt,At=new Mt,Et=new wt,Rt=new wt,Bt=new wt,zt=new wt,Pt=new wt,Lt=new wt,It=new wt,Ct=new wt,Dt=new wt,Nt=new wt;function Ft(t,e,n,s,i){for(let r=0,a=t.length-3;r<=a;r+=3){Nt.fromArray(t,r);const a=i.x*Math.abs(Nt.x)+i.y*Math.abs(Nt.y)+i.z*Math.abs(Nt.z),o=e.dot(Nt),l=n.dot(Nt),h=s.dot(Nt);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Ot=new Mt,Wt=new wt,Ut=new wt;class qt{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=-1),this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Ot.setFromPoints(t).getCenter(n);let s=0;for(let i=0,r=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Wt.subVectors(t,this.center);const e=Wt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(Wt,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ut.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Wt.copy(t.center).add(Ut)),this.expandByPoint(Wt.copy(t.center).sub(Ut))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const jt=new wt,Vt=new wt,Gt=new wt,Ht=new wt,Yt=new wt,Xt=new wt,Zt=new wt;class Jt{constructor(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f){Jt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f)}set(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f){const y=this.elements;return y[0]=t,y[4]=e,y[8]=n,y[12]=s,y[1]=i,y[5]=r,y[9]=a,y[13]=o,y[2]=l,y[6]=h,y[10]=u,y[14]=c,y[3]=d,y[7]=p,y[11]=m,y[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Jt).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/$t.setFromMatrixColumn(t,0).length(),i=1/$t.setFromMatrixColumn(t,1).length(),r=1/$t.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,i=t.z,r=Math.cos(n),a=Math.sin(n),o=Math.cos(s),l=Math.sin(s),h=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){const t=r*h,n=r*u,s=a*h,i=a*u;e[0]=o*h,e[4]=-o*u,e[8]=l,e[1]=n+s*l,e[5]=t-i*l,e[9]=-a*o,e[2]=i-t*l,e[6]=s+n*l,e[10]=r*o}else if("YXZ"===t.order){const t=o*h,n=o*u,s=l*h,i=l*u;e[0]=t+i*a,e[4]=s*a-n,e[8]=r*l,e[1]=r*u,e[5]=r*h,e[9]=-a,e[2]=n*a-s,e[6]=i+t*a,e[10]=r*o}else if("ZXY"===t.order){const t=o*h,n=o*u,s=l*h,i=l*u;e[0]=t-i*a,e[4]=-r*u,e[8]=s+n*a,e[1]=n+s*a,e[5]=r*h,e[9]=i-t*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if("ZYX"===t.order){const t=r*h,n=r*u,s=a*h,i=a*u;e[0]=o*h,e[4]=s*l-n,e[8]=t*l+i,e[1]=o*u,e[5]=i*l+t,e[9]=n*l-s,e[2]=-l,e[6]=a*o,e[10]=r*o}else if("YZX"===t.order){const t=r*o,n=r*l,s=a*o,i=a*l;e[0]=o*h,e[4]=i-t*u,e[8]=s*u+n,e[1]=u,e[5]=r*h,e[9]=-a*h,e[2]=-l*h,e[6]=n*u+s,e[10]=t-i*u}else if("XZY"===t.order){const t=r*o,n=r*l,s=a*o,i=a*l;e[0]=o*h,e[4]=-u,e[8]=l*h,e[1]=t*u+i,e[5]=r*h,e[9]=n*u-s,e[2]=s*u-n,e[6]=a*h,e[10]=i*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Qt,t,te)}lookAt(t,e,n){const s=this.elements;return se.subVectors(t,e),0===se.lengthSq()&&(se.z=1),se.normalize(),ee.crossVectors(n,se),0===ee.lengthSq()&&(1===Math.abs(n.z)?se.x+=1e-4:se.z+=1e-4,se.normalize(),ee.crossVectors(n,se)),ee.normalize(),ne.crossVectors(se,ee),s[0]=ee.x,s[4]=ne.x,s[8]=se.x,s[1]=ee.y,s[5]=ne.y,s[9]=se.y,s[2]=ee.z,s[6]=ne.z,s[10]=se.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,i=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],h=n[1],u=n[5],c=n[9],d=n[13],p=n[2],m=n[6],f=n[10],y=n[14],g=n[3],_=n[7],x=n[11],b=n[15],w=s[0],v=s[4],k=s[8],M=s[12],S=s[1],T=s[5],A=s[9],E=s[13],R=s[2],B=s[6],z=s[10],P=s[14],L=s[3],I=s[7],C=s[11],D=s[15];return i[0]=r*w+a*S+o*R+l*L,i[4]=r*v+a*T+o*B+l*I,i[8]=r*k+a*A+o*z+l*C,i[12]=r*M+a*E+o*P+l*D,i[1]=h*w+u*S+c*R+d*L,i[5]=h*v+u*T+c*B+d*I,i[9]=h*k+u*A+c*z+d*C,i[13]=h*M+u*E+c*P+d*D,i[2]=p*w+m*S+f*R+y*L,i[6]=p*v+m*T+f*B+y*I,i[10]=p*k+m*A+f*z+y*C,i[14]=p*M+m*E+f*P+y*D,i[3]=g*w+_*S+x*R+b*L,i[7]=g*v+_*T+x*B+b*I,i[11]=g*k+_*A+x*z+b*C,i[15]=g*M+_*E+x*P+b*D,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],i=t[12],r=t[1],a=t[5],o=t[9],l=t[13],h=t[2],u=t[6],c=t[10],d=t[14];return t[3]*(+i*o*u-s*l*u-i*a*c+n*l*c+s*a*d-n*o*d)+t[7]*(+e*o*d-e*l*c+i*r*c-s*r*d+s*l*h-i*o*h)+t[11]*(+e*l*u-e*a*d-i*r*u+n*r*d+i*a*h-n*l*h)+t[15]*(-s*a*h-e*o*u+e*a*c+s*r*u-n*r*c+n*o*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],u=t[9],c=t[10],d=t[11],p=t[12],m=t[13],f=t[14],y=t[15],g=u*f*l-m*c*l+m*o*d-a*f*d-u*o*y+a*c*y,_=p*c*l-h*f*l-p*o*d+r*f*d+h*o*y-r*c*y,x=h*m*l-p*u*l+p*a*d-r*m*d-h*a*y+r*u*y,b=p*u*o-h*m*o-p*a*c+r*m*c+h*a*f-r*u*f,w=e*g+n*_+s*x+i*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const v=1/w;return t[0]=g*v,t[1]=(m*c*i-u*f*i-m*s*d+n*f*d+u*s*y-n*c*y)*v,t[2]=(a*f*i-m*o*i+m*s*l-n*f*l-a*s*y+n*o*y)*v,t[3]=(u*o*i-a*c*i-u*s*l+n*c*l+a*s*d-n*o*d)*v,t[4]=_*v,t[5]=(h*f*i-p*c*i+p*s*d-e*f*d-h*s*y+e*c*y)*v,t[6]=(p*o*i-r*f*i-p*s*l+e*f*l+r*s*y-e*o*y)*v,t[7]=(r*c*i-h*o*i+h*s*l-e*c*l-r*s*d+e*o*d)*v,t[8]=x*v,t[9]=(p*u*i-h*m*i-p*n*d+e*m*d+h*n*y-e*u*y)*v,t[10]=(r*m*i-p*a*i+p*n*l-e*m*l-r*n*y+e*a*y)*v,t[11]=(h*a*i-r*u*i-h*n*l+e*u*l+r*n*d-e*a*d)*v,t[12]=b*v,t[13]=(h*m*s-p*u*s+p*n*c-e*m*c-h*n*f+e*u*f)*v,t[14]=(p*a*s-r*m*s-p*n*o+e*m*o+r*n*f-e*a*f)*v,t[15]=(r*u*s-h*a*s+h*n*o-e*u*o-r*n*c+e*a*c)*v,this}scale(t){const e=this.elements,n=t.x,s=t.y,i=t.z;return e[0]*=n,e[4]*=s,e[8]*=i,e[1]*=n,e[5]*=s,e[9]*=i,e[2]*=n,e[6]*=s,e[10]*=i,e[3]*=n,e[7]*=s,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),i=1-n,r=t.x,a=t.y,o=t.z,l=i*r,h=i*a;return this.set(l*r+n,l*a-s*o,l*o+s*a,0,l*a+s*o,h*a+n,h*o-s*r,0,l*o-s*a,h*o+s*r,i*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,i,r){return this.set(1,n,i,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,i=e._x,r=e._y,a=e._z,o=e._w,l=i+i,h=r+r,u=a+a,c=i*l,d=i*h,p=i*u,m=r*h,f=r*u,y=a*u,g=o*l,_=o*h,x=o*u,b=n.x,w=n.y,v=n.z;return s[0]=(1-(m+y))*b,s[1]=(d+x)*b,s[2]=(p-_)*b,s[3]=0,s[4]=(d-x)*w,s[5]=(1-(c+y))*w,s[6]=(f+g)*w,s[7]=0,s[8]=(p+_)*v,s[9]=(f-g)*v,s[10]=(1-(c+m))*v,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let i=$t.set(s[0],s[1],s[2]).length();const r=$t.set(s[4],s[5],s[6]).length(),a=$t.set(s[8],s[9],s[10]).length();this.determinant()<0&&(i=-i),t.x=s[12],t.y=s[13],t.z=s[14],Kt.copy(this);const o=1/i,l=1/r,h=1/a;return Kt.elements[0]*=o,Kt.elements[1]*=o,Kt.elements[2]*=o,Kt.elements[4]*=l,Kt.elements[5]*=l,Kt.elements[6]*=l,Kt.elements[8]*=h,Kt.elements[9]*=h,Kt.elements[10]*=h,e.setFromRotationMatrix(Kt),n.x=i,n.y=r,n.z=a,this}makePerspective(t,e,n,s,i,r,a){void 0===a&&(a=j);const o=this.elements,l=2*i/(e-t),h=2*i/(n-s),u=(e+t)/(e-t),c=(n+s)/(n-s);let d,p;if(a===j)d=-(r+i)/(r-i),p=-2*r*i/(r-i);else{if(2001!==a)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-r/(r-i),p=-r*i/(r-i)}return o[0]=l,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=h,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,s,i,r,a){void 0===a&&(a=j);const o=this.elements,l=1/(e-t),h=1/(n-s),u=1/(r-i),c=(e+t)*l,d=(n+s)*h;let p,m;if(a===j)p=(r+i)*u,m=-2*u;else{if(2001!==a)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=i*u,m=-1*u}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e){void 0===e&&(e=0);for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const $t=new wt,Kt=new Jt,Qt=new wt(0,0,0),te=new wt(1,1,1),ee=new wt,ne=new wt,se=new wt,ie=new Jt,re=new bt;class ae{constructor(t,e,n,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=ae.DEFAULT_ORDER),this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s){return void 0===s&&(s=this._order),this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,n){void 0===e&&(e=this._order),void 0===n&&(n=!0);const s=t.elements,i=s[0],r=s[4],a=s[8],o=s[1],l=s[5],h=s[9],u=s[2],c=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(Z(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(c,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Z(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Z(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(o,i));break;case"ZYX":this._y=Math.asin(-Z(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,d),this._z=Math.atan2(o,i)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Z(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Z(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(c,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return ie.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ie,e,n)}setFromVector3(t,e){return void 0===e&&(e=this._order),this.set(t.x,t.y,t.z,e)}reorder(t){return re.setFromEuler(this),this.setFromQuaternion(re,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ae.DEFAULT_ORDER="XYZ";class oe{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(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((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),s.maxGeometryCount=this._maxGeometryCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),null!==this.boundingBox&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=i(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,s=n.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(n.geometries=e),s.length>0&&(n.materials=s),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),u.length>0&&(n.nodes=u)}return n.object=s,n;function r(t){const e=[];for(const n in t){const s=t[n];delete s.metadata,e.push(s)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let n=0;n0?s.multiplyScalar(1/Math.sqrt(i)):s.set(0,0,0)}static getBarycoord(t,e,n,s,i){Me.subVectors(s,e),Se.subVectors(n,e),Te.subVectors(t,e);const r=Me.dot(Me),a=Me.dot(Se),o=Me.dot(Te),l=Se.dot(Se),h=Se.dot(Te),u=r*l-a*a;if(0===u)return i.set(0,0,0),null;const c=1/u,d=(l*o-a*h)*c,p=(r*h-a*o)*c;return i.set(1-d-p,p,d)}static containsPoint(t,e,n,s){return null!==this.getBarycoord(t,e,n,s,Ae)&&(Ae.x>=0&&Ae.y>=0&&Ae.x+Ae.y<=1)}static getInterpolation(t,e,n,s,i,r,a,o){return null===this.getBarycoord(t,e,n,s,Ae)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(i,Ae.x),o.addScaledVector(r,Ae.y),o.addScaledVector(a,Ae.z),o)}static isFrontFacing(t,e,n,s){return Me.subVectors(n,e),Se.subVectors(t,e),Me.cross(Se).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Me.subVectors(this.c,this.b),Se.subVectors(this.a,this.b),.5*Me.cross(Se).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ie.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ie.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,i){return Ie.getInterpolation(t,this.a,this.b,this.c,e,n,s,i)}containsPoint(t){return Ie.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ie.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,i=this.c;let r,a;Ee.subVectors(s,n),Re.subVectors(i,n),ze.subVectors(t,n);const o=Ee.dot(ze),l=Re.dot(ze);if(o<=0&&l<=0)return e.copy(n);Pe.subVectors(t,s);const h=Ee.dot(Pe),u=Re.dot(Pe);if(h>=0&&u<=h)return e.copy(s);const c=o*u-h*l;if(c<=0&&o>=0&&h<=0)return r=o/(o-h),e.copy(n).addScaledVector(Ee,r);Le.subVectors(t,i);const d=Ee.dot(Le),p=Re.dot(Le);if(p>=0&&d<=p)return e.copy(i);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Re,a);const f=h*p-d*u;if(f<=0&&u-h>=0&&d-p>=0)return Be.subVectors(i,s),a=(u-h)/(u-h+(d-p)),e.copy(s).addScaledVector(Be,a);const y=1/(f+m+c);return r=m*y,a=c*y,e.copy(n).addScaledVector(Ee,r).addScaledVector(Re,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ce={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},De={h:0,s:0,l:0},Ne={h:0,s:0,l:0};function Fe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Oe{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e){return void 0===e&&(e=C),t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ut.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s){return void 0===s&&(s=ut.workingColorSpace),this.r=t,this.g=e,this.b=n,ut.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s){if(void 0===s&&(s=ut.workingColorSpace),t=J(t,1),e=Z(e,0,1),n=Z(n,0,1),0===e)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,i=2*n-s;this.r=Fe(i,s,t+1/3),this.g=Fe(i,s,t),this.b=Fe(i,s,t-1/3)}return ut.toWorkingColorSpace(this,s),this}setStyle(t,e){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(void 0===e&&(e=C),s=/^(\w+)\(([^\)]*)\)/.exec(t)){let i;const r=s[1],a=s[2];switch(r){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],i=n.length;if(3===i)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e){void 0===e&&(e=C);const n=Ce[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ct(t.r),this.g=ct(t.g),this.b=ct(t.b),this}copyLinearToSRGB(t){return this.r=dt(t.r),this.g=dt(t.g),this.b=dt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t){return void 0===t&&(t=C),ut.fromWorkingColorSpace(We.copy(this),t),65536*Math.round(Z(255*We.r,0,255))+256*Math.round(Z(255*We.g,0,255))+Math.round(Z(255*We.b,0,255))}getHexString(t){return void 0===t&&(t=C),("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e){void 0===e&&(e=ut.workingColorSpace),ut.fromWorkingColorSpace(We.copy(this),e);const n=We.r,s=We.g,i=We.b,r=Math.max(n,s,i),a=Math.min(n,s,i);let o,l;const h=(a+r)/2;if(a===r)o=0,l=0;else{const t=r-a;switch(l=h<=.5?t/(r+a):t/(2-r-a),r){case n:o=(s-i)/t+(s0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function s(t){const e=[];for(const n in t){const s=t[n];delete s.metadata,e.push(s)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==q&&(n.stencilFail=this.stencilFail),this.stencilZFail!==q&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==q&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=s(t.textures),i=s(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let s=0;s!==t;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const je=new wt,Ve=new et;class Ge{constructor(t,e,n){if(void 0===n&&(n=!1),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return(t="THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.")in rt||(rt[t]=!0,console.warn(t)),this._updateRange;var t}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,i=this.itemSize;s=0;--e)if(t[e]>=65535)return!0;return!1}(t)?Ye:He)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n){void 0===n&&(n=0),this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new nt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const s=this.attributes.tangent;return void 0!==s&&(s.transformDirection(t),s.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Je.makeRotationFromQuaternion(t),this.applyMatrix4(Je),this}rotateX(t){return Je.makeRotationX(t),this.applyMatrix4(Je),this}rotateY(t){return Je.makeRotationY(t),this.applyMatrix4(Je),this}rotateZ(t){return Je.makeRotationZ(t),this.applyMatrix4(Je),this}translate(t,e,n){return Je.makeTranslation(t,e,n),this.applyMatrix4(Je),this}scale(t,e,n){return Je.makeScale(t,e,n),this.applyMatrix4(Je),this}lookAt(t){return $e.lookAt(t),$e.updateMatrix(),this.applyMatrix4($e.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ke).negate(),this.translate(Ke.x,Ke.y,Ke.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const o in n){const e=n[o];t.data.attributes[o]=e.toJSON(t.data)}const s={};let i=!1;for(const o in this.morphAttributes){const e=this.morphAttributes[o],n=[];for(let s=0,i=e.length;s0&&(s[o]=n,i=!0)}i&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const s=t.attributes;for(const l in s){const t=s[l];this.setAttribute(l,t.clone(e))}const i=t.morphAttributes;for(const l in i){const t=[],n=i[l];for(let s=0,i=n.length;s1?null:e.copy(t.start).addScaledVector(n,i)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||cn.getNormalMatrix(t),s=this.coplanarPoint(hn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}class pn extends xt{constructor(t,e,n,s,i,r,a,o,l,h){if(void 0===h&&(h=I),h!==I&&1027!==h)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===I&&(n=1014),void 0===n&&1027===h&&(n=1020),super(null,s,i,r,a,o,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:1003,this.minFilter=void 0!==o?o:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}new pn(1,1).compareFunction=515;class mn extends qe{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Oe(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 Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(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 ae,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class fn extends mn{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new et(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Z(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class yn{constructor(t,e,n){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===n&&(n=0),this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Z(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const gn=new wt,_n=new wt;class xn{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=new wt),this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){gn.subVectors(t,this.start),_n.subVectors(this.end,this.start);const n=_n.dot(_n);let s=_n.dot(gn)/n;return e&&(s=Z(s,0,1)),s}closestPointToPoint(t,e,n){const s=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"165"}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="165");class bn extends fn{constructor(){super(),k(this,"oBaseWeight",1),k(this,"oBaseColor",[.8,.8,.8]),k(this,"oBaseMetalness",0),k(this,"oBaseDiffuseRoughness",0),k(this,"oSpecularWeight",1),k(this,"oSpecularColor",[1,1,1]),k(this,"oSpecularRoughness",.3),k(this,"oSpecularRoughnessAnisotropy",0),k(this,"oSpecularIOR",1.5),k(this,"oCoatWeight",0),k(this,"oCoatColor",[1,1,1]),k(this,"oCoatRoughness",0),k(this,"oCoatRoughnessAnisotropy",0),k(this,"oCoatIor",1.6),k(this,"oCoatDarkening",1),k(this,"oEmissionLuminance",0),k(this,"oEmissionColor",[1,1,1]),k(this,"oThinFilmThickness",.5),k(this,"oThinFilmIOR",1.5)}}const wn=0,vn=1,kn=2,Mn=2,Sn=1.25,Tn=1,An=32,En=65535,Rn=Math.pow(2,-24),Bn=Symbol("SKIP_GENERATION");function zn(t){return function(t){return t.index?t.index.count:t.attributes.position.count}(t)/3}function Pn(t,e){if(!t.index){const n=t.attributes.position.count,s=function(t,e){return void 0===e&&(e=ArrayBuffer),t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new Ge(s,1));for(let t=0;tt-e));for(let o=0;ol&&(l=i),em&&(m=e);const _=t[g+2],x=t[g+3],b=_-x,w=_+x;bh&&(h=w),_f&&(f=_);const v=t[g+4],k=t[g+5],M=v-k,S=v+k;Mu&&(u=S),vy&&(y=v)}s[0]=r,s[1]=a,s[2]=o,s[3]=l,s[4]=h,s[5]=u,i[0]=c,i[1]=d,i[2]=p,i[3]=m,i[4]=f,i[5]=y}function Dn(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function Nn(t){let e=-1,n=-1/0;for(let s=0;s<3;s++){const i=t[s+3]-t[s];i>n&&(n=i,e=s)}return e}function Fn(t,e){e.set(t)}function On(t,e,n){let s,i;for(let r=0;r<3;r++){const a=r+3;s=t[r],i=e[r],n[r]=si?s:i}}function Wn(t,e,n){for(let s=0;s<3;s++){const i=e[t+2*s],r=e[t+2*s+1],a=i-r,o=i+r;an[s+3]&&(n[s+3]=o)}}function Un(t){const e=t[3]-t[0],n=t[4]-t[1],s=t[5]-t[2];return 2*(e*n+n*s+s*e)}const qn=32,jn=(t,e)=>t.candidate-e.candidate,Vn=new Array(qn).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),Gn=new Float32Array(6);class Hn{constructor(){this.boundingData=new Float32Array(6)}}function Yn(t,e,n,s,i,r){let a=s,o=s+i-1;const l=r.pos,h=2*r.axis;for(;;){for(;a<=o&&n[6*a+h]=l;)o--;if(!(a=l;)o--;if(!(ars)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ns[n+6]=a/4,a=ls(a,i),ns[n+7]=r,a}}function hs(t,e,n,s,i){const{maxDepth:r,verbose:a,maxLeafTris:o,strategy:l,onProgress:h,indirect:u}=i,c=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,m=u?Xn:Yn,f=zn(d),y=new Float32Array(6);let g=!1;const _=new Hn;return Cn(e,n,s,_.boundingData,y),function t(n,s,i,h,u){void 0===h&&(h=null);void 0===u&&(u=0);if(!g&&u>=r&&(g=!0,a&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),i<=o||u>=r)return x(s+i),n.offset=s,n.count=i,n;const f=function(t,e,n,s,i,r){let a=-1,o=0;if(r===wn)a=Nn(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(r===vn)a=Nn(t),-1!==a&&(o=function(t,e,n,s){let i=0;for(let r=e,a=e+n;r=r.candidate?Wn(i,n,r.rightCacheBounds):(Wn(i,n,r.leftCacheBounds),r.count++)}}for(let n=0;n=qn&&(e=qn-1);const r=Vn[e];r.count++,Wn(i,n,r.bounds)}const e=Vn[qn-1];Fn(e.bounds,e.rightCacheBounds);for(let t=qn-2;t>=0;t--){const e=Vn[t],n=Vn[t+1];On(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let n=0;n65536,i=s?4:2,r=e?new SharedArrayBuffer(n*i):new ArrayBuffer(n*i),a=s?new Uint32Array(r):new Uint16Array(r);for(let o=0,l=a.length;ot.offset-e.offset)),s=n[n.length-1];s.count=Math.min(e-s.offset,s.count);let i=0;return n.forEach((t=>{let{count:e}=t;return i+=e})),e!==i}(n)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||Pn(n,e);const s=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=function(t,e,n,s){void 0===e&&(e=null),void 0===n&&(n=null),void 0===s&&(s=null);const i=t.attributes.position,r=t.index?t.index.array:null,a=zn(t),o=i.normalized;let l;null===e?(l=new Float32Array(6*a*4),n=0,s=a):(l=e,n=n||0,s=s||a);const h=i.array,u=i.offset||0;let c=3;i.isInterleavedBufferAttribute&&(c=i.data.stride);const d=["getX","getY","getZ"];for(let p=n;pm&&(m=u),c>m&&(m=c);const f=(m-p)/2,y=2*r;l[e+y+0]=p+f,l[e+y+1]=f+(Math.abs(p)+f)*Rn}}return l}(n),r=e.indirect?Ln(n):In(n);t._roots=r.map((n=>{const r=hs(t,i,n.offset,n.count,e),a=as(r),o=new s(An*a);return os(0,r,o),o}))}class cs{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,s=-1/0;for(let i=0,r=t.length;is?r:s}this.min=n,this.max=s}setFromPoints(t,e){let n=1/0,s=-1/0;for(let i=0,r=e.length;is?a:s}this.min=n,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}cs.prototype.setFromBox=function(){const t=new wt;return function(e,n){const s=n.min,i=n.max;let r=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let n=0;n<=1;n++)for(let l=0;l<=1;l++){t.x=s.x*o+i.x*(1-o),t.y=s.y*n+i.y*(1-n),t.z=s.z*l+i.z*(1-l);const h=e.dot(t);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}}();const ds=function(){const t=new wt,e=new wt,n=new wt;return function(s,i,r){const a=s.start,o=t,l=i.start,h=e;n.subVectors(a,l),t.subVectors(s.end,s.start),e.subVectors(i.end,i.start);const u=n.dot(h),c=h.dot(o),d=h.dot(h),p=n.dot(o),m=o.dot(o)*d-c*c;let f,y;f=0!==m?(u*c-p*d)/m:0,y=(u+f*c)/d,r.x=f,r.y=y}}(),ps=function(){const t=new et,e=new wt,n=new wt;return function(s,i,r,a){ds(s,i,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return s.at(o,r),void i.at(l,a);if(o>=0&&o<=1)return l<0?i.at(0,a):i.at(1,a),void s.closestPointToPoint(a,!0,r);if(l>=0&&l<=1)return o<0?s.at(0,r):s.at(1,r),void i.closestPointToPoint(r,!0,a);{let t,h;t=o<0?s.start:s.end,h=l<0?i.start:i.end;const u=e,c=n;return s.closestPointToPoint(h,!0,e),i.closestPointToPoint(t,!0,n),u.distanceToSquared(h)<=c.distanceToSquared(t)?(r.copy(u),void a.copy(h)):(r.copy(t),void a.copy(c))}}}(),ms=function(){const t=new wt,e=new wt,n=new dn,s=new xn;return function(i,r){const{radius:a,center:o}=i,{a:l,b:h,c:u}=r;if(s.start=l,s.end=h,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a||(s.start=l,s.end=u,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a)||(s.start=h,s.end=u,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a))return!0;const c=r.getPlane(n);if(Math.abs(c.distanceToPoint(o))<=a){const t=c.projectPoint(o,e);if(r.containsPoint(t))return!0}return!1}}();function fs(t){return Math.abs(t)<1e-15}class ys extends Ie{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new wt)),this.satBounds=new Array(4).fill().map((()=>new cs)),this.points=[this.a,this.b,this.c],this.sphere=new qt,this.plane=new dn,this.needsUpdate=!0}intersectsSphere(t){return ms(t,this)}update(){const t=this.a,e=this.b,n=this.c,s=this.points,i=this.satAxes,r=this.satBounds,a=i[0],o=r[0];this.getNormal(a),o.setFromPoints(a,s);const l=i[1],h=r[1];l.subVectors(t,e),h.setFromPoints(l,s);const u=i[2],c=r[2];u.subVectors(e,n),c.setFromPoints(u,s);const d=i[3],p=r[3];d.subVectors(n,t),p.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}ys.prototype.closestPointToSegment=function(){const t=new wt,e=new wt,n=new xn;return function(s,i,r){void 0===i&&(i=null),void 0===r&&(r=null);const{start:a,end:o}=s,l=this.points;let h,u=1/0;for(let c=0;c<3;c++){const a=(c+1)%3;n.start.copy(l[c]),n.end.copy(l[a]),ps(n,s,t,e),h=t.distanceToSquared(e),h=2){(1===r?n.start:n.end).copy(p),i=2;break}if(i++,2===i&&-1===r)break}}return i}return function(a,u,p){void 0===u&&(u=null),void 0===p&&(p=!1),this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const f=this.plane,y=a.plane;if(Math.abs(f.normal.dot(y.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const i=t[e],r=o[e];if(s.setFromPoints(r,n),i.isSeparated(s))return!1}const l=a.satBounds,h=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let n=0;n<4;n++){const t=l[n],i=h[n];if(s.setFromPoints(i,e),t.isSeparated(s))return!1}for(let a=0;a<4;a++){const t=o[a];for(let a=0;a<4;a++){const o=h[a];if(r.crossVectors(t,o),s.setFromPoints(r,e),i.setFromPoints(r,n),s.isSeparated(i))return!1}}return u&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),u.start.set(0,0,0),u.end.set(0,0,0)),!0}{const t=m(this,y,c);if(1===t&&a.containsPoint(c.end))return u&&(u.start.copy(c.end),u.end.copy(c.end)),!0;if(2!==t)return!1;const e=m(a,f,d);if(1===e&&this.containsPoint(d.end))return u&&(u.start.copy(d.end),u.end.copy(d.end)),!0;if(2!==e)return!1;if(c.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=c.start.dot(o),s=c.end.dot(o),i=d.start.dot(o),r=d.end.dot(o);return(n===r||i===s||s0?u.start.copy(c.start):u.start.copy(d.start),h.subVectors(c.end,d.end),h.dot(o)<0?u.end.copy(c.end):u.end.copy(d.end)),!0)}}}(),ys.prototype.distanceToPoint=function(){const t=new wt;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),ys.prototype.distanceToTriangle=function(){const t=new wt,e=new wt,n=["a","b","c"],s=new xn,i=new xn;return function(r,a,o){void 0===a&&(a=null),void 0===o&&(o=null);const l=a||o?s:null;if(this.intersectsTriangle(r,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let e=0;e<3;e++){let s;const i=n[e],l=r[i];this.closestPointToPoint(l,t),s=l.distanceToSquared(t),snew wt)),this.satAxes=new Array(3).fill().map((()=>new wt)),this.satBounds=new Array(3).fill().map((()=>new cs)),this.alignedSatBounds=new Array(3).fill().map((()=>new cs)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}gs.prototype.update=function(){return function(){const t=this.matrix,e=this.min,n=this.max,s=this.points;for(let l=0;l<=1;l++)for(let i=0;i<=1;i++)for(let r=0;r<=1;r++){const a=s[1*l|2*i|4*r];a.x=l?n.x:e.x,a.y=i?n.y:e.y,a.z=r?n.z:e.z,a.applyMatrix4(t)}const i=this.satBounds,r=this.satAxes,a=s[0];for(let l=0;l<3;l++){const t=r[l],e=i[l],n=s[1<new xn)),n=new Array(12).fill().map((()=>new xn)),s=new wt,i=new wt;return function(r,a,o,l){if(void 0===a&&(a=0),void 0===o&&(o=null),void 0===l&&(l=null),this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||l)&&(r.getCenter(i),this.closestPointToPoint(i,s),r.closestPointToPoint(s,i),o&&o.copy(s),l&&l.copy(i)),0;const h=a*a,u=r.min,c=r.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];i.copy(e).clamp(u,c);const n=e.distanceToSquared(i);if(nnew ys))}}const bs=new xs;const ws=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let vs,ks;const Ms=[],Ss=new _s((()=>new Mt));function Ts(t,e,n,s,i,r){vs=Ss.getPrimitive(),ks=Ss.getPrimitive(),Ms.push(vs,ks),ws.setBuffer(t._roots[e]);const a=As(0,t.geometry,n,s,i,r);ws.clearBuffer(),Ss.releasePrimitive(vs),Ss.releasePrimitive(ks),Ms.pop(),Ms.pop();const o=Ms.length;return o>0&&(ks=Ms[o-1],vs=Ms[o-2]),a}function As(t,e,n,s,i,r,a){void 0===i&&(i=null),void 0===r&&(r=0),void 0===a&&(a=0);const{float32Array:o,uint16Array:l,uint32Array:h}=ws;let u=2*t;if(Zn(u,l)){const e=Jn(t,h),n=$n(u,l);return Dn(t,o,vs),s(e,n,!1,a,r+t,vs)}{let u=function(t){const{uint16Array:e,uint32Array:n}=ws;let s=2*t;for(;!Zn(s,e);)s=2*(t=Kn(t));return Jn(t,n)},c=function(t){const{uint16Array:e,uint32Array:n}=ws;let s=2*t;for(;!Zn(s,e);)s=2*(t=Qn(t,n));return Jn(t,n)+$n(s,e)};const d=Kn(t),p=Qn(t,h);let m,f,y,g,_=d,x=p;if(i&&(y=vs,g=ks,Dn(_,o,y),Dn(x,o,g),m=i(y),f=i(g),fo?null:{distance:h,point:i.clone()}}(t,Bs,zs,Ps,Os,l,h,u);if(c){s&&(Ls.fromBufferAttribute(s,r),Is.fromBufferAttribute(s,a),Cs.fromBufferAttribute(s,o),c.uv=Ie.getInterpolation(Os,Bs,zs,Ps,Ls,Is,Cs,new et)),i&&(Ls.fromBufferAttribute(i,r),Is.fromBufferAttribute(i,a),Cs.fromBufferAttribute(i,o),c.uv1=Ie.getInterpolation(Os,Bs,zs,Ps,Ls,Is,Cs,new et)),n&&(Ds.fromBufferAttribute(n,r),Ns.fromBufferAttribute(n,a),Fs.fromBufferAttribute(n,o),c.normal=Ie.getInterpolation(Os,Bs,zs,Ps,Ds,Ns,Fs,new wt),c.normal.dot(t.direction)>0&&c.normal.multiplyScalar(-1));const e={a:r,b:a,c:o,normal:new wt,materialIndex:0};Ie.getNormal(Bs,zs,Ps,e.normal),c.face=e,c.faceIndex=r}return c}function Us(t,e,n,s,i,r,a){const o=3*s;let l=o+0,h=o+1,u=o+2;const c=t.index;t.index&&(l=c.getX(l),h=c.getX(h),u=c.getX(u));const{position:d,normal:p,uv:m,uv1:f}=t.attributes,y=Ws(n,d,p,m,f,l,h,u,e,r,a);return y?(y.faceIndex=s,i&&i.push(y),y):null}function qs(t,e,n,s){const i=t.a,r=t.b,a=t.c;let o=e,l=e+1,h=e+2;n&&(o=n.getX(o),l=n.getX(l),h=n.getX(h)),i.x=s.getX(o),i.y=s.getY(o),i.z=s.getZ(o),r.x=s.getX(l),r.y=s.getY(l),r.z=s.getZ(l),a.x=s.getX(h),a.y=s.getY(h),a.z=s.getZ(h)}function js(t,e,n,s,i,r,a){const{geometry:o}=n,{index:l}=o,h=o.attributes.position;for(let u=t,c=e+t;uc&&(c=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==r||l[t+2]!==u||l[t+3]!==c||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=r,l[t+2]=u,l[t+3]=c,l[t+4]=d,l[t+5]=p,!0)}{const s=t+8,i=a[t+6],o=s+n,h=i+n;let u=r,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);const m=u||p;let f=!1;(u||d)&&(f=c(s,n,u));let y=!1;m&&(y=c(i,n,u));const g=f||y;if(g)for(let e=0;e<3;e++){const n=s+e,r=i+e,a=l[n],o=l[n+3],h=l[r],u=l[r+3];l[t+e]=au?o:u}return g}}}function Gs(t,e,n,s,i){let r,a,o,l,h,u;const c=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,m=n.origin.x,f=n.origin.y,y=n.origin.z;let g=e[t],_=e[t+3],x=e[t+1],b=e[t+3+1],w=e[t+2],v=e[t+3+2];return c>=0?(r=(g-m)*c,a=(_-m)*c):(r=(_-m)*c,a=(g-m)*c),d>=0?(o=(x-f)*d,l=(b-f)*d):(o=(b-f)*d,l=(x-f)*d),!(r>l||o>a||((o>r||isNaN(r))&&(r=o),(l=0?(h=(w-y)*p,u=(v-y)*p):(h=(v-y)*p,u=(w-y)*p),r>u||h>a))&&((h>r||r!=r)&&(r=h),(u=s)}function Hs(t,e,n,s,i,r,a){const{geometry:o}=n,{index:l}=o,h=o.attributes.position;for(let u=t,c=e+t;u=0;let c,d;u?(c=Kn(t),d=Qn(t,l)):(c=Qn(t,l),d=Kn(t));const p=Gs(c,a,s,i,r)?$s(c,e,n,s,i,r):null;if(p){const t=p.point[h];if(u?t<=a[d+o]:t>=a[d+o+3])return p}const m=Gs(d,a,s,i,r)?$s(d,e,n,s,i,r):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}const Ks=new Mt,Qs=new ys,ti=new ys,ei=new Jt,ni=new gs,si=new gs;function ii(t,e,n,s){ws.setBuffer(t._roots[e]);const i=ri(0,t,n,s);return ws.clearBuffer(),i}function ri(t,e,n,s,i){void 0===i&&(i=null);const{float32Array:r,uint16Array:a,uint32Array:o}=ws;let l=2*t;if(null===i&&(n.boundingBox||n.computeBoundingBox(),ni.set(n.boundingBox.min,n.boundingBox.max,s),i=ni),!Zn(l,a)){const a=t+8,l=o[t+6];return Dn(a,r,Ks),!!(i.intersectsBox(Ks)&&ri(a,e,n,s,i)||(Dn(l,r,Ks),i.intersectsBox(Ks)&&ri(l,e,n,s,i)))}{const i=e.geometry,h=i.index,u=i.attributes.position,c=n.index,d=n.attributes.position,p=Jn(t,o),m=$n(l,a);if(ei.copy(s).invert(),n.boundsTree)return Dn(t,r,si),si.matrix.copy(ei),si.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:t=>si.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let e=3*p,n=3*(m+p);eoi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>li.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{for(let a=e,o=e+i;ad&&(d=a),op&&(p=o),lm&&(m=l)}}return(l[n+0]!==r||l[n+1]!==h||l[n+2]!==c||l[n+3]!==d||l[n+4]!==p||l[n+5]!==m)&&(l[n+0]=r,l[n+1]=h,l[n+2]=c,l[n+3]=d,l[n+4]=p,l[n+5]=m,!0)}{const t=n+8,s=a[n+6],i=t+r,o=s+r;let u=h,d=!1,p=!1;e?u||(d=e.has(i),p=e.has(o),u=!d&&!p):(d=!0,p=!0);const m=u||p;let f=!1;(u||d)&&(f=c(t,r,u));let y=!1;m&&(y=c(s,r,u));const g=f||y;if(g)for(let e=0;e<3;e++){const i=t+e,r=s+e,a=l[i],o=l[i+3],h=l[r],u=l[r+3];l[n+e]=au?o:u}return g}}}function fi(t,e,n,s,i,r,a){ws.setBuffer(t._roots[e]),yi(0,t,n,s,i,r,a),ws.clearBuffer()}function yi(t,e,n,s,i,r,a){const{float32Array:o,uint16Array:l,uint32Array:h}=ws,u=2*t;if(Zn(u,l)){!function(t,e,n,s,i,r,a,o){const{geometry:l,_indirectBuffer:h}=t;for(let u=s,c=s+i;u=0;let c,d;u?(c=Kn(t),d=Qn(t,l)):(c=Qn(t,l),d=Kn(t));const p=Gs(c,a,s,i,r)?xi(c,e,n,s,i,r):null;if(p){const t=p.point[h];if(u?t<=a[d+o]:t>=a[d+o+3])return p}const m=Gs(d,a,s,i,r)?xi(d,e,n,s,i,r):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}const bi=new Mt,wi=new ys,vi=new ys,ki=new Jt,Mi=new gs,Si=new gs;function Ti(t,e,n,s){ws.setBuffer(t._roots[e]);const i=Ai(0,t,n,s);return ws.clearBuffer(),i}function Ai(t,e,n,s,i){void 0===i&&(i=null);const{float32Array:r,uint16Array:a,uint32Array:o}=ws;let l=2*t;if(null===i&&(n.boundingBox||n.computeBoundingBox(),Mi.set(n.boundingBox.min,n.boundingBox.max,s),i=Mi),!Zn(l,a)){const a=t+8,l=o[t+6];return Dn(a,r,bi),!!(i.intersectsBox(bi)&&Ai(a,e,n,s,i)||(Dn(l,r,bi),i.intersectsBox(bi)&&Ai(l,e,n,s,i)))}{const i=e.geometry,h=i.index,u=i.attributes.position,c=n.index,d=n.attributes.position,p=Jn(t,o),m=$n(l,a);if(ki.copy(s).invert(),n.boundsTree)return Dn(t,r,Si),Si.matrix.copy(ki),Si.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:t=>Si.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let n=p,s=m+p;nRi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>Bi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{for(let w=e,v=e+a;wnew Mt)),Oi=new Mt,Wi=new Mt,Ui=new Mt,qi=new Mt;let ji=!1;function Vi(t,e,n,s,i,r,a,o,l,h,u){let c,d;void 0===r&&(r=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===l&&(l=0),void 0===h&&(h=null),void 0===u&&(u=!1),u?(c=Ni,d=Di):(c=Di,d=Ni);const p=c.float32Array,m=c.uint32Array,f=c.uint16Array,y=d.float32Array,g=d.uint32Array,_=d.uint16Array,x=2*e,b=Zn(2*t,f),w=Zn(x,_);let v=!1;if(w&&b)v=u?i(Jn(e,g),$n(2*e,_),Jn(t,m),$n(2*t,f),l,a+e,o,r+t):i(Jn(t,m),$n(2*t,f),Jn(e,g),$n(2*e,_),o,r+t,l,a+e);else if(w){const h=Fi.getPrimitive();Dn(e,y,h),h.applyMatrix4(n);const c=Kn(t),d=Qn(t,m);Dn(c,p,Oi),Dn(d,p,Wi);const f=h.intersectsBox(Oi),g=h.intersectsBox(Wi);v=f&&Vi(e,c,s,n,i,a,r,l,o+1,h,!u)||g&&Vi(e,d,s,n,i,a,r,l,o+1,h,!u),Fi.releasePrimitive(h)}else{const c=Kn(e),d=Qn(e,g);Dn(c,y,Ui),Dn(d,y,qi);const f=h.intersectsBox(Ui),_=h.intersectsBox(qi);if(f&&_)v=Vi(t,c,n,s,i,r,a,o,l+1,h,u)||Vi(t,d,n,s,i,r,a,o,l+1,h,u);else if(f)if(b)v=Vi(t,c,n,s,i,r,a,o,l+1,h,u);else{const e=Fi.getPrimitive();e.copy(Ui).applyMatrix4(n);const h=Kn(t),d=Qn(t,m);Dn(h,p,Oi),Dn(d,p,Wi);const f=e.intersectsBox(Oi),y=e.intersectsBox(Wi);v=f&&Vi(c,h,s,n,i,a,r,l,o+1,e,!u)||y&&Vi(c,d,s,n,i,a,r,l,o+1,e,!u),Fi.releasePrimitive(e)}else if(_)if(b)v=Vi(t,d,n,s,i,r,a,o,l+1,h,u);else{const e=Fi.getPrimitive();e.copy(qi).applyMatrix4(n);const h=Kn(t),c=Qn(t,m);Dn(h,p,Oi),Dn(c,p,Wi);const f=e.intersectsBox(Oi),y=e.intersectsBox(Wi);v=f&&Vi(d,h,s,n,i,a,r,l,o+1,e,!u)||y&&Vi(d,c,s,n,i,a,r,l,o+1,e,!u),Fi.releasePrimitive(e)}}return v}const Gi=new gs,Hi=new Mt,Yi={strategy:wn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Xi{static serialize(t,e){void 0===e&&(e={}),e={cloneBuffers:!0,...e};const n=t.geometry,s=t._roots,i=t._indirectBuffer,r=n.getIndex();let a;return a=e.cloneBuffers?{roots:s.map((t=>t.slice())),index:r?r.array.slice():null,indirectBuffer:i?i.slice():null}:{roots:s,index:r?r.array:null,indirectBuffer:i},a}static deserialize(t,e,n){void 0===n&&(n={}),n={setIndex:!0,indirect:!!t.indirectBuffer,...n};const{index:s,roots:i,indirectBuffer:r}=t,a=new Xi(e,{...n,[Bn]:!0});if(a._roots=i,a._indirectBuffer=r||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new Ge(t.index,1,!1);e.setIndex(n)}else n.array!==s&&(n.array.set(s),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e){if(void 0===e&&(e={}),!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...Yi,[Bn]:!1},e)).useSharedArrayBuffer&&!(typeof SharedArrayBuffer<"u"))throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[Bn]||(us(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Mt))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t){return void 0===t&&(t=null),(this.indirect?mi:Vs)(this,t)}traverse(t,e){void 0===e&&(e=0);const n=this._roots[e],s=new Uint32Array(n),i=new Uint16Array(n);!function e(r,a){void 0===a&&(a=0);const o=2*r,l=i[o+15]===En;if(l){const e=s[r+6],h=i[o+14];t(a,l,new Float32Array(n,4*r,6),e,h)}else{const i=r+An/4,o=s[r+6],h=s[r+7];t(a,l,new Float32Array(n,4*r,6),h)||(e(i,a+1),e(o,a+1))}}(0)}raycast(t,e,n,s){void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=1/0);const i=this._roots,r=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),h=r.groups,u=o?e.side:e,c=this.indirect?fi:Ys;for(let d=0,p=i.length;d!!t(s,i,r,o,l)||n(s,i,this,a,r,o,e)}else r||(r=a?(t,s,i,r)=>n(t,s,this,a,i,r,e):(t,e,n)=>n);let o=!1,l=0;const h=this._roots;for(let u=0,c=h.length;u{const e=this.resolveTriangleIndex(t);qs(r,3*e,a,o)}:t=>{qs(r,3*t,a,o)},h=bs.getPrimitive(),u=t.geometry.index,c=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);qs(h,3*n,u,c)}:t=>{qs(h,3*t,u,c)};if(i){const t=(t,n,s,a,o,u,c,p)=>{for(let m=s,f=s+a;mGi.intersectsBox(t),intersectsTriangle:t=>Gi.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n,s,i,r){return void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i=0),void 0===r&&(r=1/0),(this.indirect?Ci:pi)(this,t,e,n,s,i,r)}closestPointToPoint(t,e,n,s){return void 0===e&&(e={}),void 0===n&&(n=0),void 0===s&&(s=1/0),function(t,e,n,s,i){void 0===n&&(n={}),void 0===s&&(s=0),void 0===i&&(i=1/0);const r=s*s,a=i*i;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(Es.copy(e).clamp(t.min,t.max),Es.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,Es);const s=e.distanceToSquared(Es);return s{Dn(0,new Float32Array(e),Hi),t.union(Hi)})),t}}function Zi(t){return t._roots.map(((e,n)=>function(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,s,i,r)=>{const a=s[3]-s[0],o=s[4]-s[1],l=s[5]-s[2],h=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(r,n.tris.min),n.tris.max=Math.max(r,n.tris.max),n.surfaceAreaScore+=h*Sn*r):(n.splits[i]++,n.surfaceAreaScore+=h*Tn)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}const Ji='alias Color = vec3;\n\nstruct Material {\n baseWeight: f32,\n baseColor: Color,\n // todo: switch order of baseDiffuseRoughness and baseMetalness\n baseDiffuseRoughness: f32,\n baseMetalness: f32,\n specularWeight: f32,\n specularColor: Color,\n specularRoughness: f32,\n specularAnisotropy: f32,\n specularRotation: f32,\n specularIor: f32,\n coatWeight: f32,\n coatColor: Color,\n coatRoughness: f32,\n coatRoughnessAnisotropy: f32,\n coatIor: f32,\n coatDarkening: f32,\n emissionLuminance: f32,\n emissionColor: Color,\n thinFilmThickness: f32,\n thinFilmIOR: f32,\n}\n\nstruct UniformData {\n invProjectionMatrix: mat4x4,\n cameraWorldMatrix: mat4x4,\n invModelMatrix: mat4x4,\n seedOffset: u32,\n priorSamples: u32,\n samplesPerPixel: u32,\n sunDirection: vec3f,\n skyPower: f32,\n skyColor: Color,\n sunPower: f32,\n sunAngularSize: f32,\n sunColor: Color,\n clearColor: Color,\n // bool is not supported in uniform\n enableClearColor: i32,\n maxRayDepth: i32,\n objectDefinitionLength: i32,\n}\n\n@group(0) @binding(0) var positions: array;\n// todo: Check when i16 is supported\n@group(0) @binding(1) var indices: array;\n\n@group(0) @binding(2) var bounds: array;\n@group(0) @binding(3) var contents: array;\n\n@group(0) @binding(4) var normals: array;\n\n@group(0) @binding(5) var indirectIndices: array;\n\n@group(0) @binding(6) var objectDefinitions: array;\n\n@group(0) @binding(7) var materials: array;\n\n@group(1) @binding(0) var texture: texture_storage_2d;\n\n@group(1) @binding(1) var readTexture: texture_storage_2d;\n\n@group(1) @binding(2) var uniformData: UniformData;\n\nconst MINIMUM_FLOAT_EPSILON = 1e-8;\nconst FLT_EPSILON = 1.1920929e-7;\nconst PI = 3.1415926535897932;\nconst PI_INVERSE = 1.0 / PI;\n\nstruct Ray {\n origin: vec3,\n direction: vec3,\n};\n\nstruct ObjectDefinition {\n start: u32,\n count: u32,\n material: MaterialDefinition,\n}\n\nstruct MaterialDefinition {\n index: u32,\n}\n\nstruct HitRecord {\n point: vec3,\n normal: vec3,\n t: f32,\n frontFace: bool,\n material: MaterialDefinition,\n}\n\nstruct Triangle {\n Q: vec3,\n u: vec3,\n v: vec3,\n material: MaterialDefinition,\n normal0: vec3,\n normal1: vec3,\n normal2: vec3,\n}\n\nstruct Interval {\n min: f32,\n max: f32,\n}\n\nstruct BinaryBvhNodeInfo {\n // 0-16: isLeaf, 17-31: splitAxis|triangleCount\n x: u32,\n // rightIndex|triangleOffset\n y: u32,\n}\n\nfn nearZero(v: vec3f) -> bool {\n let epsilon = vec3f(MINIMUM_FLOAT_EPSILON);\n return any(abs(v) < epsilon);\n}\n\nfn sqr(x: f32) -> f32 {\n return x * x;\n}\n\nfn maxVec3(v: vec3f) -> f32 {\n return max(v.x, max(v.y, v.z));\n}\n\nfn ggxNDF(H: vec3f, alpha: vec2) -> f32 {\n let safeAlpha = clamp(alpha, vec2(DENOM_TOLERANCE, DENOM_TOLERANCE), vec2(1.0, 1.0));\n let Ddenom = PI * safeAlpha.x * safeAlpha.y * sqr(sqr(H.x/safeAlpha.x) + sqr(H.y/safeAlpha.y) + sqr(H.z));\n return 1.0 / max(Ddenom, DENOM_TOLERANCE);\n}\n\n// GGX NDF sampling routine, as described in\n// "Sampling Visible GGX Normals with Spherical Caps", Dupuy et al., HPG 2023.\n// NB, this assumes wiL is in the +z hemisphere, and returns a sampled micronormal in that hemisphere.\nfn ggxNDFSample(wiL: vec3f, alpha: vec2, seed: ptr) -> vec3f {\n let Xi = vec2f(randomF32(seed), randomF32(seed));\n var V = wiL;\n \n V = normalize(vec3f(V.xy * alpha, V.z));\n\n let phi = 2.0 * PI * Xi.x;\n let z = (1.0 - Xi.y) * (1.0 + V.z) - V.z;\n let sinTheta = sqrt(clamp(1.0 - z * z, 0.0, 1.0));\n let x = sinTheta * cos(phi);\n let y = sinTheta * sin(phi);\n let c = vec3f(x, y, z);\n\n var H = c + V;\n\n H = normalize(vec3f(H.xy * alpha, H.z));\n\n return H;\n}\n\nfn ggxNDFEval(m: vec3f, alpha: vec2f) -> f32 {\n let ax = max(alpha.x, DENOM_TOLERANCE);\n let ay = max(alpha.y, DENOM_TOLERANCE);\n let Ddenom = PI * ax * ay * sqr(sqr(m.x/ax) + sqr(m.y/ay) + sqr(m.z));\n return 1.0 / max(Ddenom, DENOM_TOLERANCE);\n}\n\nfn ggxLambda(w: vec3f, alpha: vec2f) -> f32 {\n if (abs(w.z) < FLT_EPSILON) {\n return 0.0;\n }\n return (-1.0 + sqrt(1.0 + (sqr(alpha.x*w.x) + sqr(alpha.y*w.y))/sqr(w.z))) / 2.0;\n}\n\nfn ggxG1(w: vec3f, alpha: vec2f) -> f32 {\n return 1.0 / (1.0 + ggxLambda(w, alpha));\n}\n\nfn ggxG2(woL: vec3f, wiL: vec3f, alpha: vec2f) -> f32 {\n return 1.0 / (1.0 + ggxLambda(woL, alpha) + ggxLambda(wiL, alpha));\n}\n\nstruct BsdfResponse {\n response: vec3f,\n throughput: vec3f,\n thickness: f32,\n ior: f32,\n}\n\nstruct FresnelData {\n model: i32,\n ior: vec3f,\n extinction: vec3f,\n F0: vec3f,\n F90: vec3f,\n exponent: f32,\n thinFilmThickness: f32,\n thinFilmIOR: f32,\n refraction: bool,\n}\n\nconst FRESNEL_MODEL_SCHLICK = 2;\n\nfn initFresnelSchlick(F0: vec3f, F90: vec3f, exponent: f32) -> FresnelData {\n return FresnelData(\n FRESNEL_MODEL_SCHLICK,\n vec3f(0.0),\n vec3f(0.0),\n F0,\n F90,\n exponent,\n 0.0,\n 0.0,\n false\n );\n}\n\nfn fresnelSchlick(cosTheta: f32, F0: vec3f, F90: vec3f, exponent: f32) -> vec3f {\n let x = clamp(1.0 - cosTheta, 0.0, 1.0);\n return mix(F0, F90, pow(x, exponent));\n}\n\nfn fresnelSchlickV2(F0: vec3f, mu: f32) -> vec3f {\n return F0 + pow(1.0 - mu, 5.0) * (vec3f(1.0) - F0);\n}\n\nfn computeFresnel(cosTheta: f32, fd: FresnelData) -> vec3f {\n // todo: implement other models (dielectric, conductor, airy)\n if (fd.model == FRESNEL_MODEL_SCHLICK) {\n return fresnelSchlick(cosTheta, fd.F0, fd.F90, fd.exponent);\n }\n \n return vec3f(0.0);\n}\n\nfn fresnelF82Tint(mu: f32, F0: vec3f, f82Tint: vec3f) -> vec3f {\n let muBar = 1.0/7.0;\n let denom = muBar * pow(1.0 - muBar, 6);\n let fSchlickBar = fresnelSchlickV2(F0, muBar);\n let fSchlick = fresnelSchlickV2(F0, mu);\n return fSchlick - mu * pow(1.0 - mu, 6.0) * (vec3f(1.0) - f82Tint) * fSchlickBar / denom;\n}\n\n\nfn rayAt(ray: Ray, t: f32) -> vec3 {\n return ray.origin + t * ray.direction;\n}\n\nfn lengthSquared(v: vec3) -> f32 {\n return dot(v, v);\n}\n\n// CODE#RNG\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L283\nconst PCG_INC = 2891336453u;\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L278\nconst PCG_MULTIPLIER = 747796405u;\n\n// https://www.pcg-random.org/download.html#id1\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L1533\nfn randomU32(seed: u32) -> u32 {\n let state = seed * PCG_MULTIPLIER + PCG_INC;\n let word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;\n return (word >> 22u) ^ word;\n}\n\nconst range = 1.0 / f32(0xffffffffu);\n\n// Generate a random float in the range [0, 1).\nfn randomF32(seed: ptr) -> f32 {\n *seed = randomU32(*seed);\n return f32(*seed - 1u) * range;\n}\n\nfn triangleHit(triangle: Triangle, ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n let edge1 = triangle.u;\n let edge2 = triangle.v;\n let h = cross(ray.direction, edge2);\n let a = dot(edge1, h);\n // No hit if ray is parallel to the triangle\n if (a > -0.00001 && a < 0.00001) {\n return false;\n }\n let f = 1.0 / a;\n let s = ray.origin - triangle.Q;\n let u = f * dot(s, h);\n // No hit if ray is outside the triangle\n if (u < 0.0 || u > 1.0) {\n return false;\n }\n let q = cross(s, edge1);\n let v = f * dot(ray.direction, q);\n // No hit if ray is outside the triangle\n if (v < 0.0 || u + v > 1.0) {\n return false;\n }\n let t = f * dot(edge2, q);\n // No hit if triangle is behind the ray\n if (t < (rayT).min || t > (rayT).max) {\n return false;\n }\n\n (*hitRecord).t = t;\n (*hitRecord).point = rayAt(ray, t);\n (*hitRecord).normal = normalize(triangle.normal0 * (1.0 - u - v) + triangle.normal1 * u + triangle.normal2 * v);\n //(*hitRecord).normal = normalize(cross(edge1, edge2));\n //(*hitRecord).frontFace = dot(ray.direction, (*hitRecord).normal) < 0.0;\n\n (*hitRecord).material = triangle.material;\n\n return true;\n}\n\n// CODE#BVH-TESTS\n// Based on https://github.com/gkjohnson/three-mesh-bvh/blob/master/src/gpu/glsl/bvh_ray_functions.glsl.js\nfn intersectsBounds(ray: Ray, boundsMin: vec3f, boundsMax: vec3f, dist: ptr) -> bool {\n let invDir = vec3f(1.0) / ray.direction;\n \n let tMinPlane = invDir * (boundsMin - ray.origin);\n let tMaxPlane = invDir * (boundsMax - ray.origin);\n\n let tMinHit = min(tMaxPlane, tMinPlane);\n let tMaxHit = max(tMaxPlane, tMinPlane);\n\n var t = max(tMinHit.xx, tMinHit.yz);\n let t0 = max(t.x, t.y);\n\n t = min(tMaxHit.xx, tMaxHit.yz);\n let t1 = min(t.x, t.y);\n\n (*dist) = max(t0, 0.0);\n\n return t1 >= (*dist);\n}\n\nfn intersectsBVHNodeBounds(ray: Ray, currNodeIndex: u32, dist: ptr) -> bool {\n // 2 because min+max, 4 because x,y,z + unused alpha\n let cni2 = currNodeIndex * 2u * 4;\n let boundsMin = vec3(bounds[cni2], bounds[cni2 + 1], bounds[cni2 + 2]);\n // Start at 4 because of unused alpha\n let boundsMax = vec3(bounds[cni2 + 4], bounds[cni2 + 5], bounds[cni2 + 6]);\n return intersectsBounds(ray, boundsMin, boundsMax, dist);\n}\n\nfn intersectTriangles(offset: u32, count: u32, ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n var found = false;\n var localDist = hitRecord.t;\n let l = offset + count;\n \n for (var i = offset; i < l; i += 1) {\n let vIndexOffset = indirectIndices[i] * 3u;\n\n let v1Index = indices[vIndexOffset];\n let v2Index = indices[vIndexOffset+1];\n let v3Index = indices[vIndexOffset+2];\n \n let x = vec3f(positions[v1Index*3], positions[v1Index*3+1], positions[v1Index*3+2]);\n let y = vec3f(positions[v2Index*3], positions[v2Index*3+1], positions[v2Index*3+2]);\n let z = vec3f(positions[v3Index*3], positions[v3Index*3+1], positions[v3Index*3+2]);\n \n let Q = x;\n let u = y - x;\n let v = z - x;\n \n var matchingObjectDefinition: ObjectDefinition = objectDefinitions[0];\n for (var j = 0; j < uniformData.objectDefinitionLength ; j++) {\n let objectDefinition = objectDefinitions[j];\n if (objectDefinition.start <= vIndexOffset && objectDefinition.start + objectDefinition.count > vIndexOffset) {\n matchingObjectDefinition = objectDefinition;\n break;\n }\n }\n let materialDefinition = matchingObjectDefinition.material;\n\n let normalX = vec3f(normals[v1Index*3], normals[v1Index*3+1], normals[v1Index*3+2]);\n let normalY = vec3f(normals[v2Index*3], normals[v2Index*3+1], normals[v2Index*3+2]);\n let normalZ = vec3f(normals[v3Index*3], normals[v3Index*3+1], normals[v3Index*3+2]);\n \n let triangle = Triangle(Q, u, v, materialDefinition, normalX,normalY,normalZ);\n\n var tmpRecord: HitRecord;\n if (triangleHit(triangle, ray, Interval(rayT.min, localDist), &tmpRecord)) {\n if (localDist < tmpRecord.t) {\n continue;\n }\n (*hitRecord) = tmpRecord;\n\n localDist = (*hitRecord).t;\n found = true;\n }\n }\n return found;\n}\n\nfn hittableListHit(ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n var tempRecord: HitRecord;\n var hitAnything = false;\n var closestSoFar = rayT.max;\n\n // Inspired by https://github.com/gkjohnson/three-mesh-bvh/blob/master/src/gpu/glsl/bvh_ray_functions.glsl.js\n \n // BVH Intersection Detection\n var sPtr = 0;\n var stack: array = array();\n stack[sPtr] = 0u;\n\n while (sPtr > -1 && sPtr < ${maxBvhStackDepth}) {\n let currNodeIndex = stack[sPtr];\n sPtr -= 1;\n\n var boundsHitDistance: f32;\n \n if (!intersectsBVHNodeBounds(ray, currNodeIndex, &boundsHitDistance) || boundsHitDistance > closestSoFar) {\n continue;\n }\n\n let boundsInfo = contents[currNodeIndex];\n let boundsInfoX = boundsInfo.x;\n let boundsInfoY = boundsInfo.y;\n\n let isLeaf = (boundsInfoX & 0xffff0000u) == 0xffff0000u;\n\n if (isLeaf) {\n let count = boundsInfoX & 0x0000ffffu;\n let offset = boundsInfoY;\n\n let found2 = intersectTriangles(\n offset,\n count,\n ray,\n rayT,\n hitRecord\n );\n if (found2) {\n closestSoFar = (*hitRecord).t;\n }\n \n hitAnything = hitAnything || found2;\n } else {\n // Left node is always the next node\n let leftIndex = currNodeIndex + 1u;\n let splitAxis = boundsInfoX & 0x0000ffffu;\n let rightIndex = boundsInfoY;\n\n let leftToRight = ray.direction[splitAxis] > 0.0;\n let c1 = select(rightIndex, leftIndex, leftToRight);\n let c2 = select(leftIndex, rightIndex, leftToRight);\n\n sPtr += 1;\n stack[sPtr] = c2;\n sPtr += 1;\n stack[sPtr] = c1;\n }\n }\n\n return hitAnything;\n}\n\nstruct BouncingInfo {\n attenuation: Color,\n emission: Color,\n}\n\nstruct Basis {\n nW: vec3f,\n tW: vec3f,\n bW: vec3f,\n baryCoords: vec3f,\n}\n\nconst DENOM_TOLERANCE = 1.0e-10;\nconst RADIANCE_EPSILON = 1.0e-12;\n\nfn safeNormalize(v: vec3f) -> vec3f {\n let len = length(v);\n return v/max(len, DENOM_TOLERANCE);\n}\n\nfn normalToTangent(N: vec3f) -> vec3f {\n var T: vec3f;\n if (abs(N.z) < abs(N.x)) {\n T = vec3f(N.z, 0.0, -N.x);\n } else {\n T = vec3f(0.0, N.z, -N.y);\n }\n return safeNormalize(T);\n}\n\nfn makeBasis(nWI: vec3f) -> Basis {\n let nW = safeNormalize(nWI);\n let tW = normalToTangent(nWI);\n let bW = cross(nWI, tW);\n return Basis(nW, tW, bW, vec3f(0.0));\n}\n\nfn makeBasisFull(nW: vec3f, tW: vec3f, baryCoords: vec3f) -> Basis {\n let nWo = safeNormalize(nW);\n let tWo = safeNormalize(tW);\n let bWo = cross(nWo, tWo);\n return Basis(nWo, tWo, bWo, baryCoords);\n}\n\nfn worldToLocal(vWorld: vec3f, basis: Basis) -> vec3f {\n return vec3f(dot(vWorld, basis.tW), dot(vWorld, basis.bW), dot(vWorld, basis.nW));\n}\n\nfn localToWorld(vLocal: vec3f, basis: Basis) -> vec3f {\n return basis.tW * vLocal.x + basis.bW * vLocal.y + basis.nW * vLocal.z;\n}\n\nstruct LocalFrameRotation {\n M: mat2x2,\n Minv: mat2x2,\n}\n\nfn getLocalFrameRotation(angle: f32) -> LocalFrameRotation {\n if (angle == 0.0 || angle==2*PI) {\n let identity = mat2x2(1.0, 0.0, 0.0, 1.0);\n return LocalFrameRotation(identity, identity);\n } else {\n let cosRot = cos(angle);\n let sinRot = sin(angle);\n let M = mat2x2(cosRot, sinRot, -sinRot, cosRot);\n let Minv = mat2x2(cosRot, -sinRot, sinRot, cosRot);\n return LocalFrameRotation(M, Minv);\n }\n}\n\nfn localToRotated(vLocal: vec3f, rotation: LocalFrameRotation) -> vec3f {\n let xyRot = rotation.M * vLocal.xy;\n return vec3f(xyRot.x, xyRot.y, vLocal.z);\n}\n\nfn rotatedToLocal(vRotated: vec3f, rotation: LocalFrameRotation) -> vec3f {\n let xyLocal = rotation.Minv * vRotated.xy;\n return vec3f(xyLocal.x, xyLocal.y, vRotated.z);\n}\n\nstruct LobeWeights {\n m: array,\n}\n\nstruct LobeAlbedos {\n m: array,\n}\n\nstruct LobeProbs {\n m: array,\n}\n\nstruct LobePDFs {\n m: array,\n}\n\nstruct LobeData {\n weights: LobeWeights,\n albedos: LobeAlbedos,\n probs: LobeProbs,\n}\n\n// todo: implement\nfn placeholderBrdfAlbedo() -> Color {\n return Color(0.0, 0.0, 0.0);\n}\n\nfn specularNDFRoughness(material: Material) -> vec2f {\n let rsqr = material.specularRoughness * material.specularRoughness;\n let specularAnisotropyInv = 1.0 - material.specularAnisotropy;\n let alphaX = rsqr * sqrt(2.0/(1.0+(specularAnisotropyInv*specularAnisotropyInv)));\n let alphaY = (1.0 - material.specularAnisotropy) * alphaX;\n\n let minAlpha = 1.0e-4;\n return vec2f(max(alphaX, minAlpha), max(alphaY, minAlpha));\n}\n\nfn metalBrdfEvaluate(pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, material: Material, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) {\n (*pdfWoutputL) = PDF_EPSILON;\n return vec3f(0.0);\n }\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n let woutputR = localToRotated(woutputL, rotation);\n\n let alpha = specularNDFRoughness(material);\n\n let mR = normalize(winputR + woutputR);\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z);\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = max(PDF_EPSILON, DV * dwhDwo);\n\n let FnoFilm = fresnelF82Tint(abs(dot(winputR, mR)), material.baseWeight * material.baseColor, material.specularWeight * material.specularColor);\n\n // todo: thin film workflow\n\n let F = FnoFilm;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n return F * D * G2 * max(4.0*abs(woutputL.z)*abs(winputL.z), DENOM_TOLERANCE);\n}\n\nfn metalBrdfSample(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr, woutputL: ptr, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n (*pdfWoutputL) = PDF_EPSILON;\n return vec3f(0.0);\n }\n\n let alpha = specularNDFRoughness(material);\n\n var rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n var winputR = localToRotated(winputL, rotation);\n\n let mR = ggxNDFSample(winputR, alpha, seed);\n\n let woutputR = -winputR + 2.0*dot(winputR, mR)*mR;\n if (winputR.z * woutputR.z < FLT_EPSILON) {\n return vec3f(0.0);\n }\n (*woutputL) = rotatedToLocal(woutputR, rotation);\n\n let D = ggxNDF(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z); // todo: should latter max term use abs for .z?\n \n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = max(PDF_EPSILON, DV * dwhDwo);\n\n // todo: implement thin film workflow\n let F_nofilm = fresnelF82Tint(abs(dot(winputR, mR)), material.baseWeight * material.baseColor, material.specularWeight * material.specularColor);\n let F = F_nofilm;\n \n let G2 = ggxG2(winputR, woutputR, alpha);\n \n return F * D * G2 / max(4.0*abs(woutputL.z)*abs(winputL.z), DENOM_TOLERANCE);\n}\n\nfn metalBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> Color {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n\n let numSamples = 1;\n var albedo = vec3f(0.0);\n for (var n=0; n RADIANCE_EPSILON) {\n albedo += f * abs(woutputL.z) / max(PDF_EPSILON, pdfWoutputL);\n }\n }\n\n albedo /= f32(numSamples);\n return albedo;\n}\n\nfn diffuseBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n return material.baseWeight * material.baseColor;\n}\n\n// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl\nfn fujiiMaterialX(albedo: vec3f, roughness: f32, V: vec3f, L: vec3f) -> vec3f {\n let NdotV = V.z;\n let NdotL = L.z;\n let s = dot(L, V) - NdotV * NdotL;\n let stinv = select(0.0, s / max(NdotL, NdotV), s > 0.0f);\n let sigma = roughness;\n let sigma2 = sqr(sigma);\n let A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33));\n let B = 0.45 * sigma2 / (sigma2 + 0.09);\n return albedo * NdotL / PI * (A + B * stinv);\n}\n\nfn diffuseBrdfEvalImplementation(woutputL: vec3f, winputL: vec3f, material: Material) -> vec3f {\n let albedo = material.baseWeight * material.baseColor;\n let V = winputL;\n let L = woutputL;\n let NdotL = max(FLT_EPSILON, abs(L.z));\n \n return fujiiMaterialX(albedo, material.baseDiffuseRoughness, V, L) / NdotL;\n}\n\nfn diffuseBrdfEvaluate(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) {\n // todo: reset pdfWoutputL?\n return vec3f(0.0);\n }\n (*pdfWoutputL) = pdfHemisphereCosineWeighted(woutputL);\n return diffuseBrdfEvalImplementation(winputL, woutputL, material);\n}\n\nfn diffuseBrdfSample(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: ptr, pdfWoutputL: ptr, seed: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n (*woutputL) = sampleHemisphereCosineWeighted(pdfWoutputL, seed);\n return diffuseBrdfEvalImplementation(winputL, *woutputL, material);\n}\n\nfn fresnelDielectricPolarizations(mui: f32, etaTi: f32) -> vec2f {\n let mut2 = sqr(etaTi) - (1.0 - sqr(mui));\n if (mut2 <= 0.0) {\n return vec2f(1.0);\n }\n\n let mut1 = sqrt(mut2) / etaTi;\n let rs = (mui - etaTi*mut1) / (mui + etaTi*mut1);\n let rp = (mut1 - etaTi*mui) / (mut1 + etaTi*mui);\n return vec2f(rs, rp);\n}\n\nfn fresnelDielectricReflectance(mui: f32, etaTi: f32) -> f32 {\n let r = fresnelDielectricPolarizations(mui, etaTi);\n return 0.5 * dot(r, r);\n}\n\nfn specularBrdfSample(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr, woutputL: ptr, pdfWoutputL: ptr) -> vec3f {\n let beamOutgoingL = winputL;\n let externalReflection = beamOutgoingL.z > 0.0;\n\n let etaIe = specularIorRatio(material);\n let etaTiRefl = select(1.0/etaIe, etaIe, externalReflection);\n if (abs(etaTiRefl - 1.0) < IOR_EPSILON) {\n // (*pdfWoutputL) = PDF_EPSILON; // todo: reset?\n return vec3f(0.0);\n }\n\n let tint = material.specularColor;\n\n let alpha = specularNDFRoughness(material);\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n\n var mR: vec3f;\n if (winputR.z > 0.0) {\n mR = ggxNDFSample(winputR, alpha, seed);\n } else {\n var winputRReflected = winputR;\n winputRReflected.z = -winputRReflected.z;\n mR = ggxNDFSample(winputRReflected, alpha, seed);\n mR.z = -mR.z;\n }\n\n var woutputR = -winputR + 2.0*dot(winputR, mR)*mR;\n if (winputR.z * woutputR.z < 0.0) {\n (*pdfWoutputL) = 1.0;\n return vec3f(0.0);\n }\n\n (*woutputL) = rotatedToLocal(woutputR, rotation);\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * abs(dot(winputR, mR)) / max(DENOM_TOLERANCE, abs(winputR.z));\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = DV * dwhDwo;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n // todo: coat workflow\n let F = vec3f(fresnelDielectricReflectance(abs(dot(winputR, mR)), etaTiRefl));\n \n let f = F * D * G2 / max(4.0 * abs(woutputL.z) * abs(winputL.z), DENOM_TOLERANCE);\n\n return f * tint;\n}\n\nfn specularBrdfEvaluate(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, pdfWoutputL: ptr) -> vec3f {\n let transmitted = woutputL.z * winputL.z < 0.0;\n if (transmitted) {\n // (*pdfWoutputL) = PDF_EPSILON; todo: reset?\n return vec3f(0.0);\n }\n\n let beamOutgoingL = winputL;\n let externalReflection = beamOutgoingL.z > 0.0;\n\n let etaIe = specularIorRatio(material);\n let etaTiRefl = select(1.0/etaIe, etaIe, externalReflection);\n if (abs(etaTiRefl - 1.0) < IOR_EPSILON) {\n return vec3f(0.0);\n }\n\n let tint = material.specularColor;\n\n let alpha = specularNDFRoughness(material);\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n let woutputR = localToRotated(woutputL, rotation);\n\n let mR = normalize(woutputR + winputR);\n\n if (dot(mR, winputR) * winputR.z < 0.0 || dot(mR, woutputR) * woutputR.z < 0.0) {\n return vec3f(0.0);\n }\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z);\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = DV * dwhDwo;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n // todo: coat workflow\n let F = vec3f(fresnelDielectricReflectance(abs(dot(winputR, mR)), etaTiRefl));\n\n let f = F * D * G2 / max(4.0 * abs(woutputL.z) * abs(winputL.z), DENOM_TOLERANCE);\n return f * tint;\n}\n\nfn etaS(material: Material) -> f32 {\n const ambientIor = 1.0;\n let coatIorAverage = mix(ambientIor, material.coatIor, material.coatWeight);\n let etaS = material.specularIor / coatIorAverage;\n return etaS;\n}\n\nfn fresnelReflNormalIncidence(material: Material) -> f32 {\n let etaS = etaS(material);\n let Fs = sqr((etaS - 1.0)/(etaS + 1.0));\n return Fs;\n}\n\nfn specularIorRatio(material: Material) -> f32 {\n let Fs = fresnelReflNormalIncidence(material);\n let xiS = clamp(material.specularWeight, 0.0, 1.0/max(Fs, DENOM_TOLERANCE));\n let etaS = etaS(material);\n let temp = min(1.0, sign(etaS - 1.0) * sqrt(xiS * Fs));\n let etaSPrime = (1.0 + temp) / max(1.0 - temp, DENOM_TOLERANCE);\n return etaSPrime;\n}\n\nfn specularBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> vec3f {\n let etaIe = specularIorRatio(material);\n if (abs(etaIe - 1.0) < IOR_EPSILON) {\n return vec3f(0.0);\n }\n\n const samples = 1;\n var albedo = vec3f(0.0);\n for (var n = 0; n < samples; n += 1) {\n var woutputL: vec3f;\n var pdfWoutputL: f32;\n var f = specularBrdfSample(material, pW, basis, winputL, seed, &woutputL, &pdfWoutputL);\n if (length(f) > RADIANCE_EPSILON) {\n albedo += f * abs(woutputL.z) / max(DENOM_TOLERANCE, pdfWoutputL);\n }\n }\n albedo /= f32(samples);\n\n return albedo;\n}\n\nstruct WeightsAndAlbedo {\n weights: LobeWeights,\n albedos: LobeAlbedos,\n}\n\nfn openPbrLobeWeights(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr) -> WeightsAndAlbedo {\n let F = 0.0; // todo: move to material definition fuzzWeight\n let C = material.coatWeight;\n let M = material.baseMetalness;\n let T = 0.0; // todo: move to material definition transmissionWeight\n let S = 0.0; // todo: move to material definition subsurfaceWeight\n\n let coated = C > 0.0;\n let metallic = M > 0.0;\n let fullyMetallic = M == 1.0;\n let transmissive = T > 0.0;\n let fullyTransmissive = T == 1.0;\n let subsurfaced = S > 0.0;\n let fullySubsurfaced = S == 1.0;\n\n var albedos = LobeAlbedos();\n albedos.m[ID_COAT_BRDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), coated);\n albedos.m[ID_META_BRDF] = select(vec3f(0.0), metalBrdfAlbedo(material, pW, basis, winputL, seed), metallic);\n albedos.m[ID_SPEC_BRDF] = select(vec3f(0.0), specularBrdfAlbedo(material, pW, basis, winputL, seed), !fullyMetallic);\n albedos.m[ID_SPEC_BTDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), !fullyMetallic && transmissive);\n albedos.m[ID_DIFF_BRDF] = select(vec3f(0.0), diffuseBrdfAlbedo(material, pW, basis, winputL, seed), !fullyMetallic && !fullyTransmissive && !fullySubsurfaced);\n albedos.m[ID_SSSC_BTDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), !fullyMetallic && !fullyTransmissive && subsurfaced);\n\n var weights = LobeWeights();\n\n weights.m[ID_FUZZ_BRDF] = vec3f(0.0); // todo: check\n\n let wCoatedBase = vec3f(1.0); // todo: check \n\n weights.m[ID_COAT_BRDF] = wCoatedBase * C;\n\n // todo: implement coat workflow\n let baseDarkening = vec3f(1.0); // todo: check\n let materialCoatColor = vec3f(1.0); // todo: move to material definition (coat_color)\n let wBaseSubstrate = wCoatedBase * mix(vec3f(1.0), baseDarkening * materialCoatColor * (vec3(1.0) - albedos.m[ID_COAT_BRDF]), C);\n\n weights.m[ID_META_BRDF] = wBaseSubstrate * M;\n\n let wDielectricBase = wBaseSubstrate * vec3f(max(0.0, 1.0 - M));\n\n weights.m[ID_SPEC_BRDF] = wDielectricBase;\n\n weights.m[ID_SPEC_BTDF] = wDielectricBase * T;\n\n let wOpaqueDielectricBase = wDielectricBase * (1.0 - T);\n\n weights.m[ID_SSSC_BTDF] = wOpaqueDielectricBase * S;\n\n weights.m[ID_DIFF_BRDF] = wOpaqueDielectricBase * (1.0 - S) * (vec3f(1.0) - albedos.m[ID_SPEC_BRDF]);\n\n return WeightsAndAlbedo(\n weights,\n albedos\n );\n}\n\n\nfn openPbrLobeProbabilities(weights: LobeWeights, albedos: LobeAlbedos) -> LobeProbs {\n var probs = LobeProbs();\n var Wtotal = 0.0;\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n probs.m[lobeId] = length(weights.m[lobeId] * albedos.m[lobeId]);\n Wtotal += probs.m[lobeId];\n }\n Wtotal = max(DENOM_TOLERANCE, Wtotal);\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n probs.m[lobeId] /= Wtotal;\n }\n return probs;\n}\n\nfn openPbrPrepare(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr) -> LobeData {\n let weightsAndAlbedo = openPbrLobeWeights(pW, basis, winputL, material, seed);\n let probs = openPbrLobeProbabilities(weightsAndAlbedo.weights, weightsAndAlbedo.albedos);\n\n return LobeData(\n weightsAndAlbedo.weights,\n weightsAndAlbedo.albedos,\n probs,\n );\n}\n\nconst PDF_EPSILON = 1.0e-6;\nconst IOR_EPSILON = 1.0e-5;\nconst RAY_OFFSET = 1.0e-4;\n\nfn pdfHemisphereCosineWeighted(wiL: vec3f) -> f32 {\n if (wiL.z <= PDF_EPSILON) {\n return PDF_EPSILON / PI;\n }\n return wiL.z / PI;\n}\n\nfn sampleHemisphereCosineWeighted(pdf: ptr, seed: ptr) -> vec3f {\n let r = sqrt(randomF32(seed));\n let theta = 2.0 * PI * randomF32(seed);\n let x = r * cos(theta);\n let y = r * sin(theta);\n let z = sqrt(max(0.0, 1.0 - x*x - y*y));\n (*pdf) = max(PDF_EPSILON, abs(z) / PI);\n return vec3f(x, y, z);\n}\n\nfn skyPdf(woutputL: vec3f, woutputWs: vec3f) -> f32 {\n return pdfHemisphereCosineWeighted(woutputL);\n}\n\nfn sunPdf(woutputL: vec3f, woutputW: vec3f) -> f32 {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n if (dot(woutputW, uniformData.sunDirection) < cos(thetaMax)) {\n return 0.0;\n }\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n return 1.0 / solidAngle;\n}\n\nfn sunTotalPower() -> f32 {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n return length(uniformData.sunPower * uniformData.sunColor) * solidAngle;\n}\n\nfn skyTotalPower() -> f32 {\n return length(uniformData.skyPower * uniformData.skyColor) * 2.0 * PI;\n}\n\nfn sunRadiance(woutputW: vec3f) -> vec3f {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n if (dot(woutputW, uniformData.sunDirection) < cos(thetaMax)) {\n return vec3f(0.0);\n }\n return uniformData.sunPower * uniformData.sunColor;\n}\n\nfn skyRadiance() -> vec3f {\n return uniformData.skyPower * uniformData.skyColor;\n}\n\nfn lightPdf(shadowW: vec3f, basis: Basis) -> f32 {\n let shadowL = worldToLocal(shadowW, basis);\n let pdfSky = skyPdf(shadowL, shadowW);\n let pdfSun = sunPdf(shadowL, shadowW);\n let wSun = sunTotalPower();\n let wSky = skyTotalPower();\n let pSun = wSun / (wSun + wSky);\n let pSky = max(0.0, 1.0 - pSun);\n let lightPdf = pSun * pdfSun + pSky * pdfSky;\n \n return lightPdf;\n}\n\nfn powerHeuristic(a: f32, b: f32) -> f32 {\n return pow(a, 2) / max(DENOM_TOLERANCE, pow(a, 2) + pow(b, 2));\n}\n\nfn brdfSamplePlaceholder() -> vec3f {\n return vec3f(0.0);\n}\n\nfn brdfEvaluatePlaceholder() -> vec3f {\n return vec3f(0.0);\n}\n\nfn openpbrBsdfEvaluateLobes(pW: vec3f, basis: Basis, material: Material, winputL: vec3f, woutputL: vec3f, skipLobeId: i32, lobeData: LobeData, pdfs: ptr) -> vec3f {\n var f = vec3f(0.0);\n if (skipLobeId != ID_FUZZ_BRDF && lobeData.probs.m[ID_FUZZ_BRDF] > 0.0) {\n f += vec3f(0.0);\n }\n if (skipLobeId != ID_COAT_BRDF && lobeData.probs.m[ID_COAT_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_COAT_BRDF] * brdfEvaluatePlaceholder();\n }\n if (skipLobeId != ID_META_BRDF && lobeData.probs.m[ID_META_BRDF] > 0.0) {\n f += metalBrdfEvaluate(pW, basis, winputL, woutputL, material, &pdfs.m[ID_META_BRDF]);\n }\n if (skipLobeId != ID_SPEC_BRDF && lobeData.probs.m[ID_SPEC_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_SPEC_BRDF] * specularBrdfEvaluate(material, pW, basis, winputL, woutputL, &pdfs.m[ID_SPEC_BRDF]);\n }\n if (skipLobeId != ID_DIFF_BRDF && lobeData.probs.m[ID_DIFF_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_DIFF_BRDF] * diffuseBrdfEvaluate(material, pW, basis, winputL, woutputL, &pdfs.m[ID_DIFF_BRDF]);\n }\n\n let evalSpecBtdf = skipLobeId != ID_SPEC_BTDF && lobeData.probs.m[ID_SPEC_BTDF] > 0.0;\n let evalSsscBtdf = skipLobeId != ID_SSSC_BTDF && lobeData.probs.m[ID_SSSC_BTDF] > 0.0;\n let evalTransmission = evalSpecBtdf || evalSsscBtdf;\n if (evalTransmission) {\n // todo: implement\n }\n\n return f;\n}\n\nfn openpbrBsdfTotalPdf(pdfs: LobePDFs, lobeData: LobeData) -> f32 {\n var pdfWoutputL = 0.0;\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n pdfWoutputL += lobeData.probs.m[lobeId] * pdfs.m[lobeId];\n }\n return pdfWoutputL;\n}\n\nconst ID_FUZZ_BRDF = 0;\nconst ID_COAT_BRDF = 1;\nconst ID_META_BRDF = 2;\nconst ID_SPEC_BRDF = 3;\nconst ID_SPEC_BTDF = 4;\nconst ID_DIFF_BRDF = 5;\nconst ID_SSSC_BTDF = 6;\nconst NUM_LOBES = 7;\n\nfn sampleBsdf(pW: vec3f, basis: Basis, winputL: vec3f, lobeData: LobeData, material: Material, woutputL: ptr, pdfWoutputL: ptr, seed: ptr) -> vec3f {\n let X = randomF32(seed);\n var CDF = 0.0;\n\n //(*woutputL) = vec3f(lobeData.probs.m[3],lobeData.probs.m[4],lobeData.probs.m[5]);\n //(*woutputL) = vec3f(lobeData.probs.m[3],0,0);\n //return vec3f(0.0);\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n CDF += lobeData.probs.m[lobeId];\n if (X < CDF) {\n var pdfLobe: f32;\n var fLobe: vec3f;\n if (lobeId == ID_FUZZ_BRDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_COAT_BRDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_META_BRDF) {\n fLobe = metalBrdfSample(pW, basis, winputL, material, seed, woutputL, &pdfLobe);\n }\n else if (lobeId == ID_SPEC_BRDF) {\n fLobe = specularBrdfSample(material, pW, basis, winputL, seed, woutputL, &pdfLobe);\n }\n else if (lobeId == ID_SPEC_BTDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_SSSC_BTDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_DIFF_BRDF) {\n fLobe = diffuseBrdfSample(material, pW, basis, winputL, woutputL, &pdfLobe, seed);\n }\n else { break; }\n //fLobe = specularBrdfSample(material, pW, basis, winputL, seed, woutputL, &pdfLobe);\n //let basis2 = makeBasis(vec3(0.33,0.33,0.33));\n //let pW2 = vec3f(0.0);\n //let winputL2 = vec3f(0.33, 0.33, 0.33);\n //var seed2 = 3u;\n //fLobe = specularBrdfSample(material, pW2, basis2, winputL2, &seed2, woutputL, &pdfLobe);\n //fLobe = metalBrdfSample(pW2, basis2, winputL2, material, &seed2, woutputL, &pdfLobe);\n //fLobe = vec3f(0.33);\n //return fLobe;\n //fLobe = diffuseBrdfSample(material, pW, basis, winputL, woutputL, &pdfLobe, seed);\n\n var pdfs: LobePDFs;\n var skipLobeId = lobeId;\n var f = openpbrBsdfEvaluateLobes(pW, basis, material, winputL, *woutputL, skipLobeId, lobeData, &pdfs);\n f += lobeData.weights.m[lobeId] * fLobe;\n\n pdfs.m[lobeId] = pdfLobe;\n (*pdfWoutputL) = openpbrBsdfTotalPdf(pdfs, lobeData);\n \n let transmitted = woutputL.z * winputL.z < 0.0;\n let transmittedInside = transmitted && woutputL.z < 0.0;\n if (!transmittedInside) {\n return f;\n }\n\n // todo: volume\n\n return f;\n }\n }\n\n (*pdfWoutputL) = 1.0;\n return vec3f(0);\n}\n\nfn evaluateBsdf(pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, lobeData: LobeData, material: Material, pdfWoutputL: ptr) -> vec3f {\n var pdfs: LobePDFs;\n let f = openpbrBsdfEvaluateLobes(pW, basis, material, winputL, woutputL, -1, lobeData, &pdfs);\n (*pdfWoutputL) = openpbrBsdfTotalPdf(pdfs, lobeData);\n \n return f;\n}\n\nfn evaluateEdf(material: Material) -> vec3f {\n return material.emissionColor * material.emissionLuminance;\n}\n\nfn sunSample(basis: Basis, sunBasis: Basis, woutputL: ptr, woutputW: ptr, pdfDir: ptr, seed: ptr) -> vec3f {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n let theta = thetaMax * sqrt(randomF32(seed));\n let cosTheta = cos(theta);\n let sinTheta = sqrt(max(0, 1.0-cosTheta*cosTheta));\n let phi = 2.0 * PI * randomF32(seed);\n let cosPhi = cos(phi);\n let sinPhi = sin(phi);\n let x = sinTheta * cosPhi;\n let y = sinTheta * sinPhi;\n let z = cosTheta;\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n *pdfDir = 1.0 / solidAngle;\n *woutputW = localToWorld(vec3f(x, y, z), sunBasis);\n *woutputL = worldToLocal(*woutputW, basis);\n return uniformData.sunPower * uniformData.sunColor;\n}\n\nfn skySample(basis: Basis, woutputL: ptr, woutputW: ptr, pdfDir: ptr, seed: ptr) -> vec3f {\n *woutputL = sampleHemisphereCosineWeighted(pdfDir, seed);\n *woutputW = localToWorld(*woutputL, basis);\n return skyRadiance();\n}\n\nfn getDirectLighting(pW: vec3f, basis: Basis, sunBasis: Basis, shadowL: ptr, shadowW: ptr, lightPdf: ptr, seed: ptr) -> vec3f {\n var Li: vec3f;\n\n let wSun = sunTotalPower();\n let wSky = skyTotalPower();\n let pSun = wSun / (wSun + wSky);\n let pSky = max(0.0, 1.0 - pSun);\n var pdfSun: f32;\n var pdfSky: f32;\n let r = randomF32(seed);\n if (r < pSun) {\n Li = sunSample(basis, sunBasis, shadowL, shadowW, &pdfSun, seed);\n Li += skyRadiance();\n pdfSky = skyPdf(*shadowL, *shadowW);\n } else {\n Li = skySample(basis, shadowL, shadowW, &pdfSky, seed);\n Li += sunRadiance(*shadowW);\n pdfSun = sunPdf(*shadowL, *shadowW);\n }\n *lightPdf = pSun * pdfSun + pSky * pdfSky;\n\n if (shadowL.z < 0) {\n return vec3f(0);\n }\n if (maxVec3(Li) < RADIANCE_EPSILON) {\n return vec3f(0);\n }\n\n let occluded = isOccluded(Ray(pW, *shadowW), TRIANGLE_MAX_DISTANCE_THRESHOLD);\n let visibility = select(1.0, 0.0, occluded);\n\n return visibility * Li;\n}\n\nfn isOccluded(ray: Ray, maxDistance: f32) -> bool {\n var hitRecord = HitRecord();\n hitRecord.t = maxDistance;\n return hittableListHit(ray, Interval(TRIANGLE_MIN_DISTANCE_THRESHOLD, maxDistance), &hitRecord);\n}\n\nconst TRIANGLE_MIN_DISTANCE_THRESHOLD = 0.0005;\nconst TRIANGLE_MAX_DISTANCE_THRESHOLD = 10e37f;\n\nfn rayColor(cameraRay: Ray, seed: ptr, sunBasis: Basis) -> vec4f {\n var hitRecord: HitRecord;\n var ray = cameraRay;\n\n var throughput = vec3f(1.0);\n var L = vec3f(0.0);\n var bsdfPdfContinuation = 1.0;\n\n var dW = ray.direction;\n var pW = ray.origin;\n\n var basis: Basis;\n\n var inDielectric = false;\n\n for (var i = 0; i < uniformData.maxRayDepth; i += 1) {\n // todo: handle setting t nicely\n hitRecord.t = TRIANGLE_MAX_DISTANCE_THRESHOLD;\n let hit = hittableListHit(ray, Interval(TRIANGLE_MIN_DISTANCE_THRESHOLD, TRIANGLE_MAX_DISTANCE_THRESHOLD), &hitRecord);\n\n // todo: consider normal handling\n\n if (!hit) {\n // did not hit anything until infinity\n\n var misWeightLight = 1.0;\n \n if (i > 0) {\n let lightPdf = lightPdf(\n dW,\n basis\n );\n misWeightLight = powerHeuristic(bsdfPdfContinuation, lightPdf);\n } else {\n if (uniformData.enableClearColor == 1) {\n return vec4f(uniformData.clearColor, 0.0);\n }\n }\n L += throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n \n /*\n // metal-wall configuraiton\n if (i > 2) {\n L += 1.0*throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n } else if (i > 1) {\n L += 1.3*throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n } else {\n L += 2.7 * throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n }*/\n \n break;\n }\n\n let material = materials[hitRecord.material.index];\n\n // Surface Normal\n var NsW = hitRecord.normal;\n // Geometric Normal todo: distinguish between geometric and shading normal\n var NgW = NsW;\n // Tangent\n let TsW = normalToTangent(NsW);\n let baryCoords = vec3f(0.0); // todo: implement\n \n pW = hitRecord.point;\n\n if (\n (inDielectric && dot(NsW, dW) < 0.0) ||\n (!inDielectric && dot(NsW, dW) > 0.0)) {\n NsW = -NsW;\n }\n\n if (dot(NgW, NsW) < 0.0) {\n NgW = -NgW;\n }\n\n basis = makeBasisFull(NgW, TsW, baryCoords);\n\n let winputW = -dW;\n let winputL = worldToLocal(winputW, basis);\n\n let lobeData = openPbrPrepare(pW, basis, winputL, material, seed);\n\n var woutputL: vec3f;\n let f = sampleBsdf(pW, basis, winputL, lobeData, material, &woutputL, &bsdfPdfContinuation, seed);\n let woutputW = localToWorld(woutputL, basis);\n let surfaceThroughput = f / max(PDF_EPSILON, bsdfPdfContinuation) * abs(dot(woutputW, basis.nW));\n dW = woutputW;\n\n L += throughput * evaluateEdf(material);\n\n pW += NgW * sign(dot(dW, NgW)) * RAY_OFFSET;\n\n ray = Ray(pW, dW);\n\n var transmitted = dot(winputW, NgW) * dot(dW, NgW) < 0.0;\n if (transmitted) {\n inDielectric = !inDielectric;\n }\n\n if (!inDielectric && !transmitted) {\n var shadowL: vec3f;\n var shadowW: vec3f;\n var lightPdf: f32;\n let Li = getDirectLighting(pW, basis, sunBasis, &shadowL, &shadowW, &lightPdf, seed);\n if (maxVec3(Li) > RADIANCE_EPSILON) {\n var bsdfPdfShadow = PDF_EPSILON;\n let fShadow = evaluateBsdf(pW, basis, winputL, shadowL, lobeData, material, &bsdfPdfShadow);\n let misWeightLight = powerHeuristic(lightPdf, bsdfPdfShadow);\n L += throughput * misWeightLight * fShadow * abs(dot(shadowW, basis.nW)) * Li / max(PDF_EPSILON, lightPdf);\n }\n }\n\n throughput *= surfaceThroughput;\n\n // CODE#RUSSIAN-ROULETTE\n // Russian Roulette\n if (maxVec3(throughput) < 1.0 && i > 1) {\n let q = max(0.0, 1.0 - maxVec3(throughput));\n if (randomF32(seed) < q) {\n break;\n }\n throughput /= 1.0 - q;\n }\n }\n\n return vec4f(L, 1.0);\n}\n\nfn writeColor(pixelColor: vec4f, x: i32, y: i32, samples: i32) {\n let previousColor = textureLoad(readTexture, vec2(x, y));\n let previousColorAdjusted = previousColor * f32(uniformData.priorSamples);\n let samplesPerPixel = uniformData.samplesPerPixel;\n let scale = 1.0 / f32(uniformData.priorSamples + samplesPerPixel);\n let adjustedColor = (pixelColor + previousColorAdjusted) * scale;\n textureStore(texture, vec2(x, y), adjustedColor);\n}\n\n@must_use\nfn identityMatrix() -> mat4x4 {\n return mat4x4(\n 1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n}\n\nfn sampleTriangleFilter(xi: f32) -> f32 {\n return select(1.0 - sqrt(2.0 - 2.0 * xi), sqrt(2.0 * xi) - 1.0, xi < 0.5);\n}\n\n// CODE#VIEWPROJECTION\nfn ndcToCameraRay(coord: vec2f, cameraWorld: mat4x4, invProjectionMatrix: mat4x4, seed: ptr) -> Ray {\n let lookDirection = cameraWorld * vec4f(0.0, 0.0, -1.0, 0.0);\n let nearVector = invProjectionMatrix * vec4f(0.0, 0.0, -1.0, 1.0);\n let near = abs(nearVector.z / nearVector.w);\n\n var origin = cameraWorld * vec4f(0.0, 0.0, 0.0, 1.0);\n \n let randomOffset = randomF32(seed) * vec2f(0.5, 0.5);\n\n var direction = invProjectionMatrix * vec4f(coord.x, coord.y, 0.5, 1.0);\n direction /= direction.w;\n direction = cameraWorld * direction - origin;\n\n origin += vec4f(direction.xyz * near / dot(direction, lookDirection), 0);\n /*// orthographic projection, direction is identical for all points, origin differs based on parameters\n\n var direction = vec4f(0.0, 0.0, -1.0, 0.0);\n direction = cameraWorld * direction;\n\n // with increased orthographic size\n origin += vec4f((coord.x - 0.5 + randomOffset.x) * 8.0, (coord.y - 0.5 + randomOffset.y) * 8.0, 0.0, 0.0);\n\n //origin += vec4f(direction.xyz * near / dot(direction, lookDirection), 0);*/\n\n return Ray(\n origin.xyz,\n direction.xyz\n );\n}\n\nfn getPixelJitter(seed: ptr) -> vec2f {\n let jitterX = 0.5 * sampleTriangleFilter(randomF32(seed));\n let jitterY = 0.5 * sampleTriangleFilter(randomF32(seed));\n return vec2f(jitterX, jitterY);\n}\n\n@compute\n@workgroup_size(${maxWorkgroupDimension}, ${maxWorkgroupDimension}, 1)\nfn computeMain(@builtin(global_invocation_id) local_id: vec3) {\n var seed = local_id.x + local_id.y * ${imageWidth};\n seed ^= uniformData.seedOffset;\n \n let i = f32(local_id.x);\n let j = f32(local_id.y);\n \n var pixelColor = vec4f(0.0);\n\n // todo: consider not re-creating the basis every time\n var sunBasis = makeBasis(uniformData.sunDirection);\n \n let samplesPerPixel = i32(uniformData.samplesPerPixel);\n for (var sample = 0; sample < samplesPerPixel; sample += 1) {\n // CODE#ALIASING\n // anti-aliasing\n let pixel = vec2(i, j) + getPixelJitter(&seed);\n let ndc = -1.0 + 2.0*pixel / vec2(${imageWidth}, ${imageHeight});\n \n var ray = ndcToCameraRay(ndc, uniformData.invModelMatrix * uniformData.cameraWorldMatrix, uniformData.invProjectionMatrix, &seed);\n ray.direction = normalize(ray.direction);\n\n pixelColor += rayColor(ray, &seed, sunBasis);\n }\n\n \n writeColor(pixelColor, i32(local_id.x), i32(local_id.y), samplesPerPixel);\n}\n',$i={imageWidth:"imageWidth",imageHeight:"imageHeight",maxWorkgroupDimension:"maxWorkgroupDimension",maxBvhStackDepth:"maxBvhStackDepth"};const Ki="const pos = array(\n // 1\n vec2f(-1.0, -1.0),\n vec2f(1.0, -1.0),\n vec2f(-1.0, 1.0),\n // 2\n vec2f( -1.0, 1.0),\n vec2f( 1.0, -1.0),\n vec2f( 1.0, 1.0),\n);\n\nstruct VertexInput {\n @builtin(vertex_index) instance: u32,\n};\n\nstruct VertexOutput {\n @builtin(position) pos: vec4f,\n @location(0) texcoord: vec2f,\n};\n\nfn convertToZeroOne(position: vec2f) -> vec2f {\n return (position + 1.0) / 2;\n}\n\n@vertex\nfn vertexMain(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let xy = pos[input.instance];\n output.pos = vec4f(xy, 0, 1);\n\n let baseCoord = convertToZeroOne(vec2f(xy.x, -xy.y));\n output.texcoord = vec2f(baseCoord.x, 1.0 - baseCoord.y);\n return output;\n}\n\n@group(0) @binding(0) var texture_sampler: sampler;\n@group(0) @binding(1) var texture: texture_2d;\n\n// CODE#TONE-MAPPER\n// Khronos PBR neutral tone mapper\n// See: https://github.com/KhronosGroup/ToneMapping/blob/main/PBR_Neutral/pbrNeutral.glsl\nfn khronosPBRNeutralToneMapping(colorP: vec3f) -> vec3f {\n var color = colorP;\n let startCompression = 0.8 - 0.04;\n let desaturation = 0.15;\n\n let x = min(color.r, min(color.g, color.b));\n let offset = select(0.04, x - 6.25 * x * x, x < 0.08);\n color -= offset;\n\n let peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) {\n return color;\n }\n\n let d = 1.0 - startCompression;\n let newPeak = 1. - d * d / (peak + d - startCompression);\n color *= newPeak / peak;\n\n let g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n return mix(color, newPeak * vec3(1, 1, 1), g);\n}\n\n@fragment\nfn fragmentMain(input: VertexOutput) -> @location(0) vec4f {\n let hdrColor = textureSample(texture, texture_sampler, input.texcoord);\n\n //return hdrColor;\n\n // respect clear color\n if (hdrColor.a == 0.0) {\n return vec4f(hdrColor.rgb, 0.0);\n }\n\n let tonemappedColor = khronosPBRNeutralToneMapping(hdrColor.rgb);\n return vec4f(tonemappedColor, 1.0);\n}\n";function Qi(t){const e=window.performance.now();return{end(){const n=window.performance.now()-e;return console.log(`${t}: ${n}ms`),n}}}function tr(t){let e,n,s,i=-1,r=0;for(let h=0;h{er(t)&&e.push(t)}));return e}(t),n=function(t,e){void 0===e&&(e=!1);const n=null!==t[0].index,s=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),r={},a={},o=t[0].morphTargetsRelative,l=new nn;let h=0;for(let u=0;ut.geometry)),!0);return{geometry:n,materials:e.map((t=>t.material)).flat(1)}}const sr=(t,e)=>((t+e-1)/e|0)*e;const ir=t=>t&&"number"==typeof t.length&&t.buffer instanceof ArrayBuffer&&"number"==typeof t.byteLength,rr={i32:{numElements:1,align:4,size:4,type:"i32",View:Int32Array},u32:{numElements:1,align:4,size:4,type:"u32",View:Uint32Array},f32:{numElements:1,align:4,size:4,type:"f32",View:Float32Array},f16:{numElements:1,align:2,size:2,type:"u16",View:Uint16Array},vec2f:{numElements:2,align:8,size:8,type:"f32",View:Float32Array},vec2i:{numElements:2,align:8,size:8,type:"i32",View:Int32Array},vec2u:{numElements:2,align:8,size:8,type:"u32",View:Uint32Array},vec2h:{numElements:2,align:4,size:4,type:"u16",View:Uint16Array},vec3i:{numElements:3,align:16,size:12,type:"i32",View:Int32Array},vec3u:{numElements:3,align:16,size:12,type:"u32",View:Uint32Array},vec3f:{numElements:3,align:16,size:12,type:"f32",View:Float32Array},vec3h:{numElements:3,align:8,size:6,type:"u16",View:Uint16Array},vec4i:{numElements:4,align:16,size:16,type:"i32",View:Int32Array},vec4u:{numElements:4,align:16,size:16,type:"u32",View:Uint32Array},vec4f:{numElements:4,align:16,size:16,type:"f32",View:Float32Array},vec4h:{numElements:4,align:8,size:8,type:"u16",View:Uint16Array},mat2x2f:{numElements:4,align:8,size:16,type:"f32",View:Float32Array},mat2x2h:{numElements:4,align:4,size:8,type:"u16",View:Uint16Array},mat3x2f:{numElements:6,align:8,size:24,type:"f32",View:Float32Array},mat3x2h:{numElements:6,align:4,size:12,type:"u16",View:Uint16Array},mat4x2f:{numElements:8,align:8,size:32,type:"f32",View:Float32Array},mat4x2h:{numElements:8,align:4,size:16,type:"u16",View:Uint16Array},mat2x3f:{numElements:8,align:16,size:32,pad:[3,1],type:"f32",View:Float32Array},mat2x3h:{numElements:8,align:8,size:16,pad:[3,1],type:"u16",View:Uint16Array},mat3x3f:{numElements:12,align:16,size:48,pad:[3,1],type:"f32",View:Float32Array},mat3x3h:{numElements:12,align:8,size:24,pad:[3,1],type:"u16",View:Uint16Array},mat4x3f:{numElements:16,align:16,size:64,pad:[3,1],type:"f32",View:Float32Array},mat4x3h:{numElements:16,align:8,size:32,pad:[3,1],type:"u16",View:Uint16Array},mat2x4f:{numElements:8,align:16,size:32,type:"f32",View:Float32Array},mat2x4h:{numElements:8,align:8,size:16,type:"u16",View:Uint16Array},mat3x4f:{numElements:12,align:16,size:48,pad:[3,1],type:"f32",View:Float32Array},mat3x4h:{numElements:12,align:8,size:24,pad:[3,1],type:"u16",View:Uint16Array},mat4x4f:{numElements:16,align:16,size:64,type:"f32",View:Float32Array},mat4x4h:{numElements:16,align:8,size:32,type:"u16",View:Uint16Array},bool:{numElements:0,align:1,size:0,type:"bool",View:Uint32Array}},ar={...rr,"atomic":rr.i32,"atomic":rr.u32,"vec2":rr.vec2i,"vec2":rr.vec2u,"vec2":rr.vec2f,"vec2":rr.vec2h,"vec3":rr.vec3i,"vec3":rr.vec3u,"vec3":rr.vec3f,"vec3":rr.vec3h,"vec4":rr.vec4i,"vec4":rr.vec4u,"vec4":rr.vec4f,"vec4":rr.vec4h,"mat2x2":rr.mat2x2f,"mat2x2":rr.mat2x2h,"mat3x2":rr.mat3x2f,"mat3x2":rr.mat3x2h,"mat4x2":rr.mat4x2f,"mat4x2":rr.mat4x2h,"mat2x3":rr.mat2x3f,"mat2x3":rr.mat2x3h,"mat3x3":rr.mat3x3f,"mat3x3":rr.mat3x3h,"mat4x3":rr.mat4x3f,"mat4x3":rr.mat4x3h,"mat2x4":rr.mat2x4f,"mat2x4":rr.mat2x4h,"mat3x4":rr.mat3x4f,"mat3x4":rr.mat3x4h,"mat4x4":rr.mat4x4f,"mat4x4":rr.mat4x4h},or=(lr=ar,Object.keys(lr));var lr,hr,ur,cr,dr,pr;function mr(t,e,n,s){const{size:i,type:r}=t;try{const{View:t,align:a}=ar[r],o=void 0!==s,l=o?sr(i,a):i,h=l/t.BYTES_PER_ELEMENT;return new t(e,n,h*(o?0===s?(e.byteLength-n)/l:s:1))}catch{throw new Error(`unknown type: ${r}`)}}function fr(t,e,n){const s=n||0,i=e||new ArrayBuffer(function(t){const e=t;if(e.elementType)return e.size;{const n=t,s=e.numElements||1;if(n.fields)return t.size*s;{const e=t,{align:n}=ar[e.type];return s>1?sr(t.size,n)*s:t.size}}}(t)),r=(t,e)=>{const n=t,s=n.elementType;if(s){if(function(t){return!t.fields&&!t.elementType}(s)&&ar[s.type].flatten)return mr(s,i,e,n.numElements);{const{size:a}=xr(t);return function(t,e){return new Array(t).fill(0).map(((t,n)=>e(n)))}(0===n.numElements?(i.byteLength-e)/a:n.numElements,(t=>r(s,e+a*t)))}}if("string"==typeof t)throw Error("unreachable");{const n=t.fields;if(n){const t={};for(const[s,{type:i,offset:a}]of Object.entries(n))t[s]=r(i,e+a);return t}return mr(t,i,e)}};return{views:r(t,s),arrayBuffer:i}}function yr(t,e){if(void 0!==t)if(ir(e)){const n=e;if(1===n.length&&"number"==typeof t)n[0]=t;else if(Array.isArray(t[0])||ir(t[0])){const e=t[0].length,s=3===e?4:e;for(let i=0;i{yr(t,n[e])}))}else{const n=e;for(const[e,s]of Object.entries(t)){const t=n[e];t&&yr(s,t)}}}function gr(t,e,n){void 0===n&&(n=0);const s=t,i=fr(void 0===s.group?t:s.typeDefinition,e,n);return{...i,set(t){yr(t,i.views)}}}function _r(t){const e=t.elementType;if(e)return _r(e);const n=t.fields;if(n)return Object.values(n).reduce(((t,e)=>{let{type:n}=e;return Math.max(t,_r(n))}),0);const{type:s}=t,{align:i}=ar[s];return i}function xr(t){const e=t.elementType;if(e){const t=e.size,n=_r(e);return{unalignedSize:t,align:n,size:sr(t,n)}}const n=t.fields;if(n){const t=Object.values(n).pop();if(0===t.type.size)return xr(t.type)}return{size:0,unalignedSize:0,align:1}}!function(t,e){void 0===t&&(t=[]);const n=new Set;for(const s of or){const i=ar[s];n.has(i)||(n.add(i),i.flatten=t.includes(s)?e:!e)}}();class br{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class wr{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(t){throw new Error("Cannot evaluate node")}evaluateString(t){return this.evaluate(t).toString()}search(t){}searchBlock(t,e){if(t){e(vr.instance);for(const n of t)n instanceof Array?this.searchBlock(n,e):n.search(e);e(kr.instance)}}}class vr extends wr{}vr.instance=new vr;class kr extends wr{}kr.instance=new kr;class Mr extends wr{constructor(){super()}}class Sr extends Mr{constructor(t,e,n,s,i,r){super(),this.calls=new Set,this.name=t,this.args=e,this.returnType=n,this.body=s,this.startLine=i,this.endLine=r}get astNodeType(){return"function"}search(t){this.searchBlock(this.body,t)}}class Tr extends Mr{constructor(t){super(),this.expression=t}get astNodeType(){return"staticAssert"}search(t){this.expression.search(t)}}class Ar extends Mr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"while"}search(t){this.condition.search(t),this.searchBlock(this.body,t)}}class Er extends Mr{constructor(t){super(),this.body=t}get astNodeType(){return"continuing"}search(t){this.searchBlock(this.body,t)}}class Rr extends Mr{constructor(t,e,n,s){super(),this.init=t,this.condition=e,this.increment=n,this.body=s}get astNodeType(){return"for"}search(t){var e,n,s;null===(e=this.init)||void 0===e||e.search(t),null===(n=this.condition)||void 0===n||n.search(t),null===(s=this.increment)||void 0===s||s.search(t),this.searchBlock(this.body,t)}}class Br extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"var"}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}class zr extends Mr{constructor(t,e,n){super(),this.name=t,this.type=e,this.value=n}get astNodeType(){return"override"}search(t){var e;null===(e=this.value)||void 0===e||e.search(t)}}class Pr extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"let"}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}class Lr extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"const"}evaluate(t){return this.value.evaluate(t)}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}!function(t){t.increment="++",t.decrement="--"}(hr||(hr={})),function(t){t.parse=function(e){const n=e;if("parse"==n)throw new Error("Invalid value for IncrementOperator");return t[n]}}(hr||(hr={}));class Ir extends Mr{constructor(t,e){super(),this.operator=t,this.variable=e}get astNodeType(){return"increment"}search(t){this.variable.search(t)}}!function(t){t.assign="=",t.addAssign="+=",t.subtractAssin="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="}(ur||(ur={})),function(t){t.parse=function(t){const e=t;if("parse"==e)throw new Error("Invalid value for AssignOperator");return e}}(ur||(ur={}));class Cr extends Mr{constructor(t,e,n){super(),this.operator=t,this.variable=e,this.value=n}get astNodeType(){return"assign"}search(t){this.variable.search(t),this.value.search(t)}}class Dr extends Mr{constructor(t,e){super(),this.name=t,this.args=e}get astNodeType(){return"call"}search(t){for(const e of this.args)e.search(t);t(this)}}class Nr extends Mr{constructor(t,e){super(),this.body=t,this.continuing=e}get astNodeType(){return"loop"}}class Fr extends Mr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"body"}}class Or extends Mr{constructor(t,e,n,s){super(),this.condition=t,this.body=e,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(t){this.condition.search(t),this.searchBlock(this.body,t),this.searchBlock(this.elseif,t),this.searchBlock(this.else,t)}}class Wr extends Mr{constructor(t){super(),this.value=t}get astNodeType(){return"return"}search(t){var e;null===(e=this.value)||void 0===e||e.search(t)}}class Ur extends Mr{constructor(t){super(),this.name=t}get astNodeType(){return"enable"}}class qr extends Mr{constructor(t){super(),this.extensions=t}get astNodeType(){return"requires"}}class jr extends Mr{constructor(t,e){super(),this.severity=t,this.rule=e}get astNodeType(){return"diagnostic"}}class Vr extends Mr{constructor(t,e){super(),this.name=t,this.type=e}get astNodeType(){return"alias"}}class Gr extends Mr{constructor(){super()}get astNodeType(){return"discard"}}class Hr extends Mr{constructor(){super()}get astNodeType(){return"break"}}class Yr extends Mr{constructor(){super()}get astNodeType(){return"continue"}}class Xr extends Mr{constructor(t){super(),this.name=t}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}}class Zr extends Xr{constructor(t,e,n,s){super(t),this.members=e,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(t){for(let e=0;e":return this.left.evaluate(t)>this.right.evaluate(t)?1:0;case"<=":return this.left.evaluate(t)<=this.right.evaluate(t)?1:0;case">=":return this.left.evaluate(t)>=this.right.evaluate(t)?1:0;case"&&":return this.left.evaluate(t)&&this.right.evaluate(t)?1:0;case"||":return this.left.evaluate(t)||this.right.evaluate(t)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(t){this.left.search(t),this.right.search(t)}}class ma extends wr{constructor(){super()}}class fa extends ma{constructor(t,e){super(),this.selector=t,this.body=e}get astNodeType(){return"case"}search(t){this.searchBlock(this.body,t)}}class ya extends ma{constructor(t){super(),this.body=t}get astNodeType(){return"default"}search(t){this.searchBlock(this.body,t)}}class ga extends wr{constructor(t,e,n){super(),this.name=t,this.type=e,this.attributes=n}get astNodeType(){return"argument"}}class _a extends wr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"elseif"}search(t){this.condition.search(t),this.searchBlock(this.body,t)}}class xa extends wr{constructor(t,e,n){super(),this.name=t,this.type=e,this.attributes=n}get astNodeType(){return"member"}}class ba extends wr{constructor(t,e){super(),this.name=t,this.value=e}get astNodeType(){return"attribute"}}!function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"}(dr||(dr={}));class wa{constructor(t,e,n){this.name=t,this.type=e,this.rule=n}toString(){return this.name}}class va{}cr=va,va.none=new wa("",dr.reserved,""),va.eof=new wa("EOF",dr.token,""),va.reserved={asm:new wa("asm",dr.reserved,"asm"),bf16:new wa("bf16",dr.reserved,"bf16"),do:new wa("do",dr.reserved,"do"),enum:new wa("enum",dr.reserved,"enum"),f16:new wa("f16",dr.reserved,"f16"),f64:new wa("f64",dr.reserved,"f64"),handle:new wa("handle",dr.reserved,"handle"),i8:new wa("i8",dr.reserved,"i8"),i16:new wa("i16",dr.reserved,"i16"),i64:new wa("i64",dr.reserved,"i64"),mat:new wa("mat",dr.reserved,"mat"),premerge:new wa("premerge",dr.reserved,"premerge"),regardless:new wa("regardless",dr.reserved,"regardless"),typedef:new wa("typedef",dr.reserved,"typedef"),u8:new wa("u8",dr.reserved,"u8"),u16:new wa("u16",dr.reserved,"u16"),u64:new wa("u64",dr.reserved,"u64"),unless:new wa("unless",dr.reserved,"unless"),using:new wa("using",dr.reserved,"using"),vec:new wa("vec",dr.reserved,"vec"),void:new wa("void",dr.reserved,"void")},va.keywords={array:new wa("array",dr.keyword,"array"),atomic:new wa("atomic",dr.keyword,"atomic"),bool:new wa("bool",dr.keyword,"bool"),f32:new wa("f32",dr.keyword,"f32"),i32:new wa("i32",dr.keyword,"i32"),mat2x2:new wa("mat2x2",dr.keyword,"mat2x2"),mat2x3:new wa("mat2x3",dr.keyword,"mat2x3"),mat2x4:new wa("mat2x4",dr.keyword,"mat2x4"),mat3x2:new wa("mat3x2",dr.keyword,"mat3x2"),mat3x3:new wa("mat3x3",dr.keyword,"mat3x3"),mat3x4:new wa("mat3x4",dr.keyword,"mat3x4"),mat4x2:new wa("mat4x2",dr.keyword,"mat4x2"),mat4x3:new wa("mat4x3",dr.keyword,"mat4x3"),mat4x4:new wa("mat4x4",dr.keyword,"mat4x4"),ptr:new wa("ptr",dr.keyword,"ptr"),sampler:new wa("sampler",dr.keyword,"sampler"),sampler_comparison:new wa("sampler_comparison",dr.keyword,"sampler_comparison"),struct:new wa("struct",dr.keyword,"struct"),texture_1d:new wa("texture_1d",dr.keyword,"texture_1d"),texture_2d:new wa("texture_2d",dr.keyword,"texture_2d"),texture_2d_array:new wa("texture_2d_array",dr.keyword,"texture_2d_array"),texture_3d:new wa("texture_3d",dr.keyword,"texture_3d"),texture_cube:new wa("texture_cube",dr.keyword,"texture_cube"),texture_cube_array:new wa("texture_cube_array",dr.keyword,"texture_cube_array"),texture_multisampled_2d:new wa("texture_multisampled_2d",dr.keyword,"texture_multisampled_2d"),texture_storage_1d:new wa("texture_storage_1d",dr.keyword,"texture_storage_1d"),texture_storage_2d:new wa("texture_storage_2d",dr.keyword,"texture_storage_2d"),texture_storage_2d_array:new wa("texture_storage_2d_array",dr.keyword,"texture_storage_2d_array"),texture_storage_3d:new wa("texture_storage_3d",dr.keyword,"texture_storage_3d"),texture_depth_2d:new wa("texture_depth_2d",dr.keyword,"texture_depth_2d"),texture_depth_2d_array:new wa("texture_depth_2d_array",dr.keyword,"texture_depth_2d_array"),texture_depth_cube:new wa("texture_depth_cube",dr.keyword,"texture_depth_cube"),texture_depth_cube_array:new wa("texture_depth_cube_array",dr.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new wa("texture_depth_multisampled_2d",dr.keyword,"texture_depth_multisampled_2d"),texture_external:new wa("texture_external",dr.keyword,"texture_external"),u32:new wa("u32",dr.keyword,"u32"),vec2:new wa("vec2",dr.keyword,"vec2"),vec3:new wa("vec3",dr.keyword,"vec3"),vec4:new wa("vec4",dr.keyword,"vec4"),bitcast:new wa("bitcast",dr.keyword,"bitcast"),block:new wa("block",dr.keyword,"block"),break:new wa("break",dr.keyword,"break"),case:new wa("case",dr.keyword,"case"),continue:new wa("continue",dr.keyword,"continue"),continuing:new wa("continuing",dr.keyword,"continuing"),default:new wa("default",dr.keyword,"default"),diagnostic:new wa("diagnostic",dr.keyword,"diagnostic"),discard:new wa("discard",dr.keyword,"discard"),else:new wa("else",dr.keyword,"else"),enable:new wa("enable",dr.keyword,"enable"),fallthrough:new wa("fallthrough",dr.keyword,"fallthrough"),false:new wa("false",dr.keyword,"false"),fn:new wa("fn",dr.keyword,"fn"),for:new wa("for",dr.keyword,"for"),function:new wa("function",dr.keyword,"function"),if:new wa("if",dr.keyword,"if"),let:new wa("let",dr.keyword,"let"),const:new wa("const",dr.keyword,"const"),loop:new wa("loop",dr.keyword,"loop"),while:new wa("while",dr.keyword,"while"),private:new wa("private",dr.keyword,"private"),read:new wa("read",dr.keyword,"read"),read_write:new wa("read_write",dr.keyword,"read_write"),return:new wa("return",dr.keyword,"return"),requires:new wa("requires",dr.keyword,"requires"),storage:new wa("storage",dr.keyword,"storage"),switch:new wa("switch",dr.keyword,"switch"),true:new wa("true",dr.keyword,"true"),alias:new wa("alias",dr.keyword,"alias"),type:new wa("type",dr.keyword,"type"),uniform:new wa("uniform",dr.keyword,"uniform"),var:new wa("var",dr.keyword,"var"),override:new wa("override",dr.keyword,"override"),workgroup:new wa("workgroup",dr.keyword,"workgroup"),write:new wa("write",dr.keyword,"write"),r8unorm:new wa("r8unorm",dr.keyword,"r8unorm"),r8snorm:new wa("r8snorm",dr.keyword,"r8snorm"),r8uint:new wa("r8uint",dr.keyword,"r8uint"),r8sint:new wa("r8sint",dr.keyword,"r8sint"),r16uint:new wa("r16uint",dr.keyword,"r16uint"),r16sint:new wa("r16sint",dr.keyword,"r16sint"),r16float:new wa("r16float",dr.keyword,"r16float"),rg8unorm:new wa("rg8unorm",dr.keyword,"rg8unorm"),rg8snorm:new wa("rg8snorm",dr.keyword,"rg8snorm"),rg8uint:new wa("rg8uint",dr.keyword,"rg8uint"),rg8sint:new wa("rg8sint",dr.keyword,"rg8sint"),r32uint:new wa("r32uint",dr.keyword,"r32uint"),r32sint:new wa("r32sint",dr.keyword,"r32sint"),r32float:new wa("r32float",dr.keyword,"r32float"),rg16uint:new wa("rg16uint",dr.keyword,"rg16uint"),rg16sint:new wa("rg16sint",dr.keyword,"rg16sint"),rg16float:new wa("rg16float",dr.keyword,"rg16float"),rgba8unorm:new wa("rgba8unorm",dr.keyword,"rgba8unorm"),rgba8unorm_srgb:new wa("rgba8unorm_srgb",dr.keyword,"rgba8unorm_srgb"),rgba8snorm:new wa("rgba8snorm",dr.keyword,"rgba8snorm"),rgba8uint:new wa("rgba8uint",dr.keyword,"rgba8uint"),rgba8sint:new wa("rgba8sint",dr.keyword,"rgba8sint"),bgra8unorm:new wa("bgra8unorm",dr.keyword,"bgra8unorm"),bgra8unorm_srgb:new wa("bgra8unorm_srgb",dr.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new wa("rgb10a2unorm",dr.keyword,"rgb10a2unorm"),rg11b10float:new wa("rg11b10float",dr.keyword,"rg11b10float"),rg32uint:new wa("rg32uint",dr.keyword,"rg32uint"),rg32sint:new wa("rg32sint",dr.keyword,"rg32sint"),rg32float:new wa("rg32float",dr.keyword,"rg32float"),rgba16uint:new wa("rgba16uint",dr.keyword,"rgba16uint"),rgba16sint:new wa("rgba16sint",dr.keyword,"rgba16sint"),rgba16float:new wa("rgba16float",dr.keyword,"rgba16float"),rgba32uint:new wa("rgba32uint",dr.keyword,"rgba32uint"),rgba32sint:new wa("rgba32sint",dr.keyword,"rgba32sint"),rgba32float:new wa("rgba32float",dr.keyword,"rgba32float"),static_assert:new wa("static_assert",dr.keyword,"static_assert")},va.tokens={decimal_float_literal:new wa("decimal_float_literal",dr.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new wa("hex_float_literal",dr.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new wa("int_literal",dr.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new wa("uint_literal",dr.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new wa("ident",dr.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new wa("and",dr.token,"&"),and_and:new wa("and_and",dr.token,"&&"),arrow:new wa("arrow ",dr.token,"->"),attr:new wa("attr",dr.token,"@"),attr_left:new wa("attr_left",dr.token,"[["),attr_right:new wa("attr_right",dr.token,"]]"),forward_slash:new wa("forward_slash",dr.token,"/"),bang:new wa("bang",dr.token,"!"),bracket_left:new wa("bracket_left",dr.token,"["),bracket_right:new wa("bracket_right",dr.token,"]"),brace_left:new wa("brace_left",dr.token,"{"),brace_right:new wa("brace_right",dr.token,"}"),colon:new wa("colon",dr.token,":"),comma:new wa("comma",dr.token,","),equal:new wa("equal",dr.token,"="),equal_equal:new wa("equal_equal",dr.token,"=="),not_equal:new wa("not_equal",dr.token,"!="),greater_than:new wa("greater_than",dr.token,">"),greater_than_equal:new wa("greater_than_equal",dr.token,">="),shift_right:new wa("shift_right",dr.token,">>"),less_than:new wa("less_than",dr.token,"<"),less_than_equal:new wa("less_than_equal",dr.token,"<="),shift_left:new wa("shift_left",dr.token,"<<"),modulo:new wa("modulo",dr.token,"%"),minus:new wa("minus",dr.token,"-"),minus_minus:new wa("minus_minus",dr.token,"--"),period:new wa("period",dr.token,"."),plus:new wa("plus",dr.token,"+"),plus_plus:new wa("plus_plus",dr.token,"++"),or:new wa("or",dr.token,"|"),or_or:new wa("or_or",dr.token,"||"),paren_left:new wa("paren_left",dr.token,"("),paren_right:new wa("paren_right",dr.token,")"),semicolon:new wa("semicolon",dr.token,";"),star:new wa("star",dr.token,"*"),tilde:new wa("tilde",dr.token,"~"),underscore:new wa("underscore",dr.token,"_"),xor:new wa("xor",dr.token,"^"),plus_equal:new wa("plus_equal",dr.token,"+="),minus_equal:new wa("minus_equal",dr.token,"-="),times_equal:new wa("times_equal",dr.token,"*="),division_equal:new wa("division_equal",dr.token,"/="),modulo_equal:new wa("modulo_equal",dr.token,"%="),and_equal:new wa("and_equal",dr.token,"&="),or_equal:new wa("or_equal",dr.token,"|="),xor_equal:new wa("xor_equal",dr.token,"^="),shift_right_equal:new wa("shift_right_equal",dr.token,">>="),shift_left_equal:new wa("shift_left_equal",dr.token,"<<=")},va.simpleTokens={"@":cr.tokens.attr,"{":cr.tokens.brace_left,"}":cr.tokens.brace_right,":":cr.tokens.colon,",":cr.tokens.comma,"(":cr.tokens.paren_left,")":cr.tokens.paren_right,";":cr.tokens.semicolon},va.literalTokens={"&":cr.tokens.and,"&&":cr.tokens.and_and,"->":cr.tokens.arrow,"[[":cr.tokens.attr_left,"]]":cr.tokens.attr_right,"/":cr.tokens.forward_slash,"!":cr.tokens.bang,"[":cr.tokens.bracket_left,"]":cr.tokens.bracket_right,"=":cr.tokens.equal,"==":cr.tokens.equal_equal,"!=":cr.tokens.not_equal,">":cr.tokens.greater_than,">=":cr.tokens.greater_than_equal,">>":cr.tokens.shift_right,"<":cr.tokens.less_than,"<=":cr.tokens.less_than_equal,"<<":cr.tokens.shift_left,"%":cr.tokens.modulo,"-":cr.tokens.minus,"--":cr.tokens.minus_minus,".":cr.tokens.period,"+":cr.tokens.plus,"++":cr.tokens.plus_plus,"|":cr.tokens.or,"||":cr.tokens.or_or,"*":cr.tokens.star,"~":cr.tokens.tilde,_:cr.tokens.underscore,"^":cr.tokens.xor,"+=":cr.tokens.plus_equal,"-=":cr.tokens.minus_equal,"*=":cr.tokens.times_equal,"/=":cr.tokens.division_equal,"%=":cr.tokens.modulo_equal,"&=":cr.tokens.and_equal,"|=":cr.tokens.or_equal,"^=":cr.tokens.xor_equal,">>=":cr.tokens.shift_right_equal,"<<=":cr.tokens.shift_left_equal},va.regexTokens={decimal_float_literal:cr.tokens.decimal_float_literal,hex_float_literal:cr.tokens.hex_float_literal,int_literal:cr.tokens.int_literal,uint_literal:cr.tokens.uint_literal,ident:cr.tokens.ident},va.storage_class=[cr.keywords.function,cr.keywords.private,cr.keywords.workgroup,cr.keywords.uniform,cr.keywords.storage],va.access_mode=[cr.keywords.read,cr.keywords.write,cr.keywords.read_write],va.sampler_type=[cr.keywords.sampler,cr.keywords.sampler_comparison],va.sampled_texture_type=[cr.keywords.texture_1d,cr.keywords.texture_2d,cr.keywords.texture_2d_array,cr.keywords.texture_3d,cr.keywords.texture_cube,cr.keywords.texture_cube_array],va.multisampled_texture_type=[cr.keywords.texture_multisampled_2d],va.storage_texture_type=[cr.keywords.texture_storage_1d,cr.keywords.texture_storage_2d,cr.keywords.texture_storage_2d_array,cr.keywords.texture_storage_3d],va.depth_texture_type=[cr.keywords.texture_depth_2d,cr.keywords.texture_depth_2d_array,cr.keywords.texture_depth_cube,cr.keywords.texture_depth_cube_array,cr.keywords.texture_depth_multisampled_2d],va.texture_external_type=[cr.keywords.texture_external],va.any_texture_type=[...cr.sampled_texture_type,...cr.multisampled_texture_type,...cr.storage_texture_type,...cr.depth_texture_type,...cr.texture_external_type],va.texel_format=[cr.keywords.r8unorm,cr.keywords.r8snorm,cr.keywords.r8uint,cr.keywords.r8sint,cr.keywords.r16uint,cr.keywords.r16sint,cr.keywords.r16float,cr.keywords.rg8unorm,cr.keywords.rg8snorm,cr.keywords.rg8uint,cr.keywords.rg8sint,cr.keywords.r32uint,cr.keywords.r32sint,cr.keywords.r32float,cr.keywords.rg16uint,cr.keywords.rg16sint,cr.keywords.rg16float,cr.keywords.rgba8unorm,cr.keywords.rgba8unorm_srgb,cr.keywords.rgba8snorm,cr.keywords.rgba8uint,cr.keywords.rgba8sint,cr.keywords.bgra8unorm,cr.keywords.bgra8unorm_srgb,cr.keywords.rgb10a2unorm,cr.keywords.rg11b10float,cr.keywords.rg32uint,cr.keywords.rg32sint,cr.keywords.rg32float,cr.keywords.rgba16uint,cr.keywords.rgba16sint,cr.keywords.rgba16float,cr.keywords.rgba32uint,cr.keywords.rgba32sint,cr.keywords.rgba32float],va.const_literal=[cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.decimal_float_literal,cr.tokens.hex_float_literal,cr.keywords.true,cr.keywords.false],va.literal_or_ident=[cr.tokens.ident,cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.decimal_float_literal,cr.tokens.hex_float_literal],va.element_count_expression=[cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.ident],va.template_types=[cr.keywords.vec2,cr.keywords.vec3,cr.keywords.vec4,cr.keywords.mat2x2,cr.keywords.mat2x3,cr.keywords.mat2x4,cr.keywords.mat3x2,cr.keywords.mat3x3,cr.keywords.mat3x4,cr.keywords.mat4x2,cr.keywords.mat4x3,cr.keywords.mat4x4,cr.keywords.atomic,cr.keywords.bitcast,...cr.any_texture_type],va.attribute_name=[cr.tokens.ident,cr.keywords.block,cr.keywords.diagnostic],va.assignment_operators=[cr.tokens.equal,cr.tokens.plus_equal,cr.tokens.minus_equal,cr.tokens.times_equal,cr.tokens.division_equal,cr.tokens.modulo_equal,cr.tokens.and_equal,cr.tokens.or_equal,cr.tokens.xor_equal,cr.tokens.shift_right_equal,cr.tokens.shift_left_equal],va.increment_operators=[cr.tokens.plus_plus,cr.tokens.minus_minus];class ka{constructor(t,e,n){this.type=t,this.lexeme=e,this.line=n}toString(){return this.lexeme}isTemplateType(){return-1!=va.template_types.indexOf(this.type)}isArrayType(){return this.type==va.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Ma{constructor(t){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=t??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new ka(va.eof,"",this._line)),this._tokens}scanToken(){let t=this._advance();if("\n"==t)return this._line++,!0;if(this._isWhitespace(t))return!0;if("/"==t){if("/"==this._peekAhead()){for(;"\n"!=t;){if(this._isAtEnd())return!0;t=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let e=1;for(;e>0;){if(this._isAtEnd())return!0;if(t=this._advance(),"\n"==t)this._line++;else if("*"==t){if("/"==this._peekAhead()&&(this._advance(),e--,0==e))return!0}else"/"==t&&"*"==this._peekAhead()&&(this._advance(),e++)}return!0}}const e=va.simpleTokens[t];if(e)return this._addToken(e),!0;let n=va.none;const s=this._isAlpha(t),i="_"===t;if(this._isAlphaNumeric(t)){let e=this._peekAhead();for(;this._isAlphaNumeric(e);)t+=this._advance(),e=this._peekAhead()}if(s){const e=va.keywords[t];if(e)return this._addToken(e),!0}if(s||i)return this._addToken(va.tokens.ident),!0;for(;;){let e=this._findType(t);const s=this._peekAhead();if(">"==t&&(">"==s||"="==s)){let t=!1,n=this._tokens.length-1;for(let e=0;e<5&&n>=0;++e,--n)if(this._tokens[n].type===va.tokens.less_than){n>0&&this._tokens[n-1].isArrayOrTemplateType()&&(t=!0);break}if(t)return this._addToken(e),!0}if(e===va.none){let s=t,i=0;const r=2;for(let t=0;t=this._source.length}_isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}_isAlphaNumeric(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||"_"==t||t>="0"&&t<="9"}_isWhitespace(t){return" "==t||"\t"==t||"\r"==t}_advance(t){void 0===t&&(t=0);let e=this._source[this._current];return t=t||0,t++,this._current+=t,e}_peekAhead(t){return void 0===t&&(t=0),t=t||0,this._current+t>=this._source.length?"\0":this._source[this._current+t]}_addToken(t){const e=this._source.substring(this._start,this._current);this._tokens.push(new ka(t,e,this._line))}}class Sa{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new br,this._deferArrayCountEval=[]}parse(t){this._initialize(t),this._deferArrayCountEval.length=0;const e=[];for(;!this._isAtEnd();){const t=this._global_decl_or_directive();if(!t)break;e.push(t)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const e=t.arrayType,n=t.countNode;if(n instanceof ia){const t=n.name,s=this._context.constants.get(t);if(s)try{const t=s.evaluate(this._context);e.count=t}catch{}}}this._deferArrayCountEval.length=0}return e}_initialize(t){if(t)if("string"==typeof t){const e=new Ma(t);this._tokens=e.scanTokens()}else this._tokens=t;else this._tokens=[];this._current=0}_error(t,e){return{token:t,message:e,toString:function(){return`${e}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==va.eof}_match(t){if(t instanceof wa)return!!this._check(t)&&(this._advance(),!0);for(let e=0,n=t.length;e'.");const e=this._paren_expression();return new oa(t,e)}const t=this._type_decl(),e=this._argument_expression_list();return new la(t,e)}_argument_expression_list(){if(!this._match(va.tokens.paren_left))return null;const t=[];do{if(this._check(va.tokens.paren_right))break;const e=this._short_circuit_or_expression();t.push(e)}while(this._match(va.tokens.comma));return this._consume(va.tokens.paren_right,"Expected ')' for agument list"),t}_optional_paren_expression(){this._match(va.tokens.paren_left);const t=this._short_circuit_or_expression();return this._match(va.tokens.paren_right),new ha([t])}_paren_expression(){this._consume(va.tokens.paren_left,"Expected '('.");const t=this._short_circuit_or_expression();return this._consume(va.tokens.paren_right,"Expected ')'."),new ha([t])}_struct_decl(){if(!this._match(va.keywords.struct))return null;const t=this._currentLine,e=this._consume(va.tokens.ident,"Expected name for struct.").toString();this._consume(va.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(va.tokens.brace_right);){const t=this._attribute(),e=this._consume(va.tokens.ident,"Expected variable name.").toString();this._consume(va.tokens.colon,"Expected ':' for struct member type.");const s=this._attribute(),i=this._type_decl();null!=i&&(i.attributes=s),this._check(va.tokens.brace_right)?this._match(va.tokens.comma):this._consume(va.tokens.comma,"Expected ',' for struct member."),n.push(new xa(e,i,t))}this._consume(va.tokens.brace_right,"Expected '}' after struct body.");const s=this._currentLine,i=new Zr(e,n,t,s);return this._context.structs.set(e,i),i}_global_variable_decl(){const t=this._variable_decl();return t&&this._match(va.tokens.equal)&&(t.value=this._const_expression()),t}_override_variable_decl(){const t=this._override_decl();return t&&this._match(va.tokens.equal)&&(t.value=this._const_expression()),t}_global_const_decl(){if(!this._match(va.keywords.const))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}let n=null;if(this._match(va.tokens.equal)){const t=this._short_circuit_or_expression();if(t instanceof na)n=t;else if(t instanceof ra&&t.initializer instanceof na)n=t.initializer;else try{const e=t.evaluate(this._context);n=new aa(e)}catch{n=t}}const s=new Lr(t.toString(),e,"","",n);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(va.keywords.let))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}let n=null;return this._match(va.tokens.equal)&&(n=this._const_expression()),new Pr(t.toString(),e,"","",n)}_const_expression(){if(this._match(va.const_literal))return new ea(this._previous().toString());const t=this._type_decl();this._consume(va.tokens.paren_left,"Expected '('.");let e=[];for(;!this._check(va.tokens.paren_right)&&(e.push(this._const_expression()),this._check(va.tokens.comma));)this._advance();return this._consume(va.tokens.paren_right,"Expected ')'."),new na(t,e)}_variable_decl(){if(!this._match(va.keywords.var))return null;let t="",e="";this._match(va.tokens.less_than)&&(t=this._consume(va.storage_class,"Expected storage_class.").toString(),this._match(va.tokens.comma)&&(e=this._consume(va.access_mode,"Expected access_mode.").toString()),this._consume(va.tokens.greater_than,"Expected '>'."));const n=this._consume(va.tokens.ident,"Expected variable name");let s=null;if(this._match(va.tokens.colon)){const t=this._attribute();s=this._type_decl(),null!=s&&(s.attributes=t)}return new Br(n.toString(),s,t,e,null)}_override_decl(){if(!this._match(va.keywords.override))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}return new zr(t.toString(),e,null)}_diagnostic(){this._consume(va.tokens.paren_left,"Expected '('");const t=this._consume(va.tokens.ident,"Expected severity control name.");this._consume(va.tokens.comma,"Expected ','");const e=this._consume(va.tokens.ident,"Expected diagnostic rule name.");return this._consume(va.tokens.paren_right,"Expected ')'"),new jr(t.toString(),e.toString())}_enable_directive(){const t=this._consume(va.tokens.ident,"identity expected.");return new Ur(t.toString())}_requires_directive(){const t=[this._consume(va.tokens.ident,"identity expected.").toString()];for(;this._match(va.tokens.comma);){const e=this._consume(va.tokens.ident,"identity expected.");t.push(e.toString())}return new qr(t)}_type_alias(){const t=this._consume(va.tokens.ident,"identity expected.");this._consume(va.tokens.equal,"Expected '=' for type alias.");let e=this._type_decl();if(null===e)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(e.name)&&(e=this._context.aliases.get(e.name).type);const n=new Vr(t.toString(),e);return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([va.tokens.ident,...va.texel_format,va.keywords.bool,va.keywords.f32,va.keywords.i32,va.keywords.u32])){const t=this._advance(),e=t.toString();return this._context.structs.has(e)?this._context.structs.get(e):this._context.aliases.has(e)?this._context.aliases.get(e).type:new Xr(t.toString())}let t=this._texture_sampler_types();if(t)return t;if(this._check(va.template_types)){let t=this._advance().toString(),e=null,n=null;return this._match(va.tokens.less_than)&&(e=this._type_decl(),n=null,this._match(va.tokens.comma)&&(n=this._consume(va.access_mode,"Expected access_mode for pointer").toString()),this._consume(va.tokens.greater_than,"Expected '>' for type.")),new Jr(t,e,n)}if(this._match(va.keywords.ptr)){let t=this._previous().toString();this._consume(va.tokens.less_than,"Expected '<' for pointer.");const e=this._consume(va.storage_class,"Expected storage_class for pointer");this._consume(va.tokens.comma,"Expected ',' for pointer.");const n=this._type_decl();let s=null;return this._match(va.tokens.comma)&&(s=this._consume(va.access_mode,"Expected access_mode for pointer").toString()),this._consume(va.tokens.greater_than,"Expected '>' for pointer."),new $r(t,e.toString(),n,s)}const e=this._attribute();if(this._match(va.keywords.array)){let t=null,n=-1;const s=this._previous();let i=null;if(this._match(va.tokens.less_than)){t=this._type_decl(),this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let e="";if(this._match(va.tokens.comma)){i=this._shift_expression();try{e=i.evaluate(this._context).toString(),i=null}catch{e="1"}}this._consume(va.tokens.greater_than,"Expected '>' for array."),n=e?parseInt(e):0}const r=new Kr(s.toString(),e,t,n);return i&&this._deferArrayCountEval.push({arrayType:r,countNode:i}),r}return null}_texture_sampler_types(){if(this._match(va.sampler_type))return new Qr(this._previous().toString(),null,null);if(this._match(va.depth_texture_type))return new Qr(this._previous().toString(),null,null);if(this._match(va.sampled_texture_type)||this._match(va.multisampled_texture_type)){const t=this._previous();this._consume(va.tokens.less_than,"Expected '<' for sampler type.");const e=this._type_decl();return this._consume(va.tokens.greater_than,"Expected '>' for sampler type."),new Qr(t.toString(),e,null)}if(this._match(va.storage_texture_type)){const t=this._previous();this._consume(va.tokens.less_than,"Expected '<' for sampler type.");const e=this._consume(va.texel_format,"Invalid texel format.").toString();this._consume(va.tokens.comma,"Expected ',' after texel format.");const n=this._consume(va.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(va.tokens.greater_than,"Expected '>' for sampler type."),new Qr(t.toString(),e,n)}return null}_attribute(){let t=[];for(;this._match(va.tokens.attr);){const e=this._consume(va.attribute_name,"Expected attribute name"),n=new ba(e.toString(),null);if(this._match(va.tokens.paren_left)){if(n.value=this._consume(va.literal_or_ident,"Expected attribute value").toString(),this._check(va.tokens.comma)){this._advance();do{const t=this._consume(va.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(t)}while(this._match(va.tokens.comma))}this._consume(va.tokens.paren_right,"Expected ')'")}t.push(n)}for(;this._match(va.tokens.attr_left);){if(!this._check(va.tokens.attr_right))do{const e=this._consume(va.attribute_name,"Expected attribute name"),n=new ba(e.toString(),null);if(this._match(va.tokens.paren_left)){if(n.value=[this._consume(va.literal_or_ident,"Expected attribute value").toString()],this._check(va.tokens.comma)){this._advance();do{const t=this._consume(va.literal_or_ident,"Expected attribute value").toString();n.value.push(t)}while(this._match(va.tokens.comma))}this._consume(va.tokens.paren_right,"Expected ')'")}t.push(n)}while(this._match(va.tokens.comma));this._consume(va.tokens.attr_right,"Expected ']]' after attribute declarations")}return 0==t.length?null:t}}class Ta{constructor(t,e){this.name=t,this.attributes=e,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}}class Aa{constructor(t,e,n){this.name=t,this.type=e,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Ea extends Ta{constructor(t,e){super(t,e),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Ra extends Ta{constructor(t,e){super(t,e),this.count=0,this.stride=0}get isArray(){return!0}}class Ba extends Ta{constructor(t,e,n,s){super(t,n),this.format=e,this.access=s}get isTemplate(){return!0}}!function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"}(pr||(pr={}));class za{constructor(t,e,n,s,i,r,a){this.name=t,this.type=e,this.group=n,this.binding=s,this.attributes=i,this.resourceType=r,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Pa{constructor(t,e){this.name=t,this.type=e}}class La{constructor(t,e){this.align=t,this.size=e}}class Ia{constructor(t,e,n,s){this.name=t,this.type=e,this.locationType=n,this.location=s,this.interpolation=null}}class Ca{constructor(t,e,n,s){this.name=t,this.type=e,this.locationType=n,this.location=s}}class Da{constructor(t,e){void 0===e&&(e=null),this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=t,this.stage=e}}class Na{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}class Fa{constructor(t,e,n,s){this.name=t,this.type=e,this.attributes=n,this.id=s}}class Oa{constructor(t){this.resources=null,this.inUse=!1,this.info=null,this.node=t}}class Wa{constructor(t){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Na,this.functions=[],this._types=new Map,this._functions=new Map,t&&this.update(t)}_isStorageTexture(t){return"texture_storage_1d"==t.name||"texture_storage_2d"==t.name||"texture_storage_2d_array"==t.name||"texture_storage_3d"==t.name}update(t){const e=(new Sa).parse(t);for(const n of e)n instanceof Sr&&this._functions.set(n.name,new Oa(n));for(const n of e)if(n instanceof Zr){const t=this._getTypeInfo(n,null);t instanceof Ea&&this.structs.push(t)}for(const n of e)if(n instanceof Vr)this.aliases.push(this._getAliasInfo(n));else if(n instanceof zr){const t=n,e=this._getAttributeNum(t.attributes,"id",0),s=null!=t.type?this._getTypeInfo(t.type,t.attributes):null;this.overrides.push(new Fa(t.name,s,t.attributes,e))}else if(this._isUniformVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=new za(t.name,i,e,s,t.attributes,pr.Uniform,t.access);this.uniforms.push(r)}else if(this._isStorageVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=this._isStorageTexture(i),a=new za(t.name,i,e,s,t.attributes,r?pr.StorageTexture:pr.Storage,t.access);this.storage.push(a)}else if(this._isTextureVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=this._isStorageTexture(i),a=new za(t.name,i,e,s,t.attributes,r?pr.StorageTexture:pr.Texture,t.access);r?this.storage.push(a):this.textures.push(a)}else if(this._isSamplerVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=new za(t.name,i,e,s,t.attributes,pr.Sampler,t.access);this.samplers.push(r)}else if(n instanceof Sr){const t=this._getAttribute(n,"vertex"),e=this._getAttribute(n,"fragment"),s=this._getAttribute(n,"compute"),i=t||e||s,r=new Da(n.name,null==i?void 0:i.name);r.startLine=n.startLine,r.endLine=n.endLine,this.functions.push(r),this._functions.get(n.name).info=r,i&&(this._functions.get(n.name).inUse=!0,r.inUse=!0,r.resources=this._findResources(n,!!i),r.inputs=this._getInputs(n.args),r.outputs=this._getOutputs(n.returnType),this.entry[i.name].push(r))}else;for(const n of this._functions.values())n.info&&(n.info.inUse=n.inUse,this._addCalls(n.node,n.info.calls));for(const n of this.uniforms)this._markStructsInUse(n.type);for(const n of this.storage)this._markStructsInUse(n.type)}_markStructsInUse(t){if(t.isStruct){t.inUse=!0;for(const e of t.members)this._markStructsInUse(e.type)}else if(t.isArray)this._markStructsInUse(t.format);else if(t.isTemplate)this._markStructsInUse(t.format);else{const e=this._getAlias(t.name);e&&this._markStructsInUse(e)}}_addCalls(t,e){var n;for(const s of t.calls){const t=null===(n=this._functions.get(s.name))||void 0===n?void 0:n.info;t&&e.add(t)}}findResource(t,e){for(const n of this.uniforms)if(n.group==t&&n.binding==e)return n;for(const n of this.storage)if(n.group==t&&n.binding==e)return n;for(const n of this.textures)if(n.group==t&&n.binding==e)return n;for(const n of this.samplers)if(n.group==t&&n.binding==e)return n;return null}_findResource(t){for(const e of this.uniforms)if(e.name==t)return e;for(const e of this.storage)if(e.name==t)return e;for(const e of this.textures)if(e.name==t)return e;for(const e of this.samplers)if(e.name==t)return e;return null}_markStructsFromAST(t){const e=this._getTypeInfo(t,null);this._markStructsInUse(e)}_findResources(t,e){const n=[],s=this,i=[];return t.search((r=>{if(r instanceof vr)i.push({});else if(r instanceof kr)i.pop();else if(r instanceof Br){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type),i.length>0&&(i[i.length-1][t.name]=t)}else if(r instanceof na){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type)}else if(r instanceof Pr){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type),i.length>0&&(i[i.length-1][t.name]=t)}else if(r instanceof ia){const t=r;if(i.length>0&&i[i.length-1][t.name])return;const e=s._findResource(t.name);e&&n.push(e)}else if(r instanceof sa){const i=r,a=s._functions.get(i.name);a&&(e&&(a.inUse=!0),t.calls.add(a.node),null===a.resources&&(a.resources=s._findResources(a.node,e)),n.push(...a.resources))}else if(r instanceof Dr){const i=r,a=s._functions.get(i.name);a&&(e&&(a.inUse=!0),t.calls.add(a.node),null===a.resources&&(a.resources=s._findResources(a.node,e)),n.push(...a.resources))}})),[...new Map(n.map((t=>[t.name,t]))).values()]}getBindGroups(){const t=[];function e(e,n){e>=t.length&&(t.length=e+1),void 0===t[e]&&(t[e]=[]),n>=t[e].length&&(t[e].length=n+1)}for(const n of this.uniforms){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.storage){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.textures){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.samplers){e(n.group,n.binding);t[n.group][n.binding]=n}return t}_getOutputs(t,e){if(void 0===e&&(e=void 0),void 0===e&&(e=[]),t instanceof Zr)this._getStructOutputs(t,e);else{const n=this._getOutputInfo(t);null!==n&&e.push(n)}return e}_getStructOutputs(t,e){for(const n of t.members)if(n.type instanceof Zr)this._getStructOutputs(n.type,e);else{const t=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(null!==t){const s=this._getTypeInfo(n.type,n.type.attributes),i=this._parseInt(t.value),r=new Ca(n.name,s,t.name,i);e.push(r)}}}_getOutputInfo(t){const e=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(null!==e){const n=this._getTypeInfo(t,t.attributes),s=this._parseInt(e.value);return new Ca("",n,e.name,s)}return null}_getInputs(t,e){void 0===e&&(e=void 0),void 0===e&&(e=[]);for(const n of t)if(n.type instanceof Zr)this._getStructInputs(n.type,e);else{const t=this._getInputInfo(n);null!==t&&e.push(t)}return e}_getStructInputs(t,e){for(const n of t.members)if(n.type instanceof Zr)this._getStructInputs(n.type,e);else{const t=this._getInputInfo(n);null!==t&&e.push(t)}}_getInputInfo(t){const e=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(null!==e){const n=this._getAttribute(t,"interpolation"),s=this._getTypeInfo(t.type,t.attributes),i=this._parseInt(e.value),r=new Ia(t.name,s,e.name,i);return null!==n&&(r.interpolation=this._parseString(n.value)),r}return null}_parseString(t){return t instanceof Array&&(t=t[0]),t}_parseInt(t){t instanceof Array&&(t=t[0]);const e=parseInt(t);return isNaN(e)?t:e}_getAlias(t){for(const e of this.aliases)if(e.name==t)return e.type;return null}_getAliasInfo(t){return new Pa(t.name,this._getTypeInfo(t.type,null))}_getTypeInfo(t,e){if(this._types.has(t))return this._types.get(t);if(t instanceof Kr){const n=t,s=this._getTypeInfo(n.format,n.attributes),i=new Ra(n.name,e);return i.format=s,i.count=n.count,this._types.set(t,i),this._updateTypeInfo(i),i}if(t instanceof Zr){const n=t,s=new Ea(n.name,e);s.startLine=n.startLine,s.endLine=n.endLine;for(const t of n.members){const e=this._getTypeInfo(t.type,t.attributes);s.members.push(new Aa(t.name,e,t.attributes))}return this._types.set(t,s),this._updateTypeInfo(s),s}if(t instanceof Qr){const n=t,s=n.format instanceof Xr,i=n.format?s?this._getTypeInfo(n.format,null):new Ta(n.format,null):null,r=new Ba(n.name,i,e,n.access);return this._types.set(t,r),this._updateTypeInfo(r),r}if(t instanceof Jr){const n=t,s=n.format?this._getTypeInfo(n.format,null):null,i=new Ba(n.name,s,e,n.access);return this._types.set(t,i),this._updateTypeInfo(i),i}const n=new Ta(t.name,e);return this._types.set(t,n),this._updateTypeInfo(n),n}_updateTypeInfo(t){var e,n;const s=this._getTypeSize(t);if(t.size=null!==(e=null==s?void 0:s.size)&&void 0!==e?e:0,t instanceof Ra){const e=this._getTypeSize(t.format);t.stride=null!==(n=null==e?void 0:e.size)&&void 0!==n?n:0,this._updateTypeInfo(t.format)}t instanceof Ea&&this._updateStructInfo(t)}_updateStructInfo(t){var e;let n=0,s=0,i=0,r=0;for(let a=0,o=t.members.length;a{const n=function(t,e,n){switch(e.resourceType){case pr.Uniform:case pr.Storage:case pr.StorageTexture:return Ja(t,e.type,n);default:return{size:0,type:e.type.name}}}(t,e,0);return[e.name,{typeDefinition:n,group:e.group,binding:e.binding,size:n.size}]})))}function qa(t,e,n){return{fields:Object.fromEntries(e.members.map((e=>[e.name,{offset:e.offset,type:Ja(t,e.type,0)}]))),size:e.size,offset:n}}function ja(t){var e;if(t.name.includes("depth"))return"depth";switch(null==(e=t.format)?void 0:e.name){case"f32":return"float";case"i32":return"sint";case"u32":return"uint";default:throw new Error("unknown texture sample type")}}function Va(t){return t.name.includes("2d_array")?"2d-array":t.name.includes("cube_array")?"cube-array":t.name.includes("3d")?"3d":t.name.includes("1d")?"1d":t.name.includes("cube")?"cube":"2d"}function Ga(t){switch(t.access){case"read":return"read-only";case"write":return"write-only";case"read_write":return"read-write";default:throw new Error("unknonw storage texture access")}}function Ha(t){return t.name.endsWith("_comparison")?"comparison":"filtering"}function Ya(t,e){const{binding:n,access:s,type:i}=t;switch(t.resourceType){case pr.Uniform:return{binding:n,visibility:e,buffer:{}};case pr.Storage:return{binding:n,visibility:e,buffer:{type:""===s||"read"===s?"read-only-storage":"storage"}};case pr.Texture:{if("texture_external"===i.name)return{binding:n,visibility:e,externalTexture:{}};const t=i.name.includes("multisampled");return{binding:n,visibility:e,texture:{sampleType:ja(i),viewDimension:Va(i),multisampled:t}}}case pr.Sampler:return{binding:n,visibility:e,sampler:{type:Ha(i)}};case pr.StorageTexture:return{binding:n,visibility:e,storageTexture:{access:Ga(i),format:i.format.name,viewDimension:Va(i)}};default:throw new Error("unknown resource type")}}function Xa(t,e){const n={};for(const s of t)n[s.name]={stage:e,resources:s.resources.map((t=>{const{name:n,group:s}=t;return{name:n,group:s,entry:Ya(t,e)}}))};return n}function Za(t,e){if(void 0===e&&(e=""),!t)throw new Error(e)}function Ja(t,e,n){if(e.isArray){Za(!e.isStruct,"struct array is invalid"),Za(!e.isStruct,"template array is invalid");const s=e;return{size:s.size,elementType:Ja(t,s.format,n),numElements:s.count}}if(e.isStruct)return Za(!e.isTemplate,"template struct is invalid"),qa(t,e,n);{const t=e,n=e.isTemplate?`${t.name}<${t.format.name}>`:e.name;return{size:e.size,type:n}}}Wa._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},Wa._textureTypes=va.any_texture_type.map((t=>t.name)),Wa._samplerTypes=va.sampler_type.map((t=>t.name));const $a=new Map([[Int8Array,{formats:["sint8","snorm8"],defaultForType:1}],[Uint8Array,{formats:["uint8","unorm8"],defaultForType:1}],[Int16Array,{formats:["sint16","snorm16"],defaultForType:1}],[Uint16Array,{formats:["uint16","unorm16"],defaultForType:1}],[Int32Array,{formats:["sint32","snorm32"],defaultForType:0}],[Uint32Array,{formats:["uint32","unorm32"],defaultForType:0}],[Float32Array,{formats:["float32","float32"],defaultForType:0}]]);new Map([...$a.entries()].map((t=>{let[e,{formats:[n,s]}]=t;return[[n,e],[s,e]]})).flat());class Ka extends Error{constructor(t){super(`[WebGPUNotSupportedError] WebGPU is not supported in this environment. Make sure to use a browser and device that supports WebGPU. (Reason: ${t})`)}}class Qa extends Error{constructor(){super("[CanvasReferenceError] Canvas reference is not set. Make sure to set the canvas to a DOM node before calling any methods.")}}class to extends Error{constructor(){super("[SignalAlreadyAbortedError] Signal is already aborted. Make sure to check the aborted property before calling any methods.")}}class eo extends Error{constructor(t){super("[InvalidMaterialError] Material is invalid. Make sure to configure all materials to be instances of OpenPBRMaterial."),this.invalidMaterial=t}}class no extends Error{constructor(t){super(`[InternalError] Library error occurred, please get in contact. (Reason: ${t})`)}}const so=32;function io(t,e){return 65535===e[t+15]}function ro(t,e){return e[t+6]}function ao(t,e){return e[t+14]}function oo(t,e){return e[t+6]}function lo(t,e){return e[t+7]}function ho(){return{sky:{power:1,color:[1,1,1]},sun:{power:.5,angularSize:40,latitude:45,longitude:180,color:[1,1,1]}}}function uo(t){return null==t}const co={type:"change"},po={type:"start"},mo={type:"end"},fo=new class{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=new wt(0,0,-1)),this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,jt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=jt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(jt.copy(this.origin).addScaledVector(this.direction,e),jt.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Vt.copy(t).add(e).multiplyScalar(.5),Gt.copy(e).sub(t).normalize(),Ht.copy(this.origin).sub(Vt);const i=.5*t.distanceTo(e),r=-this.direction.dot(Gt),a=Ht.dot(this.direction),o=-Ht.dot(Gt),l=Ht.lengthSq(),h=Math.abs(1-r*r);let u,c,d,p;if(h>0)if(u=r*o-a,c=r*a-o,p=i*h,u>=0)if(c>=-p)if(c<=p){const t=1/h;u*=t,c*=t,d=u*(u+r*c+2*a)+c*(r*u+c+2*o)+l}else c=i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;else c=-i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;else c<=-p?(u=Math.max(0,-(-r*i+a)),c=u>0?-i:Math.min(Math.max(-i,-o),i),d=-u*u+c*(c+2*o)+l):c<=p?(u=0,c=Math.min(Math.max(-i,-o),i),d=c*(c+2*o)+l):(u=Math.max(0,-(r*i+a)),c=u>0?i:Math.min(Math.max(-i,-o),i),d=-u*u+c*(c+2*o)+l);else c=r>0?-i:i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Vt).addScaledVector(Gt,c),d}intersectSphere(t,e){jt.subVectors(t.center,this.origin);const n=jt.dot(this.direction),s=jt.dot(jt)-n*n,i=t.radius*t.radius;if(s>i)return null;const r=Math.sqrt(i-s),a=n-r,o=n+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,i,r,a,o;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,c=this.origin;return l>=0?(n=(t.min.x-c.x)*l,s=(t.max.x-c.x)*l):(n=(t.max.x-c.x)*l,s=(t.min.x-c.x)*l),h>=0?(i=(t.min.y-c.y)*h,r=(t.max.y-c.y)*h):(i=(t.max.y-c.y)*h,r=(t.min.y-c.y)*h),n>r||i>s||((i>n||isNaN(n))&&(n=i),(r=0?(a=(t.min.z-c.z)*u,o=(t.max.z-c.z)*u):(a=(t.max.z-c.z)*u,o=(t.min.z-c.z)*u),n>o||a>s)||((a>n||n!=n)&&(n=a),(o=0?n:s,e)}intersectsBox(t){return null!==this.intersectBox(t,jt)}intersectTriangle(t,e,n,s,i){Yt.subVectors(e,t),Xt.subVectors(n,t),Zt.crossVectors(Yt,Xt);let r,a=this.direction.dot(Zt);if(a>0){if(s)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}Ht.subVectors(this.origin,t);const o=r*this.direction.dot(Xt.crossVectors(Ht,Xt));if(o<0)return null;const l=r*this.direction.dot(Yt.cross(Ht));if(l<0||o+l>a)return null;const h=-r*Ht.dot(Zt);return h<0?null:this.at(h/a,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},yo=new dn,go=Math.cos(70*tt);class _o extends V{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new wt,this.cursor=new wt,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:M,MIDDLE:S,RIGHT:T},this.touches={ONE:A,TWO:R},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",st),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",st),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(co),n.update(),i=s.NONE},this.update=function(){const e=new wt,u=(new bt).setFromUnitVectors(t.up,new wt(0,1,0)),c=u.clone().invert(),d=new wt,p=new bt,m=new wt,f=2*Math.PI;return function(y){void 0===y&&(y=null);const g=n.object.position;e.copy(g).sub(n.target),e.applyQuaternion(u),a.setFromVector3(e),n.autoRotate&&i===s.NONE&&L(function(t){return null!==t?2*Math.PI/60*n.autoRotateSpeed*t:2*Math.PI/60/60*n.autoRotateSpeed}(y)),n.enableDamping?(a.theta+=o.theta*n.dampingFactor,a.phi+=o.phi*n.dampingFactor):(a.theta+=o.theta,a.phi+=o.phi);let _=n.minAzimuthAngle,v=n.maxAzimuthAngle;isFinite(_)&&isFinite(v)&&(_<-Math.PI?_+=f:_>Math.PI&&(_-=f),v<-Math.PI?v+=f:v>Math.PI&&(v-=f),a.theta=_<=v?Math.max(_,Math.min(v,a.theta)):a.theta>(_+v)/2?Math.max(_,a.theta):Math.min(v,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let k=!1;if(n.zoomToCursor&&w||n.object.isOrthographicCamera)a.radius=U(a.radius);else{const t=a.radius;a.radius=U(a.radius*l),k=t!=a.radius}if(e.setFromSpherical(a),e.applyQuaternion(c),g.copy(n.target).add(e),n.object.lookAt(n.target),!0===n.enableDamping?(o.theta*=1-n.dampingFactor,o.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(o.set(0,0,0),h.set(0,0,0)),n.zoomToCursor&&w){let s=null;if(n.object.isPerspectiveCamera){const t=e.length();s=U(t*l);const i=t-s;n.object.position.addScaledVector(x,i),n.object.updateMatrixWorld(),k=!!i}else if(n.object.isOrthographicCamera){const t=new wt(b.x,b.y,0);t.unproject(n.object);const i=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),k=i!==n.object.zoom;const r=new wt(b.x,b.y,0);r.unproject(n.object),n.object.position.sub(r).add(t),n.object.updateMatrixWorld(),s=e.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==s&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(s).add(n.object.position):(fo.origin.copy(n.object.position),fo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(fo.direction))r||8*(1-p.dot(n.object.quaternion))>r||m.distanceToSquared(n.target)>r)&&(n.dispatchEvent(co),d.copy(n.object.position),p.copy(n.object.quaternion),m.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",rt),n.domElement.removeEventListener("pointerdown",J),n.domElement.removeEventListener("pointercancel",K),n.domElement.removeEventListener("wheel",Q),n.domElement.removeEventListener("pointermove",$),n.domElement.removeEventListener("pointerup",K),n.domElement.getRootNode().removeEventListener("keydown",tt,{capture:!0}),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",st),n._domElementKeyEvents=null)};const n=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=s.NONE;const r=1e-6,a=new yn,o=new yn;let l=1;const h=new wt,u=new et,c=new et,d=new et,p=new et,m=new et,f=new et,y=new et,g=new et,_=new et,x=new wt,b=new et;let w=!1;const v=[],k={};let z=!1;function P(t){const e=Math.abs(.01*t);return Math.pow(.95,n.zoomSpeed*e)}function L(t){o.theta-=t}function I(t){o.phi-=t}const C=function(){const t=new wt;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),h.add(t)}}(),D=function(){const t=new wt;return function(e,s){!0===n.screenSpacePanning?t.setFromMatrixColumn(s,1):(t.setFromMatrixColumn(s,0),t.crossVectors(n.object.up,t)),t.multiplyScalar(e),h.add(t)}}(),N=function(){const t=new wt;return function(e,s){const i=n.domElement;if(n.object.isPerspectiveCamera){const r=n.object.position;t.copy(r).sub(n.target);let a=t.length();a*=Math.tan(n.object.fov/2*Math.PI/180),C(2*e*a/i.clientHeight,n.object.matrix),D(2*s*a/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(C(e*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),D(s*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function F(t){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(t){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function W(t,e){if(!n.zoomToCursor)return;w=!0;const s=n.domElement.getBoundingClientRect(),i=t-s.left,r=e-s.top,a=s.width,o=s.height;b.x=i/a*2-1,b.y=-r/o*2+1,x.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function U(t){return Math.max(n.minDistance,Math.min(n.maxDistance,t))}function q(t){u.set(t.clientX,t.clientY)}function j(t){p.set(t.clientX,t.clientY)}function V(t){if(1===v.length)u.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);u.set(n,s)}}function G(t){if(1===v.length)p.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);p.set(n,s)}}function H(t){const e=ot(t),n=t.pageX-e.x,s=t.pageY-e.y,i=Math.sqrt(n*n+s*s);y.set(0,i)}function Y(t){if(1==v.length)c.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);c.set(n,s)}d.subVectors(c,u).multiplyScalar(n.rotateSpeed);const e=n.domElement;L(2*Math.PI*d.x/e.clientHeight),I(2*Math.PI*d.y/e.clientHeight),u.copy(c)}function X(t){if(1===v.length)m.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);m.set(n,s)}f.subVectors(m,p).multiplyScalar(n.panSpeed),N(f.x,f.y),p.copy(m)}function Z(t){const e=ot(t),s=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(s*s+i*i);g.set(0,r),_.set(0,Math.pow(g.y/y.y,n.zoomSpeed)),F(_.y),y.copy(g);W(.5*(t.pageX+e.x),.5*(t.pageY+e.y))}function J(t){!1!==n.enabled&&(0===v.length&&(n.domElement.setPointerCapture(t.pointerId),n.domElement.addEventListener("pointermove",$),n.domElement.addEventListener("pointerup",K)),!function(t){for(let e=0;e0?F(P(_.y)):_.y<0&&O(P(_.y)),y.copy(g),n.update()}(t);break;case s.PAN:if(!1===n.enablePan)return;!function(t){m.set(t.clientX,t.clientY),f.subVectors(m,p).multiplyScalar(n.panSpeed),N(f.x,f.y),p.copy(m),n.update()}(t)}}(t))}function K(t){switch(function(t){delete k[t.pointerId];for(let e=0;e0&&F(P(t.deltaY)),n.update()}(function(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return t.ctrlKey&&!z&&(n.deltaY*=10),n}(t)),n.dispatchEvent(mo))}function tt(t){"Control"===t.key&&(z=!0,n.domElement.getRootNode().addEventListener("keyup",nt,{passive:!0,capture:!0}))}function nt(t){"Control"===t.key&&(z=!1,n.domElement.getRootNode().removeEventListener("keyup",nt,{passive:!0,capture:!0}))}function st(t){!1===n.enabled||!1===n.enablePan||function(t){let e=!1;switch(t.code){case n.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?I(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,n.keyPanSpeed),e=!0;break;case n.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?I(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,-n.keyPanSpeed),e=!0;break;case n.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?L(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(n.keyPanSpeed,0),e=!0;break;case n.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?L(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(-n.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),n.update())}(t)}function it(t){switch(at(t),v.length){case 1:switch(n.touches.ONE){case A:if(!1===n.enableRotate)return;V(t),i=s.TOUCH_ROTATE;break;case E:if(!1===n.enablePan)return;G(t),i=s.TOUCH_PAN;break;default:i=s.NONE}break;case 2:switch(n.touches.TWO){case R:if(!1===n.enableZoom&&!1===n.enablePan)return;(function(t){n.enableZoom&&H(t),n.enablePan&&G(t)})(t),i=s.TOUCH_DOLLY_PAN;break;case B:if(!1===n.enableZoom&&!1===n.enableRotate)return;(function(t){n.enableZoom&&H(t),n.enableRotate&&V(t)})(t),i=s.TOUCH_DOLLY_ROTATE;break;default:i=s.NONE}break;default:i=s.NONE}i!==s.NONE&&n.dispatchEvent(po)}function rt(t){!1!==n.enabled&&t.preventDefault()}function at(t){let e=k[t.pointerId];void 0===e&&(e=new et,k[t.pointerId]=e),e.set(t.pageX,t.pageY)}function ot(t){const e=t.pointerId===v[0]?v[1]:v[0];return k[e]}n.domElement.addEventListener("contextmenu",rt),n.domElement.addEventListener("pointerdown",J),n.domElement.addEventListener("pointercancel",K),n.domElement.addEventListener("wheel",Q,{passive:!1}),n.domElement.getRootNode().addEventListener("keydown",tt,{passive:!0,capture:!0}),this.update()}}function xo(t){const e=nr([t.scene]),n=Qi("cpu"),s=new Xi(e.geometry,{indirect:!0}),i=Zi(s)[0].depth.max;console.log(s);const{boundsArray:r,contentsArray:a}=function(t){if(!function(t){return"_roots"in t}(t))throw new no("MeshBVH internal structure does not match, this indicates a change in the library which is not supported.");const e=t._roots;if(1!==e.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const n=e[0],s=new Uint16Array(n),i=new Uint32Array(n),r=new Float32Array(n),a=n.byteLength/so,o=2*Math.ceil(Math.sqrt(a/2)),l=new Float32Array(4*o*o),h=Math.ceil(Math.sqrt(a)),u=new Uint32Array(2*h*h);for(let c=0;c{}),signal:c=(new AbortController).signal}=void 0===n?{}:n;var d;const p={isRunning:!0,abortNotifiers:new Map};if(c.aborted)throw new to;c.addEventListener("abort",(()=>{p.isRunning=!1;for(const[,t]of p.abortNotifiers)t();p.abortNotifiers.clear()}));const m=s,f=Qi("init"),{indirectBuffer:y,boundsArray:g,contentsArray:_,positions:x,normals:b,maxBvhDepth:w,modelGroups:v,modelMaterials:k,meshIndices:M,bvhBuildTime:S}=xo(e),T=document.getElementById(t);if(!(T instanceof HTMLCanvasElement))throw new Qa;if(!navigator.gpu)throw new Ka("navigator.gpu is not available, most likely due to browser");const A=await navigator.gpu.requestAdapter();if(!A)throw new Ka("No suitable WebGPU adapter available");const E=await A.requestDevice({requiredFeatures:["timestamp-query"]});var R,B;R="device",B=()=>{E.destroy()},p.abortNotifiers.set(R,B);const z=E.createQuerySet({type:"timestamp",count:2}),P=E.createBuffer({size:8*z.count,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE}),L=E.createBuffer({size:P.size,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),I=T.getContext("webgpu");if(!I)throw new Ka("No WebGPU context available");const C=navigator.gpu.getPreferredCanvasFormat();I.configure({device:E,format:C});const D=i,N=i,F=function(t){return Object.entries($i).reduce(((e,n)=>{let[s,i]=n;return e.replaceAll(`\${${i}}`,`${t[s]}`)}),Ji)}({imageWidth:N,imageHeight:N,maxWorkgroupDimension:16,maxBvhStackDepth:w}),O=new Uint8Array(i*D*4),W=E.createTexture({size:[i,D],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING});E.queue.writeTexture({texture:W},O,{bytesPerRow:4*i},{width:i,height:D});const U=E.createTexture({size:[i,D],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING});E.queue.writeTexture({texture:U},O,{bytesPerRow:4*i},{width:i,height:D});const q=E.createSampler(),j=E.createShaderModule({label:"Render Shader",code:Ki}),V=E.createBindGroupLayout({label:"Texture sampler bind group layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]}),G=E.createPipelineLayout({label:"Pipeline Layout",bindGroupLayouts:[V]}),H=E.createRenderPipeline({label:"Render pipeline",layout:G,vertex:{module:j,entryPoint:"vertexMain",buffers:[]},fragment:{module:j,entryPoint:"fragmentMain",targets:[{format:C}]}}),Y=e.scene.matrixWorld,X=function(t){return!uo(t.camera)}(r);let Z;Z=X?r:function(t,e){const n=new Jt;n.fromArray(t.matrixWorldContent);const s=new ln(t.fov,1,.01,1e3),i=new _o(s,e);s.applyMatrix4(n),console.log(s.position);const r=new wt;s.getWorldDirection(r);const a=s.position.clone().addScaledVector(r,t.cameraTargetDistance);return i.target.copy(a),i.update(),{camera:s,controls:i}}(r,T);const J=E.createBuffer({label:"Position buffer",size:Float32Array.BYTES_PER_ELEMENT*x.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),$=J.getMappedRange();new Float32Array($).set(x),J.unmap();const K=new Uint32Array(M),Q=E.createBuffer({label:"Index buffer",size:Uint32Array.BYTES_PER_ELEMENT*K.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),tt=Q.getMappedRange();new Uint32Array(tt).set(K),Q.unmap();const et=E.createBuffer({label:"Normal buffer",size:Float32Array.BYTES_PER_ELEMENT*b.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),nt=et.getMappedRange();new Float32Array(nt).set(b),et.unmap();const st=E.createBuffer({label:"BVH bounds buffer",size:Float32Array.BYTES_PER_ELEMENT*g.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),it=st.getMappedRange();new Float32Array(it).set(g),st.unmap();const rt=E.createBuffer({label:"BVH contents buffer",size:Uint32Array.BYTES_PER_ELEMENT*_.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),at=rt.getMappedRange();new Uint32Array(at).set(_),rt.unmap();const ot=E.createBuffer({label:"BVH indirect buffer",size:Uint32Array.BYTES_PER_ELEMENT*y.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),lt=ot.getMappedRange();new Uint32Array(lt).set(y),ot.unmap();const ht=3*Uint32Array.BYTES_PER_ELEMENT,ut=v,ct=E.createBuffer({label:"Object definitions buffer",size:ht*ut.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),dt=ct.getMappedRange();new Uint32Array(dt).set(ut.map((t=>[t.start,t.count,t.materialIndex])).flat(1)),ct.unmap();const pt=k,mt=function(t){const e=new Wa(t),n=Object.fromEntries(e.structs.map((t=>[t.name,qa(e,t,0)]))),s=Ua(e,e.uniforms),i=Ua(e,e.storage.filter((t=>t.resourceType===pr.Storage))),r=Ua(e,e.storage.filter((t=>t.resourceType===pr.StorageTexture))),a=Ua(e,e.textures.filter((t=>"texture_external"!==t.type.name)));return{externalTextures:Ua(e,e.textures.filter((t=>"texture_external"===t.type.name))),samplers:Ua(e,e.samplers),structs:n,storages:i,storageTextures:r,textures:a,uniforms:s,entryPoints:{...Xa(e.entry.vertex,GPUShaderStage.VERTEX),...Xa(e.entry.fragment,GPUShaderStage.FRAGMENT),...Xa(e.entry.compute,GPUShaderStage.COMPUTE)}}}(F),{size:ft}=function(t){const e=t;return xr(void 0===e.group?t:e.typeDefinition)}(mt.storages.materials),yt=gr(mt.storages.materials,new ArrayBuffer(ft*pt.length)),gt=E.createBuffer({label:"Material buffer",size:ft*pt.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});yt.set(pt.map((t=>{if(!(t instanceof bn))throw new eo(t);return{baseWeight:t.oBaseWeight,baseColor:t.oBaseColor,baseDiffuseRoughness:t.oBaseDiffuseRoughness,baseMetalness:t.oBaseMetalness,specularWeight:t.oSpecularWeight,specularColor:t.oSpecularColor,specularRoughness:t.oSpecularRoughness,specularAnisotropy:t.oSpecularRoughnessAnisotropy,specularIor:t.oSpecularIOR,coatWeight:t.oCoatWeight,coatColor:t.oCoatColor,coatRoughness:t.oCoatRoughness,coatRoughnessAnisotropy:t.oCoatRoughnessAnisotropy,coatIor:t.oCoatIor,coatDarkening:t.oCoatDarkening,emissionLuminance:t.oEmissionLuminance,emissionColor:t.oEmissionColor,thinFilmThickness:t.oThinFilmThickness,thinFilmIOR:t.oThinFilmIOR}}))),E.queue.writeBuffer(gt,0,yt.arrayBuffer);const _t=E.createBindGroupLayout({label:"Static compute bind group layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:3,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:4,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:5,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:6,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:7,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}}]}),xt=E.createBindGroupLayout({label:"Dynamic compute bind group layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,storageTexture:{format:"rgba8unorm"}},{binding:1,visibility:GPUShaderStage.COMPUTE,storageTexture:{format:"rgba8unorm",access:"read-only"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}]}),bt=E.createPipelineLayout({label:"Compute pipeline layout",bindGroupLayouts:[_t,xt]}),vt=Math.ceil(N*N/256),kt=E.createShaderModule({label:"Ray Tracing Compute Shader",code:F}),Mt=E.createBindGroup({label:"Static compute bind group",layout:_t,entries:[{binding:0,resource:{buffer:J}},{binding:1,resource:{buffer:Q}},{binding:2,resource:{buffer:st}},{binding:3,resource:{buffer:rt}},{binding:4,resource:{buffer:et}},{binding:5,resource:{buffer:ot}},{binding:6,resource:{buffer:ct}},{binding:7,resource:{buffer:gt}}]}),St=function(t){const{latitude:e,longitude:n}=t,s=(90-e)*Math.PI/180,i=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return[a*Math.cos(i),r,a*Math.sin(i)]}(a.sun);f.end();const Tt=Qi("render loop full"),At=()=>{let t="running";let e=null,n=0,s=0,i=[];const r=async()=>{console.log(Z.camera.matrixWorld);const c=Z.camera.matrixWorld,d=Z.camera.projectionMatrixInverse,f=Qi("render"),y=n%2==0?W:U,g=n%2==0?U:W,{size:_}=mt.uniforms.uniformData,x=gr(mt.uniforms.uniformData,new ArrayBuffer(_)),b=E.createBuffer({label:"Uniform data buffer",size:_,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});x.set({invProjectionMatrix:d.elements,cameraWorldMatrix:c.elements,invModelMatrix:Y.clone().invert().elements,seedOffset:Math.random()*Number.MAX_SAFE_INTEGER,priorSamples:n,samplesPerPixel:o,sunDirection:St,skyPower:a.sky.power,skyColor:a.sky.color,sunPower:Math.pow(10,a.sun.power),sunAngularSize:a.sun.angularSize,sunColor:a.sun.color,clearColor:l,enableClearColor:uo(l)?0:1,maxRayDepth:h,objectDefinitionLength:ut.length}),E.queue.writeBuffer(b,0,x.arrayBuffer);const w=E.createBindGroup({label:"Dynamic compute bind group",layout:xt,entries:[{binding:0,resource:y.createView()},{binding:1,resource:g.createView()},{binding:2,resource:{buffer:b}}]}),v=E.createComputePipeline({label:"Ray Tracing Compute pipeline",layout:bt,compute:{module:kt,entryPoint:"computeMain"}}),k=E.createCommandEncoder(),M=k.beginComputePass({timestampWrites:{querySet:z,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}});M.setBindGroup(0,Mt),M.setBindGroup(1,w),M.setPipeline(v),M.dispatchWorkgroups(Math.sqrt(vt),Math.sqrt(vt)),M.end(),k.resolveQuerySet(z,0,2,P,0),"unmapped"===L.mapState&&k.copyBufferToBuffer(P,0,L,0,P.size);const T=k.beginRenderPass({colorAttachments:[{view:I.getCurrentTexture().createView(),loadOp:"clear",clearValue:{r:0,g:0,b:.2,a:1},storeOp:"store"}]});T.setPipeline(H);const A=E.createBindGroup({label:"Texture sampler bind group",layout:V,entries:[{binding:0,resource:q},{binding:1,resource:W.createView()}]});T.setBindGroup(0,A),T.draw(6),T.end();const R=k.finish();if(E.queue.submit([R]),"unmapped"===L.mapState){try{await L.mapAsync(GPUMapMode.READ)}catch(C){if(!p.isRunning)return void console.warn("Aborted render loop");throw C}const t=new BigUint64Array(L.getMappedRange()),e=t[1]-t[0];console.log(`GPU Time: ${e}ns`),L.unmap()}const B=f.end();if(i.push(B),s+=B,n{t="halted",null!==e&&cancelAnimationFrame(e)}}};let Et=At();null==(d=Z.controls)||d.addEventListener("change",(()=>{Et.terminateLoop(),Et=At()}))}const wo={container:"container_nBh_",wrapper:"wrapper_q6N5",heroTitle:"heroTitle__SVE",hero:"hero_GiET",lead:"lead_SBUB",text:"text_R33k"},vo=bn;async function ko(t){const e=new w.B;const n=new vo;n.oBaseColor=[0,.9,1];const s=new vo;s.oBaseColor=[.9,.7,.23],s.oSpecularWeight=.01;const i=new vo;i.oBaseColor=[.4,.6,.33];const r=new vo;r.oBaseColor=[.67,.18,.12],r.oSpecularColor=[1,1,.9],r.oSpecularWeight=.2;const a=new vo;a.oBaseColor=[.9,.9,.9],a.oBaseMetalness=1;const o=new vo;o.oBaseColor=[.9,.9,.9],o.oBaseMetalness=1,o.oBaseDiffuseRoughness=.5;const l=new vo;l.oBaseColor=[.9,.9,.9];const h=new vo;h.oBaseColor=[.9,.9,.9],h.oSpecularWeight=0,l.oBaseMetalness=1;const u=new vo;u.oBaseColor=[.4,.4,.4],u.oBaseMetalness=.4,u.oSpecularWeight=.2;const c=new vo;c.oBaseColor=[.9,.6,.4],c.oBaseMetalness=1;const d=new vo;d.oBaseColor=[.25,.25,.25],d.oSpecularWeight=1;const p=new vo;p.oBaseColor=[.8,.8,.8];const m=new vo;m.oBaseColor=[.5,.5,.5],m.oSpecularWeight=0;const f=new vo;f.oBaseColor=[.9,.8,.7],f.oBaseMetalness=0,f.oBaseDiffuseRoughness=0;const y={material_name_kunststoff_gelbFCBE37_rau_2_mtl:s,material_name_kunststoff_gelbFCBE37_rau_3_mtl:s,material_name_kunststoff_verkehrsrotB81D12_rau_5_mtl:r,material_name_kunststoff_gruen9CC289_glanz_SSS_0_mtl:i,material_name_kunststoff_schwarz141414_rau_1_mtl:d,material_name_metall_stahl67686A_abgenutzt_7_mtl:o,material_name_kunststoff_weissDCDCDC_rau_6_mtl:p,material_name_kunststoff_schwarz000000_rau_0_mtl:d,material_name_kunststoff_schwarz000000_rau_31_mtl:d,material_name_metall_stahl67686A_abgenutzt_32_mtl:h,material_name_kunststoff_verkehrsrotB81D12_rau_33_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_34_mtl:p,material_name_kunststoff_verkehrsrotB81D12_rau_2_mtl:r,material_name_kunststoff_verkehrsrotB81D12_rau_3_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_4_mtl:p,material_name_kunststoff_gelbFCBE37_rau_5_mtl:s,material_name_kunststoff_schwarz000000_rau_6_mtl:d,material_name_kunststoff_gruen006054_rau_7_mtl:i,material_name_metall_stahl737364_abgenutzt_rau_8_mtl:o,material_name_metall_stahl909086_abgenutzt_rauer_9_mtl:o,material_name_kunststoff_weissDCDCDC_transparent_trueb_10_mtl:p,material_name_kunststoff_schwarz000000_rau_11_mtl:d,material_name_metall_stahl67686A_abgenutzt_12_mtl:l,material_name_kunststoff_verkehrsrotB81D12_rau_13_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_14_mtl:p,material_name_kunststoff_schwarz000000_rau_15_mtl:d,material_name_kunststoff_schwarz000000_rau_16_mtl:d,material_name_metall_stahl67686A_abgenutzt_17_mtl:l,material_name_kunststoff_weissDCDCDC_transparent_trueb_18_mtl:p};!async function(){const s=await async function(t){return new Promise(((n,s)=>{e.load(t,n,void 0,s)}))}("https://stuckisimon.github.io/strahl-sample-models/45-series/45-series-cleaned.gltf");s.scene.traverseVisible((t=>{if(void 0===t.material)return;const e=t.material.name;e in y?t.material=y[e]:(console.log(e),t.material=n)})),t.aborted||await bo("render-target",s,{targetSamples:100,signal:t})}()}function Mo(){const t=_.useRef(!1);return _.useEffect((()=>{const e=new AbortController,n=e.signal;return t.current||(t.current=!0,ko(n)),()=>{e.abort()}}),[]),(0,l.jsx)("div",{className:wo.container,children:(0,l.jsxs)("div",{className:"container",children:[(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("div",{className:(0,s.A)("col",wo.hero),children:[(0,l.jsx)("p",{className:wo.lead,children:"Demo"}),(0,l.jsx)(a.A,{as:"h2",className:wo.heroTitle,children:"Show me"})]})}),(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:(0,s.A)("col",wo.wrapper),children:(0,l.jsx)("canvas",{width:"512",height:"512",id:"render-target"})})}),(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:"col",children:(0,l.jsx)("p",{className:wo.text,children:"Make sure your browser supports WebGPU."})})})]})})}const So={container:"container_UWvi",ray:"ray_OIi6","position-animation":"position-animation_AFLE","pulsate-animation":"pulsate-animation_nwAU"};function To(){return(0,l.jsxs)("div",{className:So.container,children:[(0,l.jsx)("span",{className:So.ray}),(0,l.jsx)("span",{className:So.ray}),(0,l.jsx)("span",{className:So.ray})]})}function Ao(){const{siteConfig:t}=(0,i.A)(),e=["fast","efficient","powerful","beautiful","simple","open-source","understandable","accessible"],n=_.useRef(null),r=_.useRef({currentText:e[0],currentTextIndex:0}),o=b(n);return _.useEffect((()=>o(e,r.current)),[]),(0,l.jsxs)("header",{className:(0,s.A)("hero",p.heroBanner),children:[(0,l.jsxs)("div",{className:"container",children:[(0,l.jsxs)(a.A,{as:"h1",className:p.heroTitle,children:["Path Tracing ",(0,l.jsx)("span",{className:p.heroMark,children:"made"})]}),(0,l.jsxs)("div",{className:p.typewriterContainer,children:[(0,l.jsx)("p",{className:(0,s.A)("hero__subtitle",p.heroTypewriter),ref:n,children:"\xa0"}),(0,l.jsx)("div",{className:p.cursorContainer,children:(0,l.jsx)("div",{className:p.cursor})})]}),(0,l.jsx)("p",{className:(0,s.A)("hero__subtitle",p.heroText),children:"strahl is an open-source path tracing library built using WebGPU."}),(0,l.jsxs)("div",{className:p.buttons,children:[(0,l.jsx)(g,{to:"/blog",children:"Get Started"}),(0,l.jsx)(g,{to:"https://github.com/StuckiSimon/strahl",icon:d.Vz1,variant:"secondary",children:"Github"})]})]}),(0,l.jsx)(To,{})]})}function Eo(){const{siteConfig:t}=(0,i.A)();return(0,l.jsxs)(r.A,{title:"strahl",description:"strahl \u2013 path tracing library using WebGPU and OpenPBR",children:[(0,l.jsx)(Ao,{}),(0,l.jsxs)("main",{children:[(0,l.jsx)(c,{}),(0,l.jsx)(Mo,{})]})]})}}}]); \ No newline at end of file +/*! For license information please see 1df93b7f.2fc294ab.js.LICENSE.txt */ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[583],{9269:(t,e,n)=>{n.r(e),n.d(e,{default:()=>Eo});var s=n(4164),i=n(4586),r=n(781),a=n(1107);const o={features:"features_t9lD"};var l=n(4848);const h=[{title:"Modern Technology",description:(0,l.jsx)(l.Fragment,{children:"Strahl leverages WebGPU, the latest web graphics API built for years to come."})},{title:"Fully Open-Source",description:(0,l.jsx)(l.Fragment,{children:"Strahl is built out in public under MIT license, your feedback is welcome."})},{title:"Using OpenPBR",description:(0,l.jsx)(l.Fragment,{children:"Strahl supports Physically-based Rendering based on the OpenPBR surface shading model."})}];function u(t){let{title:e,description:n}=t;return(0,l.jsx)("div",{className:(0,s.A)("col col--4"),children:(0,l.jsxs)("div",{className:"text--center padding-horiz--md",children:[(0,l.jsx)(a.A,{as:"h3",children:e}),(0,l.jsx)("p",{children:n})]})})}function c(){return(0,l.jsx)("section",{className:o.features,children:(0,l.jsx)("div",{className:"container",children:(0,l.jsx)("div",{className:"row",children:h.map(((t,e)=>(0,l.jsx)(u,{...t},e)))})})})}var d=n(7875);const p={heroBanner:"heroBanner_qdFl",heroTitle:"heroTitle_qg2I",heroMark:"heroMark_V22N",typewriterContainer:"typewriterContainer_MUFz",heroTypewriter:"heroTypewriter_T0w2",cursorContainer:"cursorContainer_gtpg",cursor:"cursor_m5HY",opacityFade:"opacityFade_eRto",heroText:"heroText_ryRM",buttons:"buttons_AeoN"};var m=n(8774),f=n(3914);const y={icon:"icon_FiRX"};function g(t){let{to:e,children:n,icon:i,variant:r="primary"}=t;return(0,l.jsxs)(m.A,{to:e,className:`button button--${r} button--lg`,children:[i?(0,l.jsx)(f.g,{icon:i,className:(0,s.A)("margin-right--sm",y.icon)}):null,n]})}var _=n(6540);const x=function(t){const e=(0,_.useRef)(null);(0,_.useLayoutEffect)((()=>{e.current=t}));return(0,_.useCallback)((function(){if(!e.current)throw new Error("event called before initialization");return(0,e.current)(...arguments)}),[])};const b=function(t){return x(((e,n)=>{let s,i="write",r=0;const a=()=>{"write"===i?r+=1:r-=1;const o=n.currentText.substring(0,r);if(t.current&&(0===o.length?t.current.innerHTML=" ":t.current.textContent=o),"write"===i&&r===n?.currentText.length)i="shift";else if("delete"===i&&0===r){i="write";const t=(n.currentTextIndex+1)%e.length;n.currentText=e[t],n.currentTextIndex=t}"write"===i?s=setTimeout(a,100+80*Math.random()):"delete"===i?s=setTimeout(a,40+20*Math.random()):"shift"===i&&(i="delete",s=setTimeout(a,1400))};return a(),()=>{clearTimeout(s)}}))};var w=n(5348),v=Object.defineProperty,k=(t,e,n)=>((t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const M=0,S=1,T=2,A=0,E=1,R=2,B=3,z=1,P=2,L=1001,I=1026,C="srgb",D="srgb-linear",N="display-p3",F="display-p3-linear",O="linear",W="srgb",U="rec709",q=7680,j=2e3;class V{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,s=n.length;e>8&255]+G[t>>16&255]+G[t>>24&255]+"-"+G[255&e]+G[e>>8&255]+"-"+G[e>>16&15|64]+G[e>>24&255]+"-"+G[63&n|128]+G[n>>8&255]+"-"+G[n>>16&255]+G[n>>24&255]+G[255&s]+G[s>>8&255]+G[s>>16&255]+G[s>>24&255]).toLowerCase()}function Z(t,e,n){return Math.max(e,Math.min(n,t))}function J(t,e){return(t%e+e)%e}function $(t,e,n){return(1-n)*t+n*e}function K(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Q(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const tt=H;class et{constructor(t,e){void 0===t&&(t=0),void 0===e&&(e=0),et.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Z(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),i=this.x-t.x,r=this.y-t.y;return this.x=i*n-r*s+t.x,this.y=i*s+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class nt{constructor(t,e,n,s,i,r,a,o,l){nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,s,i,r,a,o,l)}set(t,e,n,s,i,r,a,o,l){const h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=i,h[5]=o,h[6]=n,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,i=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],h=n[4],u=n[7],c=n[2],d=n[5],p=n[8],m=s[0],f=s[3],y=s[6],g=s[1],_=s[4],x=s[7],b=s[2],w=s[5],v=s[8];return i[0]=r*m+a*g+o*b,i[3]=r*f+a*_+o*w,i[6]=r*y+a*x+o*v,i[1]=l*m+h*g+u*b,i[4]=l*f+h*_+u*w,i[7]=l*y+h*x+u*v,i[2]=c*m+d*g+p*b,i[5]=c*f+d*_+p*w,i[8]=c*y+d*x+p*v,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*r*h-e*a*l-n*i*h+n*a*o+s*i*l-s*r*o}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],u=h*r-a*l,c=a*o-h*i,d=l*i-r*o,p=e*u+n*c+s*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=u*m,t[1]=(s*l-h*n)*m,t[2]=(a*n-s*r)*m,t[3]=c*m,t[4]=(h*e-s*o)*m,t[5]=(s*i-a*e)*m,t[6]=d*m,t[7]=(n*o-l*e)*m,t[8]=(r*e-n*i)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,i,r,a){const o=Math.cos(i),l=Math.sin(i);return this.set(n*o,n*l,-n*(o*r+l*a)+r+t,-s*l,s*o,-s*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(st.makeScale(t,e)),this}rotate(t){return this.premultiply(st.makeRotation(-t)),this}translate(t,e){return this.premultiply(st.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e){void 0===e&&(e=0);for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const st=new nt;function it(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const rt={};const at=(new nt).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ot=(new nt).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),lt={[D]:{transfer:O,primaries:U,toReference:t=>t,fromReference:t=>t},[C]:{transfer:W,primaries:U,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[F]:{transfer:O,primaries:"p3",toReference:t=>t.applyMatrix3(ot),fromReference:t=>t.applyMatrix3(at)},[N]:{transfer:W,primaries:"p3",toReference:t=>t.convertSRGBToLinear().applyMatrix3(ot),fromReference:t=>t.applyMatrix3(at).convertLinearToSRGB()}},ht=new Set([D,F]),ut={enabled:!0,_workingColorSpace:D,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!ht.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;const s=lt[e].toReference;return(0,lt[n].fromReference)(s(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return lt[t].primaries},getTransfer:function(t){return""===t?O:lt[t].transfer}};function ct(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function dt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let pt;class mt{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===pt&&(pt=it("canvas")),pt.width=t.width,pt.height=t.height;const n=pt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=pt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=it("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),i=s.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case L:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case L:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}xt.DEFAULT_IMAGE=null,xt.DEFAULT_MAPPING=300,xt.DEFAULT_ANISOTROPY=1;class bt{constructor(t,e,n,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=1),this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,i,r,a){let o=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3];const c=i[r+0],d=i[r+1],p=i[r+2],m=i[r+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=u);if(1===a)return t[e+0]=c,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(u!==m||o!==c||l!==d||h!==p){let t=1-a;const e=o*c+l*d+h*p+u*m,n=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const i=Math.sqrt(s),r=Math.atan2(i,e*n);t=Math.sin(t*r)/i,a=Math.sin(a*r)/i}const i=a*n;if(o=o*t+c*i,l=l*t+d*i,h=h*t+p*i,u=u*t+m*i,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=t,l*=t,h*=t,u*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,i,r){const a=n[s],o=n[s+1],l=n[s+2],h=n[s+3],u=i[r],c=i[r+1],d=i[r+2],p=i[r+3];return t[e]=a*p+h*u+o*d-l*c,t[e+1]=o*p+h*c+l*u-a*d,t[e+2]=l*p+h*d+a*c-o*u,t[e+3]=h*p-a*u-o*c-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){void 0===e&&(e=!0);const n=t._x,s=t._y,i=t._z,r=t._order,a=Math.cos,o=Math.sin,l=a(n/2),h=a(s/2),u=a(i/2),c=o(n/2),d=o(s/2),p=o(i/2);switch(r){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],h=e[6],u=e[10],c=n+a+u;if(c>0){const t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(h-o)*t,this._y=(i-l)*t,this._z=(r-s)*t}else if(n>a&&n>u){const t=2*Math.sqrt(1+n-a-u);this._w=(h-o)/t,this._x=.25*t,this._y=(s+r)/t,this._z=(i+l)/t}else if(a>u){const t=2*Math.sqrt(1+a-n-u);this._w=(i-l)/t,this._x=(s+r)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+u-n-a);this._w=(r-s)/t,this._x=(i+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Z(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const s=Math.min(1,e/n);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,i=t._z,r=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=n*h+r*a+s*l-i*o,this._y=s*h+r*o+i*a-n*l,this._z=i*h+r*l+n*o-s*a,this._w=r*h-n*a-s*o-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,s=this._y,i=this._z,r=this._w;let a=r*t._w+n*t._x+s*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=n,this._y=s,this._z=i,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*n+e*this._x,this._y=t*s+e*this._y,this._z=t*i+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-e)*h)/l,c=Math.sin(e*h)/l;return this._w=r*u+this._w*c,this._x=n*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class wt{constructor(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),wt.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(kt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(kt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*s,this.y=i[1]*e+i[4]*n+i[7]*s,this.z=i[2]*e+i[5]*n+i[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,i=t.elements,r=1/(i[3]*e+i[7]*n+i[11]*s+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*s+i[12])*r,this.y=(i[1]*e+i[5]*n+i[9]*s+i[13])*r,this.z=(i[2]*e+i[6]*n+i[10]*s+i[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,i=t.x,r=t.y,a=t.z,o=t.w,l=2*(r*s-a*n),h=2*(a*e-i*s),u=2*(i*n-r*e);return this.x=e+o*l+r*u-a*h,this.y=n+o*h+a*l-i*u,this.z=s+o*u+i*h-r*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*s,this.y=i[1]*e+i[5]*n+i[9]*s,this.z=i[2]*e+i[6]*n+i[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,i=t.z,r=e.x,a=e.y,o=e.z;return this.x=s*o-i*a,this.y=i*r-n*o,this.z=n*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return vt.copy(this).projectOnVector(t),this.sub(vt)}reflect(t){return this.sub(vt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Z(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vt=new wt,kt=new bt;class Mt{constructor(t,e){void 0===t&&(t=new wt(1/0,1/0,1/0)),void 0===e&&(e=new wt(-1/0,-1/0,-1/0)),this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Tt),Tt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(It),Ct.subVectors(this.max,It),Et.subVectors(t.a,It),Rt.subVectors(t.b,It),Bt.subVectors(t.c,It),zt.subVectors(Rt,Et),Pt.subVectors(Bt,Rt),Lt.subVectors(Et,Bt);let e=[0,-zt.z,zt.y,0,-Pt.z,Pt.y,0,-Lt.z,Lt.y,zt.z,0,-zt.x,Pt.z,0,-Pt.x,Lt.z,0,-Lt.x,-zt.y,zt.x,0,-Pt.y,Pt.x,0,-Lt.y,Lt.x,0];return!(!Ft(e,Et,Rt,Bt,Ct)||(e=[1,0,0,0,1,0,0,0,1],!Ft(e,Et,Rt,Bt,Ct)))&&(Dt.crossVectors(zt,Pt),e=[Dt.x,Dt.y,Dt.z],Ft(e,Et,Rt,Bt,Ct))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Tt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Tt).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(St[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),St[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),St[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),St[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),St[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),St[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),St[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),St[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(St)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const St=[new wt,new wt,new wt,new wt,new wt,new wt,new wt,new wt],Tt=new wt,At=new Mt,Et=new wt,Rt=new wt,Bt=new wt,zt=new wt,Pt=new wt,Lt=new wt,It=new wt,Ct=new wt,Dt=new wt,Nt=new wt;function Ft(t,e,n,s,i){for(let r=0,a=t.length-3;r<=a;r+=3){Nt.fromArray(t,r);const a=i.x*Math.abs(Nt.x)+i.y*Math.abs(Nt.y)+i.z*Math.abs(Nt.z),o=e.dot(Nt),l=n.dot(Nt),h=s.dot(Nt);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Ot=new Mt,Wt=new wt,Ut=new wt;class qt{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=-1),this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Ot.setFromPoints(t).getCenter(n);let s=0;for(let i=0,r=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Wt.subVectors(t,this.center);const e=Wt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(Wt,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ut.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Wt.copy(t.center).add(Ut)),this.expandByPoint(Wt.copy(t.center).sub(Ut))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const jt=new wt,Vt=new wt,Gt=new wt,Ht=new wt,Yt=new wt,Xt=new wt,Zt=new wt;class Jt{constructor(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f){Jt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f)}set(t,e,n,s,i,r,a,o,l,h,u,c,d,p,m,f){const y=this.elements;return y[0]=t,y[4]=e,y[8]=n,y[12]=s,y[1]=i,y[5]=r,y[9]=a,y[13]=o,y[2]=l,y[6]=h,y[10]=u,y[14]=c,y[3]=d,y[7]=p,y[11]=m,y[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Jt).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/$t.setFromMatrixColumn(t,0).length(),i=1/$t.setFromMatrixColumn(t,1).length(),r=1/$t.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,i=t.z,r=Math.cos(n),a=Math.sin(n),o=Math.cos(s),l=Math.sin(s),h=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){const t=r*h,n=r*u,s=a*h,i=a*u;e[0]=o*h,e[4]=-o*u,e[8]=l,e[1]=n+s*l,e[5]=t-i*l,e[9]=-a*o,e[2]=i-t*l,e[6]=s+n*l,e[10]=r*o}else if("YXZ"===t.order){const t=o*h,n=o*u,s=l*h,i=l*u;e[0]=t+i*a,e[4]=s*a-n,e[8]=r*l,e[1]=r*u,e[5]=r*h,e[9]=-a,e[2]=n*a-s,e[6]=i+t*a,e[10]=r*o}else if("ZXY"===t.order){const t=o*h,n=o*u,s=l*h,i=l*u;e[0]=t-i*a,e[4]=-r*u,e[8]=s+n*a,e[1]=n+s*a,e[5]=r*h,e[9]=i-t*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if("ZYX"===t.order){const t=r*h,n=r*u,s=a*h,i=a*u;e[0]=o*h,e[4]=s*l-n,e[8]=t*l+i,e[1]=o*u,e[5]=i*l+t,e[9]=n*l-s,e[2]=-l,e[6]=a*o,e[10]=r*o}else if("YZX"===t.order){const t=r*o,n=r*l,s=a*o,i=a*l;e[0]=o*h,e[4]=i-t*u,e[8]=s*u+n,e[1]=u,e[5]=r*h,e[9]=-a*h,e[2]=-l*h,e[6]=n*u+s,e[10]=t-i*u}else if("XZY"===t.order){const t=r*o,n=r*l,s=a*o,i=a*l;e[0]=o*h,e[4]=-u,e[8]=l*h,e[1]=t*u+i,e[5]=r*h,e[9]=n*u-s,e[2]=s*u-n,e[6]=a*h,e[10]=i*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Qt,t,te)}lookAt(t,e,n){const s=this.elements;return se.subVectors(t,e),0===se.lengthSq()&&(se.z=1),se.normalize(),ee.crossVectors(n,se),0===ee.lengthSq()&&(1===Math.abs(n.z)?se.x+=1e-4:se.z+=1e-4,se.normalize(),ee.crossVectors(n,se)),ee.normalize(),ne.crossVectors(se,ee),s[0]=ee.x,s[4]=ne.x,s[8]=se.x,s[1]=ee.y,s[5]=ne.y,s[9]=se.y,s[2]=ee.z,s[6]=ne.z,s[10]=se.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,i=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],h=n[1],u=n[5],c=n[9],d=n[13],p=n[2],m=n[6],f=n[10],y=n[14],g=n[3],_=n[7],x=n[11],b=n[15],w=s[0],v=s[4],k=s[8],M=s[12],S=s[1],T=s[5],A=s[9],E=s[13],R=s[2],B=s[6],z=s[10],P=s[14],L=s[3],I=s[7],C=s[11],D=s[15];return i[0]=r*w+a*S+o*R+l*L,i[4]=r*v+a*T+o*B+l*I,i[8]=r*k+a*A+o*z+l*C,i[12]=r*M+a*E+o*P+l*D,i[1]=h*w+u*S+c*R+d*L,i[5]=h*v+u*T+c*B+d*I,i[9]=h*k+u*A+c*z+d*C,i[13]=h*M+u*E+c*P+d*D,i[2]=p*w+m*S+f*R+y*L,i[6]=p*v+m*T+f*B+y*I,i[10]=p*k+m*A+f*z+y*C,i[14]=p*M+m*E+f*P+y*D,i[3]=g*w+_*S+x*R+b*L,i[7]=g*v+_*T+x*B+b*I,i[11]=g*k+_*A+x*z+b*C,i[15]=g*M+_*E+x*P+b*D,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],i=t[12],r=t[1],a=t[5],o=t[9],l=t[13],h=t[2],u=t[6],c=t[10],d=t[14];return t[3]*(+i*o*u-s*l*u-i*a*c+n*l*c+s*a*d-n*o*d)+t[7]*(+e*o*d-e*l*c+i*r*c-s*r*d+s*l*h-i*o*h)+t[11]*(+e*l*u-e*a*d-i*r*u+n*r*d+i*a*h-n*l*h)+t[15]*(-s*a*h-e*o*u+e*a*c+s*r*u-n*r*c+n*o*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],i=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],u=t[9],c=t[10],d=t[11],p=t[12],m=t[13],f=t[14],y=t[15],g=u*f*l-m*c*l+m*o*d-a*f*d-u*o*y+a*c*y,_=p*c*l-h*f*l-p*o*d+r*f*d+h*o*y-r*c*y,x=h*m*l-p*u*l+p*a*d-r*m*d-h*a*y+r*u*y,b=p*u*o-h*m*o-p*a*c+r*m*c+h*a*f-r*u*f,w=e*g+n*_+s*x+i*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const v=1/w;return t[0]=g*v,t[1]=(m*c*i-u*f*i-m*s*d+n*f*d+u*s*y-n*c*y)*v,t[2]=(a*f*i-m*o*i+m*s*l-n*f*l-a*s*y+n*o*y)*v,t[3]=(u*o*i-a*c*i-u*s*l+n*c*l+a*s*d-n*o*d)*v,t[4]=_*v,t[5]=(h*f*i-p*c*i+p*s*d-e*f*d-h*s*y+e*c*y)*v,t[6]=(p*o*i-r*f*i-p*s*l+e*f*l+r*s*y-e*o*y)*v,t[7]=(r*c*i-h*o*i+h*s*l-e*c*l-r*s*d+e*o*d)*v,t[8]=x*v,t[9]=(p*u*i-h*m*i-p*n*d+e*m*d+h*n*y-e*u*y)*v,t[10]=(r*m*i-p*a*i+p*n*l-e*m*l-r*n*y+e*a*y)*v,t[11]=(h*a*i-r*u*i-h*n*l+e*u*l+r*n*d-e*a*d)*v,t[12]=b*v,t[13]=(h*m*s-p*u*s+p*n*c-e*m*c-h*n*f+e*u*f)*v,t[14]=(p*a*s-r*m*s-p*n*o+e*m*o+r*n*f-e*a*f)*v,t[15]=(r*u*s-h*a*s+h*n*o-e*u*o-r*n*c+e*a*c)*v,this}scale(t){const e=this.elements,n=t.x,s=t.y,i=t.z;return e[0]*=n,e[4]*=s,e[8]*=i,e[1]*=n,e[5]*=s,e[9]*=i,e[2]*=n,e[6]*=s,e[10]*=i,e[3]*=n,e[7]*=s,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),i=1-n,r=t.x,a=t.y,o=t.z,l=i*r,h=i*a;return this.set(l*r+n,l*a-s*o,l*o+s*a,0,l*a+s*o,h*a+n,h*o-s*r,0,l*o-s*a,h*o+s*r,i*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,i,r){return this.set(1,n,i,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,i=e._x,r=e._y,a=e._z,o=e._w,l=i+i,h=r+r,u=a+a,c=i*l,d=i*h,p=i*u,m=r*h,f=r*u,y=a*u,g=o*l,_=o*h,x=o*u,b=n.x,w=n.y,v=n.z;return s[0]=(1-(m+y))*b,s[1]=(d+x)*b,s[2]=(p-_)*b,s[3]=0,s[4]=(d-x)*w,s[5]=(1-(c+y))*w,s[6]=(f+g)*w,s[7]=0,s[8]=(p+_)*v,s[9]=(f-g)*v,s[10]=(1-(c+m))*v,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let i=$t.set(s[0],s[1],s[2]).length();const r=$t.set(s[4],s[5],s[6]).length(),a=$t.set(s[8],s[9],s[10]).length();this.determinant()<0&&(i=-i),t.x=s[12],t.y=s[13],t.z=s[14],Kt.copy(this);const o=1/i,l=1/r,h=1/a;return Kt.elements[0]*=o,Kt.elements[1]*=o,Kt.elements[2]*=o,Kt.elements[4]*=l,Kt.elements[5]*=l,Kt.elements[6]*=l,Kt.elements[8]*=h,Kt.elements[9]*=h,Kt.elements[10]*=h,e.setFromRotationMatrix(Kt),n.x=i,n.y=r,n.z=a,this}makePerspective(t,e,n,s,i,r,a){void 0===a&&(a=j);const o=this.elements,l=2*i/(e-t),h=2*i/(n-s),u=(e+t)/(e-t),c=(n+s)/(n-s);let d,p;if(a===j)d=-(r+i)/(r-i),p=-2*r*i/(r-i);else{if(2001!==a)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-r/(r-i),p=-r*i/(r-i)}return o[0]=l,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=h,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,s,i,r,a){void 0===a&&(a=j);const o=this.elements,l=1/(e-t),h=1/(n-s),u=1/(r-i),c=(e+t)*l,d=(n+s)*h;let p,m;if(a===j)p=(r+i)*u,m=-2*u;else{if(2001!==a)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=i*u,m=-1*u}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e){void 0===e&&(e=0);for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const $t=new wt,Kt=new Jt,Qt=new wt(0,0,0),te=new wt(1,1,1),ee=new wt,ne=new wt,se=new wt,ie=new Jt,re=new bt;class ae{constructor(t,e,n,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=ae.DEFAULT_ORDER),this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s){return void 0===s&&(s=this._order),this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,n){void 0===e&&(e=this._order),void 0===n&&(n=!0);const s=t.elements,i=s[0],r=s[4],a=s[8],o=s[1],l=s[5],h=s[9],u=s[2],c=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(Z(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(c,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Z(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Z(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(o,i));break;case"ZYX":this._y=Math.asin(-Z(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,d),this._z=Math.atan2(o,i)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Z(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Z(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(c,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return ie.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ie,e,n)}setFromVector3(t,e){return void 0===e&&(e=this._order),this.set(t.x,t.y,t.z,e)}reorder(t){return re.setFromEuler(this),this.setFromQuaternion(re,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ae.DEFAULT_ORDER="XYZ";class oe{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(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((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),s.maxGeometryCount=this._maxGeometryCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),null!==this.boundingBox&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=i(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,s=n.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(n.geometries=e),s.length>0&&(n.materials=s),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),u.length>0&&(n.nodes=u)}return n.object=s,n;function r(t){const e=[];for(const n in t){const s=t[n];delete s.metadata,e.push(s)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let n=0;n0?s.multiplyScalar(1/Math.sqrt(i)):s.set(0,0,0)}static getBarycoord(t,e,n,s,i){Me.subVectors(s,e),Se.subVectors(n,e),Te.subVectors(t,e);const r=Me.dot(Me),a=Me.dot(Se),o=Me.dot(Te),l=Se.dot(Se),h=Se.dot(Te),u=r*l-a*a;if(0===u)return i.set(0,0,0),null;const c=1/u,d=(l*o-a*h)*c,p=(r*h-a*o)*c;return i.set(1-d-p,p,d)}static containsPoint(t,e,n,s){return null!==this.getBarycoord(t,e,n,s,Ae)&&(Ae.x>=0&&Ae.y>=0&&Ae.x+Ae.y<=1)}static getInterpolation(t,e,n,s,i,r,a,o){return null===this.getBarycoord(t,e,n,s,Ae)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(i,Ae.x),o.addScaledVector(r,Ae.y),o.addScaledVector(a,Ae.z),o)}static isFrontFacing(t,e,n,s){return Me.subVectors(n,e),Se.subVectors(t,e),Me.cross(Se).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Me.subVectors(this.c,this.b),Se.subVectors(this.a,this.b),.5*Me.cross(Se).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ie.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ie.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,i){return Ie.getInterpolation(t,this.a,this.b,this.c,e,n,s,i)}containsPoint(t){return Ie.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ie.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,i=this.c;let r,a;Ee.subVectors(s,n),Re.subVectors(i,n),ze.subVectors(t,n);const o=Ee.dot(ze),l=Re.dot(ze);if(o<=0&&l<=0)return e.copy(n);Pe.subVectors(t,s);const h=Ee.dot(Pe),u=Re.dot(Pe);if(h>=0&&u<=h)return e.copy(s);const c=o*u-h*l;if(c<=0&&o>=0&&h<=0)return r=o/(o-h),e.copy(n).addScaledVector(Ee,r);Le.subVectors(t,i);const d=Ee.dot(Le),p=Re.dot(Le);if(p>=0&&d<=p)return e.copy(i);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Re,a);const f=h*p-d*u;if(f<=0&&u-h>=0&&d-p>=0)return Be.subVectors(i,s),a=(u-h)/(u-h+(d-p)),e.copy(s).addScaledVector(Be,a);const y=1/(f+m+c);return r=m*y,a=c*y,e.copy(n).addScaledVector(Ee,r).addScaledVector(Re,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ce={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},De={h:0,s:0,l:0},Ne={h:0,s:0,l:0};function Fe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Oe{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e){return void 0===e&&(e=C),t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ut.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s){return void 0===s&&(s=ut.workingColorSpace),this.r=t,this.g=e,this.b=n,ut.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s){if(void 0===s&&(s=ut.workingColorSpace),t=J(t,1),e=Z(e,0,1),n=Z(n,0,1),0===e)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,i=2*n-s;this.r=Fe(i,s,t+1/3),this.g=Fe(i,s,t),this.b=Fe(i,s,t-1/3)}return ut.toWorkingColorSpace(this,s),this}setStyle(t,e){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(void 0===e&&(e=C),s=/^(\w+)\(([^\)]*)\)/.exec(t)){let i;const r=s[1],a=s[2];switch(r){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],i=n.length;if(3===i)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e){void 0===e&&(e=C);const n=Ce[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ct(t.r),this.g=ct(t.g),this.b=ct(t.b),this}copyLinearToSRGB(t){return this.r=dt(t.r),this.g=dt(t.g),this.b=dt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t){return void 0===t&&(t=C),ut.fromWorkingColorSpace(We.copy(this),t),65536*Math.round(Z(255*We.r,0,255))+256*Math.round(Z(255*We.g,0,255))+Math.round(Z(255*We.b,0,255))}getHexString(t){return void 0===t&&(t=C),("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e){void 0===e&&(e=ut.workingColorSpace),ut.fromWorkingColorSpace(We.copy(this),e);const n=We.r,s=We.g,i=We.b,r=Math.max(n,s,i),a=Math.min(n,s,i);let o,l;const h=(a+r)/2;if(a===r)o=0,l=0;else{const t=r-a;switch(l=h<=.5?t/(r+a):t/(2-r-a),r){case n:o=(s-i)/t+(s0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function s(t){const e=[];for(const n in t){const s=t[n];delete s.metadata,e.push(s)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==q&&(n.stencilFail=this.stencilFail),this.stencilZFail!==q&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==q&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=s(t.textures),i=s(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let s=0;s!==t;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const je=new wt,Ve=new et;class Ge{constructor(t,e,n){if(void 0===n&&(n=!1),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return(t="THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.")in rt||(rt[t]=!0,console.warn(t)),this._updateRange;var t}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,i=this.itemSize;s=0;--e)if(t[e]>=65535)return!0;return!1}(t)?Ye:He)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n){void 0===n&&(n=0),this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new nt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const s=this.attributes.tangent;return void 0!==s&&(s.transformDirection(t),s.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Je.makeRotationFromQuaternion(t),this.applyMatrix4(Je),this}rotateX(t){return Je.makeRotationX(t),this.applyMatrix4(Je),this}rotateY(t){return Je.makeRotationY(t),this.applyMatrix4(Je),this}rotateZ(t){return Je.makeRotationZ(t),this.applyMatrix4(Je),this}translate(t,e,n){return Je.makeTranslation(t,e,n),this.applyMatrix4(Je),this}scale(t,e,n){return Je.makeScale(t,e,n),this.applyMatrix4(Je),this}lookAt(t){return $e.lookAt(t),$e.updateMatrix(),this.applyMatrix4($e.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ke).negate(),this.translate(Ke.x,Ke.y,Ke.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const o in n){const e=n[o];t.data.attributes[o]=e.toJSON(t.data)}const s={};let i=!1;for(const o in this.morphAttributes){const e=this.morphAttributes[o],n=[];for(let s=0,i=e.length;s0&&(s[o]=n,i=!0)}i&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const s=t.attributes;for(const l in s){const t=s[l];this.setAttribute(l,t.clone(e))}const i=t.morphAttributes;for(const l in i){const t=[],n=i[l];for(let s=0,i=n.length;s1?null:e.copy(t.start).addScaledVector(n,i)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||cn.getNormalMatrix(t),s=this.coplanarPoint(hn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}class pn extends xt{constructor(t,e,n,s,i,r,a,o,l,h){if(void 0===h&&(h=I),h!==I&&1027!==h)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===I&&(n=1014),void 0===n&&1027===h&&(n=1020),super(null,s,i,r,a,o,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:1003,this.minFilter=void 0!==o?o:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}new pn(1,1).compareFunction=515;class mn extends qe{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Oe(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 Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(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 ae,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class fn extends mn{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new et(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Z(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class yn{constructor(t,e,n){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===n&&(n=0),this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Z(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const gn=new wt,_n=new wt;class xn{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=new wt),this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){gn.subVectors(t,this.start),_n.subVectors(this.end,this.start);const n=_n.dot(_n);let s=_n.dot(gn)/n;return e&&(s=Z(s,0,1)),s}closestPointToPoint(t,e,n){const s=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"165"}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="165");class bn extends fn{constructor(){super(),k(this,"oBaseWeight",1),k(this,"oBaseColor",[.8,.8,.8]),k(this,"oBaseMetalness",0),k(this,"oBaseDiffuseRoughness",0),k(this,"oSpecularWeight",1),k(this,"oSpecularColor",[1,1,1]),k(this,"oSpecularRoughness",.3),k(this,"oSpecularRoughnessAnisotropy",0),k(this,"oSpecularIOR",1.5),k(this,"oCoatWeight",0),k(this,"oCoatColor",[1,1,1]),k(this,"oCoatRoughness",0),k(this,"oCoatRoughnessAnisotropy",0),k(this,"oCoatIor",1.6),k(this,"oCoatDarkening",1),k(this,"oEmissionLuminance",0),k(this,"oEmissionColor",[1,1,1]),k(this,"oThinFilmThickness",.5),k(this,"oThinFilmIOR",1.5)}}const wn=0,vn=1,kn=2,Mn=2,Sn=1.25,Tn=1,An=32,En=65535,Rn=Math.pow(2,-24),Bn=Symbol("SKIP_GENERATION");function zn(t){return function(t){return t.index?t.index.count:t.attributes.position.count}(t)/3}function Pn(t,e){if(!t.index){const n=t.attributes.position.count,s=function(t,e){return void 0===e&&(e=ArrayBuffer),t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new Ge(s,1));for(let t=0;tt-e));for(let o=0;ol&&(l=i),em&&(m=e);const _=t[g+2],x=t[g+3],b=_-x,w=_+x;bh&&(h=w),_f&&(f=_);const v=t[g+4],k=t[g+5],M=v-k,S=v+k;Mu&&(u=S),vy&&(y=v)}s[0]=r,s[1]=a,s[2]=o,s[3]=l,s[4]=h,s[5]=u,i[0]=c,i[1]=d,i[2]=p,i[3]=m,i[4]=f,i[5]=y}function Dn(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function Nn(t){let e=-1,n=-1/0;for(let s=0;s<3;s++){const i=t[s+3]-t[s];i>n&&(n=i,e=s)}return e}function Fn(t,e){e.set(t)}function On(t,e,n){let s,i;for(let r=0;r<3;r++){const a=r+3;s=t[r],i=e[r],n[r]=si?s:i}}function Wn(t,e,n){for(let s=0;s<3;s++){const i=e[t+2*s],r=e[t+2*s+1],a=i-r,o=i+r;an[s+3]&&(n[s+3]=o)}}function Un(t){const e=t[3]-t[0],n=t[4]-t[1],s=t[5]-t[2];return 2*(e*n+n*s+s*e)}const qn=32,jn=(t,e)=>t.candidate-e.candidate,Vn=new Array(qn).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),Gn=new Float32Array(6);class Hn{constructor(){this.boundingData=new Float32Array(6)}}function Yn(t,e,n,s,i,r){let a=s,o=s+i-1;const l=r.pos,h=2*r.axis;for(;;){for(;a<=o&&n[6*a+h]=l;)o--;if(!(a=l;)o--;if(!(ars)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ns[n+6]=a/4,a=ls(a,i),ns[n+7]=r,a}}function hs(t,e,n,s,i){const{maxDepth:r,verbose:a,maxLeafTris:o,strategy:l,onProgress:h,indirect:u}=i,c=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,m=u?Xn:Yn,f=zn(d),y=new Float32Array(6);let g=!1;const _=new Hn;return Cn(e,n,s,_.boundingData,y),function t(n,s,i,h,u){void 0===h&&(h=null);void 0===u&&(u=0);if(!g&&u>=r&&(g=!0,a&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),i<=o||u>=r)return x(s+i),n.offset=s,n.count=i,n;const f=function(t,e,n,s,i,r){let a=-1,o=0;if(r===wn)a=Nn(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(r===vn)a=Nn(t),-1!==a&&(o=function(t,e,n,s){let i=0;for(let r=e,a=e+n;r=r.candidate?Wn(i,n,r.rightCacheBounds):(Wn(i,n,r.leftCacheBounds),r.count++)}}for(let n=0;n=qn&&(e=qn-1);const r=Vn[e];r.count++,Wn(i,n,r.bounds)}const e=Vn[qn-1];Fn(e.bounds,e.rightCacheBounds);for(let t=qn-2;t>=0;t--){const e=Vn[t],n=Vn[t+1];On(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let n=0;n65536,i=s?4:2,r=e?new SharedArrayBuffer(n*i):new ArrayBuffer(n*i),a=s?new Uint32Array(r):new Uint16Array(r);for(let o=0,l=a.length;ot.offset-e.offset)),s=n[n.length-1];s.count=Math.min(e-s.offset,s.count);let i=0;return n.forEach((t=>{let{count:e}=t;return i+=e})),e!==i}(n)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||Pn(n,e);const s=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=function(t,e,n,s){void 0===e&&(e=null),void 0===n&&(n=null),void 0===s&&(s=null);const i=t.attributes.position,r=t.index?t.index.array:null,a=zn(t),o=i.normalized;let l;null===e?(l=new Float32Array(6*a*4),n=0,s=a):(l=e,n=n||0,s=s||a);const h=i.array,u=i.offset||0;let c=3;i.isInterleavedBufferAttribute&&(c=i.data.stride);const d=["getX","getY","getZ"];for(let p=n;pm&&(m=u),c>m&&(m=c);const f=(m-p)/2,y=2*r;l[e+y+0]=p+f,l[e+y+1]=f+(Math.abs(p)+f)*Rn}}return l}(n),r=e.indirect?Ln(n):In(n);t._roots=r.map((n=>{const r=hs(t,i,n.offset,n.count,e),a=as(r),o=new s(An*a);return os(0,r,o),o}))}class cs{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,s=-1/0;for(let i=0,r=t.length;is?r:s}this.min=n,this.max=s}setFromPoints(t,e){let n=1/0,s=-1/0;for(let i=0,r=e.length;is?a:s}this.min=n,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}cs.prototype.setFromBox=function(){const t=new wt;return function(e,n){const s=n.min,i=n.max;let r=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let n=0;n<=1;n++)for(let l=0;l<=1;l++){t.x=s.x*o+i.x*(1-o),t.y=s.y*n+i.y*(1-n),t.z=s.z*l+i.z*(1-l);const h=e.dot(t);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}}();const ds=function(){const t=new wt,e=new wt,n=new wt;return function(s,i,r){const a=s.start,o=t,l=i.start,h=e;n.subVectors(a,l),t.subVectors(s.end,s.start),e.subVectors(i.end,i.start);const u=n.dot(h),c=h.dot(o),d=h.dot(h),p=n.dot(o),m=o.dot(o)*d-c*c;let f,y;f=0!==m?(u*c-p*d)/m:0,y=(u+f*c)/d,r.x=f,r.y=y}}(),ps=function(){const t=new et,e=new wt,n=new wt;return function(s,i,r,a){ds(s,i,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return s.at(o,r),void i.at(l,a);if(o>=0&&o<=1)return l<0?i.at(0,a):i.at(1,a),void s.closestPointToPoint(a,!0,r);if(l>=0&&l<=1)return o<0?s.at(0,r):s.at(1,r),void i.closestPointToPoint(r,!0,a);{let t,h;t=o<0?s.start:s.end,h=l<0?i.start:i.end;const u=e,c=n;return s.closestPointToPoint(h,!0,e),i.closestPointToPoint(t,!0,n),u.distanceToSquared(h)<=c.distanceToSquared(t)?(r.copy(u),void a.copy(h)):(r.copy(t),void a.copy(c))}}}(),ms=function(){const t=new wt,e=new wt,n=new dn,s=new xn;return function(i,r){const{radius:a,center:o}=i,{a:l,b:h,c:u}=r;if(s.start=l,s.end=h,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a||(s.start=l,s.end=u,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a)||(s.start=h,s.end=u,s.closestPointToPoint(o,!0,t).distanceTo(o)<=a))return!0;const c=r.getPlane(n);if(Math.abs(c.distanceToPoint(o))<=a){const t=c.projectPoint(o,e);if(r.containsPoint(t))return!0}return!1}}();function fs(t){return Math.abs(t)<1e-15}class ys extends Ie{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new wt)),this.satBounds=new Array(4).fill().map((()=>new cs)),this.points=[this.a,this.b,this.c],this.sphere=new qt,this.plane=new dn,this.needsUpdate=!0}intersectsSphere(t){return ms(t,this)}update(){const t=this.a,e=this.b,n=this.c,s=this.points,i=this.satAxes,r=this.satBounds,a=i[0],o=r[0];this.getNormal(a),o.setFromPoints(a,s);const l=i[1],h=r[1];l.subVectors(t,e),h.setFromPoints(l,s);const u=i[2],c=r[2];u.subVectors(e,n),c.setFromPoints(u,s);const d=i[3],p=r[3];d.subVectors(n,t),p.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}ys.prototype.closestPointToSegment=function(){const t=new wt,e=new wt,n=new xn;return function(s,i,r){void 0===i&&(i=null),void 0===r&&(r=null);const{start:a,end:o}=s,l=this.points;let h,u=1/0;for(let c=0;c<3;c++){const a=(c+1)%3;n.start.copy(l[c]),n.end.copy(l[a]),ps(n,s,t,e),h=t.distanceToSquared(e),h=2){(1===r?n.start:n.end).copy(p),i=2;break}if(i++,2===i&&-1===r)break}}return i}return function(a,u,p){void 0===u&&(u=null),void 0===p&&(p=!1),this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const f=this.plane,y=a.plane;if(Math.abs(f.normal.dot(y.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const i=t[e],r=o[e];if(s.setFromPoints(r,n),i.isSeparated(s))return!1}const l=a.satBounds,h=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let n=0;n<4;n++){const t=l[n],i=h[n];if(s.setFromPoints(i,e),t.isSeparated(s))return!1}for(let a=0;a<4;a++){const t=o[a];for(let a=0;a<4;a++){const o=h[a];if(r.crossVectors(t,o),s.setFromPoints(r,e),i.setFromPoints(r,n),s.isSeparated(i))return!1}}return u&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),u.start.set(0,0,0),u.end.set(0,0,0)),!0}{const t=m(this,y,c);if(1===t&&a.containsPoint(c.end))return u&&(u.start.copy(c.end),u.end.copy(c.end)),!0;if(2!==t)return!1;const e=m(a,f,d);if(1===e&&this.containsPoint(d.end))return u&&(u.start.copy(d.end),u.end.copy(d.end)),!0;if(2!==e)return!1;if(c.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=c.start.dot(o),s=c.end.dot(o),i=d.start.dot(o),r=d.end.dot(o);return(n===r||i===s||s0?u.start.copy(c.start):u.start.copy(d.start),h.subVectors(c.end,d.end),h.dot(o)<0?u.end.copy(c.end):u.end.copy(d.end)),!0)}}}(),ys.prototype.distanceToPoint=function(){const t=new wt;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),ys.prototype.distanceToTriangle=function(){const t=new wt,e=new wt,n=["a","b","c"],s=new xn,i=new xn;return function(r,a,o){void 0===a&&(a=null),void 0===o&&(o=null);const l=a||o?s:null;if(this.intersectsTriangle(r,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let e=0;e<3;e++){let s;const i=n[e],l=r[i];this.closestPointToPoint(l,t),s=l.distanceToSquared(t),snew wt)),this.satAxes=new Array(3).fill().map((()=>new wt)),this.satBounds=new Array(3).fill().map((()=>new cs)),this.alignedSatBounds=new Array(3).fill().map((()=>new cs)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}gs.prototype.update=function(){return function(){const t=this.matrix,e=this.min,n=this.max,s=this.points;for(let l=0;l<=1;l++)for(let i=0;i<=1;i++)for(let r=0;r<=1;r++){const a=s[1*l|2*i|4*r];a.x=l?n.x:e.x,a.y=i?n.y:e.y,a.z=r?n.z:e.z,a.applyMatrix4(t)}const i=this.satBounds,r=this.satAxes,a=s[0];for(let l=0;l<3;l++){const t=r[l],e=i[l],n=s[1<new xn)),n=new Array(12).fill().map((()=>new xn)),s=new wt,i=new wt;return function(r,a,o,l){if(void 0===a&&(a=0),void 0===o&&(o=null),void 0===l&&(l=null),this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||l)&&(r.getCenter(i),this.closestPointToPoint(i,s),r.closestPointToPoint(s,i),o&&o.copy(s),l&&l.copy(i)),0;const h=a*a,u=r.min,c=r.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];i.copy(e).clamp(u,c);const n=e.distanceToSquared(i);if(nnew ys))}}const bs=new xs;const ws=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let vs,ks;const Ms=[],Ss=new _s((()=>new Mt));function Ts(t,e,n,s,i,r){vs=Ss.getPrimitive(),ks=Ss.getPrimitive(),Ms.push(vs,ks),ws.setBuffer(t._roots[e]);const a=As(0,t.geometry,n,s,i,r);ws.clearBuffer(),Ss.releasePrimitive(vs),Ss.releasePrimitive(ks),Ms.pop(),Ms.pop();const o=Ms.length;return o>0&&(ks=Ms[o-1],vs=Ms[o-2]),a}function As(t,e,n,s,i,r,a){void 0===i&&(i=null),void 0===r&&(r=0),void 0===a&&(a=0);const{float32Array:o,uint16Array:l,uint32Array:h}=ws;let u=2*t;if(Zn(u,l)){const e=Jn(t,h),n=$n(u,l);return Dn(t,o,vs),s(e,n,!1,a,r+t,vs)}{let u=function(t){const{uint16Array:e,uint32Array:n}=ws;let s=2*t;for(;!Zn(s,e);)s=2*(t=Kn(t));return Jn(t,n)},c=function(t){const{uint16Array:e,uint32Array:n}=ws;let s=2*t;for(;!Zn(s,e);)s=2*(t=Qn(t,n));return Jn(t,n)+$n(s,e)};const d=Kn(t),p=Qn(t,h);let m,f,y,g,_=d,x=p;if(i&&(y=vs,g=ks,Dn(_,o,y),Dn(x,o,g),m=i(y),f=i(g),fo?null:{distance:h,point:i.clone()}}(t,Bs,zs,Ps,Os,l,h,u);if(c){s&&(Ls.fromBufferAttribute(s,r),Is.fromBufferAttribute(s,a),Cs.fromBufferAttribute(s,o),c.uv=Ie.getInterpolation(Os,Bs,zs,Ps,Ls,Is,Cs,new et)),i&&(Ls.fromBufferAttribute(i,r),Is.fromBufferAttribute(i,a),Cs.fromBufferAttribute(i,o),c.uv1=Ie.getInterpolation(Os,Bs,zs,Ps,Ls,Is,Cs,new et)),n&&(Ds.fromBufferAttribute(n,r),Ns.fromBufferAttribute(n,a),Fs.fromBufferAttribute(n,o),c.normal=Ie.getInterpolation(Os,Bs,zs,Ps,Ds,Ns,Fs,new wt),c.normal.dot(t.direction)>0&&c.normal.multiplyScalar(-1));const e={a:r,b:a,c:o,normal:new wt,materialIndex:0};Ie.getNormal(Bs,zs,Ps,e.normal),c.face=e,c.faceIndex=r}return c}function Us(t,e,n,s,i,r,a){const o=3*s;let l=o+0,h=o+1,u=o+2;const c=t.index;t.index&&(l=c.getX(l),h=c.getX(h),u=c.getX(u));const{position:d,normal:p,uv:m,uv1:f}=t.attributes,y=Ws(n,d,p,m,f,l,h,u,e,r,a);return y?(y.faceIndex=s,i&&i.push(y),y):null}function qs(t,e,n,s){const i=t.a,r=t.b,a=t.c;let o=e,l=e+1,h=e+2;n&&(o=n.getX(o),l=n.getX(l),h=n.getX(h)),i.x=s.getX(o),i.y=s.getY(o),i.z=s.getZ(o),r.x=s.getX(l),r.y=s.getY(l),r.z=s.getZ(l),a.x=s.getX(h),a.y=s.getY(h),a.z=s.getZ(h)}function js(t,e,n,s,i,r,a){const{geometry:o}=n,{index:l}=o,h=o.attributes.position;for(let u=t,c=e+t;uc&&(c=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==r||l[t+2]!==u||l[t+3]!==c||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=r,l[t+2]=u,l[t+3]=c,l[t+4]=d,l[t+5]=p,!0)}{const s=t+8,i=a[t+6],o=s+n,h=i+n;let u=r,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);const m=u||p;let f=!1;(u||d)&&(f=c(s,n,u));let y=!1;m&&(y=c(i,n,u));const g=f||y;if(g)for(let e=0;e<3;e++){const n=s+e,r=i+e,a=l[n],o=l[n+3],h=l[r],u=l[r+3];l[t+e]=au?o:u}return g}}}function Gs(t,e,n,s,i){let r,a,o,l,h,u;const c=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,m=n.origin.x,f=n.origin.y,y=n.origin.z;let g=e[t],_=e[t+3],x=e[t+1],b=e[t+3+1],w=e[t+2],v=e[t+3+2];return c>=0?(r=(g-m)*c,a=(_-m)*c):(r=(_-m)*c,a=(g-m)*c),d>=0?(o=(x-f)*d,l=(b-f)*d):(o=(b-f)*d,l=(x-f)*d),!(r>l||o>a||((o>r||isNaN(r))&&(r=o),(l=0?(h=(w-y)*p,u=(v-y)*p):(h=(v-y)*p,u=(w-y)*p),r>u||h>a))&&((h>r||r!=r)&&(r=h),(u=s)}function Hs(t,e,n,s,i,r,a){const{geometry:o}=n,{index:l}=o,h=o.attributes.position;for(let u=t,c=e+t;u=0;let c,d;u?(c=Kn(t),d=Qn(t,l)):(c=Qn(t,l),d=Kn(t));const p=Gs(c,a,s,i,r)?$s(c,e,n,s,i,r):null;if(p){const t=p.point[h];if(u?t<=a[d+o]:t>=a[d+o+3])return p}const m=Gs(d,a,s,i,r)?$s(d,e,n,s,i,r):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}const Ks=new Mt,Qs=new ys,ti=new ys,ei=new Jt,ni=new gs,si=new gs;function ii(t,e,n,s){ws.setBuffer(t._roots[e]);const i=ri(0,t,n,s);return ws.clearBuffer(),i}function ri(t,e,n,s,i){void 0===i&&(i=null);const{float32Array:r,uint16Array:a,uint32Array:o}=ws;let l=2*t;if(null===i&&(n.boundingBox||n.computeBoundingBox(),ni.set(n.boundingBox.min,n.boundingBox.max,s),i=ni),!Zn(l,a)){const a=t+8,l=o[t+6];return Dn(a,r,Ks),!!(i.intersectsBox(Ks)&&ri(a,e,n,s,i)||(Dn(l,r,Ks),i.intersectsBox(Ks)&&ri(l,e,n,s,i)))}{const i=e.geometry,h=i.index,u=i.attributes.position,c=n.index,d=n.attributes.position,p=Jn(t,o),m=$n(l,a);if(ei.copy(s).invert(),n.boundsTree)return Dn(t,r,si),si.matrix.copy(ei),si.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:t=>si.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let e=3*p,n=3*(m+p);eoi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>li.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{for(let a=e,o=e+i;ad&&(d=a),op&&(p=o),lm&&(m=l)}}return(l[n+0]!==r||l[n+1]!==h||l[n+2]!==c||l[n+3]!==d||l[n+4]!==p||l[n+5]!==m)&&(l[n+0]=r,l[n+1]=h,l[n+2]=c,l[n+3]=d,l[n+4]=p,l[n+5]=m,!0)}{const t=n+8,s=a[n+6],i=t+r,o=s+r;let u=h,d=!1,p=!1;e?u||(d=e.has(i),p=e.has(o),u=!d&&!p):(d=!0,p=!0);const m=u||p;let f=!1;(u||d)&&(f=c(t,r,u));let y=!1;m&&(y=c(s,r,u));const g=f||y;if(g)for(let e=0;e<3;e++){const i=t+e,r=s+e,a=l[i],o=l[i+3],h=l[r],u=l[r+3];l[n+e]=au?o:u}return g}}}function fi(t,e,n,s,i,r,a){ws.setBuffer(t._roots[e]),yi(0,t,n,s,i,r,a),ws.clearBuffer()}function yi(t,e,n,s,i,r,a){const{float32Array:o,uint16Array:l,uint32Array:h}=ws,u=2*t;if(Zn(u,l)){!function(t,e,n,s,i,r,a,o){const{geometry:l,_indirectBuffer:h}=t;for(let u=s,c=s+i;u=0;let c,d;u?(c=Kn(t),d=Qn(t,l)):(c=Qn(t,l),d=Kn(t));const p=Gs(c,a,s,i,r)?xi(c,e,n,s,i,r):null;if(p){const t=p.point[h];if(u?t<=a[d+o]:t>=a[d+o+3])return p}const m=Gs(d,a,s,i,r)?xi(d,e,n,s,i,r):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}const bi=new Mt,wi=new ys,vi=new ys,ki=new Jt,Mi=new gs,Si=new gs;function Ti(t,e,n,s){ws.setBuffer(t._roots[e]);const i=Ai(0,t,n,s);return ws.clearBuffer(),i}function Ai(t,e,n,s,i){void 0===i&&(i=null);const{float32Array:r,uint16Array:a,uint32Array:o}=ws;let l=2*t;if(null===i&&(n.boundingBox||n.computeBoundingBox(),Mi.set(n.boundingBox.min,n.boundingBox.max,s),i=Mi),!Zn(l,a)){const a=t+8,l=o[t+6];return Dn(a,r,bi),!!(i.intersectsBox(bi)&&Ai(a,e,n,s,i)||(Dn(l,r,bi),i.intersectsBox(bi)&&Ai(l,e,n,s,i)))}{const i=e.geometry,h=i.index,u=i.attributes.position,c=n.index,d=n.attributes.position,p=Jn(t,o),m=$n(l,a);if(ki.copy(s).invert(),n.boundsTree)return Dn(t,r,Si),Si.matrix.copy(ki),Si.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:t=>Si.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let n=p,s=m+p;nRi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>Bi.distanceToBox(t),intersectsBounds:(t,e,n)=>n<_&&n{for(let w=e,v=e+a;wnew Mt)),Oi=new Mt,Wi=new Mt,Ui=new Mt,qi=new Mt;let ji=!1;function Vi(t,e,n,s,i,r,a,o,l,h,u){let c,d;void 0===r&&(r=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===l&&(l=0),void 0===h&&(h=null),void 0===u&&(u=!1),u?(c=Ni,d=Di):(c=Di,d=Ni);const p=c.float32Array,m=c.uint32Array,f=c.uint16Array,y=d.float32Array,g=d.uint32Array,_=d.uint16Array,x=2*e,b=Zn(2*t,f),w=Zn(x,_);let v=!1;if(w&&b)v=u?i(Jn(e,g),$n(2*e,_),Jn(t,m),$n(2*t,f),l,a+e,o,r+t):i(Jn(t,m),$n(2*t,f),Jn(e,g),$n(2*e,_),o,r+t,l,a+e);else if(w){const h=Fi.getPrimitive();Dn(e,y,h),h.applyMatrix4(n);const c=Kn(t),d=Qn(t,m);Dn(c,p,Oi),Dn(d,p,Wi);const f=h.intersectsBox(Oi),g=h.intersectsBox(Wi);v=f&&Vi(e,c,s,n,i,a,r,l,o+1,h,!u)||g&&Vi(e,d,s,n,i,a,r,l,o+1,h,!u),Fi.releasePrimitive(h)}else{const c=Kn(e),d=Qn(e,g);Dn(c,y,Ui),Dn(d,y,qi);const f=h.intersectsBox(Ui),_=h.intersectsBox(qi);if(f&&_)v=Vi(t,c,n,s,i,r,a,o,l+1,h,u)||Vi(t,d,n,s,i,r,a,o,l+1,h,u);else if(f)if(b)v=Vi(t,c,n,s,i,r,a,o,l+1,h,u);else{const e=Fi.getPrimitive();e.copy(Ui).applyMatrix4(n);const h=Kn(t),d=Qn(t,m);Dn(h,p,Oi),Dn(d,p,Wi);const f=e.intersectsBox(Oi),y=e.intersectsBox(Wi);v=f&&Vi(c,h,s,n,i,a,r,l,o+1,e,!u)||y&&Vi(c,d,s,n,i,a,r,l,o+1,e,!u),Fi.releasePrimitive(e)}else if(_)if(b)v=Vi(t,d,n,s,i,r,a,o,l+1,h,u);else{const e=Fi.getPrimitive();e.copy(qi).applyMatrix4(n);const h=Kn(t),c=Qn(t,m);Dn(h,p,Oi),Dn(c,p,Wi);const f=e.intersectsBox(Oi),y=e.intersectsBox(Wi);v=f&&Vi(d,h,s,n,i,a,r,l,o+1,e,!u)||y&&Vi(d,c,s,n,i,a,r,l,o+1,e,!u),Fi.releasePrimitive(e)}}return v}const Gi=new gs,Hi=new Mt,Yi={strategy:wn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Xi{static serialize(t,e){void 0===e&&(e={}),e={cloneBuffers:!0,...e};const n=t.geometry,s=t._roots,i=t._indirectBuffer,r=n.getIndex();let a;return a=e.cloneBuffers?{roots:s.map((t=>t.slice())),index:r?r.array.slice():null,indirectBuffer:i?i.slice():null}:{roots:s,index:r?r.array:null,indirectBuffer:i},a}static deserialize(t,e,n){void 0===n&&(n={}),n={setIndex:!0,indirect:!!t.indirectBuffer,...n};const{index:s,roots:i,indirectBuffer:r}=t,a=new Xi(e,{...n,[Bn]:!0});if(a._roots=i,a._indirectBuffer=r||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new Ge(t.index,1,!1);e.setIndex(n)}else n.array!==s&&(n.array.set(s),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e){if(void 0===e&&(e={}),!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...Yi,[Bn]:!1},e)).useSharedArrayBuffer&&!(typeof SharedArrayBuffer<"u"))throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[Bn]||(us(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Mt))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t){return void 0===t&&(t=null),(this.indirect?mi:Vs)(this,t)}traverse(t,e){void 0===e&&(e=0);const n=this._roots[e],s=new Uint32Array(n),i=new Uint16Array(n);!function e(r,a){void 0===a&&(a=0);const o=2*r,l=i[o+15]===En;if(l){const e=s[r+6],h=i[o+14];t(a,l,new Float32Array(n,4*r,6),e,h)}else{const i=r+An/4,o=s[r+6],h=s[r+7];t(a,l,new Float32Array(n,4*r,6),h)||(e(i,a+1),e(o,a+1))}}(0)}raycast(t,e,n,s){void 0===e&&(e=0),void 0===n&&(n=0),void 0===s&&(s=1/0);const i=this._roots,r=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),h=r.groups,u=o?e.side:e,c=this.indirect?fi:Ys;for(let d=0,p=i.length;d!!t(s,i,r,o,l)||n(s,i,this,a,r,o,e)}else r||(r=a?(t,s,i,r)=>n(t,s,this,a,i,r,e):(t,e,n)=>n);let o=!1,l=0;const h=this._roots;for(let u=0,c=h.length;u{const e=this.resolveTriangleIndex(t);qs(r,3*e,a,o)}:t=>{qs(r,3*t,a,o)},h=bs.getPrimitive(),u=t.geometry.index,c=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);qs(h,3*n,u,c)}:t=>{qs(h,3*t,u,c)};if(i){const t=(t,n,s,a,o,u,c,p)=>{for(let m=s,f=s+a;mGi.intersectsBox(t),intersectsTriangle:t=>Gi.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n,s,i,r){return void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i=0),void 0===r&&(r=1/0),(this.indirect?Ci:pi)(this,t,e,n,s,i,r)}closestPointToPoint(t,e,n,s){return void 0===e&&(e={}),void 0===n&&(n=0),void 0===s&&(s=1/0),function(t,e,n,s,i){void 0===n&&(n={}),void 0===s&&(s=0),void 0===i&&(i=1/0);const r=s*s,a=i*i;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(Es.copy(e).clamp(t.min,t.max),Es.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,Es);const s=e.distanceToSquared(Es);return s{Dn(0,new Float32Array(e),Hi),t.union(Hi)})),t}}function Zi(t){return t._roots.map(((e,n)=>function(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,s,i,r)=>{const a=s[3]-s[0],o=s[4]-s[1],l=s[5]-s[2],h=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(r,n.tris.min),n.tris.max=Math.max(r,n.tris.max),n.surfaceAreaScore+=h*Sn*r):(n.splits[i]++,n.surfaceAreaScore+=h*Tn)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}const Ji='alias Color = vec3;\n\nstruct Material {\n baseWeight: f32,\n baseColor: Color,\n // todo: switch order of baseDiffuseRoughness and baseMetalness\n baseDiffuseRoughness: f32,\n baseMetalness: f32,\n specularWeight: f32,\n specularColor: Color,\n specularRoughness: f32,\n specularAnisotropy: f32,\n specularRotation: f32,\n specularIor: f32,\n coatWeight: f32,\n coatColor: Color,\n coatRoughness: f32,\n coatRoughnessAnisotropy: f32,\n coatIor: f32,\n coatDarkening: f32,\n emissionLuminance: f32,\n emissionColor: Color,\n thinFilmThickness: f32,\n thinFilmIOR: f32,\n}\n\nstruct UniformData {\n invProjectionMatrix: mat4x4,\n cameraWorldMatrix: mat4x4,\n invModelMatrix: mat4x4,\n seedOffset: u32,\n priorSamples: u32,\n samplesPerPixel: u32,\n sunDirection: vec3f,\n skyPower: f32,\n skyColor: Color,\n sunPower: f32,\n sunAngularSize: f32,\n sunColor: Color,\n clearColor: Color,\n // bool is not supported in uniform\n enableClearColor: i32,\n maxRayDepth: i32,\n objectDefinitionLength: i32,\n}\n\n@group(0) @binding(0) var positions: array;\n// todo: Check when i16 is supported\n@group(0) @binding(1) var indices: array;\n\n@group(0) @binding(2) var bounds: array;\n@group(0) @binding(3) var contents: array;\n\n@group(0) @binding(4) var normals: array;\n\n@group(0) @binding(5) var indirectIndices: array;\n\n@group(0) @binding(6) var objectDefinitions: array;\n\n@group(0) @binding(7) var materials: array;\n\n@group(1) @binding(0) var texture: texture_storage_2d;\n\n@group(1) @binding(1) var readTexture: texture_storage_2d;\n\n@group(1) @binding(2) var uniformData: UniformData;\n\nconst MINIMUM_FLOAT_EPSILON = 1e-8;\nconst FLT_EPSILON = 1.1920929e-7;\nconst PI = 3.1415926535897932;\nconst PI_INVERSE = 1.0 / PI;\n\nstruct Ray {\n origin: vec3,\n direction: vec3,\n};\n\nstruct ObjectDefinition {\n start: u32,\n count: u32,\n material: MaterialDefinition,\n}\n\nstruct MaterialDefinition {\n index: u32,\n}\n\nstruct HitRecord {\n point: vec3,\n normal: vec3,\n t: f32,\n frontFace: bool,\n material: MaterialDefinition,\n}\n\nstruct Triangle {\n Q: vec3,\n u: vec3,\n v: vec3,\n material: MaterialDefinition,\n normal0: vec3,\n normal1: vec3,\n normal2: vec3,\n}\n\nstruct Interval {\n min: f32,\n max: f32,\n}\n\nstruct BinaryBvhNodeInfo {\n // 0-16: isLeaf, 17-31: splitAxis|triangleCount\n x: u32,\n // rightIndex|triangleOffset\n y: u32,\n}\n\nfn nearZero(v: vec3f) -> bool {\n let epsilon = vec3f(MINIMUM_FLOAT_EPSILON);\n return any(abs(v) < epsilon);\n}\n\nfn sqr(x: f32) -> f32 {\n return x * x;\n}\n\nfn maxVec3(v: vec3f) -> f32 {\n return max(v.x, max(v.y, v.z));\n}\n\nfn ggxNDF(H: vec3f, alpha: vec2) -> f32 {\n let safeAlpha = clamp(alpha, vec2(DENOM_TOLERANCE, DENOM_TOLERANCE), vec2(1.0, 1.0));\n let Ddenom = PI * safeAlpha.x * safeAlpha.y * sqr(sqr(H.x/safeAlpha.x) + sqr(H.y/safeAlpha.y) + sqr(H.z));\n return 1.0 / max(Ddenom, DENOM_TOLERANCE);\n}\n\n// GGX NDF sampling routine, as described in\n// "Sampling Visible GGX Normals with Spherical Caps", Dupuy et al., HPG 2023.\n// NB, this assumes wiL is in the +z hemisphere, and returns a sampled micronormal in that hemisphere.\nfn ggxNDFSample(wiL: vec3f, alpha: vec2, seed: ptr) -> vec3f {\n let Xi = vec2f(randomF32(seed), randomF32(seed));\n var V = wiL;\n \n V = normalize(vec3f(V.xy * alpha, V.z));\n\n let phi = 2.0 * PI * Xi.x;\n let z = (1.0 - Xi.y) * (1.0 + V.z) - V.z;\n let sinTheta = sqrt(clamp(1.0 - z * z, 0.0, 1.0));\n let x = sinTheta * cos(phi);\n let y = sinTheta * sin(phi);\n let c = vec3f(x, y, z);\n\n var H = c + V;\n\n H = normalize(vec3f(H.xy * alpha, H.z));\n\n return H;\n}\n\nfn ggxNDFEval(m: vec3f, alpha: vec2f) -> f32 {\n let ax = max(alpha.x, DENOM_TOLERANCE);\n let ay = max(alpha.y, DENOM_TOLERANCE);\n let Ddenom = PI * ax * ay * sqr(sqr(m.x/ax) + sqr(m.y/ay) + sqr(m.z));\n return 1.0 / max(Ddenom, DENOM_TOLERANCE);\n}\n\nfn ggxLambda(w: vec3f, alpha: vec2f) -> f32 {\n if (abs(w.z) < FLT_EPSILON) {\n return 0.0;\n }\n return (-1.0 + sqrt(1.0 + (sqr(alpha.x*w.x) + sqr(alpha.y*w.y))/sqr(w.z))) / 2.0;\n}\n\nfn ggxG1(w: vec3f, alpha: vec2f) -> f32 {\n return 1.0 / (1.0 + ggxLambda(w, alpha));\n}\n\nfn ggxG2(woL: vec3f, wiL: vec3f, alpha: vec2f) -> f32 {\n return 1.0 / (1.0 + ggxLambda(woL, alpha) + ggxLambda(wiL, alpha));\n}\n\nstruct BsdfResponse {\n response: vec3f,\n throughput: vec3f,\n thickness: f32,\n ior: f32,\n}\n\nstruct FresnelData {\n model: i32,\n ior: vec3f,\n extinction: vec3f,\n F0: vec3f,\n F90: vec3f,\n exponent: f32,\n thinFilmThickness: f32,\n thinFilmIOR: f32,\n refraction: bool,\n}\n\nconst FRESNEL_MODEL_SCHLICK = 2;\n\nfn initFresnelSchlick(F0: vec3f, F90: vec3f, exponent: f32) -> FresnelData {\n return FresnelData(\n FRESNEL_MODEL_SCHLICK,\n vec3f(0.0),\n vec3f(0.0),\n F0,\n F90,\n exponent,\n 0.0,\n 0.0,\n false\n );\n}\n\nfn fresnelSchlick(cosTheta: f32, F0: vec3f, F90: vec3f, exponent: f32) -> vec3f {\n let x = clamp(1.0 - cosTheta, 0.0, 1.0);\n return mix(F0, F90, pow(x, exponent));\n}\n\nfn fresnelSchlickV2(F0: vec3f, mu: f32) -> vec3f {\n return F0 + pow(1.0 - mu, 5.0) * (vec3f(1.0) - F0);\n}\n\nfn computeFresnel(cosTheta: f32, fd: FresnelData) -> vec3f {\n // todo: implement other models (dielectric, conductor, airy)\n if (fd.model == FRESNEL_MODEL_SCHLICK) {\n return fresnelSchlick(cosTheta, fd.F0, fd.F90, fd.exponent);\n }\n \n return vec3f(0.0);\n}\n\nfn fresnelF82Tint(mu: f32, F0: vec3f, f82Tint: vec3f) -> vec3f {\n let muBar = 1.0/7.0;\n let denom = muBar * pow(1.0 - muBar, 6);\n let fSchlickBar = fresnelSchlickV2(F0, muBar);\n let fSchlick = fresnelSchlickV2(F0, mu);\n return fSchlick - mu * pow(1.0 - mu, 6.0) * (vec3f(1.0) - f82Tint) * fSchlickBar / denom;\n}\n\n\nfn rayAt(ray: Ray, t: f32) -> vec3 {\n return ray.origin + t * ray.direction;\n}\n\nfn lengthSquared(v: vec3) -> f32 {\n return dot(v, v);\n}\n\n// CODE#RNG\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L283\nconst PCG_INC = 2891336453u;\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L278\nconst PCG_MULTIPLIER = 747796405u;\n\n// https://www.pcg-random.org/download.html#id1\n// See https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L1533\nfn randomU32(seed: u32) -> u32 {\n let state = seed * PCG_MULTIPLIER + PCG_INC;\n let word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;\n return (word >> 22u) ^ word;\n}\n\nconst range = 1.0 / f32(0xffffffffu);\n\n// Generate a random float in the range [0, 1).\nfn randomF32(seed: ptr) -> f32 {\n *seed = randomU32(*seed);\n return f32(*seed - 1u) * range;\n}\n\nfn triangleHit(triangle: Triangle, ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n let edge1 = triangle.u;\n let edge2 = triangle.v;\n let h = cross(ray.direction, edge2);\n let a = dot(edge1, h);\n // No hit if ray is parallel to the triangle\n if (a > -0.00001 && a < 0.00001) {\n return false;\n }\n let f = 1.0 / a;\n let s = ray.origin - triangle.Q;\n let u = f * dot(s, h);\n // No hit if ray is outside the triangle\n if (u < 0.0 || u > 1.0) {\n return false;\n }\n let q = cross(s, edge1);\n let v = f * dot(ray.direction, q);\n // No hit if ray is outside the triangle\n if (v < 0.0 || u + v > 1.0) {\n return false;\n }\n let t = f * dot(edge2, q);\n // No hit if triangle is behind the ray\n if (t < (rayT).min || t > (rayT).max) {\n return false;\n }\n\n (*hitRecord).t = t;\n (*hitRecord).point = rayAt(ray, t);\n (*hitRecord).normal = normalize(triangle.normal0 * (1.0 - u - v) + triangle.normal1 * u + triangle.normal2 * v);\n //(*hitRecord).normal = normalize(cross(edge1, edge2));\n //(*hitRecord).frontFace = dot(ray.direction, (*hitRecord).normal) < 0.0;\n\n (*hitRecord).material = triangle.material;\n\n return true;\n}\n\n// CODE#BVH-TESTS\n// Based on https://github.com/gkjohnson/three-mesh-bvh/blob/master/src/gpu/glsl/bvh_ray_functions.glsl.js\nfn intersectsBounds(ray: Ray, boundsMin: vec3f, boundsMax: vec3f, dist: ptr) -> bool {\n let invDir = vec3f(1.0) / ray.direction;\n \n let tMinPlane = invDir * (boundsMin - ray.origin);\n let tMaxPlane = invDir * (boundsMax - ray.origin);\n\n let tMinHit = min(tMaxPlane, tMinPlane);\n let tMaxHit = max(tMaxPlane, tMinPlane);\n\n var t = max(tMinHit.xx, tMinHit.yz);\n let t0 = max(t.x, t.y);\n\n t = min(tMaxHit.xx, tMaxHit.yz);\n let t1 = min(t.x, t.y);\n\n (*dist) = max(t0, 0.0);\n\n return t1 >= (*dist);\n}\n\nfn intersectsBVHNodeBounds(ray: Ray, currNodeIndex: u32, dist: ptr) -> bool {\n // 2 because min+max, 4 because x,y,z + unused alpha\n let cni2 = currNodeIndex * 2u * 4;\n let boundsMin = vec3(bounds[cni2], bounds[cni2 + 1], bounds[cni2 + 2]);\n // Start at 4 because of unused alpha\n let boundsMax = vec3(bounds[cni2 + 4], bounds[cni2 + 5], bounds[cni2 + 6]);\n return intersectsBounds(ray, boundsMin, boundsMax, dist);\n}\n\nfn intersectTriangles(offset: u32, count: u32, ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n var found = false;\n var localDist = hitRecord.t;\n let l = offset + count;\n \n for (var i = offset; i < l; i += 1) {\n let vIndexOffset = indirectIndices[i] * 3u;\n\n let v1Index = indices[vIndexOffset];\n let v2Index = indices[vIndexOffset+1];\n let v3Index = indices[vIndexOffset+2];\n \n let x = vec3f(positions[v1Index*3], positions[v1Index*3+1], positions[v1Index*3+2]);\n let y = vec3f(positions[v2Index*3], positions[v2Index*3+1], positions[v2Index*3+2]);\n let z = vec3f(positions[v3Index*3], positions[v3Index*3+1], positions[v3Index*3+2]);\n \n let Q = x;\n let u = y - x;\n let v = z - x;\n \n var matchingObjectDefinition: ObjectDefinition = objectDefinitions[0];\n for (var j = 0; j < uniformData.objectDefinitionLength ; j++) {\n let objectDefinition = objectDefinitions[j];\n if (objectDefinition.start <= vIndexOffset && objectDefinition.start + objectDefinition.count > vIndexOffset) {\n matchingObjectDefinition = objectDefinition;\n break;\n }\n }\n let materialDefinition = matchingObjectDefinition.material;\n\n let normalX = vec3f(normals[v1Index*3], normals[v1Index*3+1], normals[v1Index*3+2]);\n let normalY = vec3f(normals[v2Index*3], normals[v2Index*3+1], normals[v2Index*3+2]);\n let normalZ = vec3f(normals[v3Index*3], normals[v3Index*3+1], normals[v3Index*3+2]);\n \n let triangle = Triangle(Q, u, v, materialDefinition, normalX,normalY,normalZ);\n\n var tmpRecord: HitRecord;\n if (triangleHit(triangle, ray, Interval(rayT.min, localDist), &tmpRecord)) {\n if (localDist < tmpRecord.t) {\n continue;\n }\n (*hitRecord) = tmpRecord;\n\n localDist = (*hitRecord).t;\n found = true;\n }\n }\n return found;\n}\n\nfn hittableListHit(ray: Ray, rayT: Interval, hitRecord: ptr) -> bool {\n var tempRecord: HitRecord;\n var hitAnything = false;\n var closestSoFar = rayT.max;\n\n // Inspired by https://github.com/gkjohnson/three-mesh-bvh/blob/master/src/gpu/glsl/bvh_ray_functions.glsl.js\n \n // BVH Intersection Detection\n var sPtr = 0;\n var stack: array = array();\n stack[sPtr] = 0u;\n\n while (sPtr > -1 && sPtr < ${maxBvhStackDepth}) {\n let currNodeIndex = stack[sPtr];\n sPtr -= 1;\n\n var boundsHitDistance: f32;\n \n if (!intersectsBVHNodeBounds(ray, currNodeIndex, &boundsHitDistance) || boundsHitDistance > closestSoFar) {\n continue;\n }\n\n let boundsInfo = contents[currNodeIndex];\n let boundsInfoX = boundsInfo.x;\n let boundsInfoY = boundsInfo.y;\n\n let isLeaf = (boundsInfoX & 0xffff0000u) == 0xffff0000u;\n\n if (isLeaf) {\n let count = boundsInfoX & 0x0000ffffu;\n let offset = boundsInfoY;\n\n let found2 = intersectTriangles(\n offset,\n count,\n ray,\n rayT,\n hitRecord\n );\n if (found2) {\n closestSoFar = (*hitRecord).t;\n }\n \n hitAnything = hitAnything || found2;\n } else {\n // Left node is always the next node\n let leftIndex = currNodeIndex + 1u;\n let splitAxis = boundsInfoX & 0x0000ffffu;\n let rightIndex = boundsInfoY;\n\n let leftToRight = ray.direction[splitAxis] > 0.0;\n let c1 = select(rightIndex, leftIndex, leftToRight);\n let c2 = select(leftIndex, rightIndex, leftToRight);\n\n sPtr += 1;\n stack[sPtr] = c2;\n sPtr += 1;\n stack[sPtr] = c1;\n }\n }\n\n return hitAnything;\n}\n\nstruct BouncingInfo {\n attenuation: Color,\n emission: Color,\n}\n\nstruct Basis {\n nW: vec3f,\n tW: vec3f,\n bW: vec3f,\n baryCoords: vec3f,\n}\n\nconst DENOM_TOLERANCE = 1.0e-10;\nconst RADIANCE_EPSILON = 1.0e-12;\n\nfn safeNormalize(v: vec3f) -> vec3f {\n let len = length(v);\n return v/max(len, DENOM_TOLERANCE);\n}\n\nfn normalToTangent(N: vec3f) -> vec3f {\n var T: vec3f;\n if (abs(N.z) < abs(N.x)) {\n T = vec3f(N.z, 0.0, -N.x);\n } else {\n T = vec3f(0.0, N.z, -N.y);\n }\n return safeNormalize(T);\n}\n\nfn makeBasis(nWI: vec3f) -> Basis {\n let nW = safeNormalize(nWI);\n let tW = normalToTangent(nWI);\n let bW = cross(nWI, tW);\n return Basis(nW, tW, bW, vec3f(0.0));\n}\n\nfn makeBasisFull(nW: vec3f, tW: vec3f, baryCoords: vec3f) -> Basis {\n let nWo = safeNormalize(nW);\n let tWo = safeNormalize(tW);\n let bWo = cross(nWo, tWo);\n return Basis(nWo, tWo, bWo, baryCoords);\n}\n\nfn worldToLocal(vWorld: vec3f, basis: Basis) -> vec3f {\n return vec3f(dot(vWorld, basis.tW), dot(vWorld, basis.bW), dot(vWorld, basis.nW));\n}\n\nfn localToWorld(vLocal: vec3f, basis: Basis) -> vec3f {\n return basis.tW * vLocal.x + basis.bW * vLocal.y + basis.nW * vLocal.z;\n}\n\nstruct LocalFrameRotation {\n M: mat2x2,\n Minv: mat2x2,\n}\n\nfn getLocalFrameRotation(angle: f32) -> LocalFrameRotation {\n if (angle == 0.0 || angle==2*PI) {\n let identity = mat2x2(1.0, 0.0, 0.0, 1.0);\n return LocalFrameRotation(identity, identity);\n } else {\n let cosRot = cos(angle);\n let sinRot = sin(angle);\n let M = mat2x2(cosRot, sinRot, -sinRot, cosRot);\n let Minv = mat2x2(cosRot, -sinRot, sinRot, cosRot);\n return LocalFrameRotation(M, Minv);\n }\n}\n\nfn localToRotated(vLocal: vec3f, rotation: LocalFrameRotation) -> vec3f {\n let xyRot = rotation.M * vLocal.xy;\n return vec3f(xyRot.x, xyRot.y, vLocal.z);\n}\n\nfn rotatedToLocal(vRotated: vec3f, rotation: LocalFrameRotation) -> vec3f {\n let xyLocal = rotation.Minv * vRotated.xy;\n return vec3f(xyLocal.x, xyLocal.y, vRotated.z);\n}\n\nstruct LobeWeights {\n m: array,\n}\n\nstruct LobeAlbedos {\n m: array,\n}\n\nstruct LobeProbs {\n m: array,\n}\n\nstruct LobePDFs {\n m: array,\n}\n\nstruct LobeData {\n weights: LobeWeights,\n albedos: LobeAlbedos,\n probs: LobeProbs,\n}\n\n// todo: implement\nfn placeholderBrdfAlbedo() -> Color {\n return Color(0.0, 0.0, 0.0);\n}\n\nfn specularNDFRoughness(material: Material) -> vec2f {\n let rsqr = material.specularRoughness * material.specularRoughness;\n let specularAnisotropyInv = 1.0 - material.specularAnisotropy;\n let alphaX = rsqr * sqrt(2.0/(1.0+(specularAnisotropyInv*specularAnisotropyInv)));\n let alphaY = (1.0 - material.specularAnisotropy) * alphaX;\n\n let minAlpha = 1.0e-4;\n return vec2f(max(alphaX, minAlpha), max(alphaY, minAlpha));\n}\n\nfn metalBrdfEvaluate(pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, material: Material, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) {\n (*pdfWoutputL) = PDF_EPSILON;\n return vec3f(0.0);\n }\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n let woutputR = localToRotated(woutputL, rotation);\n\n let alpha = specularNDFRoughness(material);\n\n let mR = normalize(winputR + woutputR);\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z);\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = max(PDF_EPSILON, DV * dwhDwo);\n\n let FnoFilm = fresnelF82Tint(abs(dot(winputR, mR)), material.baseWeight * material.baseColor, material.specularWeight * material.specularColor);\n\n // todo: thin film workflow\n\n let F = FnoFilm;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n return F * D * G2 * max(4.0*abs(woutputL.z)*abs(winputL.z), DENOM_TOLERANCE);\n}\n\nfn metalBrdfSample(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr, woutputL: ptr, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n (*pdfWoutputL) = PDF_EPSILON;\n return vec3f(0.0);\n }\n\n let alpha = specularNDFRoughness(material);\n\n var rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n var winputR = localToRotated(winputL, rotation);\n\n let mR = ggxNDFSample(winputR, alpha, seed);\n\n let woutputR = -winputR + 2.0*dot(winputR, mR)*mR;\n if (winputR.z * woutputR.z < FLT_EPSILON) {\n return vec3f(0.0);\n }\n (*woutputL) = rotatedToLocal(woutputR, rotation);\n\n let D = ggxNDF(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z); // todo: should latter max term use abs for .z?\n \n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = max(PDF_EPSILON, DV * dwhDwo);\n\n // todo: implement thin film workflow\n let F_nofilm = fresnelF82Tint(abs(dot(winputR, mR)), material.baseWeight * material.baseColor, material.specularWeight * material.specularColor);\n let F = F_nofilm;\n \n let G2 = ggxG2(winputR, woutputR, alpha);\n \n return F * D * G2 / max(4.0*abs(woutputL.z)*abs(winputL.z), DENOM_TOLERANCE);\n}\n\nfn metalBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> Color {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n\n let numSamples = 1;\n var albedo = vec3f(0.0);\n for (var n=0; n RADIANCE_EPSILON) {\n albedo += f * abs(woutputL.z) / max(PDF_EPSILON, pdfWoutputL);\n }\n }\n\n albedo /= f32(numSamples);\n return albedo;\n}\n\nfn diffuseBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n return material.baseWeight * material.baseColor;\n}\n\n// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl\nfn fujiiMaterialX(albedo: vec3f, roughness: f32, V: vec3f, L: vec3f) -> vec3f {\n let NdotV = V.z;\n let NdotL = L.z;\n let s = dot(L, V) - NdotV * NdotL;\n let stinv = select(0.0, s / max(NdotL, NdotV), s > 0.0f);\n let sigma = roughness;\n let sigma2 = sqr(sigma);\n let A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33));\n let B = 0.45 * sigma2 / (sigma2 + 0.09);\n return albedo * NdotL / PI * (A + B * stinv);\n}\n\nfn diffuseBrdfEvalImplementation(woutputL: vec3f, winputL: vec3f, material: Material) -> vec3f {\n let albedo = material.baseWeight * material.baseColor;\n let V = winputL;\n let L = woutputL;\n let NdotL = max(FLT_EPSILON, abs(L.z));\n \n return fujiiMaterialX(albedo, material.baseDiffuseRoughness, V, L) / NdotL;\n}\n\nfn diffuseBrdfEvaluate(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, pdfWoutputL: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) {\n // todo: reset pdfWoutputL?\n return vec3f(0.0);\n }\n (*pdfWoutputL) = pdfHemisphereCosineWeighted(woutputL);\n return diffuseBrdfEvalImplementation(winputL, woutputL, material);\n}\n\nfn diffuseBrdfSample(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: ptr, pdfWoutputL: ptr, seed: ptr) -> vec3f {\n if (winputL.z < DENOM_TOLERANCE) {\n return vec3f(0.0);\n }\n (*woutputL) = sampleHemisphereCosineWeighted(pdfWoutputL, seed);\n return diffuseBrdfEvalImplementation(winputL, *woutputL, material);\n}\n\nfn fresnelDielectricPolarizations(mui: f32, etaTi: f32) -> vec2f {\n let mut2 = sqr(etaTi) - (1.0 - sqr(mui));\n if (mut2 <= 0.0) {\n return vec2f(1.0);\n }\n\n let mut1 = sqrt(mut2) / etaTi;\n let rs = (mui - etaTi*mut1) / (mui + etaTi*mut1);\n let rp = (mut1 - etaTi*mui) / (mut1 + etaTi*mui);\n return vec2f(rs, rp);\n}\n\nfn fresnelDielectricReflectance(mui: f32, etaTi: f32) -> f32 {\n let r = fresnelDielectricPolarizations(mui, etaTi);\n return 0.5 * dot(r, r);\n}\n\nfn specularBrdfSample(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr, woutputL: ptr, pdfWoutputL: ptr) -> vec3f {\n let beamOutgoingL = winputL;\n let externalReflection = beamOutgoingL.z > 0.0;\n\n let etaIe = specularIorRatio(material);\n let etaTiRefl = select(1.0/etaIe, etaIe, externalReflection);\n if (abs(etaTiRefl - 1.0) < IOR_EPSILON) {\n // (*pdfWoutputL) = PDF_EPSILON; // todo: reset?\n return vec3f(0.0);\n }\n\n let tint = material.specularColor;\n\n let alpha = specularNDFRoughness(material);\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n\n var mR: vec3f;\n if (winputR.z > 0.0) {\n mR = ggxNDFSample(winputR, alpha, seed);\n } else {\n var winputRReflected = winputR;\n winputRReflected.z = -winputRReflected.z;\n mR = ggxNDFSample(winputRReflected, alpha, seed);\n mR.z = -mR.z;\n }\n\n var woutputR = -winputR + 2.0*dot(winputR, mR)*mR;\n if (winputR.z * woutputR.z < 0.0) {\n (*pdfWoutputL) = 1.0;\n return vec3f(0.0);\n }\n\n (*woutputL) = rotatedToLocal(woutputR, rotation);\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * abs(dot(winputR, mR)) / max(DENOM_TOLERANCE, abs(winputR.z));\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = DV * dwhDwo;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n // todo: coat workflow\n let F = vec3f(fresnelDielectricReflectance(abs(dot(winputR, mR)), etaTiRefl));\n \n let f = F * D * G2 / max(4.0 * abs(woutputL.z) * abs(winputL.z), DENOM_TOLERANCE);\n\n return f * tint;\n}\n\nfn specularBrdfEvaluate(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, pdfWoutputL: ptr) -> vec3f {\n let transmitted = woutputL.z * winputL.z < 0.0;\n if (transmitted) {\n // (*pdfWoutputL) = PDF_EPSILON; todo: reset?\n return vec3f(0.0);\n }\n\n let beamOutgoingL = winputL;\n let externalReflection = beamOutgoingL.z > 0.0;\n\n let etaIe = specularIorRatio(material);\n let etaTiRefl = select(1.0/etaIe, etaIe, externalReflection);\n if (abs(etaTiRefl - 1.0) < IOR_EPSILON) {\n return vec3f(0.0);\n }\n\n let tint = material.specularColor;\n\n let alpha = specularNDFRoughness(material);\n\n let rotation = getLocalFrameRotation(2*PI*material.specularRotation);\n let winputR = localToRotated(winputL, rotation);\n let woutputR = localToRotated(woutputL, rotation);\n\n let mR = normalize(woutputR + winputR);\n\n if (dot(mR, winputR) * winputR.z < 0.0 || dot(mR, woutputR) * woutputR.z < 0.0) {\n return vec3f(0.0);\n }\n\n let D = ggxNDFEval(mR, alpha);\n let DV = D * ggxG1(winputR, alpha) * max(0.0, dot(winputR, mR)) / max(DENOM_TOLERANCE, winputR.z);\n\n let dwhDwo = 1.0 / max(abs(4.0*dot(winputR, mR)), DENOM_TOLERANCE);\n (*pdfWoutputL) = DV * dwhDwo;\n\n let G2 = ggxG2(winputR, woutputR, alpha);\n\n // todo: coat workflow\n let F = vec3f(fresnelDielectricReflectance(abs(dot(winputR, mR)), etaTiRefl));\n\n let f = F * D * G2 / max(4.0 * abs(woutputL.z) * abs(winputL.z), DENOM_TOLERANCE);\n return f * tint;\n}\n\nfn etaS(material: Material) -> f32 {\n const ambientIor = 1.0;\n let coatIorAverage = mix(ambientIor, material.coatIor, material.coatWeight);\n let etaS = material.specularIor / coatIorAverage;\n return etaS;\n}\n\nfn fresnelReflNormalIncidence(material: Material) -> f32 {\n let etaS = etaS(material);\n let Fs = sqr((etaS - 1.0)/(etaS + 1.0));\n return Fs;\n}\n\nfn specularIorRatio(material: Material) -> f32 {\n let Fs = fresnelReflNormalIncidence(material);\n let xiS = clamp(material.specularWeight, 0.0, 1.0/max(Fs, DENOM_TOLERANCE));\n let etaS = etaS(material);\n let temp = min(1.0, sign(etaS - 1.0) * sqrt(xiS * Fs));\n let etaSPrime = (1.0 + temp) / max(1.0 - temp, DENOM_TOLERANCE);\n return etaSPrime;\n}\n\nfn specularBrdfAlbedo(material: Material, pW: vec3f, basis: Basis, winputL: vec3f, seed: ptr) -> vec3f {\n let etaIe = specularIorRatio(material);\n if (abs(etaIe - 1.0) < IOR_EPSILON) {\n return vec3f(0.0);\n }\n\n const samples = 1;\n var albedo = vec3f(0.0);\n for (var n = 0; n < samples; n += 1) {\n var woutputL: vec3f;\n var pdfWoutputL: f32;\n var f = specularBrdfSample(material, pW, basis, winputL, seed, &woutputL, &pdfWoutputL);\n if (length(f) > RADIANCE_EPSILON) {\n albedo += f * abs(woutputL.z) / max(DENOM_TOLERANCE, pdfWoutputL);\n }\n }\n albedo /= f32(samples);\n\n return albedo;\n}\n\nstruct WeightsAndAlbedo {\n weights: LobeWeights,\n albedos: LobeAlbedos,\n}\n\nfn openPbrLobeWeights(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr) -> WeightsAndAlbedo {\n let F = 0.0; // todo: move to material definition fuzzWeight\n let C = material.coatWeight;\n let M = material.baseMetalness;\n let T = 0.0; // todo: move to material definition transmissionWeight\n let S = 0.0; // todo: move to material definition subsurfaceWeight\n\n let coated = C > 0.0;\n let metallic = M > 0.0;\n let fullyMetallic = M == 1.0;\n let transmissive = T > 0.0;\n let fullyTransmissive = T == 1.0;\n let subsurfaced = S > 0.0;\n let fullySubsurfaced = S == 1.0;\n\n var albedos = LobeAlbedos();\n albedos.m[ID_COAT_BRDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), coated);\n albedos.m[ID_META_BRDF] = select(vec3f(0.0), metalBrdfAlbedo(material, pW, basis, winputL, seed), metallic);\n albedos.m[ID_SPEC_BRDF] = select(vec3f(0.0), specularBrdfAlbedo(material, pW, basis, winputL, seed), !fullyMetallic);\n albedos.m[ID_SPEC_BTDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), !fullyMetallic && transmissive);\n albedos.m[ID_DIFF_BRDF] = select(vec3f(0.0), diffuseBrdfAlbedo(material, pW, basis, winputL, seed), !fullyMetallic && !fullyTransmissive && !fullySubsurfaced);\n albedos.m[ID_SSSC_BTDF] = select(vec3f(0.0), placeholderBrdfAlbedo(), !fullyMetallic && !fullyTransmissive && subsurfaced);\n\n var weights = LobeWeights();\n\n weights.m[ID_FUZZ_BRDF] = vec3f(0.0); // todo: check\n\n let wCoatedBase = vec3f(1.0); // todo: check \n\n weights.m[ID_COAT_BRDF] = wCoatedBase * C;\n\n // todo: implement coat workflow\n let baseDarkening = vec3f(1.0); // todo: check\n let materialCoatColor = vec3f(1.0); // todo: move to material definition (coat_color)\n let wBaseSubstrate = wCoatedBase * mix(vec3f(1.0), baseDarkening * materialCoatColor * (vec3(1.0) - albedos.m[ID_COAT_BRDF]), C);\n\n weights.m[ID_META_BRDF] = wBaseSubstrate * M;\n\n let wDielectricBase = wBaseSubstrate * vec3f(max(0.0, 1.0 - M));\n\n weights.m[ID_SPEC_BRDF] = wDielectricBase;\n\n weights.m[ID_SPEC_BTDF] = wDielectricBase * T;\n\n let wOpaqueDielectricBase = wDielectricBase * (1.0 - T);\n\n weights.m[ID_SSSC_BTDF] = wOpaqueDielectricBase * S;\n\n weights.m[ID_DIFF_BRDF] = wOpaqueDielectricBase * (1.0 - S) * (vec3f(1.0) - albedos.m[ID_SPEC_BRDF]);\n\n return WeightsAndAlbedo(\n weights,\n albedos\n );\n}\n\n\nfn openPbrLobeProbabilities(weights: LobeWeights, albedos: LobeAlbedos) -> LobeProbs {\n var probs = LobeProbs();\n var Wtotal = 0.0;\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n probs.m[lobeId] = length(weights.m[lobeId] * albedos.m[lobeId]);\n Wtotal += probs.m[lobeId];\n }\n Wtotal = max(DENOM_TOLERANCE, Wtotal);\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n probs.m[lobeId] /= Wtotal;\n }\n return probs;\n}\n\nfn openPbrPrepare(pW: vec3f, basis: Basis, winputL: vec3f, material: Material, seed: ptr) -> LobeData {\n let weightsAndAlbedo = openPbrLobeWeights(pW, basis, winputL, material, seed);\n let probs = openPbrLobeProbabilities(weightsAndAlbedo.weights, weightsAndAlbedo.albedos);\n\n return LobeData(\n weightsAndAlbedo.weights,\n weightsAndAlbedo.albedos,\n probs,\n );\n}\n\nconst PDF_EPSILON = 1.0e-6;\nconst IOR_EPSILON = 1.0e-5;\nconst RAY_OFFSET = 1.0e-4;\n\nfn pdfHemisphereCosineWeighted(wiL: vec3f) -> f32 {\n if (wiL.z <= PDF_EPSILON) {\n return PDF_EPSILON / PI;\n }\n return wiL.z / PI;\n}\n\nfn sampleHemisphereCosineWeighted(pdf: ptr, seed: ptr) -> vec3f {\n let r = sqrt(randomF32(seed));\n let theta = 2.0 * PI * randomF32(seed);\n let x = r * cos(theta);\n let y = r * sin(theta);\n let z = sqrt(max(0.0, 1.0 - x*x - y*y));\n (*pdf) = max(PDF_EPSILON, abs(z) / PI);\n return vec3f(x, y, z);\n}\n\nfn skyPdf(woutputL: vec3f, woutputWs: vec3f) -> f32 {\n return pdfHemisphereCosineWeighted(woutputL);\n}\n\nfn sunPdf(woutputL: vec3f, woutputW: vec3f) -> f32 {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n if (dot(woutputW, uniformData.sunDirection) < cos(thetaMax)) {\n return 0.0;\n }\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n return 1.0 / solidAngle;\n}\n\nfn sunTotalPower() -> f32 {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n return length(uniformData.sunPower * uniformData.sunColor) * solidAngle;\n}\n\nfn skyTotalPower() -> f32 {\n return length(uniformData.skyPower * uniformData.skyColor) * 2.0 * PI;\n}\n\nfn sunRadiance(woutputW: vec3f) -> vec3f {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n if (dot(woutputW, uniformData.sunDirection) < cos(thetaMax)) {\n return vec3f(0.0);\n }\n return uniformData.sunPower * uniformData.sunColor;\n}\n\nfn skyRadiance() -> vec3f {\n return uniformData.skyPower * uniformData.skyColor;\n}\n\nfn lightPdf(shadowW: vec3f, basis: Basis) -> f32 {\n let shadowL = worldToLocal(shadowW, basis);\n let pdfSky = skyPdf(shadowL, shadowW);\n let pdfSun = sunPdf(shadowL, shadowW);\n let wSun = sunTotalPower();\n let wSky = skyTotalPower();\n let pSun = wSun / (wSun + wSky);\n let pSky = max(0.0, 1.0 - pSun);\n let lightPdf = pSun * pdfSun + pSky * pdfSky;\n \n return lightPdf;\n}\n\nfn powerHeuristic(a: f32, b: f32) -> f32 {\n return pow(a, 2) / max(DENOM_TOLERANCE, pow(a, 2) + pow(b, 2));\n}\n\nfn brdfSamplePlaceholder() -> vec3f {\n return vec3f(0.0);\n}\n\nfn brdfEvaluatePlaceholder() -> vec3f {\n return vec3f(0.0);\n}\n\nfn openpbrBsdfEvaluateLobes(pW: vec3f, basis: Basis, material: Material, winputL: vec3f, woutputL: vec3f, skipLobeId: i32, lobeData: LobeData, pdfs: ptr) -> vec3f {\n var f = vec3f(0.0);\n if (skipLobeId != ID_FUZZ_BRDF && lobeData.probs.m[ID_FUZZ_BRDF] > 0.0) {\n f += vec3f(0.0);\n }\n if (skipLobeId != ID_COAT_BRDF && lobeData.probs.m[ID_COAT_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_COAT_BRDF] * brdfEvaluatePlaceholder();\n }\n if (skipLobeId != ID_META_BRDF && lobeData.probs.m[ID_META_BRDF] > 0.0) {\n f += metalBrdfEvaluate(pW, basis, winputL, woutputL, material, &pdfs.m[ID_META_BRDF]);\n }\n if (skipLobeId != ID_SPEC_BRDF && lobeData.probs.m[ID_SPEC_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_SPEC_BRDF] * specularBrdfEvaluate(material, pW, basis, winputL, woutputL, &pdfs.m[ID_SPEC_BRDF]);\n }\n if (skipLobeId != ID_DIFF_BRDF && lobeData.probs.m[ID_DIFF_BRDF] > 0.0) {\n f += lobeData.weights.m[ID_DIFF_BRDF] * diffuseBrdfEvaluate(material, pW, basis, winputL, woutputL, &pdfs.m[ID_DIFF_BRDF]);\n }\n\n let evalSpecBtdf = skipLobeId != ID_SPEC_BTDF && lobeData.probs.m[ID_SPEC_BTDF] > 0.0;\n let evalSsscBtdf = skipLobeId != ID_SSSC_BTDF && lobeData.probs.m[ID_SSSC_BTDF] > 0.0;\n let evalTransmission = evalSpecBtdf || evalSsscBtdf;\n if (evalTransmission) {\n // todo: implement\n }\n\n return f;\n}\n\nfn openpbrBsdfTotalPdf(pdfs: LobePDFs, lobeData: LobeData) -> f32 {\n var pdfWoutputL = 0.0;\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n pdfWoutputL += lobeData.probs.m[lobeId] * pdfs.m[lobeId];\n }\n return pdfWoutputL;\n}\n\nconst ID_FUZZ_BRDF = 0;\nconst ID_COAT_BRDF = 1;\nconst ID_META_BRDF = 2;\nconst ID_SPEC_BRDF = 3;\nconst ID_SPEC_BTDF = 4;\nconst ID_DIFF_BRDF = 5;\nconst ID_SSSC_BTDF = 6;\nconst NUM_LOBES = 7;\n\nfn sampleBsdf(pW: vec3f, basis: Basis, winputL: vec3f, lobeData: LobeData, material: Material, woutputL: ptr, pdfWoutputL: ptr, seed: ptr) -> vec3f {\n let X = randomF32(seed);\n var CDF = 0.0;\n\n //(*woutputL) = vec3f(lobeData.probs.m[3],lobeData.probs.m[4],lobeData.probs.m[5]);\n //(*woutputL) = vec3f(lobeData.probs.m[3],0,0);\n //return vec3f(0.0);\n for (var lobeId = 0; lobeId < NUM_LOBES; lobeId += 1) {\n CDF += lobeData.probs.m[lobeId];\n if (X < CDF) {\n var pdfLobe: f32;\n var fLobe: vec3f;\n if (lobeId == ID_FUZZ_BRDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_COAT_BRDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_META_BRDF) {\n fLobe = metalBrdfSample(pW, basis, winputL, material, seed, woutputL, &pdfLobe);\n }\n else if (lobeId == ID_SPEC_BRDF) {\n fLobe = specularBrdfSample(material, pW, basis, winputL, seed, woutputL, &pdfLobe);\n }\n else if (lobeId == ID_SPEC_BTDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_SSSC_BTDF) { fLobe = brdfSamplePlaceholder(); }\n else if (lobeId == ID_DIFF_BRDF) {\n fLobe = diffuseBrdfSample(material, pW, basis, winputL, woutputL, &pdfLobe, seed);\n }\n else { break; }\n //fLobe = specularBrdfSample(material, pW, basis, winputL, seed, woutputL, &pdfLobe);\n //let basis2 = makeBasis(vec3(0.33,0.33,0.33));\n //let pW2 = vec3f(0.0);\n //let winputL2 = vec3f(0.33, 0.33, 0.33);\n //var seed2 = 3u;\n //fLobe = specularBrdfSample(material, pW2, basis2, winputL2, &seed2, woutputL, &pdfLobe);\n //fLobe = metalBrdfSample(pW2, basis2, winputL2, material, &seed2, woutputL, &pdfLobe);\n //fLobe = vec3f(0.33);\n //return fLobe;\n //fLobe = diffuseBrdfSample(material, pW, basis, winputL, woutputL, &pdfLobe, seed);\n\n var pdfs: LobePDFs;\n var skipLobeId = lobeId;\n var f = openpbrBsdfEvaluateLobes(pW, basis, material, winputL, *woutputL, skipLobeId, lobeData, &pdfs);\n f += lobeData.weights.m[lobeId] * fLobe;\n\n pdfs.m[lobeId] = pdfLobe;\n (*pdfWoutputL) = openpbrBsdfTotalPdf(pdfs, lobeData);\n \n let transmitted = woutputL.z * winputL.z < 0.0;\n let transmittedInside = transmitted && woutputL.z < 0.0;\n if (!transmittedInside) {\n return f;\n }\n\n // todo: volume\n\n return f;\n }\n }\n\n (*pdfWoutputL) = 1.0;\n return vec3f(0);\n}\n\nfn evaluateBsdf(pW: vec3f, basis: Basis, winputL: vec3f, woutputL: vec3f, lobeData: LobeData, material: Material, pdfWoutputL: ptr) -> vec3f {\n var pdfs: LobePDFs;\n let f = openpbrBsdfEvaluateLobes(pW, basis, material, winputL, woutputL, -1, lobeData, &pdfs);\n (*pdfWoutputL) = openpbrBsdfTotalPdf(pdfs, lobeData);\n \n return f;\n}\n\nfn evaluateEdf(material: Material) -> vec3f {\n return material.emissionColor * material.emissionLuminance;\n}\n\nfn sunSample(basis: Basis, sunBasis: Basis, woutputL: ptr, woutputW: ptr, pdfDir: ptr, seed: ptr) -> vec3f {\n let thetaMax = uniformData.sunAngularSize * PI/180.0;\n let theta = thetaMax * sqrt(randomF32(seed));\n let cosTheta = cos(theta);\n let sinTheta = sqrt(max(0, 1.0-cosTheta*cosTheta));\n let phi = 2.0 * PI * randomF32(seed);\n let cosPhi = cos(phi);\n let sinPhi = sin(phi);\n let x = sinTheta * cosPhi;\n let y = sinTheta * sinPhi;\n let z = cosTheta;\n let solidAngle = 2.0 * PI * (1.0 - cos(thetaMax));\n *pdfDir = 1.0 / solidAngle;\n *woutputW = localToWorld(vec3f(x, y, z), sunBasis);\n *woutputL = worldToLocal(*woutputW, basis);\n return uniformData.sunPower * uniformData.sunColor;\n}\n\nfn skySample(basis: Basis, woutputL: ptr, woutputW: ptr, pdfDir: ptr, seed: ptr) -> vec3f {\n *woutputL = sampleHemisphereCosineWeighted(pdfDir, seed);\n *woutputW = localToWorld(*woutputL, basis);\n return skyRadiance();\n}\n\nfn getDirectLighting(pW: vec3f, basis: Basis, sunBasis: Basis, shadowL: ptr, shadowW: ptr, lightPdf: ptr, seed: ptr) -> vec3f {\n var Li: vec3f;\n\n let wSun = sunTotalPower();\n let wSky = skyTotalPower();\n let pSun = wSun / (wSun + wSky);\n let pSky = max(0.0, 1.0 - pSun);\n var pdfSun: f32;\n var pdfSky: f32;\n let r = randomF32(seed);\n if (r < pSun) {\n Li = sunSample(basis, sunBasis, shadowL, shadowW, &pdfSun, seed);\n Li += skyRadiance();\n pdfSky = skyPdf(*shadowL, *shadowW);\n } else {\n Li = skySample(basis, shadowL, shadowW, &pdfSky, seed);\n Li += sunRadiance(*shadowW);\n pdfSun = sunPdf(*shadowL, *shadowW);\n }\n *lightPdf = pSun * pdfSun + pSky * pdfSky;\n\n if (shadowL.z < 0) {\n return vec3f(0);\n }\n if (maxVec3(Li) < RADIANCE_EPSILON) {\n return vec3f(0);\n }\n\n let occluded = isOccluded(Ray(pW, *shadowW), TRIANGLE_MAX_DISTANCE_THRESHOLD);\n let visibility = select(1.0, 0.0, occluded);\n\n return visibility * Li;\n}\n\nfn isOccluded(ray: Ray, maxDistance: f32) -> bool {\n var hitRecord = HitRecord();\n hitRecord.t = maxDistance;\n return hittableListHit(ray, Interval(TRIANGLE_MIN_DISTANCE_THRESHOLD, maxDistance), &hitRecord);\n}\n\nconst TRIANGLE_MIN_DISTANCE_THRESHOLD = 0.0005;\nconst TRIANGLE_MAX_DISTANCE_THRESHOLD = 10e37f;\n\nfn rayColor(cameraRay: Ray, seed: ptr, sunBasis: Basis) -> vec4f {\n var hitRecord: HitRecord;\n var ray = cameraRay;\n\n var throughput = vec3f(1.0);\n var L = vec3f(0.0);\n var bsdfPdfContinuation = 1.0;\n\n var dW = ray.direction;\n var pW = ray.origin;\n\n var basis: Basis;\n\n var inDielectric = false;\n\n for (var i = 0; i < uniformData.maxRayDepth; i += 1) {\n // todo: handle setting t nicely\n hitRecord.t = TRIANGLE_MAX_DISTANCE_THRESHOLD;\n let hit = hittableListHit(ray, Interval(TRIANGLE_MIN_DISTANCE_THRESHOLD, TRIANGLE_MAX_DISTANCE_THRESHOLD), &hitRecord);\n\n // todo: consider normal handling\n\n if (!hit) {\n // did not hit anything until infinity\n\n var misWeightLight = 1.0;\n \n if (i > 0) {\n let lightPdf = lightPdf(\n dW,\n basis\n );\n misWeightLight = powerHeuristic(bsdfPdfContinuation, lightPdf);\n } else {\n if (uniformData.enableClearColor == 1) {\n return vec4f(uniformData.clearColor, 0.0);\n }\n }\n L += throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n \n /*\n // metal-wall configuraiton\n if (i > 2) {\n L += 1.0*throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n } else if (i > 1) {\n L += 1.3*throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n } else {\n L += 2.7 * throughput * misWeightLight * (sunRadiance(dW) + skyRadiance());\n }*/\n \n break;\n }\n\n let material = materials[hitRecord.material.index];\n\n // Surface Normal\n var NsW = hitRecord.normal;\n // Geometric Normal todo: distinguish between geometric and shading normal\n var NgW = NsW;\n // Tangent\n let TsW = normalToTangent(NsW);\n let baryCoords = vec3f(0.0); // todo: implement\n \n pW = hitRecord.point;\n\n if (\n (inDielectric && dot(NsW, dW) < 0.0) ||\n (!inDielectric && dot(NsW, dW) > 0.0)) {\n NsW = -NsW;\n }\n\n if (dot(NgW, NsW) < 0.0) {\n NgW = -NgW;\n }\n\n basis = makeBasisFull(NgW, TsW, baryCoords);\n\n let winputW = -dW;\n let winputL = worldToLocal(winputW, basis);\n\n let lobeData = openPbrPrepare(pW, basis, winputL, material, seed);\n\n var woutputL: vec3f;\n let f = sampleBsdf(pW, basis, winputL, lobeData, material, &woutputL, &bsdfPdfContinuation, seed);\n let woutputW = localToWorld(woutputL, basis);\n let surfaceThroughput = f / max(PDF_EPSILON, bsdfPdfContinuation) * abs(dot(woutputW, basis.nW));\n dW = woutputW;\n\n L += throughput * evaluateEdf(material);\n\n pW += NgW * sign(dot(dW, NgW)) * RAY_OFFSET;\n\n ray = Ray(pW, dW);\n\n var transmitted = dot(winputW, NgW) * dot(dW, NgW) < 0.0;\n if (transmitted) {\n inDielectric = !inDielectric;\n }\n\n if (!inDielectric && !transmitted) {\n var shadowL: vec3f;\n var shadowW: vec3f;\n var lightPdf: f32;\n let Li = getDirectLighting(pW, basis, sunBasis, &shadowL, &shadowW, &lightPdf, seed);\n if (maxVec3(Li) > RADIANCE_EPSILON) {\n var bsdfPdfShadow = PDF_EPSILON;\n let fShadow = evaluateBsdf(pW, basis, winputL, shadowL, lobeData, material, &bsdfPdfShadow);\n let misWeightLight = powerHeuristic(lightPdf, bsdfPdfShadow);\n L += throughput * misWeightLight * fShadow * abs(dot(shadowW, basis.nW)) * Li / max(PDF_EPSILON, lightPdf);\n }\n }\n\n throughput *= surfaceThroughput;\n\n // CODE#RUSSIAN-ROULETTE\n // Russian Roulette\n if (maxVec3(throughput) < 1.0 && i > 1) {\n let q = max(0.0, 1.0 - maxVec3(throughput));\n if (randomF32(seed) < q) {\n break;\n }\n throughput /= 1.0 - q;\n }\n }\n\n return vec4f(L, 1.0);\n}\n\nfn writeColor(pixelColor: vec4f, x: i32, y: i32, samples: i32) {\n let previousColor = textureLoad(readTexture, vec2(x, y));\n let previousColorAdjusted = previousColor * f32(uniformData.priorSamples);\n let samplesPerPixel = uniformData.samplesPerPixel;\n let scale = 1.0 / f32(uniformData.priorSamples + samplesPerPixel);\n let adjustedColor = (pixelColor + previousColorAdjusted) * scale;\n textureStore(texture, vec2(x, y), adjustedColor);\n}\n\n@must_use\nfn identityMatrix() -> mat4x4 {\n return mat4x4(\n 1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n}\n\nfn sampleTriangleFilter(xi: f32) -> f32 {\n return select(1.0 - sqrt(2.0 - 2.0 * xi), sqrt(2.0 * xi) - 1.0, xi < 0.5);\n}\n\n// CODE#VIEWPROJECTION\nfn ndcToCameraRay(coord: vec2f, cameraWorld: mat4x4, invProjectionMatrix: mat4x4, seed: ptr) -> Ray {\n let lookDirection = cameraWorld * vec4f(0.0, 0.0, -1.0, 0.0);\n let nearVector = invProjectionMatrix * vec4f(0.0, 0.0, -1.0, 1.0);\n let near = abs(nearVector.z / nearVector.w);\n\n var origin = cameraWorld * vec4f(0.0, 0.0, 0.0, 1.0);\n \n let randomOffset = randomF32(seed) * vec2f(0.5, 0.5);\n\n var direction = invProjectionMatrix * vec4f(coord.x, coord.y, 0.5, 1.0);\n direction /= direction.w;\n direction = cameraWorld * direction - origin;\n\n origin += vec4f(direction.xyz * near / dot(direction, lookDirection), 0);\n /*// orthographic projection, direction is identical for all points, origin differs based on parameters\n\n var direction = vec4f(0.0, 0.0, -1.0, 0.0);\n direction = cameraWorld * direction;\n\n // with increased orthographic size\n origin += vec4f((coord.x - 0.5 + randomOffset.x) * 8.0, (coord.y - 0.5 + randomOffset.y) * 8.0, 0.0, 0.0);\n\n //origin += vec4f(direction.xyz * near / dot(direction, lookDirection), 0);*/\n\n return Ray(\n origin.xyz,\n direction.xyz\n );\n}\n\nfn getPixelJitter(seed: ptr) -> vec2f {\n let jitterX = 0.5 * sampleTriangleFilter(randomF32(seed));\n let jitterY = 0.5 * sampleTriangleFilter(randomF32(seed));\n return vec2f(jitterX, jitterY);\n}\n\n@compute\n@workgroup_size(${maxWorkgroupDimension}, ${maxWorkgroupDimension}, 1)\nfn computeMain(@builtin(global_invocation_id) local_id: vec3) {\n var seed = local_id.x + local_id.y * ${imageWidth};\n seed ^= uniformData.seedOffset;\n \n let i = f32(local_id.x);\n let j = f32(local_id.y);\n \n var pixelColor = vec4f(0.0);\n\n // todo: consider not re-creating the basis every time\n var sunBasis = makeBasis(uniformData.sunDirection);\n \n let samplesPerPixel = i32(uniformData.samplesPerPixel);\n for (var sample = 0; sample < samplesPerPixel; sample += 1) {\n // CODE#ALIASING\n // anti-aliasing\n let pixel = vec2(i, j) + getPixelJitter(&seed);\n let ndc = -1.0 + 2.0*pixel / vec2(${imageWidth}, ${imageHeight});\n \n var ray = ndcToCameraRay(ndc, uniformData.invModelMatrix * uniformData.cameraWorldMatrix, uniformData.invProjectionMatrix, &seed);\n ray.direction = normalize(ray.direction);\n\n pixelColor += rayColor(ray, &seed, sunBasis);\n }\n\n \n writeColor(pixelColor, i32(local_id.x), i32(local_id.y), samplesPerPixel);\n}\n',$i={imageWidth:"imageWidth",imageHeight:"imageHeight",maxWorkgroupDimension:"maxWorkgroupDimension",maxBvhStackDepth:"maxBvhStackDepth"};const Ki="const pos = array(\n // 1\n vec2f(-1.0, -1.0),\n vec2f(1.0, -1.0),\n vec2f(-1.0, 1.0),\n // 2\n vec2f( -1.0, 1.0),\n vec2f( 1.0, -1.0),\n vec2f( 1.0, 1.0),\n);\n\nstruct VertexInput {\n @builtin(vertex_index) instance: u32,\n};\n\nstruct VertexOutput {\n @builtin(position) pos: vec4f,\n @location(0) texcoord: vec2f,\n};\n\nfn convertToZeroOne(position: vec2f) -> vec2f {\n return (position + 1.0) / 2;\n}\n\n@vertex\nfn vertexMain(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let xy = pos[input.instance];\n output.pos = vec4f(xy, 0, 1);\n\n let baseCoord = convertToZeroOne(vec2f(xy.x, -xy.y));\n output.texcoord = vec2f(baseCoord.x, 1.0 - baseCoord.y);\n return output;\n}\n\n@group(0) @binding(0) var texture_sampler: sampler;\n@group(0) @binding(1) var texture: texture_2d;\n\n// CODE#TONE-MAPPER\n// Khronos PBR neutral tone mapper\n// See: https://github.com/KhronosGroup/ToneMapping/blob/main/PBR_Neutral/pbrNeutral.glsl\nfn khronosPBRNeutralToneMapping(colorP: vec3f) -> vec3f {\n var color = colorP;\n let startCompression = 0.8 - 0.04;\n let desaturation = 0.15;\n\n let x = min(color.r, min(color.g, color.b));\n let offset = select(0.04, x - 6.25 * x * x, x < 0.08);\n color -= offset;\n\n let peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) {\n return color;\n }\n\n let d = 1.0 - startCompression;\n let newPeak = 1. - d * d / (peak + d - startCompression);\n color *= newPeak / peak;\n\n let g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n return mix(color, newPeak * vec3(1, 1, 1), g);\n}\n\n@fragment\nfn fragmentMain(input: VertexOutput) -> @location(0) vec4f {\n let hdrColor = textureSample(texture, texture_sampler, input.texcoord);\n\n //return hdrColor;\n\n // respect clear color\n if (hdrColor.a == 0.0) {\n return vec4f(hdrColor.rgb, 0.0);\n }\n\n let tonemappedColor = khronosPBRNeutralToneMapping(hdrColor.rgb);\n return vec4f(tonemappedColor, 1.0);\n}\n";function Qi(t){const e=window.performance.now();return{end(){const n=window.performance.now()-e;return console.log(`${t}: ${n}ms`),n}}}function tr(t){let e,n,s,i=-1,r=0;for(let h=0;h{er(t)&&e.push(t)}));return e}(t),n=function(t,e){void 0===e&&(e=!1);const n=null!==t[0].index,s=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),r={},a={},o=t[0].morphTargetsRelative,l=new nn;let h=0;for(let u=0;ut.geometry)),!0);return{geometry:n,materials:e.map((t=>t.material)).flat(1)}}const sr=(t,e)=>((t+e-1)/e|0)*e;const ir=t=>t&&"number"==typeof t.length&&t.buffer instanceof ArrayBuffer&&"number"==typeof t.byteLength,rr={i32:{numElements:1,align:4,size:4,type:"i32",View:Int32Array},u32:{numElements:1,align:4,size:4,type:"u32",View:Uint32Array},f32:{numElements:1,align:4,size:4,type:"f32",View:Float32Array},f16:{numElements:1,align:2,size:2,type:"u16",View:Uint16Array},vec2f:{numElements:2,align:8,size:8,type:"f32",View:Float32Array},vec2i:{numElements:2,align:8,size:8,type:"i32",View:Int32Array},vec2u:{numElements:2,align:8,size:8,type:"u32",View:Uint32Array},vec2h:{numElements:2,align:4,size:4,type:"u16",View:Uint16Array},vec3i:{numElements:3,align:16,size:12,type:"i32",View:Int32Array},vec3u:{numElements:3,align:16,size:12,type:"u32",View:Uint32Array},vec3f:{numElements:3,align:16,size:12,type:"f32",View:Float32Array},vec3h:{numElements:3,align:8,size:6,type:"u16",View:Uint16Array},vec4i:{numElements:4,align:16,size:16,type:"i32",View:Int32Array},vec4u:{numElements:4,align:16,size:16,type:"u32",View:Uint32Array},vec4f:{numElements:4,align:16,size:16,type:"f32",View:Float32Array},vec4h:{numElements:4,align:8,size:8,type:"u16",View:Uint16Array},mat2x2f:{numElements:4,align:8,size:16,type:"f32",View:Float32Array},mat2x2h:{numElements:4,align:4,size:8,type:"u16",View:Uint16Array},mat3x2f:{numElements:6,align:8,size:24,type:"f32",View:Float32Array},mat3x2h:{numElements:6,align:4,size:12,type:"u16",View:Uint16Array},mat4x2f:{numElements:8,align:8,size:32,type:"f32",View:Float32Array},mat4x2h:{numElements:8,align:4,size:16,type:"u16",View:Uint16Array},mat2x3f:{numElements:8,align:16,size:32,pad:[3,1],type:"f32",View:Float32Array},mat2x3h:{numElements:8,align:8,size:16,pad:[3,1],type:"u16",View:Uint16Array},mat3x3f:{numElements:12,align:16,size:48,pad:[3,1],type:"f32",View:Float32Array},mat3x3h:{numElements:12,align:8,size:24,pad:[3,1],type:"u16",View:Uint16Array},mat4x3f:{numElements:16,align:16,size:64,pad:[3,1],type:"f32",View:Float32Array},mat4x3h:{numElements:16,align:8,size:32,pad:[3,1],type:"u16",View:Uint16Array},mat2x4f:{numElements:8,align:16,size:32,type:"f32",View:Float32Array},mat2x4h:{numElements:8,align:8,size:16,type:"u16",View:Uint16Array},mat3x4f:{numElements:12,align:16,size:48,pad:[3,1],type:"f32",View:Float32Array},mat3x4h:{numElements:12,align:8,size:24,pad:[3,1],type:"u16",View:Uint16Array},mat4x4f:{numElements:16,align:16,size:64,type:"f32",View:Float32Array},mat4x4h:{numElements:16,align:8,size:32,type:"u16",View:Uint16Array},bool:{numElements:0,align:1,size:0,type:"bool",View:Uint32Array}},ar={...rr,"atomic":rr.i32,"atomic":rr.u32,"vec2":rr.vec2i,"vec2":rr.vec2u,"vec2":rr.vec2f,"vec2":rr.vec2h,"vec3":rr.vec3i,"vec3":rr.vec3u,"vec3":rr.vec3f,"vec3":rr.vec3h,"vec4":rr.vec4i,"vec4":rr.vec4u,"vec4":rr.vec4f,"vec4":rr.vec4h,"mat2x2":rr.mat2x2f,"mat2x2":rr.mat2x2h,"mat3x2":rr.mat3x2f,"mat3x2":rr.mat3x2h,"mat4x2":rr.mat4x2f,"mat4x2":rr.mat4x2h,"mat2x3":rr.mat2x3f,"mat2x3":rr.mat2x3h,"mat3x3":rr.mat3x3f,"mat3x3":rr.mat3x3h,"mat4x3":rr.mat4x3f,"mat4x3":rr.mat4x3h,"mat2x4":rr.mat2x4f,"mat2x4":rr.mat2x4h,"mat3x4":rr.mat3x4f,"mat3x4":rr.mat3x4h,"mat4x4":rr.mat4x4f,"mat4x4":rr.mat4x4h},or=(lr=ar,Object.keys(lr));var lr,hr,ur,cr,dr,pr;function mr(t,e,n,s){const{size:i,type:r}=t;try{const{View:t,align:a}=ar[r],o=void 0!==s,l=o?sr(i,a):i,h=l/t.BYTES_PER_ELEMENT;return new t(e,n,h*(o?0===s?(e.byteLength-n)/l:s:1))}catch{throw new Error(`unknown type: ${r}`)}}function fr(t,e,n){const s=n||0,i=e||new ArrayBuffer(function(t){const e=t;if(e.elementType)return e.size;{const n=t,s=e.numElements||1;if(n.fields)return t.size*s;{const e=t,{align:n}=ar[e.type];return s>1?sr(t.size,n)*s:t.size}}}(t)),r=(t,e)=>{const n=t,s=n.elementType;if(s){if(function(t){return!t.fields&&!t.elementType}(s)&&ar[s.type].flatten)return mr(s,i,e,n.numElements);{const{size:a}=xr(t);return function(t,e){return new Array(t).fill(0).map(((t,n)=>e(n)))}(0===n.numElements?(i.byteLength-e)/a:n.numElements,(t=>r(s,e+a*t)))}}if("string"==typeof t)throw Error("unreachable");{const n=t.fields;if(n){const t={};for(const[s,{type:i,offset:a}]of Object.entries(n))t[s]=r(i,e+a);return t}return mr(t,i,e)}};return{views:r(t,s),arrayBuffer:i}}function yr(t,e){if(void 0!==t)if(ir(e)){const n=e;if(1===n.length&&"number"==typeof t)n[0]=t;else if(Array.isArray(t[0])||ir(t[0])){const e=t[0].length,s=3===e?4:e;for(let i=0;i{yr(t,n[e])}))}else{const n=e;for(const[e,s]of Object.entries(t)){const t=n[e];t&&yr(s,t)}}}function gr(t,e,n){void 0===n&&(n=0);const s=t,i=fr(void 0===s.group?t:s.typeDefinition,e,n);return{...i,set(t){yr(t,i.views)}}}function _r(t){const e=t.elementType;if(e)return _r(e);const n=t.fields;if(n)return Object.values(n).reduce(((t,e)=>{let{type:n}=e;return Math.max(t,_r(n))}),0);const{type:s}=t,{align:i}=ar[s];return i}function xr(t){const e=t.elementType;if(e){const t=e.size,n=_r(e);return{unalignedSize:t,align:n,size:sr(t,n)}}const n=t.fields;if(n){const t=Object.values(n).pop();if(0===t.type.size)return xr(t.type)}return{size:0,unalignedSize:0,align:1}}!function(t,e){void 0===t&&(t=[]);const n=new Set;for(const s of or){const i=ar[s];n.has(i)||(n.add(i),i.flatten=t.includes(s)?e:!e)}}();class br{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class wr{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(t){throw new Error("Cannot evaluate node")}evaluateString(t){return this.evaluate(t).toString()}search(t){}searchBlock(t,e){if(t){e(vr.instance);for(const n of t)n instanceof Array?this.searchBlock(n,e):n.search(e);e(kr.instance)}}}class vr extends wr{}vr.instance=new vr;class kr extends wr{}kr.instance=new kr;class Mr extends wr{constructor(){super()}}class Sr extends Mr{constructor(t,e,n,s,i,r){super(),this.calls=new Set,this.name=t,this.args=e,this.returnType=n,this.body=s,this.startLine=i,this.endLine=r}get astNodeType(){return"function"}search(t){this.searchBlock(this.body,t)}}class Tr extends Mr{constructor(t){super(),this.expression=t}get astNodeType(){return"staticAssert"}search(t){this.expression.search(t)}}class Ar extends Mr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"while"}search(t){this.condition.search(t),this.searchBlock(this.body,t)}}class Er extends Mr{constructor(t){super(),this.body=t}get astNodeType(){return"continuing"}search(t){this.searchBlock(this.body,t)}}class Rr extends Mr{constructor(t,e,n,s){super(),this.init=t,this.condition=e,this.increment=n,this.body=s}get astNodeType(){return"for"}search(t){var e,n,s;null===(e=this.init)||void 0===e||e.search(t),null===(n=this.condition)||void 0===n||n.search(t),null===(s=this.increment)||void 0===s||s.search(t),this.searchBlock(this.body,t)}}class Br extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"var"}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}class zr extends Mr{constructor(t,e,n){super(),this.name=t,this.type=e,this.value=n}get astNodeType(){return"override"}search(t){var e;null===(e=this.value)||void 0===e||e.search(t)}}class Pr extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"let"}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}class Lr extends Mr{constructor(t,e,n,s,i){super(),this.name=t,this.type=e,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"const"}evaluate(t){return this.value.evaluate(t)}search(t){var e;t(this),null===(e=this.value)||void 0===e||e.search(t)}}!function(t){t.increment="++",t.decrement="--"}(hr||(hr={})),function(t){t.parse=function(e){const n=e;if("parse"==n)throw new Error("Invalid value for IncrementOperator");return t[n]}}(hr||(hr={}));class Ir extends Mr{constructor(t,e){super(),this.operator=t,this.variable=e}get astNodeType(){return"increment"}search(t){this.variable.search(t)}}!function(t){t.assign="=",t.addAssign="+=",t.subtractAssin="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="}(ur||(ur={})),function(t){t.parse=function(t){const e=t;if("parse"==e)throw new Error("Invalid value for AssignOperator");return e}}(ur||(ur={}));class Cr extends Mr{constructor(t,e,n){super(),this.operator=t,this.variable=e,this.value=n}get astNodeType(){return"assign"}search(t){this.variable.search(t),this.value.search(t)}}class Dr extends Mr{constructor(t,e){super(),this.name=t,this.args=e}get astNodeType(){return"call"}search(t){for(const e of this.args)e.search(t);t(this)}}class Nr extends Mr{constructor(t,e){super(),this.body=t,this.continuing=e}get astNodeType(){return"loop"}}class Fr extends Mr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"body"}}class Or extends Mr{constructor(t,e,n,s){super(),this.condition=t,this.body=e,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(t){this.condition.search(t),this.searchBlock(this.body,t),this.searchBlock(this.elseif,t),this.searchBlock(this.else,t)}}class Wr extends Mr{constructor(t){super(),this.value=t}get astNodeType(){return"return"}search(t){var e;null===(e=this.value)||void 0===e||e.search(t)}}class Ur extends Mr{constructor(t){super(),this.name=t}get astNodeType(){return"enable"}}class qr extends Mr{constructor(t){super(),this.extensions=t}get astNodeType(){return"requires"}}class jr extends Mr{constructor(t,e){super(),this.severity=t,this.rule=e}get astNodeType(){return"diagnostic"}}class Vr extends Mr{constructor(t,e){super(),this.name=t,this.type=e}get astNodeType(){return"alias"}}class Gr extends Mr{constructor(){super()}get astNodeType(){return"discard"}}class Hr extends Mr{constructor(){super()}get astNodeType(){return"break"}}class Yr extends Mr{constructor(){super()}get astNodeType(){return"continue"}}class Xr extends Mr{constructor(t){super(),this.name=t}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}}class Zr extends Xr{constructor(t,e,n,s){super(t),this.members=e,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(t){for(let e=0;e":return this.left.evaluate(t)>this.right.evaluate(t)?1:0;case"<=":return this.left.evaluate(t)<=this.right.evaluate(t)?1:0;case">=":return this.left.evaluate(t)>=this.right.evaluate(t)?1:0;case"&&":return this.left.evaluate(t)&&this.right.evaluate(t)?1:0;case"||":return this.left.evaluate(t)||this.right.evaluate(t)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(t){this.left.search(t),this.right.search(t)}}class ma extends wr{constructor(){super()}}class fa extends ma{constructor(t,e){super(),this.selector=t,this.body=e}get astNodeType(){return"case"}search(t){this.searchBlock(this.body,t)}}class ya extends ma{constructor(t){super(),this.body=t}get astNodeType(){return"default"}search(t){this.searchBlock(this.body,t)}}class ga extends wr{constructor(t,e,n){super(),this.name=t,this.type=e,this.attributes=n}get astNodeType(){return"argument"}}class _a extends wr{constructor(t,e){super(),this.condition=t,this.body=e}get astNodeType(){return"elseif"}search(t){this.condition.search(t),this.searchBlock(this.body,t)}}class xa extends wr{constructor(t,e,n){super(),this.name=t,this.type=e,this.attributes=n}get astNodeType(){return"member"}}class ba extends wr{constructor(t,e){super(),this.name=t,this.value=e}get astNodeType(){return"attribute"}}!function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"}(dr||(dr={}));class wa{constructor(t,e,n){this.name=t,this.type=e,this.rule=n}toString(){return this.name}}class va{}cr=va,va.none=new wa("",dr.reserved,""),va.eof=new wa("EOF",dr.token,""),va.reserved={asm:new wa("asm",dr.reserved,"asm"),bf16:new wa("bf16",dr.reserved,"bf16"),do:new wa("do",dr.reserved,"do"),enum:new wa("enum",dr.reserved,"enum"),f16:new wa("f16",dr.reserved,"f16"),f64:new wa("f64",dr.reserved,"f64"),handle:new wa("handle",dr.reserved,"handle"),i8:new wa("i8",dr.reserved,"i8"),i16:new wa("i16",dr.reserved,"i16"),i64:new wa("i64",dr.reserved,"i64"),mat:new wa("mat",dr.reserved,"mat"),premerge:new wa("premerge",dr.reserved,"premerge"),regardless:new wa("regardless",dr.reserved,"regardless"),typedef:new wa("typedef",dr.reserved,"typedef"),u8:new wa("u8",dr.reserved,"u8"),u16:new wa("u16",dr.reserved,"u16"),u64:new wa("u64",dr.reserved,"u64"),unless:new wa("unless",dr.reserved,"unless"),using:new wa("using",dr.reserved,"using"),vec:new wa("vec",dr.reserved,"vec"),void:new wa("void",dr.reserved,"void")},va.keywords={array:new wa("array",dr.keyword,"array"),atomic:new wa("atomic",dr.keyword,"atomic"),bool:new wa("bool",dr.keyword,"bool"),f32:new wa("f32",dr.keyword,"f32"),i32:new wa("i32",dr.keyword,"i32"),mat2x2:new wa("mat2x2",dr.keyword,"mat2x2"),mat2x3:new wa("mat2x3",dr.keyword,"mat2x3"),mat2x4:new wa("mat2x4",dr.keyword,"mat2x4"),mat3x2:new wa("mat3x2",dr.keyword,"mat3x2"),mat3x3:new wa("mat3x3",dr.keyword,"mat3x3"),mat3x4:new wa("mat3x4",dr.keyword,"mat3x4"),mat4x2:new wa("mat4x2",dr.keyword,"mat4x2"),mat4x3:new wa("mat4x3",dr.keyword,"mat4x3"),mat4x4:new wa("mat4x4",dr.keyword,"mat4x4"),ptr:new wa("ptr",dr.keyword,"ptr"),sampler:new wa("sampler",dr.keyword,"sampler"),sampler_comparison:new wa("sampler_comparison",dr.keyword,"sampler_comparison"),struct:new wa("struct",dr.keyword,"struct"),texture_1d:new wa("texture_1d",dr.keyword,"texture_1d"),texture_2d:new wa("texture_2d",dr.keyword,"texture_2d"),texture_2d_array:new wa("texture_2d_array",dr.keyword,"texture_2d_array"),texture_3d:new wa("texture_3d",dr.keyword,"texture_3d"),texture_cube:new wa("texture_cube",dr.keyword,"texture_cube"),texture_cube_array:new wa("texture_cube_array",dr.keyword,"texture_cube_array"),texture_multisampled_2d:new wa("texture_multisampled_2d",dr.keyword,"texture_multisampled_2d"),texture_storage_1d:new wa("texture_storage_1d",dr.keyword,"texture_storage_1d"),texture_storage_2d:new wa("texture_storage_2d",dr.keyword,"texture_storage_2d"),texture_storage_2d_array:new wa("texture_storage_2d_array",dr.keyword,"texture_storage_2d_array"),texture_storage_3d:new wa("texture_storage_3d",dr.keyword,"texture_storage_3d"),texture_depth_2d:new wa("texture_depth_2d",dr.keyword,"texture_depth_2d"),texture_depth_2d_array:new wa("texture_depth_2d_array",dr.keyword,"texture_depth_2d_array"),texture_depth_cube:new wa("texture_depth_cube",dr.keyword,"texture_depth_cube"),texture_depth_cube_array:new wa("texture_depth_cube_array",dr.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new wa("texture_depth_multisampled_2d",dr.keyword,"texture_depth_multisampled_2d"),texture_external:new wa("texture_external",dr.keyword,"texture_external"),u32:new wa("u32",dr.keyword,"u32"),vec2:new wa("vec2",dr.keyword,"vec2"),vec3:new wa("vec3",dr.keyword,"vec3"),vec4:new wa("vec4",dr.keyword,"vec4"),bitcast:new wa("bitcast",dr.keyword,"bitcast"),block:new wa("block",dr.keyword,"block"),break:new wa("break",dr.keyword,"break"),case:new wa("case",dr.keyword,"case"),continue:new wa("continue",dr.keyword,"continue"),continuing:new wa("continuing",dr.keyword,"continuing"),default:new wa("default",dr.keyword,"default"),diagnostic:new wa("diagnostic",dr.keyword,"diagnostic"),discard:new wa("discard",dr.keyword,"discard"),else:new wa("else",dr.keyword,"else"),enable:new wa("enable",dr.keyword,"enable"),fallthrough:new wa("fallthrough",dr.keyword,"fallthrough"),false:new wa("false",dr.keyword,"false"),fn:new wa("fn",dr.keyword,"fn"),for:new wa("for",dr.keyword,"for"),function:new wa("function",dr.keyword,"function"),if:new wa("if",dr.keyword,"if"),let:new wa("let",dr.keyword,"let"),const:new wa("const",dr.keyword,"const"),loop:new wa("loop",dr.keyword,"loop"),while:new wa("while",dr.keyword,"while"),private:new wa("private",dr.keyword,"private"),read:new wa("read",dr.keyword,"read"),read_write:new wa("read_write",dr.keyword,"read_write"),return:new wa("return",dr.keyword,"return"),requires:new wa("requires",dr.keyword,"requires"),storage:new wa("storage",dr.keyword,"storage"),switch:new wa("switch",dr.keyword,"switch"),true:new wa("true",dr.keyword,"true"),alias:new wa("alias",dr.keyword,"alias"),type:new wa("type",dr.keyword,"type"),uniform:new wa("uniform",dr.keyword,"uniform"),var:new wa("var",dr.keyword,"var"),override:new wa("override",dr.keyword,"override"),workgroup:new wa("workgroup",dr.keyword,"workgroup"),write:new wa("write",dr.keyword,"write"),r8unorm:new wa("r8unorm",dr.keyword,"r8unorm"),r8snorm:new wa("r8snorm",dr.keyword,"r8snorm"),r8uint:new wa("r8uint",dr.keyword,"r8uint"),r8sint:new wa("r8sint",dr.keyword,"r8sint"),r16uint:new wa("r16uint",dr.keyword,"r16uint"),r16sint:new wa("r16sint",dr.keyword,"r16sint"),r16float:new wa("r16float",dr.keyword,"r16float"),rg8unorm:new wa("rg8unorm",dr.keyword,"rg8unorm"),rg8snorm:new wa("rg8snorm",dr.keyword,"rg8snorm"),rg8uint:new wa("rg8uint",dr.keyword,"rg8uint"),rg8sint:new wa("rg8sint",dr.keyword,"rg8sint"),r32uint:new wa("r32uint",dr.keyword,"r32uint"),r32sint:new wa("r32sint",dr.keyword,"r32sint"),r32float:new wa("r32float",dr.keyword,"r32float"),rg16uint:new wa("rg16uint",dr.keyword,"rg16uint"),rg16sint:new wa("rg16sint",dr.keyword,"rg16sint"),rg16float:new wa("rg16float",dr.keyword,"rg16float"),rgba8unorm:new wa("rgba8unorm",dr.keyword,"rgba8unorm"),rgba8unorm_srgb:new wa("rgba8unorm_srgb",dr.keyword,"rgba8unorm_srgb"),rgba8snorm:new wa("rgba8snorm",dr.keyword,"rgba8snorm"),rgba8uint:new wa("rgba8uint",dr.keyword,"rgba8uint"),rgba8sint:new wa("rgba8sint",dr.keyword,"rgba8sint"),bgra8unorm:new wa("bgra8unorm",dr.keyword,"bgra8unorm"),bgra8unorm_srgb:new wa("bgra8unorm_srgb",dr.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new wa("rgb10a2unorm",dr.keyword,"rgb10a2unorm"),rg11b10float:new wa("rg11b10float",dr.keyword,"rg11b10float"),rg32uint:new wa("rg32uint",dr.keyword,"rg32uint"),rg32sint:new wa("rg32sint",dr.keyword,"rg32sint"),rg32float:new wa("rg32float",dr.keyword,"rg32float"),rgba16uint:new wa("rgba16uint",dr.keyword,"rgba16uint"),rgba16sint:new wa("rgba16sint",dr.keyword,"rgba16sint"),rgba16float:new wa("rgba16float",dr.keyword,"rgba16float"),rgba32uint:new wa("rgba32uint",dr.keyword,"rgba32uint"),rgba32sint:new wa("rgba32sint",dr.keyword,"rgba32sint"),rgba32float:new wa("rgba32float",dr.keyword,"rgba32float"),static_assert:new wa("static_assert",dr.keyword,"static_assert")},va.tokens={decimal_float_literal:new wa("decimal_float_literal",dr.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new wa("hex_float_literal",dr.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new wa("int_literal",dr.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new wa("uint_literal",dr.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new wa("ident",dr.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new wa("and",dr.token,"&"),and_and:new wa("and_and",dr.token,"&&"),arrow:new wa("arrow ",dr.token,"->"),attr:new wa("attr",dr.token,"@"),attr_left:new wa("attr_left",dr.token,"[["),attr_right:new wa("attr_right",dr.token,"]]"),forward_slash:new wa("forward_slash",dr.token,"/"),bang:new wa("bang",dr.token,"!"),bracket_left:new wa("bracket_left",dr.token,"["),bracket_right:new wa("bracket_right",dr.token,"]"),brace_left:new wa("brace_left",dr.token,"{"),brace_right:new wa("brace_right",dr.token,"}"),colon:new wa("colon",dr.token,":"),comma:new wa("comma",dr.token,","),equal:new wa("equal",dr.token,"="),equal_equal:new wa("equal_equal",dr.token,"=="),not_equal:new wa("not_equal",dr.token,"!="),greater_than:new wa("greater_than",dr.token,">"),greater_than_equal:new wa("greater_than_equal",dr.token,">="),shift_right:new wa("shift_right",dr.token,">>"),less_than:new wa("less_than",dr.token,"<"),less_than_equal:new wa("less_than_equal",dr.token,"<="),shift_left:new wa("shift_left",dr.token,"<<"),modulo:new wa("modulo",dr.token,"%"),minus:new wa("minus",dr.token,"-"),minus_minus:new wa("minus_minus",dr.token,"--"),period:new wa("period",dr.token,"."),plus:new wa("plus",dr.token,"+"),plus_plus:new wa("plus_plus",dr.token,"++"),or:new wa("or",dr.token,"|"),or_or:new wa("or_or",dr.token,"||"),paren_left:new wa("paren_left",dr.token,"("),paren_right:new wa("paren_right",dr.token,")"),semicolon:new wa("semicolon",dr.token,";"),star:new wa("star",dr.token,"*"),tilde:new wa("tilde",dr.token,"~"),underscore:new wa("underscore",dr.token,"_"),xor:new wa("xor",dr.token,"^"),plus_equal:new wa("plus_equal",dr.token,"+="),minus_equal:new wa("minus_equal",dr.token,"-="),times_equal:new wa("times_equal",dr.token,"*="),division_equal:new wa("division_equal",dr.token,"/="),modulo_equal:new wa("modulo_equal",dr.token,"%="),and_equal:new wa("and_equal",dr.token,"&="),or_equal:new wa("or_equal",dr.token,"|="),xor_equal:new wa("xor_equal",dr.token,"^="),shift_right_equal:new wa("shift_right_equal",dr.token,">>="),shift_left_equal:new wa("shift_left_equal",dr.token,"<<=")},va.simpleTokens={"@":cr.tokens.attr,"{":cr.tokens.brace_left,"}":cr.tokens.brace_right,":":cr.tokens.colon,",":cr.tokens.comma,"(":cr.tokens.paren_left,")":cr.tokens.paren_right,";":cr.tokens.semicolon},va.literalTokens={"&":cr.tokens.and,"&&":cr.tokens.and_and,"->":cr.tokens.arrow,"[[":cr.tokens.attr_left,"]]":cr.tokens.attr_right,"/":cr.tokens.forward_slash,"!":cr.tokens.bang,"[":cr.tokens.bracket_left,"]":cr.tokens.bracket_right,"=":cr.tokens.equal,"==":cr.tokens.equal_equal,"!=":cr.tokens.not_equal,">":cr.tokens.greater_than,">=":cr.tokens.greater_than_equal,">>":cr.tokens.shift_right,"<":cr.tokens.less_than,"<=":cr.tokens.less_than_equal,"<<":cr.tokens.shift_left,"%":cr.tokens.modulo,"-":cr.tokens.minus,"--":cr.tokens.minus_minus,".":cr.tokens.period,"+":cr.tokens.plus,"++":cr.tokens.plus_plus,"|":cr.tokens.or,"||":cr.tokens.or_or,"*":cr.tokens.star,"~":cr.tokens.tilde,_:cr.tokens.underscore,"^":cr.tokens.xor,"+=":cr.tokens.plus_equal,"-=":cr.tokens.minus_equal,"*=":cr.tokens.times_equal,"/=":cr.tokens.division_equal,"%=":cr.tokens.modulo_equal,"&=":cr.tokens.and_equal,"|=":cr.tokens.or_equal,"^=":cr.tokens.xor_equal,">>=":cr.tokens.shift_right_equal,"<<=":cr.tokens.shift_left_equal},va.regexTokens={decimal_float_literal:cr.tokens.decimal_float_literal,hex_float_literal:cr.tokens.hex_float_literal,int_literal:cr.tokens.int_literal,uint_literal:cr.tokens.uint_literal,ident:cr.tokens.ident},va.storage_class=[cr.keywords.function,cr.keywords.private,cr.keywords.workgroup,cr.keywords.uniform,cr.keywords.storage],va.access_mode=[cr.keywords.read,cr.keywords.write,cr.keywords.read_write],va.sampler_type=[cr.keywords.sampler,cr.keywords.sampler_comparison],va.sampled_texture_type=[cr.keywords.texture_1d,cr.keywords.texture_2d,cr.keywords.texture_2d_array,cr.keywords.texture_3d,cr.keywords.texture_cube,cr.keywords.texture_cube_array],va.multisampled_texture_type=[cr.keywords.texture_multisampled_2d],va.storage_texture_type=[cr.keywords.texture_storage_1d,cr.keywords.texture_storage_2d,cr.keywords.texture_storage_2d_array,cr.keywords.texture_storage_3d],va.depth_texture_type=[cr.keywords.texture_depth_2d,cr.keywords.texture_depth_2d_array,cr.keywords.texture_depth_cube,cr.keywords.texture_depth_cube_array,cr.keywords.texture_depth_multisampled_2d],va.texture_external_type=[cr.keywords.texture_external],va.any_texture_type=[...cr.sampled_texture_type,...cr.multisampled_texture_type,...cr.storage_texture_type,...cr.depth_texture_type,...cr.texture_external_type],va.texel_format=[cr.keywords.r8unorm,cr.keywords.r8snorm,cr.keywords.r8uint,cr.keywords.r8sint,cr.keywords.r16uint,cr.keywords.r16sint,cr.keywords.r16float,cr.keywords.rg8unorm,cr.keywords.rg8snorm,cr.keywords.rg8uint,cr.keywords.rg8sint,cr.keywords.r32uint,cr.keywords.r32sint,cr.keywords.r32float,cr.keywords.rg16uint,cr.keywords.rg16sint,cr.keywords.rg16float,cr.keywords.rgba8unorm,cr.keywords.rgba8unorm_srgb,cr.keywords.rgba8snorm,cr.keywords.rgba8uint,cr.keywords.rgba8sint,cr.keywords.bgra8unorm,cr.keywords.bgra8unorm_srgb,cr.keywords.rgb10a2unorm,cr.keywords.rg11b10float,cr.keywords.rg32uint,cr.keywords.rg32sint,cr.keywords.rg32float,cr.keywords.rgba16uint,cr.keywords.rgba16sint,cr.keywords.rgba16float,cr.keywords.rgba32uint,cr.keywords.rgba32sint,cr.keywords.rgba32float],va.const_literal=[cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.decimal_float_literal,cr.tokens.hex_float_literal,cr.keywords.true,cr.keywords.false],va.literal_or_ident=[cr.tokens.ident,cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.decimal_float_literal,cr.tokens.hex_float_literal],va.element_count_expression=[cr.tokens.int_literal,cr.tokens.uint_literal,cr.tokens.ident],va.template_types=[cr.keywords.vec2,cr.keywords.vec3,cr.keywords.vec4,cr.keywords.mat2x2,cr.keywords.mat2x3,cr.keywords.mat2x4,cr.keywords.mat3x2,cr.keywords.mat3x3,cr.keywords.mat3x4,cr.keywords.mat4x2,cr.keywords.mat4x3,cr.keywords.mat4x4,cr.keywords.atomic,cr.keywords.bitcast,...cr.any_texture_type],va.attribute_name=[cr.tokens.ident,cr.keywords.block,cr.keywords.diagnostic],va.assignment_operators=[cr.tokens.equal,cr.tokens.plus_equal,cr.tokens.minus_equal,cr.tokens.times_equal,cr.tokens.division_equal,cr.tokens.modulo_equal,cr.tokens.and_equal,cr.tokens.or_equal,cr.tokens.xor_equal,cr.tokens.shift_right_equal,cr.tokens.shift_left_equal],va.increment_operators=[cr.tokens.plus_plus,cr.tokens.minus_minus];class ka{constructor(t,e,n){this.type=t,this.lexeme=e,this.line=n}toString(){return this.lexeme}isTemplateType(){return-1!=va.template_types.indexOf(this.type)}isArrayType(){return this.type==va.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Ma{constructor(t){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=t??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new ka(va.eof,"",this._line)),this._tokens}scanToken(){let t=this._advance();if("\n"==t)return this._line++,!0;if(this._isWhitespace(t))return!0;if("/"==t){if("/"==this._peekAhead()){for(;"\n"!=t;){if(this._isAtEnd())return!0;t=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let e=1;for(;e>0;){if(this._isAtEnd())return!0;if(t=this._advance(),"\n"==t)this._line++;else if("*"==t){if("/"==this._peekAhead()&&(this._advance(),e--,0==e))return!0}else"/"==t&&"*"==this._peekAhead()&&(this._advance(),e++)}return!0}}const e=va.simpleTokens[t];if(e)return this._addToken(e),!0;let n=va.none;const s=this._isAlpha(t),i="_"===t;if(this._isAlphaNumeric(t)){let e=this._peekAhead();for(;this._isAlphaNumeric(e);)t+=this._advance(),e=this._peekAhead()}if(s){const e=va.keywords[t];if(e)return this._addToken(e),!0}if(s||i)return this._addToken(va.tokens.ident),!0;for(;;){let e=this._findType(t);const s=this._peekAhead();if(">"==t&&(">"==s||"="==s)){let t=!1,n=this._tokens.length-1;for(let e=0;e<5&&n>=0;++e,--n)if(this._tokens[n].type===va.tokens.less_than){n>0&&this._tokens[n-1].isArrayOrTemplateType()&&(t=!0);break}if(t)return this._addToken(e),!0}if(e===va.none){let s=t,i=0;const r=2;for(let t=0;t=this._source.length}_isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}_isAlphaNumeric(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||"_"==t||t>="0"&&t<="9"}_isWhitespace(t){return" "==t||"\t"==t||"\r"==t}_advance(t){void 0===t&&(t=0);let e=this._source[this._current];return t=t||0,t++,this._current+=t,e}_peekAhead(t){return void 0===t&&(t=0),t=t||0,this._current+t>=this._source.length?"\0":this._source[this._current+t]}_addToken(t){const e=this._source.substring(this._start,this._current);this._tokens.push(new ka(t,e,this._line))}}class Sa{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new br,this._deferArrayCountEval=[]}parse(t){this._initialize(t),this._deferArrayCountEval.length=0;const e=[];for(;!this._isAtEnd();){const t=this._global_decl_or_directive();if(!t)break;e.push(t)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const e=t.arrayType,n=t.countNode;if(n instanceof ia){const t=n.name,s=this._context.constants.get(t);if(s)try{const t=s.evaluate(this._context);e.count=t}catch{}}}this._deferArrayCountEval.length=0}return e}_initialize(t){if(t)if("string"==typeof t){const e=new Ma(t);this._tokens=e.scanTokens()}else this._tokens=t;else this._tokens=[];this._current=0}_error(t,e){return{token:t,message:e,toString:function(){return`${e}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==va.eof}_match(t){if(t instanceof wa)return!!this._check(t)&&(this._advance(),!0);for(let e=0,n=t.length;e'.");const e=this._paren_expression();return new oa(t,e)}const t=this._type_decl(),e=this._argument_expression_list();return new la(t,e)}_argument_expression_list(){if(!this._match(va.tokens.paren_left))return null;const t=[];do{if(this._check(va.tokens.paren_right))break;const e=this._short_circuit_or_expression();t.push(e)}while(this._match(va.tokens.comma));return this._consume(va.tokens.paren_right,"Expected ')' for agument list"),t}_optional_paren_expression(){this._match(va.tokens.paren_left);const t=this._short_circuit_or_expression();return this._match(va.tokens.paren_right),new ha([t])}_paren_expression(){this._consume(va.tokens.paren_left,"Expected '('.");const t=this._short_circuit_or_expression();return this._consume(va.tokens.paren_right,"Expected ')'."),new ha([t])}_struct_decl(){if(!this._match(va.keywords.struct))return null;const t=this._currentLine,e=this._consume(va.tokens.ident,"Expected name for struct.").toString();this._consume(va.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(va.tokens.brace_right);){const t=this._attribute(),e=this._consume(va.tokens.ident,"Expected variable name.").toString();this._consume(va.tokens.colon,"Expected ':' for struct member type.");const s=this._attribute(),i=this._type_decl();null!=i&&(i.attributes=s),this._check(va.tokens.brace_right)?this._match(va.tokens.comma):this._consume(va.tokens.comma,"Expected ',' for struct member."),n.push(new xa(e,i,t))}this._consume(va.tokens.brace_right,"Expected '}' after struct body.");const s=this._currentLine,i=new Zr(e,n,t,s);return this._context.structs.set(e,i),i}_global_variable_decl(){const t=this._variable_decl();return t&&this._match(va.tokens.equal)&&(t.value=this._const_expression()),t}_override_variable_decl(){const t=this._override_decl();return t&&this._match(va.tokens.equal)&&(t.value=this._const_expression()),t}_global_const_decl(){if(!this._match(va.keywords.const))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}let n=null;if(this._match(va.tokens.equal)){const t=this._short_circuit_or_expression();if(t instanceof na)n=t;else if(t instanceof ra&&t.initializer instanceof na)n=t.initializer;else try{const e=t.evaluate(this._context);n=new aa(e)}catch{n=t}}const s=new Lr(t.toString(),e,"","",n);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(va.keywords.let))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}let n=null;return this._match(va.tokens.equal)&&(n=this._const_expression()),new Pr(t.toString(),e,"","",n)}_const_expression(){if(this._match(va.const_literal))return new ea(this._previous().toString());const t=this._type_decl();this._consume(va.tokens.paren_left,"Expected '('.");let e=[];for(;!this._check(va.tokens.paren_right)&&(e.push(this._const_expression()),this._check(va.tokens.comma));)this._advance();return this._consume(va.tokens.paren_right,"Expected ')'."),new na(t,e)}_variable_decl(){if(!this._match(va.keywords.var))return null;let t="",e="";this._match(va.tokens.less_than)&&(t=this._consume(va.storage_class,"Expected storage_class.").toString(),this._match(va.tokens.comma)&&(e=this._consume(va.access_mode,"Expected access_mode.").toString()),this._consume(va.tokens.greater_than,"Expected '>'."));const n=this._consume(va.tokens.ident,"Expected variable name");let s=null;if(this._match(va.tokens.colon)){const t=this._attribute();s=this._type_decl(),null!=s&&(s.attributes=t)}return new Br(n.toString(),s,t,e,null)}_override_decl(){if(!this._match(va.keywords.override))return null;const t=this._consume(va.tokens.ident,"Expected variable name");let e=null;if(this._match(va.tokens.colon)){const t=this._attribute();e=this._type_decl(),null!=e&&(e.attributes=t)}return new zr(t.toString(),e,null)}_diagnostic(){this._consume(va.tokens.paren_left,"Expected '('");const t=this._consume(va.tokens.ident,"Expected severity control name.");this._consume(va.tokens.comma,"Expected ','");const e=this._consume(va.tokens.ident,"Expected diagnostic rule name.");return this._consume(va.tokens.paren_right,"Expected ')'"),new jr(t.toString(),e.toString())}_enable_directive(){const t=this._consume(va.tokens.ident,"identity expected.");return new Ur(t.toString())}_requires_directive(){const t=[this._consume(va.tokens.ident,"identity expected.").toString()];for(;this._match(va.tokens.comma);){const e=this._consume(va.tokens.ident,"identity expected.");t.push(e.toString())}return new qr(t)}_type_alias(){const t=this._consume(va.tokens.ident,"identity expected.");this._consume(va.tokens.equal,"Expected '=' for type alias.");let e=this._type_decl();if(null===e)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(e.name)&&(e=this._context.aliases.get(e.name).type);const n=new Vr(t.toString(),e);return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([va.tokens.ident,...va.texel_format,va.keywords.bool,va.keywords.f32,va.keywords.i32,va.keywords.u32])){const t=this._advance(),e=t.toString();return this._context.structs.has(e)?this._context.structs.get(e):this._context.aliases.has(e)?this._context.aliases.get(e).type:new Xr(t.toString())}let t=this._texture_sampler_types();if(t)return t;if(this._check(va.template_types)){let t=this._advance().toString(),e=null,n=null;return this._match(va.tokens.less_than)&&(e=this._type_decl(),n=null,this._match(va.tokens.comma)&&(n=this._consume(va.access_mode,"Expected access_mode for pointer").toString()),this._consume(va.tokens.greater_than,"Expected '>' for type.")),new Jr(t,e,n)}if(this._match(va.keywords.ptr)){let t=this._previous().toString();this._consume(va.tokens.less_than,"Expected '<' for pointer.");const e=this._consume(va.storage_class,"Expected storage_class for pointer");this._consume(va.tokens.comma,"Expected ',' for pointer.");const n=this._type_decl();let s=null;return this._match(va.tokens.comma)&&(s=this._consume(va.access_mode,"Expected access_mode for pointer").toString()),this._consume(va.tokens.greater_than,"Expected '>' for pointer."),new $r(t,e.toString(),n,s)}const e=this._attribute();if(this._match(va.keywords.array)){let t=null,n=-1;const s=this._previous();let i=null;if(this._match(va.tokens.less_than)){t=this._type_decl(),this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let e="";if(this._match(va.tokens.comma)){i=this._shift_expression();try{e=i.evaluate(this._context).toString(),i=null}catch{e="1"}}this._consume(va.tokens.greater_than,"Expected '>' for array."),n=e?parseInt(e):0}const r=new Kr(s.toString(),e,t,n);return i&&this._deferArrayCountEval.push({arrayType:r,countNode:i}),r}return null}_texture_sampler_types(){if(this._match(va.sampler_type))return new Qr(this._previous().toString(),null,null);if(this._match(va.depth_texture_type))return new Qr(this._previous().toString(),null,null);if(this._match(va.sampled_texture_type)||this._match(va.multisampled_texture_type)){const t=this._previous();this._consume(va.tokens.less_than,"Expected '<' for sampler type.");const e=this._type_decl();return this._consume(va.tokens.greater_than,"Expected '>' for sampler type."),new Qr(t.toString(),e,null)}if(this._match(va.storage_texture_type)){const t=this._previous();this._consume(va.tokens.less_than,"Expected '<' for sampler type.");const e=this._consume(va.texel_format,"Invalid texel format.").toString();this._consume(va.tokens.comma,"Expected ',' after texel format.");const n=this._consume(va.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(va.tokens.greater_than,"Expected '>' for sampler type."),new Qr(t.toString(),e,n)}return null}_attribute(){let t=[];for(;this._match(va.tokens.attr);){const e=this._consume(va.attribute_name,"Expected attribute name"),n=new ba(e.toString(),null);if(this._match(va.tokens.paren_left)){if(n.value=this._consume(va.literal_or_ident,"Expected attribute value").toString(),this._check(va.tokens.comma)){this._advance();do{const t=this._consume(va.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(t)}while(this._match(va.tokens.comma))}this._consume(va.tokens.paren_right,"Expected ')'")}t.push(n)}for(;this._match(va.tokens.attr_left);){if(!this._check(va.tokens.attr_right))do{const e=this._consume(va.attribute_name,"Expected attribute name"),n=new ba(e.toString(),null);if(this._match(va.tokens.paren_left)){if(n.value=[this._consume(va.literal_or_ident,"Expected attribute value").toString()],this._check(va.tokens.comma)){this._advance();do{const t=this._consume(va.literal_or_ident,"Expected attribute value").toString();n.value.push(t)}while(this._match(va.tokens.comma))}this._consume(va.tokens.paren_right,"Expected ')'")}t.push(n)}while(this._match(va.tokens.comma));this._consume(va.tokens.attr_right,"Expected ']]' after attribute declarations")}return 0==t.length?null:t}}class Ta{constructor(t,e){this.name=t,this.attributes=e,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}}class Aa{constructor(t,e,n){this.name=t,this.type=e,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Ea extends Ta{constructor(t,e){super(t,e),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Ra extends Ta{constructor(t,e){super(t,e),this.count=0,this.stride=0}get isArray(){return!0}}class Ba extends Ta{constructor(t,e,n,s){super(t,n),this.format=e,this.access=s}get isTemplate(){return!0}}!function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"}(pr||(pr={}));class za{constructor(t,e,n,s,i,r,a){this.name=t,this.type=e,this.group=n,this.binding=s,this.attributes=i,this.resourceType=r,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Pa{constructor(t,e){this.name=t,this.type=e}}class La{constructor(t,e){this.align=t,this.size=e}}class Ia{constructor(t,e,n,s){this.name=t,this.type=e,this.locationType=n,this.location=s,this.interpolation=null}}class Ca{constructor(t,e,n,s){this.name=t,this.type=e,this.locationType=n,this.location=s}}class Da{constructor(t,e){void 0===e&&(e=null),this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=t,this.stage=e}}class Na{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}class Fa{constructor(t,e,n,s){this.name=t,this.type=e,this.attributes=n,this.id=s}}class Oa{constructor(t){this.resources=null,this.inUse=!1,this.info=null,this.node=t}}class Wa{constructor(t){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Na,this.functions=[],this._types=new Map,this._functions=new Map,t&&this.update(t)}_isStorageTexture(t){return"texture_storage_1d"==t.name||"texture_storage_2d"==t.name||"texture_storage_2d_array"==t.name||"texture_storage_3d"==t.name}update(t){const e=(new Sa).parse(t);for(const n of e)n instanceof Sr&&this._functions.set(n.name,new Oa(n));for(const n of e)if(n instanceof Zr){const t=this._getTypeInfo(n,null);t instanceof Ea&&this.structs.push(t)}for(const n of e)if(n instanceof Vr)this.aliases.push(this._getAliasInfo(n));else if(n instanceof zr){const t=n,e=this._getAttributeNum(t.attributes,"id",0),s=null!=t.type?this._getTypeInfo(t.type,t.attributes):null;this.overrides.push(new Fa(t.name,s,t.attributes,e))}else if(this._isUniformVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=new za(t.name,i,e,s,t.attributes,pr.Uniform,t.access);this.uniforms.push(r)}else if(this._isStorageVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=this._isStorageTexture(i),a=new za(t.name,i,e,s,t.attributes,r?pr.StorageTexture:pr.Storage,t.access);this.storage.push(a)}else if(this._isTextureVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=this._isStorageTexture(i),a=new za(t.name,i,e,s,t.attributes,r?pr.StorageTexture:pr.Texture,t.access);r?this.storage.push(a):this.textures.push(a)}else if(this._isSamplerVar(n)){const t=n,e=this._getAttributeNum(t.attributes,"group",0),s=this._getAttributeNum(t.attributes,"binding",0),i=this._getTypeInfo(t.type,t.attributes),r=new za(t.name,i,e,s,t.attributes,pr.Sampler,t.access);this.samplers.push(r)}else if(n instanceof Sr){const t=this._getAttribute(n,"vertex"),e=this._getAttribute(n,"fragment"),s=this._getAttribute(n,"compute"),i=t||e||s,r=new Da(n.name,null==i?void 0:i.name);r.startLine=n.startLine,r.endLine=n.endLine,this.functions.push(r),this._functions.get(n.name).info=r,i&&(this._functions.get(n.name).inUse=!0,r.inUse=!0,r.resources=this._findResources(n,!!i),r.inputs=this._getInputs(n.args),r.outputs=this._getOutputs(n.returnType),this.entry[i.name].push(r))}else;for(const n of this._functions.values())n.info&&(n.info.inUse=n.inUse,this._addCalls(n.node,n.info.calls));for(const n of this.uniforms)this._markStructsInUse(n.type);for(const n of this.storage)this._markStructsInUse(n.type)}_markStructsInUse(t){if(t.isStruct){t.inUse=!0;for(const e of t.members)this._markStructsInUse(e.type)}else if(t.isArray)this._markStructsInUse(t.format);else if(t.isTemplate)this._markStructsInUse(t.format);else{const e=this._getAlias(t.name);e&&this._markStructsInUse(e)}}_addCalls(t,e){var n;for(const s of t.calls){const t=null===(n=this._functions.get(s.name))||void 0===n?void 0:n.info;t&&e.add(t)}}findResource(t,e){for(const n of this.uniforms)if(n.group==t&&n.binding==e)return n;for(const n of this.storage)if(n.group==t&&n.binding==e)return n;for(const n of this.textures)if(n.group==t&&n.binding==e)return n;for(const n of this.samplers)if(n.group==t&&n.binding==e)return n;return null}_findResource(t){for(const e of this.uniforms)if(e.name==t)return e;for(const e of this.storage)if(e.name==t)return e;for(const e of this.textures)if(e.name==t)return e;for(const e of this.samplers)if(e.name==t)return e;return null}_markStructsFromAST(t){const e=this._getTypeInfo(t,null);this._markStructsInUse(e)}_findResources(t,e){const n=[],s=this,i=[];return t.search((r=>{if(r instanceof vr)i.push({});else if(r instanceof kr)i.pop();else if(r instanceof Br){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type),i.length>0&&(i[i.length-1][t.name]=t)}else if(r instanceof na){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type)}else if(r instanceof Pr){const t=r;e&&null!==t.type&&this._markStructsFromAST(t.type),i.length>0&&(i[i.length-1][t.name]=t)}else if(r instanceof ia){const t=r;if(i.length>0&&i[i.length-1][t.name])return;const e=s._findResource(t.name);e&&n.push(e)}else if(r instanceof sa){const i=r,a=s._functions.get(i.name);a&&(e&&(a.inUse=!0),t.calls.add(a.node),null===a.resources&&(a.resources=s._findResources(a.node,e)),n.push(...a.resources))}else if(r instanceof Dr){const i=r,a=s._functions.get(i.name);a&&(e&&(a.inUse=!0),t.calls.add(a.node),null===a.resources&&(a.resources=s._findResources(a.node,e)),n.push(...a.resources))}})),[...new Map(n.map((t=>[t.name,t]))).values()]}getBindGroups(){const t=[];function e(e,n){e>=t.length&&(t.length=e+1),void 0===t[e]&&(t[e]=[]),n>=t[e].length&&(t[e].length=n+1)}for(const n of this.uniforms){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.storage){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.textures){e(n.group,n.binding);t[n.group][n.binding]=n}for(const n of this.samplers){e(n.group,n.binding);t[n.group][n.binding]=n}return t}_getOutputs(t,e){if(void 0===e&&(e=void 0),void 0===e&&(e=[]),t instanceof Zr)this._getStructOutputs(t,e);else{const n=this._getOutputInfo(t);null!==n&&e.push(n)}return e}_getStructOutputs(t,e){for(const n of t.members)if(n.type instanceof Zr)this._getStructOutputs(n.type,e);else{const t=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(null!==t){const s=this._getTypeInfo(n.type,n.type.attributes),i=this._parseInt(t.value),r=new Ca(n.name,s,t.name,i);e.push(r)}}}_getOutputInfo(t){const e=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(null!==e){const n=this._getTypeInfo(t,t.attributes),s=this._parseInt(e.value);return new Ca("",n,e.name,s)}return null}_getInputs(t,e){void 0===e&&(e=void 0),void 0===e&&(e=[]);for(const n of t)if(n.type instanceof Zr)this._getStructInputs(n.type,e);else{const t=this._getInputInfo(n);null!==t&&e.push(t)}return e}_getStructInputs(t,e){for(const n of t.members)if(n.type instanceof Zr)this._getStructInputs(n.type,e);else{const t=this._getInputInfo(n);null!==t&&e.push(t)}}_getInputInfo(t){const e=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(null!==e){const n=this._getAttribute(t,"interpolation"),s=this._getTypeInfo(t.type,t.attributes),i=this._parseInt(e.value),r=new Ia(t.name,s,e.name,i);return null!==n&&(r.interpolation=this._parseString(n.value)),r}return null}_parseString(t){return t instanceof Array&&(t=t[0]),t}_parseInt(t){t instanceof Array&&(t=t[0]);const e=parseInt(t);return isNaN(e)?t:e}_getAlias(t){for(const e of this.aliases)if(e.name==t)return e.type;return null}_getAliasInfo(t){return new Pa(t.name,this._getTypeInfo(t.type,null))}_getTypeInfo(t,e){if(this._types.has(t))return this._types.get(t);if(t instanceof Kr){const n=t,s=this._getTypeInfo(n.format,n.attributes),i=new Ra(n.name,e);return i.format=s,i.count=n.count,this._types.set(t,i),this._updateTypeInfo(i),i}if(t instanceof Zr){const n=t,s=new Ea(n.name,e);s.startLine=n.startLine,s.endLine=n.endLine;for(const t of n.members){const e=this._getTypeInfo(t.type,t.attributes);s.members.push(new Aa(t.name,e,t.attributes))}return this._types.set(t,s),this._updateTypeInfo(s),s}if(t instanceof Qr){const n=t,s=n.format instanceof Xr,i=n.format?s?this._getTypeInfo(n.format,null):new Ta(n.format,null):null,r=new Ba(n.name,i,e,n.access);return this._types.set(t,r),this._updateTypeInfo(r),r}if(t instanceof Jr){const n=t,s=n.format?this._getTypeInfo(n.format,null):null,i=new Ba(n.name,s,e,n.access);return this._types.set(t,i),this._updateTypeInfo(i),i}const n=new Ta(t.name,e);return this._types.set(t,n),this._updateTypeInfo(n),n}_updateTypeInfo(t){var e,n;const s=this._getTypeSize(t);if(t.size=null!==(e=null==s?void 0:s.size)&&void 0!==e?e:0,t instanceof Ra){const e=this._getTypeSize(t.format);t.stride=null!==(n=null==e?void 0:e.size)&&void 0!==n?n:0,this._updateTypeInfo(t.format)}t instanceof Ea&&this._updateStructInfo(t)}_updateStructInfo(t){var e;let n=0,s=0,i=0,r=0;for(let a=0,o=t.members.length;a{const n=function(t,e,n){switch(e.resourceType){case pr.Uniform:case pr.Storage:case pr.StorageTexture:return Ja(t,e.type,n);default:return{size:0,type:e.type.name}}}(t,e,0);return[e.name,{typeDefinition:n,group:e.group,binding:e.binding,size:n.size}]})))}function qa(t,e,n){return{fields:Object.fromEntries(e.members.map((e=>[e.name,{offset:e.offset,type:Ja(t,e.type,0)}]))),size:e.size,offset:n}}function ja(t){var e;if(t.name.includes("depth"))return"depth";switch(null==(e=t.format)?void 0:e.name){case"f32":return"float";case"i32":return"sint";case"u32":return"uint";default:throw new Error("unknown texture sample type")}}function Va(t){return t.name.includes("2d_array")?"2d-array":t.name.includes("cube_array")?"cube-array":t.name.includes("3d")?"3d":t.name.includes("1d")?"1d":t.name.includes("cube")?"cube":"2d"}function Ga(t){switch(t.access){case"read":return"read-only";case"write":return"write-only";case"read_write":return"read-write";default:throw new Error("unknonw storage texture access")}}function Ha(t){return t.name.endsWith("_comparison")?"comparison":"filtering"}function Ya(t,e){const{binding:n,access:s,type:i}=t;switch(t.resourceType){case pr.Uniform:return{binding:n,visibility:e,buffer:{}};case pr.Storage:return{binding:n,visibility:e,buffer:{type:""===s||"read"===s?"read-only-storage":"storage"}};case pr.Texture:{if("texture_external"===i.name)return{binding:n,visibility:e,externalTexture:{}};const t=i.name.includes("multisampled");return{binding:n,visibility:e,texture:{sampleType:ja(i),viewDimension:Va(i),multisampled:t}}}case pr.Sampler:return{binding:n,visibility:e,sampler:{type:Ha(i)}};case pr.StorageTexture:return{binding:n,visibility:e,storageTexture:{access:Ga(i),format:i.format.name,viewDimension:Va(i)}};default:throw new Error("unknown resource type")}}function Xa(t,e){const n={};for(const s of t)n[s.name]={stage:e,resources:s.resources.map((t=>{const{name:n,group:s}=t;return{name:n,group:s,entry:Ya(t,e)}}))};return n}function Za(t,e){if(void 0===e&&(e=""),!t)throw new Error(e)}function Ja(t,e,n){if(e.isArray){Za(!e.isStruct,"struct array is invalid"),Za(!e.isStruct,"template array is invalid");const s=e;return{size:s.size,elementType:Ja(t,s.format,n),numElements:s.count}}if(e.isStruct)return Za(!e.isTemplate,"template struct is invalid"),qa(t,e,n);{const t=e,n=e.isTemplate?`${t.name}<${t.format.name}>`:e.name;return{size:e.size,type:n}}}Wa._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},Wa._textureTypes=va.any_texture_type.map((t=>t.name)),Wa._samplerTypes=va.sampler_type.map((t=>t.name));const $a=new Map([[Int8Array,{formats:["sint8","snorm8"],defaultForType:1}],[Uint8Array,{formats:["uint8","unorm8"],defaultForType:1}],[Int16Array,{formats:["sint16","snorm16"],defaultForType:1}],[Uint16Array,{formats:["uint16","unorm16"],defaultForType:1}],[Int32Array,{formats:["sint32","snorm32"],defaultForType:0}],[Uint32Array,{formats:["uint32","unorm32"],defaultForType:0}],[Float32Array,{formats:["float32","float32"],defaultForType:0}]]);new Map([...$a.entries()].map((t=>{let[e,{formats:[n,s]}]=t;return[[n,e],[s,e]]})).flat());class Ka extends Error{constructor(t){super(`[WebGPUNotSupportedError] WebGPU is not supported in this environment. Make sure to use a browser and device that supports WebGPU. (Reason: ${t})`)}}class Qa extends Error{constructor(){super("[CanvasReferenceError] Canvas reference is not set. Make sure to set the canvas to a DOM node before calling any methods.")}}class to extends Error{constructor(){super("[SignalAlreadyAbortedError] Signal is already aborted. Make sure to check the aborted property before calling any methods.")}}class eo extends Error{constructor(t){super("[InvalidMaterialError] Material is invalid. Make sure to configure all materials to be instances of OpenPBRMaterial."),this.invalidMaterial=t}}class no extends Error{constructor(t){super(`[InternalError] Library error occurred, please get in contact. (Reason: ${t})`)}}const so=32;function io(t,e){return 65535===e[t+15]}function ro(t,e){return e[t+6]}function ao(t,e){return e[t+14]}function oo(t,e){return e[t+6]}function lo(t,e){return e[t+7]}function ho(){return{sky:{power:1,color:[1,1,1]},sun:{power:.5,angularSize:40,latitude:45,longitude:180,color:[1,1,1]}}}function uo(t){return null==t}const co={type:"change"},po={type:"start"},mo={type:"end"},fo=new class{constructor(t,e){void 0===t&&(t=new wt),void 0===e&&(e=new wt(0,0,-1)),this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,jt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=jt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(jt.copy(this.origin).addScaledVector(this.direction,e),jt.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Vt.copy(t).add(e).multiplyScalar(.5),Gt.copy(e).sub(t).normalize(),Ht.copy(this.origin).sub(Vt);const i=.5*t.distanceTo(e),r=-this.direction.dot(Gt),a=Ht.dot(this.direction),o=-Ht.dot(Gt),l=Ht.lengthSq(),h=Math.abs(1-r*r);let u,c,d,p;if(h>0)if(u=r*o-a,c=r*a-o,p=i*h,u>=0)if(c>=-p)if(c<=p){const t=1/h;u*=t,c*=t,d=u*(u+r*c+2*a)+c*(r*u+c+2*o)+l}else c=i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;else c=-i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;else c<=-p?(u=Math.max(0,-(-r*i+a)),c=u>0?-i:Math.min(Math.max(-i,-o),i),d=-u*u+c*(c+2*o)+l):c<=p?(u=0,c=Math.min(Math.max(-i,-o),i),d=c*(c+2*o)+l):(u=Math.max(0,-(r*i+a)),c=u>0?i:Math.min(Math.max(-i,-o),i),d=-u*u+c*(c+2*o)+l);else c=r>0?-i:i,u=Math.max(0,-(r*c+a)),d=-u*u+c*(c+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Vt).addScaledVector(Gt,c),d}intersectSphere(t,e){jt.subVectors(t.center,this.origin);const n=jt.dot(this.direction),s=jt.dot(jt)-n*n,i=t.radius*t.radius;if(s>i)return null;const r=Math.sqrt(i-s),a=n-r,o=n+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,i,r,a,o;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,c=this.origin;return l>=0?(n=(t.min.x-c.x)*l,s=(t.max.x-c.x)*l):(n=(t.max.x-c.x)*l,s=(t.min.x-c.x)*l),h>=0?(i=(t.min.y-c.y)*h,r=(t.max.y-c.y)*h):(i=(t.max.y-c.y)*h,r=(t.min.y-c.y)*h),n>r||i>s||((i>n||isNaN(n))&&(n=i),(r=0?(a=(t.min.z-c.z)*u,o=(t.max.z-c.z)*u):(a=(t.max.z-c.z)*u,o=(t.min.z-c.z)*u),n>o||a>s)||((a>n||n!=n)&&(n=a),(o=0?n:s,e)}intersectsBox(t){return null!==this.intersectBox(t,jt)}intersectTriangle(t,e,n,s,i){Yt.subVectors(e,t),Xt.subVectors(n,t),Zt.crossVectors(Yt,Xt);let r,a=this.direction.dot(Zt);if(a>0){if(s)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}Ht.subVectors(this.origin,t);const o=r*this.direction.dot(Xt.crossVectors(Ht,Xt));if(o<0)return null;const l=r*this.direction.dot(Yt.cross(Ht));if(l<0||o+l>a)return null;const h=-r*Ht.dot(Zt);return h<0?null:this.at(h/a,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},yo=new dn,go=Math.cos(70*tt);class _o extends V{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new wt,this.cursor=new wt,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:M,MIDDLE:S,RIGHT:T},this.touches={ONE:A,TWO:R},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",st),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",st),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(co),n.update(),i=s.NONE},this.update=function(){const e=new wt,u=(new bt).setFromUnitVectors(t.up,new wt(0,1,0)),c=u.clone().invert(),d=new wt,p=new bt,m=new wt,f=2*Math.PI;return function(y){void 0===y&&(y=null);const g=n.object.position;e.copy(g).sub(n.target),e.applyQuaternion(u),a.setFromVector3(e),n.autoRotate&&i===s.NONE&&L(function(t){return null!==t?2*Math.PI/60*n.autoRotateSpeed*t:2*Math.PI/60/60*n.autoRotateSpeed}(y)),n.enableDamping?(a.theta+=o.theta*n.dampingFactor,a.phi+=o.phi*n.dampingFactor):(a.theta+=o.theta,a.phi+=o.phi);let _=n.minAzimuthAngle,v=n.maxAzimuthAngle;isFinite(_)&&isFinite(v)&&(_<-Math.PI?_+=f:_>Math.PI&&(_-=f),v<-Math.PI?v+=f:v>Math.PI&&(v-=f),a.theta=_<=v?Math.max(_,Math.min(v,a.theta)):a.theta>(_+v)/2?Math.max(_,a.theta):Math.min(v,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let k=!1;if(n.zoomToCursor&&w||n.object.isOrthographicCamera)a.radius=U(a.radius);else{const t=a.radius;a.radius=U(a.radius*l),k=t!=a.radius}if(e.setFromSpherical(a),e.applyQuaternion(c),g.copy(n.target).add(e),n.object.lookAt(n.target),!0===n.enableDamping?(o.theta*=1-n.dampingFactor,o.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(o.set(0,0,0),h.set(0,0,0)),n.zoomToCursor&&w){let s=null;if(n.object.isPerspectiveCamera){const t=e.length();s=U(t*l);const i=t-s;n.object.position.addScaledVector(x,i),n.object.updateMatrixWorld(),k=!!i}else if(n.object.isOrthographicCamera){const t=new wt(b.x,b.y,0);t.unproject(n.object);const i=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),k=i!==n.object.zoom;const r=new wt(b.x,b.y,0);r.unproject(n.object),n.object.position.sub(r).add(t),n.object.updateMatrixWorld(),s=e.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==s&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(s).add(n.object.position):(fo.origin.copy(n.object.position),fo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(fo.direction))r||8*(1-p.dot(n.object.quaternion))>r||m.distanceToSquared(n.target)>r)&&(n.dispatchEvent(co),d.copy(n.object.position),p.copy(n.object.quaternion),m.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",rt),n.domElement.removeEventListener("pointerdown",J),n.domElement.removeEventListener("pointercancel",K),n.domElement.removeEventListener("wheel",Q),n.domElement.removeEventListener("pointermove",$),n.domElement.removeEventListener("pointerup",K),n.domElement.getRootNode().removeEventListener("keydown",tt,{capture:!0}),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",st),n._domElementKeyEvents=null)};const n=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=s.NONE;const r=1e-6,a=new yn,o=new yn;let l=1;const h=new wt,u=new et,c=new et,d=new et,p=new et,m=new et,f=new et,y=new et,g=new et,_=new et,x=new wt,b=new et;let w=!1;const v=[],k={};let z=!1;function P(t){const e=Math.abs(.01*t);return Math.pow(.95,n.zoomSpeed*e)}function L(t){o.theta-=t}function I(t){o.phi-=t}const C=function(){const t=new wt;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),h.add(t)}}(),D=function(){const t=new wt;return function(e,s){!0===n.screenSpacePanning?t.setFromMatrixColumn(s,1):(t.setFromMatrixColumn(s,0),t.crossVectors(n.object.up,t)),t.multiplyScalar(e),h.add(t)}}(),N=function(){const t=new wt;return function(e,s){const i=n.domElement;if(n.object.isPerspectiveCamera){const r=n.object.position;t.copy(r).sub(n.target);let a=t.length();a*=Math.tan(n.object.fov/2*Math.PI/180),C(2*e*a/i.clientHeight,n.object.matrix),D(2*s*a/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(C(e*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),D(s*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function F(t){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(t){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function W(t,e){if(!n.zoomToCursor)return;w=!0;const s=n.domElement.getBoundingClientRect(),i=t-s.left,r=e-s.top,a=s.width,o=s.height;b.x=i/a*2-1,b.y=-r/o*2+1,x.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function U(t){return Math.max(n.minDistance,Math.min(n.maxDistance,t))}function q(t){u.set(t.clientX,t.clientY)}function j(t){p.set(t.clientX,t.clientY)}function V(t){if(1===v.length)u.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);u.set(n,s)}}function G(t){if(1===v.length)p.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);p.set(n,s)}}function H(t){const e=ot(t),n=t.pageX-e.x,s=t.pageY-e.y,i=Math.sqrt(n*n+s*s);y.set(0,i)}function Y(t){if(1==v.length)c.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);c.set(n,s)}d.subVectors(c,u).multiplyScalar(n.rotateSpeed);const e=n.domElement;L(2*Math.PI*d.x/e.clientHeight),I(2*Math.PI*d.y/e.clientHeight),u.copy(c)}function X(t){if(1===v.length)m.set(t.pageX,t.pageY);else{const e=ot(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);m.set(n,s)}f.subVectors(m,p).multiplyScalar(n.panSpeed),N(f.x,f.y),p.copy(m)}function Z(t){const e=ot(t),s=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(s*s+i*i);g.set(0,r),_.set(0,Math.pow(g.y/y.y,n.zoomSpeed)),F(_.y),y.copy(g);W(.5*(t.pageX+e.x),.5*(t.pageY+e.y))}function J(t){!1!==n.enabled&&(0===v.length&&(n.domElement.setPointerCapture(t.pointerId),n.domElement.addEventListener("pointermove",$),n.domElement.addEventListener("pointerup",K)),!function(t){for(let e=0;e0?F(P(_.y)):_.y<0&&O(P(_.y)),y.copy(g),n.update()}(t);break;case s.PAN:if(!1===n.enablePan)return;!function(t){m.set(t.clientX,t.clientY),f.subVectors(m,p).multiplyScalar(n.panSpeed),N(f.x,f.y),p.copy(m),n.update()}(t)}}(t))}function K(t){switch(function(t){delete k[t.pointerId];for(let e=0;e0&&F(P(t.deltaY)),n.update()}(function(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return t.ctrlKey&&!z&&(n.deltaY*=10),n}(t)),n.dispatchEvent(mo))}function tt(t){"Control"===t.key&&(z=!0,n.domElement.getRootNode().addEventListener("keyup",nt,{passive:!0,capture:!0}))}function nt(t){"Control"===t.key&&(z=!1,n.domElement.getRootNode().removeEventListener("keyup",nt,{passive:!0,capture:!0}))}function st(t){!1===n.enabled||!1===n.enablePan||function(t){let e=!1;switch(t.code){case n.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?I(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,n.keyPanSpeed),e=!0;break;case n.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?I(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,-n.keyPanSpeed),e=!0;break;case n.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?L(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(n.keyPanSpeed,0),e=!0;break;case n.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?L(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(-n.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),n.update())}(t)}function it(t){switch(at(t),v.length){case 1:switch(n.touches.ONE){case A:if(!1===n.enableRotate)return;V(t),i=s.TOUCH_ROTATE;break;case E:if(!1===n.enablePan)return;G(t),i=s.TOUCH_PAN;break;default:i=s.NONE}break;case 2:switch(n.touches.TWO){case R:if(!1===n.enableZoom&&!1===n.enablePan)return;(function(t){n.enableZoom&&H(t),n.enablePan&&G(t)})(t),i=s.TOUCH_DOLLY_PAN;break;case B:if(!1===n.enableZoom&&!1===n.enableRotate)return;(function(t){n.enableZoom&&H(t),n.enableRotate&&V(t)})(t),i=s.TOUCH_DOLLY_ROTATE;break;default:i=s.NONE}break;default:i=s.NONE}i!==s.NONE&&n.dispatchEvent(po)}function rt(t){!1!==n.enabled&&t.preventDefault()}function at(t){let e=k[t.pointerId];void 0===e&&(e=new et,k[t.pointerId]=e),e.set(t.pageX,t.pageY)}function ot(t){const e=t.pointerId===v[0]?v[1]:v[0];return k[e]}n.domElement.addEventListener("contextmenu",rt),n.domElement.addEventListener("pointerdown",J),n.domElement.addEventListener("pointercancel",K),n.domElement.addEventListener("wheel",Q,{passive:!1}),n.domElement.getRootNode().addEventListener("keydown",tt,{passive:!0,capture:!0}),this.update()}}function xo(t){const e=nr([t.scene]),n=Qi("cpu"),s=new Xi(e.geometry,{indirect:!0}),i=Zi(s)[0].depth.max;console.log(s);const{boundsArray:r,contentsArray:a}=function(t){if(!function(t){return"_roots"in t}(t))throw new no("MeshBVH internal structure does not match, this indicates a change in the library which is not supported.");const e=t._roots;if(1!==e.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const n=e[0],s=new Uint16Array(n),i=new Uint32Array(n),r=new Float32Array(n),a=n.byteLength/so,o=2*Math.ceil(Math.sqrt(a/2)),l=new Float32Array(4*o*o),h=Math.ceil(Math.sqrt(a)),u=new Uint32Array(2*h*h);for(let c=0;c{}),signal:c=(new AbortController).signal}=void 0===n?{}:n;var d;const p={isRunning:!0,abortNotifiers:new Map};if(c.aborted)throw new to;c.addEventListener("abort",(()=>{p.isRunning=!1;for(const[,t]of p.abortNotifiers)t();p.abortNotifiers.clear()}));const m=s,f=Qi("init"),{indirectBuffer:y,boundsArray:g,contentsArray:_,positions:x,normals:b,maxBvhDepth:w,modelGroups:v,modelMaterials:k,meshIndices:M,bvhBuildTime:S}=xo(e),T=document.getElementById(t);if(!(T instanceof HTMLCanvasElement))throw new Qa;if(!navigator.gpu)throw new Ka("navigator.gpu is not available, most likely due to browser");const A=await navigator.gpu.requestAdapter();if(!A)throw new Ka("No suitable WebGPU adapter available");const E=await A.requestDevice({requiredFeatures:["timestamp-query"]});var R,B;R="device",B=()=>{E.destroy()},p.abortNotifiers.set(R,B);const z=E.createQuerySet({type:"timestamp",count:2}),P=E.createBuffer({size:8*z.count,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE}),L=E.createBuffer({size:P.size,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),I=T.getContext("webgpu");if(!I)throw new Ka("No WebGPU context available");const C=navigator.gpu.getPreferredCanvasFormat();I.configure({device:E,format:C});const D=i,N=i,F=function(t){return Object.entries($i).reduce(((e,n)=>{let[s,i]=n;return e.replaceAll(`\${${i}}`,`${t[s]}`)}),Ji)}({imageWidth:N,imageHeight:N,maxWorkgroupDimension:16,maxBvhStackDepth:w}),O=new Uint8Array(i*D*4),W=E.createTexture({size:[i,D],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING});E.queue.writeTexture({texture:W},O,{bytesPerRow:4*i},{width:i,height:D});const U=E.createTexture({size:[i,D],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING});E.queue.writeTexture({texture:U},O,{bytesPerRow:4*i},{width:i,height:D});const q=E.createSampler(),j=E.createShaderModule({label:"Render Shader",code:Ki}),V=E.createBindGroupLayout({label:"Texture sampler bind group layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]}),G=E.createPipelineLayout({label:"Pipeline Layout",bindGroupLayouts:[V]}),H=E.createRenderPipeline({label:"Render pipeline",layout:G,vertex:{module:j,entryPoint:"vertexMain",buffers:[]},fragment:{module:j,entryPoint:"fragmentMain",targets:[{format:C}]}}),Y=e.scene.matrixWorld,X=function(t){return!uo(t.camera)}(r);let Z;Z=X?r:function(t,e){const n=new Jt;n.fromArray(t.matrixWorldContent);const s=new ln(t.fov,1,.01,1e3),i=new _o(s,e);s.applyMatrix4(n),console.log(s.position);const r=new wt;s.getWorldDirection(r);const a=s.position.clone().addScaledVector(r,t.cameraTargetDistance);return i.target.copy(a),i.update(),{camera:s,controls:i}}(r,T);const J=E.createBuffer({label:"Position buffer",size:Float32Array.BYTES_PER_ELEMENT*x.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),$=J.getMappedRange();new Float32Array($).set(x),J.unmap();const K=new Uint32Array(M),Q=E.createBuffer({label:"Index buffer",size:Uint32Array.BYTES_PER_ELEMENT*K.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),tt=Q.getMappedRange();new Uint32Array(tt).set(K),Q.unmap();const et=E.createBuffer({label:"Normal buffer",size:Float32Array.BYTES_PER_ELEMENT*b.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),nt=et.getMappedRange();new Float32Array(nt).set(b),et.unmap();const st=E.createBuffer({label:"BVH bounds buffer",size:Float32Array.BYTES_PER_ELEMENT*g.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),it=st.getMappedRange();new Float32Array(it).set(g),st.unmap();const rt=E.createBuffer({label:"BVH contents buffer",size:Uint32Array.BYTES_PER_ELEMENT*_.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),at=rt.getMappedRange();new Uint32Array(at).set(_),rt.unmap();const ot=E.createBuffer({label:"BVH indirect buffer",size:Uint32Array.BYTES_PER_ELEMENT*y.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),lt=ot.getMappedRange();new Uint32Array(lt).set(y),ot.unmap();const ht=3*Uint32Array.BYTES_PER_ELEMENT,ut=v,ct=E.createBuffer({label:"Object definitions buffer",size:ht*ut.length,usage:GPUBufferUsage.STORAGE,mappedAtCreation:!0}),dt=ct.getMappedRange();new Uint32Array(dt).set(ut.map((t=>[t.start,t.count,t.materialIndex])).flat(1)),ct.unmap();const pt=k,mt=function(t){const e=new Wa(t),n=Object.fromEntries(e.structs.map((t=>[t.name,qa(e,t,0)]))),s=Ua(e,e.uniforms),i=Ua(e,e.storage.filter((t=>t.resourceType===pr.Storage))),r=Ua(e,e.storage.filter((t=>t.resourceType===pr.StorageTexture))),a=Ua(e,e.textures.filter((t=>"texture_external"!==t.type.name)));return{externalTextures:Ua(e,e.textures.filter((t=>"texture_external"===t.type.name))),samplers:Ua(e,e.samplers),structs:n,storages:i,storageTextures:r,textures:a,uniforms:s,entryPoints:{...Xa(e.entry.vertex,GPUShaderStage.VERTEX),...Xa(e.entry.fragment,GPUShaderStage.FRAGMENT),...Xa(e.entry.compute,GPUShaderStage.COMPUTE)}}}(F),{size:ft}=function(t){const e=t;return xr(void 0===e.group?t:e.typeDefinition)}(mt.storages.materials),yt=gr(mt.storages.materials,new ArrayBuffer(ft*pt.length)),gt=E.createBuffer({label:"Material buffer",size:ft*pt.length,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});yt.set(pt.map((t=>{if(!(t instanceof bn))throw new eo(t);return{baseWeight:t.oBaseWeight,baseColor:t.oBaseColor,baseDiffuseRoughness:t.oBaseDiffuseRoughness,baseMetalness:t.oBaseMetalness,specularWeight:t.oSpecularWeight,specularColor:t.oSpecularColor,specularRoughness:t.oSpecularRoughness,specularAnisotropy:t.oSpecularRoughnessAnisotropy,specularIor:t.oSpecularIOR,coatWeight:t.oCoatWeight,coatColor:t.oCoatColor,coatRoughness:t.oCoatRoughness,coatRoughnessAnisotropy:t.oCoatRoughnessAnisotropy,coatIor:t.oCoatIor,coatDarkening:t.oCoatDarkening,emissionLuminance:t.oEmissionLuminance,emissionColor:t.oEmissionColor,thinFilmThickness:t.oThinFilmThickness,thinFilmIOR:t.oThinFilmIOR}}))),E.queue.writeBuffer(gt,0,yt.arrayBuffer);const _t=E.createBindGroupLayout({label:"Static compute bind group layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:3,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:4,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:5,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:6,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:7,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}}]}),xt=E.createBindGroupLayout({label:"Dynamic compute bind group layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,storageTexture:{format:"rgba8unorm"}},{binding:1,visibility:GPUShaderStage.COMPUTE,storageTexture:{format:"rgba8unorm",access:"read-only"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}]}),bt=E.createPipelineLayout({label:"Compute pipeline layout",bindGroupLayouts:[_t,xt]}),vt=Math.ceil(N*N/256),kt=E.createShaderModule({label:"Ray Tracing Compute Shader",code:F}),Mt=E.createBindGroup({label:"Static compute bind group",layout:_t,entries:[{binding:0,resource:{buffer:J}},{binding:1,resource:{buffer:Q}},{binding:2,resource:{buffer:st}},{binding:3,resource:{buffer:rt}},{binding:4,resource:{buffer:et}},{binding:5,resource:{buffer:ot}},{binding:6,resource:{buffer:ct}},{binding:7,resource:{buffer:gt}}]}),St=function(t){const{latitude:e,longitude:n}=t,s=(90-e)*Math.PI/180,i=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return[a*Math.cos(i),r,a*Math.sin(i)]}(a.sun);f.end();const Tt=Qi("render loop full"),At=()=>{let t="running";let e=null,n=0,s=0,i=[];const r=async()=>{console.log(Z.camera.matrixWorld);const c=Z.camera.matrixWorld,d=Z.camera.projectionMatrixInverse,f=Qi("render"),y=n%2==0?W:U,g=n%2==0?U:W,{size:_}=mt.uniforms.uniformData,x=gr(mt.uniforms.uniformData,new ArrayBuffer(_)),b=E.createBuffer({label:"Uniform data buffer",size:_,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});x.set({invProjectionMatrix:d.elements,cameraWorldMatrix:c.elements,invModelMatrix:Y.clone().invert().elements,seedOffset:Math.random()*Number.MAX_SAFE_INTEGER,priorSamples:n,samplesPerPixel:o,sunDirection:St,skyPower:a.sky.power,skyColor:a.sky.color,sunPower:Math.pow(10,a.sun.power),sunAngularSize:a.sun.angularSize,sunColor:a.sun.color,clearColor:l,enableClearColor:uo(l)?0:1,maxRayDepth:h,objectDefinitionLength:ut.length}),E.queue.writeBuffer(b,0,x.arrayBuffer);const w=E.createBindGroup({label:"Dynamic compute bind group",layout:xt,entries:[{binding:0,resource:y.createView()},{binding:1,resource:g.createView()},{binding:2,resource:{buffer:b}}]}),v=E.createComputePipeline({label:"Ray Tracing Compute pipeline",layout:bt,compute:{module:kt,entryPoint:"computeMain"}}),k=E.createCommandEncoder(),M=k.beginComputePass({timestampWrites:{querySet:z,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}});M.setBindGroup(0,Mt),M.setBindGroup(1,w),M.setPipeline(v),M.dispatchWorkgroups(Math.sqrt(vt),Math.sqrt(vt)),M.end(),k.resolveQuerySet(z,0,2,P,0),"unmapped"===L.mapState&&k.copyBufferToBuffer(P,0,L,0,P.size);const T=k.beginRenderPass({colorAttachments:[{view:I.getCurrentTexture().createView(),loadOp:"clear",clearValue:{r:0,g:0,b:.2,a:1},storeOp:"store"}]});T.setPipeline(H);const A=E.createBindGroup({label:"Texture sampler bind group",layout:V,entries:[{binding:0,resource:q},{binding:1,resource:W.createView()}]});T.setBindGroup(0,A),T.draw(6),T.end();const R=k.finish();if(E.queue.submit([R]),"unmapped"===L.mapState){try{await L.mapAsync(GPUMapMode.READ)}catch(C){if(!p.isRunning)return void console.warn("Aborted render loop");throw C}const t=new BigUint64Array(L.getMappedRange()),e=t[1]-t[0];console.log(`GPU Time: ${e}ns`),L.unmap()}const B=f.end();if(i.push(B),s+=B,n{t="halted",null!==e&&cancelAnimationFrame(e)}}};let Et=At();null==(d=Z.controls)||d.addEventListener("change",(()=>{Et.terminateLoop(),Et=At()}))}const wo={container:"container_nBh_",wrapper:"wrapper_q6N5",heroTitle:"heroTitle__SVE",hero:"hero_GiET",lead:"lead_SBUB",text:"text_R33k"},vo=bn;async function ko(t){const e=new w.B;const n=new vo;n.oBaseColor=[0,.9,1];const s=new vo;s.oBaseColor=[.9,.7,.23],s.oSpecularWeight=.01;const i=new vo;i.oBaseColor=[.4,.6,.33];const r=new vo;r.oBaseColor=[.67,.18,.12],r.oSpecularColor=[1,1,.9],r.oSpecularWeight=.2;const a=new vo;a.oBaseColor=[.9,.9,.9],a.oBaseMetalness=1;const o=new vo;o.oBaseColor=[.9,.9,.9],o.oBaseMetalness=1,o.oBaseDiffuseRoughness=.5;const l=new vo;l.oBaseColor=[.9,.9,.9];const h=new vo;h.oBaseColor=[.9,.9,.9],h.oSpecularWeight=0,l.oBaseMetalness=1;const u=new vo;u.oBaseColor=[.4,.4,.4],u.oBaseMetalness=.4,u.oSpecularWeight=.2;const c=new vo;c.oBaseColor=[.9,.6,.4],c.oBaseMetalness=1;const d=new vo;d.oBaseColor=[.25,.25,.25],d.oSpecularWeight=1;const p=new vo;p.oBaseColor=[.8,.8,.8];const m=new vo;m.oBaseColor=[.5,.5,.5],m.oSpecularWeight=0;const f=new vo;f.oBaseColor=[.9,.8,.7],f.oBaseMetalness=0,f.oBaseDiffuseRoughness=0;const y={material_name_kunststoff_gelbFCBE37_rau_2_mtl:s,material_name_kunststoff_gelbFCBE37_rau_3_mtl:s,material_name_kunststoff_verkehrsrotB81D12_rau_5_mtl:r,material_name_kunststoff_gruen9CC289_glanz_SSS_0_mtl:i,material_name_kunststoff_schwarz141414_rau_1_mtl:d,material_name_metall_stahl67686A_abgenutzt_7_mtl:o,material_name_kunststoff_weissDCDCDC_rau_6_mtl:p,material_name_kunststoff_schwarz000000_rau_0_mtl:d,material_name_kunststoff_schwarz000000_rau_31_mtl:d,material_name_metall_stahl67686A_abgenutzt_32_mtl:h,material_name_kunststoff_verkehrsrotB81D12_rau_33_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_34_mtl:p,material_name_kunststoff_verkehrsrotB81D12_rau_2_mtl:r,material_name_kunststoff_verkehrsrotB81D12_rau_3_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_4_mtl:p,material_name_kunststoff_gelbFCBE37_rau_5_mtl:s,material_name_kunststoff_schwarz000000_rau_6_mtl:d,material_name_kunststoff_gruen006054_rau_7_mtl:i,material_name_metall_stahl737364_abgenutzt_rau_8_mtl:o,material_name_metall_stahl909086_abgenutzt_rauer_9_mtl:o,material_name_kunststoff_weissDCDCDC_transparent_trueb_10_mtl:p,material_name_kunststoff_schwarz000000_rau_11_mtl:d,material_name_metall_stahl67686A_abgenutzt_12_mtl:l,material_name_kunststoff_verkehrsrotB81D12_rau_13_mtl:r,material_name_kunststoff_weissDCDCDC_transparent_trueb_14_mtl:p,material_name_kunststoff_schwarz000000_rau_15_mtl:d,material_name_kunststoff_schwarz000000_rau_16_mtl:d,material_name_metall_stahl67686A_abgenutzt_17_mtl:l,material_name_kunststoff_weissDCDCDC_transparent_trueb_18_mtl:p};!async function(){const s=await async function(t){return new Promise(((n,s)=>{e.load(t,n,void 0,s)}))}("https://stuckisimon.github.io/strahl-sample-models/45-series/45-series-cleaned.gltf");s.scene.traverseVisible((t=>{if(void 0===t.material)return;const e=t.material.name;e in y?t.material=y[e]:(console.log(e),t.material=n)})),t.aborted||await bo("render-target",s,{targetSamples:100,signal:t})}()}function Mo(){const t=_.useRef(!1);return _.useEffect((()=>{const e=new AbortController,n=e.signal;return t.current||(t.current=!0,ko(n)),()=>{e.abort()}}),[]),(0,l.jsx)("div",{className:wo.container,children:(0,l.jsxs)("div",{className:"container",children:[(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("div",{className:(0,s.A)("col",wo.hero),children:[(0,l.jsx)("p",{className:wo.lead,children:"Demo"}),(0,l.jsx)(a.A,{as:"h2",className:wo.heroTitle,children:"Show me"})]})}),(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:(0,s.A)("col",wo.wrapper),children:(0,l.jsx)("canvas",{width:"512",height:"512",id:"render-target"})})}),(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:"col",children:(0,l.jsx)("p",{className:wo.text,children:"Make sure your browser supports WebGPU."})})})]})})}const So={container:"container_UWvi",ray:"ray_OIi6","position-animation":"position-animation_AFLE","pulsate-animation":"pulsate-animation_nwAU"};function To(){return(0,l.jsxs)("div",{className:So.container,children:[(0,l.jsx)("span",{className:So.ray}),(0,l.jsx)("span",{className:So.ray}),(0,l.jsx)("span",{className:So.ray})]})}function Ao(){const{siteConfig:t}=(0,i.A)(),e=["fast","efficient","powerful","beautiful","simple","open-source","understandable","accessible"],n=_.useRef(null),r=_.useRef({currentText:e[0],currentTextIndex:0}),o=b(n);return _.useEffect((()=>o(e,r.current)),[]),(0,l.jsxs)("header",{className:(0,s.A)("hero",p.heroBanner),children:[(0,l.jsxs)("div",{className:"container",children:[(0,l.jsxs)(a.A,{as:"h1",className:p.heroTitle,children:["Path Tracing ",(0,l.jsx)("span",{className:p.heroMark,children:"made"})]}),(0,l.jsxs)("div",{className:p.typewriterContainer,children:[(0,l.jsx)("p",{className:(0,s.A)("hero__subtitle",p.heroTypewriter),ref:n,children:"\xa0"}),(0,l.jsx)("div",{className:p.cursorContainer,children:(0,l.jsx)("div",{className:p.cursor})})]}),(0,l.jsx)("p",{className:(0,s.A)("hero__subtitle",p.heroText),children:"strahl is an open-source path tracing library built using WebGPU."}),(0,l.jsxs)("div",{className:p.buttons,children:[(0,l.jsx)(g,{to:"/docs/intro",children:"Get Started"}),(0,l.jsx)(g,{to:"https://github.com/StuckiSimon/strahl",icon:d.Vz1,variant:"secondary",children:"Github"})]})]}),(0,l.jsx)(To,{})]})}function Eo(){const{siteConfig:t}=(0,i.A)();return(0,l.jsxs)(r.A,{title:"strahl",description:"strahl \u2013 path tracing library using WebGPU and OpenPBR",children:[(0,l.jsx)(Ao,{}),(0,l.jsxs)("main",{children:[(0,l.jsx)(c,{}),(0,l.jsx)(Mo,{})]})]})}}}]); \ No newline at end of file diff --git a/assets/js/1df93b7f.487614cf.js.LICENSE.txt b/assets/js/1df93b7f.2fc294ab.js.LICENSE.txt similarity index 100% rename from assets/js/1df93b7f.487614cf.js.LICENSE.txt rename to assets/js/1df93b7f.2fc294ab.js.LICENSE.txt diff --git a/assets/js/45d3dc74.92480abd.js b/assets/js/45d3dc74.92480abd.js new file mode 100644 index 0000000..832fcec --- /dev/null +++ b/assets/js/45d3dc74.92480abd.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[787],{1875:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>p,frontMatter:()=>i,metadata:()=>s,toc:()=>d});var r=t(4848),o=t(8453);const i={},a="Exception Handling",s={id:"advanced/exception-handling",title:"Exception Handling",description:"strahl provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets ([ExceptionName] \u2026).",source:"@site/docs/advanced/exception-handling.md",sourceDirName:"advanced",slug:"/advanced/exception-handling",permalink:"/strahl/docs/advanced/exception-handling",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Environment Light",permalink:"/strahl/docs/advanced/environment-light"},next:{title:"Theory",permalink:"/strahl/docs/advanced/theory"}},c={},d=[{value:"WebGPUNotSupportedError",id:"webgpunotsupportederror",level:2},{value:"InternalError",id:"internalerror",level:2}];function l(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",p:"p",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"exception-handling",children:"Exception Handling"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"strahl"})," provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets (",(0,r.jsx)(n.code,{children:"[ExceptionName] \u2026"}),")."]}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["Certain exceptions have more detailed information attached as properties, use ",(0,r.jsx)(n.code,{children:'console.error("%O", e);'})," to log the exception object in full detail."]})}),"\n",(0,r.jsx)(n.h2,{id:"webgpunotsupportederror",children:(0,r.jsx)(n.code,{children:"WebGPUNotSupportedError"})}),"\n",(0,r.jsxs)(n.p,{children:["WebGPU adapter could not be initialized. This is usually due to a lack of support in the current environment. See ",(0,r.jsx)(n.a,{href:"/strahl/docs/intro#browser-support",children:"Intro"})," for information about browser support and how to check this."]}),"\n",(0,r.jsx)(n.h2,{id:"internalerror",children:(0,r.jsx)(n.code,{children:"InternalError"})}),"\n",(0,r.jsxs)(n.p,{children:["An error within ",(0,r.jsx)(n.code,{children:"strahl"})," has occurred, please reach out with a detailed error report with a reproduction of the issue. These are generally non-recoverable."]})]})}function p(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>s});var r=t(6540);const o={},i=r.createContext(o);function a(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/45d3dc74.ed6dbd05.js b/assets/js/45d3dc74.ed6dbd05.js deleted file mode 100644 index df125e9..0000000 --- a/assets/js/45d3dc74.ed6dbd05.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[787],{1875:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>p,frontMatter:()=>i,metadata:()=>s,toc:()=>d});var r=t(4848),o=t(8453);const i={},a="Exception Handling",s={id:"advanced/exception-handling",title:"Exception Handling",description:"strahl provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets ([ExceptionName] \u2026).",source:"@site/docs/advanced/exception-handling.md",sourceDirName:"advanced",slug:"/advanced/exception-handling",permalink:"/strahl/docs/advanced/exception-handling",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Destruction",permalink:"/strahl/docs/advanced/destruction"},next:{title:"Theory",permalink:"/strahl/docs/advanced/theory"}},c={},d=[{value:"WebGPUNotSupportedError",id:"webgpunotsupportederror",level:2},{value:"InternalError",id:"internalerror",level:2}];function l(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",p:"p",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"exception-handling",children:"Exception Handling"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"strahl"})," provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets (",(0,r.jsx)(n.code,{children:"[ExceptionName] \u2026"}),")."]}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["Certain exceptions have more detailed information attached as properties, use ",(0,r.jsx)(n.code,{children:'console.error("%O", e);'})," to log the exception object in full detail."]})}),"\n",(0,r.jsx)(n.h2,{id:"webgpunotsupportederror",children:(0,r.jsx)(n.code,{children:"WebGPUNotSupportedError"})}),"\n",(0,r.jsxs)(n.p,{children:["WebGPU adapter could not be initialized. This is usually due to a lack of support in the current environment. See ",(0,r.jsx)(n.a,{href:"/strahl/docs/intro#browser-support",children:"Intro"})," for information about browser support and how to check this."]}),"\n",(0,r.jsx)(n.h2,{id:"internalerror",children:(0,r.jsx)(n.code,{children:"InternalError"})}),"\n",(0,r.jsxs)(n.p,{children:["An error within ",(0,r.jsx)(n.code,{children:"strahl"})," has occurred, please reach out with a detailed error report with a reproduction of the issue. These are generally non-recoverable."]})]})}function p(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>s});var r=t(6540);const o={},i=r.createContext(o);function a(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4ad98c9f.eca53698.js b/assets/js/4ad98c9f.eca53698.js new file mode 100644 index 0000000..7acc84d --- /dev/null +++ b/assets/js/4ad98c9f.eca53698.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[665],{8615:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>r,default:()=>h,frontMatter:()=>s,metadata:()=>l,toc:()=>d});var a=t(4848),i=t(8453);const s={sidebar_position:2},r="Getting Started",l={id:"tutorial-basic",title:"Getting Started",description:"This is a minimal guide on how to setup strahl in 5 minutes.",source:"@site/docs/tutorial-basic.md",sourceDirName:".",slug:"/tutorial-basic",permalink:"/strahl/docs/tutorial-basic",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2},sidebar:"tutorialSidebar",previous:{title:"strahl Documentation",permalink:"/strahl/docs/intro"},next:{title:"Advanced",permalink:"/strahl/docs/category/advanced"}},o={},d=[{value:"Installation",id:"installation",level:2},{value:"Setup",id:"setup",level:2},{value:"Define canvas",id:"define-canvas",level:3},{value:"Prepare 3D data",id:"prepare-3d-data",level:3},{value:"Initialize strahl",id:"initialize-strahl",level:3},{value:"Help me! It doesn't work",id:"help-me-it-doesnt-work",level:3},{value:"What's next?",id:"whats-next",level:3}];function c(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.h1,{id:"getting-started",children:"Getting Started"}),"\n",(0,a.jsxs)(n.p,{children:["This is a minimal guide on how to setup ",(0,a.jsx)(n.code,{children:"strahl"})," in 5 minutes."]}),"\n",(0,a.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsx)(n.p,{children:"The library is available in the npm registry. To install it using npm, run:"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"npm install --save strahl\n"})}),"\n",(0,a.jsx)(n.h2,{id:"setup",children:"Setup"}),"\n",(0,a.jsx)(n.h3,{id:"define-canvas",children:"Define canvas"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-html",metastring:'title="index.html"',children:'\n\n \n \n \n \n \n \n \n\n'})}),"\n",(0,a.jsx)(n.admonition,{type:"warning",children:(0,a.jsxs)(n.p,{children:["Make sure that the ",(0,a.jsx)(n.code,{children:"canvas"})," is present in the ",(0,a.jsx)(n.code,{children:"DOM"})," before calling ",(0,a.jsx)(n.code,{children:"strahl"}),"."]})}),"\n",(0,a.jsx)(n.h3,{id:"prepare-3d-data",children:"Prepare 3D data"}),"\n",(0,a.jsxs)(n.p,{children:["Load 3D models using ",(0,a.jsx)(n.code,{children:"three"})," loaders."]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-js",metastring:'title="loadModel.js"',children:'import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";\n\nconst gltfLoader = new GLTFLoader();\n\nasync function loadGltf(url) {\n return new Promise((resolve, reject) => {\n gltfLoader.load(url, resolve, undefined, reject);\n });\n}\n\nconst model = await loadGltf(MODEL_URL);\n'})}),"\n",(0,a.jsx)(n.admonition,{type:"tip",children:(0,a.jsxs)(n.p,{children:["If you don't have a model at hand, take \"",(0,a.jsx)(n.a,{href:"https://stuckisimon.github.io/strahl-sample-models/45-series/45-series-cleaned.gltf",children:"https://stuckisimon.github.io/strahl-sample-models/45-series/45-series-cleaned.gltf"}),'". Please adhere to licenses associated with the model as described in ',(0,a.jsx)(n.a,{href:"https://stuckisimon.github.io/strahl-sample-models/",children:"Sample Models"})]})}),"\n",(0,a.jsxs)(n.p,{children:["Make sure to assign ",(0,a.jsx)(n.code,{children:"OpenPBRMaterial"})," to all materials within the scene."]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-js",metastring:'title="materialMapper.js"',children:"const MATERIAL_MAP = {\n 'name': new OpenPBRMaterial()\n}\n\nmodel.scene.traverseVisible((object: any) => {\n if (object.material === undefined) {\n return;\n }\n const materialName = object.material.name;\n if (materialName in MATERIAL_MAP) {\n object.material =\n MATERIAL_MAP[materialName as keyof typeof MATERIAL_MAP];\n } else {\n console.log('unknown material', materialName);\n object.material = defaultBlueMaterial;\n }\n});\n"})}),"\n",(0,a.jsx)(n.p,{children:"That's it! Now you're ready to start path tracing."}),"\n",(0,a.jsxs)(n.h3,{id:"initialize-strahl",children:["Initialize ",(0,a.jsx)(n.code,{children:"strahl"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-js",children:'await runPathTracer("render-target", model);\n'})}),"\n",(0,a.jsx)(n.admonition,{type:"info",children:(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.code,{children:"runPathTracer"})," accepts a third parameter for additional configuration. See the advanced guides for more information."]})}),"\n",(0,a.jsx)(n.p,{children:"Et voil\xe0! You should now see the path tracer rendering the scene."}),"\n",(0,a.jsx)(n.h3,{id:"help-me-it-doesnt-work",children:"Help me! It doesn't work"}),"\n",(0,a.jsx)(n.p,{children:"Feel free to reach out, happy to help you out and potentially improve guidance or fix bugs."}),"\n",(0,a.jsx)(n.h3,{id:"whats-next",children:"What's next?"}),"\n",(0,a.jsxs)(n.p,{children:["Check out the ",(0,a.jsx)(n.a,{href:"/docs/category/advanced",children:"advanced guides"})," for more information on how to configure the path tracer."]})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>l});var a=t(6540);const i={},s=a.createContext(i);function r(e){const n=a.useContext(s);return a.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),a.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4c15fca4.1ed6b0ad.js b/assets/js/4c15fca4.1ed6b0ad.js new file mode 100644 index 0000000..f23a7d0 --- /dev/null +++ b/assets/js/4c15fca4.1ed6b0ad.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[584],{8900:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>a,toc:()=>d});var r=n(4848),o=n(8453);const s={},i="Destruction",a={id:"advanced/destruction",title:"Destruction",description:"strahl sets up all required data structures for you, but by default it won't clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered.",source:"@site/docs/advanced/destruction.md",sourceDirName:"advanced",slug:"/advanced/destruction",permalink:"/strahl/docs/advanced/destruction",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Advanced",permalink:"/strahl/docs/category/advanced"},next:{title:"Environment Light",permalink:"/strahl/docs/advanced/environment-light"}},l={},d=[{value:"AbortSignal",id:"abortsignal",level:2},{value:"Usage in strahl",id:"usage-in-strahl",level:2},{value:"Invoke Destruction",id:"invoke-destruction",level:2},{value:"API Design Consideration",id:"api-design-consideration",level:2}];function c(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"destruction",children:"Destruction"}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"strahl"})," sets up all required data structures for you, but by default it won't clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered."]}),"\n",(0,r.jsx)(t.admonition,{type:"warning",children:(0,r.jsx)(t.p,{children:"Make sure to not start path tracing with an already aborted signal."})}),"\n",(0,r.jsx)(t.h2,{id:"abortsignal",children:"AbortSignal"}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"AbortSignal"})," is a relatively new web API supported by all major browsers. It allows for the abortion of an operation. For details on the API, please refer to ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/AbortController",children:"AbortController on developer.mozilla.org"}),"."]}),"\n",(0,r.jsxs)(t.h2,{id:"usage-in-strahl",children:["Usage in ",(0,r.jsx)(t.code,{children:"strahl"})]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",metastring:'title="strahlConfiguration.js"',children:"const destroyController = new AbortController();\nconst signal = destroyController.signal;\n\nrunPathTracer(target, model, {\n signal,\n});\n"})}),"\n",(0,r.jsx)(t.h2,{id:"invoke-destruction",children:"Invoke Destruction"}),"\n",(0,r.jsxs)(t.p,{children:["In order to cancel ",(0,r.jsx)(t.code,{children:"strahl"}),", invoke it as:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",children:"destroyController.abort();\n"})}),"\n",(0,r.jsx)(t.admonition,{type:"warning",children:(0,r.jsx)(t.p,{children:"This action is irreversible, you need to setup a new instance when doing a new rendering."})}),"\n",(0,r.jsx)(t.h2,{id:"api-design-consideration",children:"API Design Consideration"}),"\n",(0,r.jsx)(t.p,{children:"While it is more frequent to use a return type to cancel operations, signals have the unique advantage of being usable at all stages of the tracer."})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>a});var r=n(6540);const o={},s=r.createContext(o);function i(e){const t=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4c15fca4.328bf988.js b/assets/js/4c15fca4.328bf988.js deleted file mode 100644 index b6904cc..0000000 --- a/assets/js/4c15fca4.328bf988.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[584],{8900:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>a,toc:()=>d});var r=n(4848),o=n(8453);const s={},i="Destruction",a={id:"advanced/destruction",title:"Destruction",description:"strahl sets up all required data structures for you, but by default it won't clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered.",source:"@site/docs/advanced/destruction.md",sourceDirName:"advanced",slug:"/advanced/destruction",permalink:"/strahl/docs/advanced/destruction",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Advanced",permalink:"/strahl/docs/category/advanced"},next:{title:"Exception Handling",permalink:"/strahl/docs/advanced/exception-handling"}},l={},d=[{value:"AbortSignal",id:"abortsignal",level:2},{value:"Usage in strahl",id:"usage-in-strahl",level:2},{value:"Invoke Destruction",id:"invoke-destruction",level:2}];function c(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"destruction",children:"Destruction"}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"strahl"})," sets up all required data structures for you, but by default it won't clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered."]}),"\n",(0,r.jsx)(t.admonition,{type:"warning",children:(0,r.jsx)(t.p,{children:"Make sure to not start path tracing with an already aborted signal."})}),"\n",(0,r.jsx)(t.h2,{id:"abortsignal",children:"AbortSignal"}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"AbortSignal"})," is a relatively new web API supported by all major browsers. It allows for the abortion of an operation. For details on the API, please refer to ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/AbortController",children:"AbortController on developer.mozilla.org"}),"."]}),"\n",(0,r.jsxs)(t.h2,{id:"usage-in-strahl",children:["Usage in ",(0,r.jsx)(t.code,{children:"strahl"})]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",metastring:'title="strahlConfiguration.js"',children:"const destroyController = new AbortController();\nconst signal = destroyController.signal;\n\nrunPathTracer(target, model, {\n signal,\n});\n"})}),"\n",(0,r.jsx)(t.h2,{id:"invoke-destruction",children:"Invoke Destruction"}),"\n",(0,r.jsxs)(t.p,{children:["In order to cancel ",(0,r.jsx)(t.code,{children:"strahl"}),", invoke it as:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",children:"destroyController.abort();\n"})}),"\n",(0,r.jsx)(t.admonition,{type:"warning",children:(0,r.jsx)(t.p,{children:"This action is irreversible, you need to setup a new instance when doing a new rendering."})})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>a});var r=n(6540);const o={},s=r.createContext(o);function i(e){const t=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4d780be7.5b134119.js b/assets/js/4d780be7.5b134119.js new file mode 100644 index 0000000..65970fa --- /dev/null +++ b/assets/js/4d780be7.5b134119.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[236],{8117:e=>{e.exports=JSON.parse('{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","label":"strahl Documentation","href":"/strahl/docs/intro","docId":"intro","unlisted":false},{"type":"link","label":"Getting Started","href":"/strahl/docs/tutorial-basic","docId":"tutorial-basic","unlisted":false},{"type":"category","label":"Advanced","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Destruction","href":"/strahl/docs/advanced/destruction","docId":"advanced/destruction","unlisted":false},{"type":"link","label":"Environment Light","href":"/strahl/docs/advanced/environment-light","docId":"advanced/environment-light","unlisted":false},{"type":"link","label":"Exception Handling","href":"/strahl/docs/advanced/exception-handling","docId":"advanced/exception-handling","unlisted":false},{"type":"link","label":"Theory","href":"/strahl/docs/advanced/theory","docId":"advanced/theory","unlisted":false},{"type":"link","label":"View Projection","href":"/strahl/docs/advanced/view-projection","docId":"advanced/view-projection","unlisted":false}],"href":"/strahl/docs/category/advanced"}]},"docs":{"advanced/destruction":{"id":"advanced/destruction","title":"Destruction","description":"strahl sets up all required data structures for you, but by default it won\'t clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered.","sidebar":"tutorialSidebar"},"advanced/environment-light":{"id":"advanced/environment-light","title":"Environment Light","description":"Environment light is defined as the contribution of sky and sun. Sky settings are direction independent and are akin to AmbientLight. Sun is direction-dependent.","sidebar":"tutorialSidebar"},"advanced/exception-handling":{"id":"advanced/exception-handling","title":"Exception Handling","description":"strahl provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets ([ExceptionName] \u2026).","sidebar":"tutorialSidebar"},"advanced/theory":{"id":"advanced/theory","title":"Theory","description":"strahl was written as part of a master thesis. Therefore, a detailed report is available. If you\'re unsure about whether this is interesting to you, there is a short-paper which gives a brief introduction into the topic available on arXiv.","sidebar":"tutorialSidebar"},"advanced/view-projection":{"id":"advanced/view-projection","title":"View Projection","description":"View projection is about setting up the virtual camera and getting the right shot. To date, strahl only supports perspective view projection as encountered in real life.","sidebar":"tutorialSidebar"},"intro":{"id":"intro","title":"strahl Documentation","description":"The tutorial is not yet finished and will be following in the upcoming weeks.","sidebar":"tutorialSidebar"},"tutorial-basic":{"id":"tutorial-basic","title":"Getting Started","description":"This is a minimal guide on how to setup strahl in 5 minutes.","sidebar":"tutorialSidebar"}}}}')}}]); \ No newline at end of file diff --git a/assets/js/4d780be7.79413078.js b/assets/js/4d780be7.79413078.js deleted file mode 100644 index 371f018..0000000 --- a/assets/js/4d780be7.79413078.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[236],{8117:e=>{e.exports=JSON.parse('{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","label":"strahl Documentation","href":"/strahl/docs/intro","docId":"intro","unlisted":false},{"type":"link","label":"Getting Started","href":"/strahl/docs/tutorial-basic","docId":"tutorial-basic","unlisted":false},{"type":"category","label":"Advanced","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Destruction","href":"/strahl/docs/advanced/destruction","docId":"advanced/destruction","unlisted":false},{"type":"link","label":"Exception Handling","href":"/strahl/docs/advanced/exception-handling","docId":"advanced/exception-handling","unlisted":false},{"type":"link","label":"Theory","href":"/strahl/docs/advanced/theory","docId":"advanced/theory","unlisted":false},{"type":"link","label":"View Projection","href":"/strahl/docs/advanced/view-projection","docId":"advanced/view-projection","unlisted":false}],"href":"/strahl/docs/category/advanced"}]},"docs":{"advanced/destruction":{"id":"advanced/destruction","title":"Destruction","description":"strahl sets up all required data structures for you, but by default it won\'t clean them up. This can lead to a memory leak. Therefore, it should always be destroyed after it has finished processing or the page is becoming idle. Note that this will not destroy the canvas, therefore it is fine to do even if the scene is still rendered.","sidebar":"tutorialSidebar"},"advanced/exception-handling":{"id":"advanced/exception-handling","title":"Exception Handling","description":"strahl provides parseable exceptions to help debugging failures in the program. For ease-of-use, the name of the exception is written in brackets ([ExceptionName] \u2026).","sidebar":"tutorialSidebar"},"advanced/theory":{"id":"advanced/theory","title":"Theory","description":"strahl was written as part of a master thesis. Therefore, a detailed report is available. If you\'re unsure about whether this is interesting to you, there is a short-paper which gives a brief introduction into the topic available on arXiv.","sidebar":"tutorialSidebar"},"advanced/view-projection":{"id":"advanced/view-projection","title":"View Projection","description":"View projection is about setting up the virtual camera and getting the right shot. To date, strahl only supports perspective view projection as encountered in real life.","sidebar":"tutorialSidebar"},"intro":{"id":"intro","title":"strahl Documentation","description":"The tutorial is not yet finished and will be following in the upcoming weeks.","sidebar":"tutorialSidebar"},"tutorial-basic":{"id":"tutorial-basic","title":"Getting Started","description":"Installation","sidebar":"tutorialSidebar"}}}}')}}]); \ No newline at end of file diff --git a/assets/js/860ff063.179d9684.js b/assets/js/860ff063.179d9684.js new file mode 100644 index 0000000..ecfa222 --- /dev/null +++ b/assets/js/860ff063.179d9684.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[748],{8736:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>a,contentTitle:()=>s,default:()=>u,frontMatter:()=>r,metadata:()=>d,toc:()=>c});var i=t(4848),o=t(8453);const r={},s="Environment Light",d={id:"advanced/environment-light",title:"Environment Light",description:"Environment light is defined as the contribution of sky and sun. Sky settings are direction independent and are akin to AmbientLight. Sun is direction-dependent.",source:"@site/docs/advanced/environment-light.md",sourceDirName:"advanced",slug:"/advanced/environment-light",permalink:"/strahl/docs/advanced/environment-light",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Destruction",permalink:"/strahl/docs/advanced/destruction"},next:{title:"Exception Handling",permalink:"/strahl/docs/advanced/exception-handling"}},a={},c=[{value:"Configuration",id:"configuration",level:2},{value:"Sun Configuration",id:"sun-configuration",level:3},{value:"Sky Configuration",id:"sky-configuration",level:3}];function l(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,o.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.h1,{id:"environment-light",children:"Environment Light"}),"\n",(0,i.jsxs)(e.p,{children:["Environment light is defined as the contribution of sky and sun. Sky settings are direction independent and are akin to ",(0,i.jsx)(e.code,{children:"AmbientLight"}),". Sun is direction-dependent."]}),"\n",(0,i.jsx)(e.h2,{id:"configuration",children:"Configuration"}),"\n",(0,i.jsxs)(e.p,{children:["To configure the settings, you may pass your own environment light configuration to ",(0,i.jsx)(e.code,{children:"strahl"}),"."]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-js",metastring:'title="strahlConfiguration.js"',children:"runPathTracer(target, model, {\n environmentLightConfiguration: {\n sky: {\n power: 0.5,\n color: [0.8, 0.8, 1.0],\n },\n sun: {\n power: 1.0,\n angularSize: 35,\n latitude: 40,\n longitude: 160,\n color: [1.0, 1.0, 0.9],\n },\n },\n});\n"})}),"\n",(0,i.jsx)(e.h3,{id:"sun-configuration",children:"Sun Configuration"}),"\n",(0,i.jsxs)(e.p,{children:["Use ",(0,i.jsx)(e.code,{children:"angularSize"})," to determine the size of the sun, ",(0,i.jsx)(e.code,{children:"latitude"})," and ",(0,i.jsx)(e.code,{children:"longitude"})," to change the position and therefore direction of light, ",(0,i.jsx)(e.code,{children:"color"})," for different effects, and ",(0,i.jsx)(e.code,{children:"power"})," for the intensity."]}),"\n",(0,i.jsx)(e.h3,{id:"sky-configuration",children:"Sky Configuration"}),"\n",(0,i.jsxs)(e.p,{children:["Use ",(0,i.jsx)(e.code,{children:"power"})," for intensity of ambient light and ",(0,i.jsx)(e.code,{children:"color"})," for different effects."]})]})}function u(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(l,{...n})}):l(n)}},8453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>d});var i=t(6540);const o={},r=i.createContext(o);function s(n){const e=i.useContext(r);return i.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:s(n.components),i.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/main.6129305b.js b/assets/js/main.6129305b.js deleted file mode 100644 index cfc2d7b..0000000 --- a/assets/js/main.6129305b.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see main.6129305b.js.LICENSE.txt */ -(self.webpackChunkstrahl_website=self.webpackChunkstrahl_website||[]).push([[792],{8328:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});n(6540);var r=n(3259),a=n.n(r),o=n(4054);const i={"0e384e19":[()=>n.e(976).then(n.bind(n,619)),"@site/docs/intro.md",619],"1122199e":[()=>n.e(85).then(n.bind(n,132)),"@site/docs/tutorial-basic.mdx",132],"14eb3368":[()=>Promise.all([n.e(869),n.e(969)]).then(n.bind(n,4136)),"@theme/DocCategoryGeneratedIndexPage",4136],"166d5f99":[()=>n.e(11).then(n.bind(n,4602)),"@site/blog/2024-07-29-welcome/index.md",4602],17896441:[()=>Promise.all([n.e(869),n.e(554),n.e(401)]).then(n.bind(n,6011)),"@theme/DocItem",6011],"1df93b7f":[()=>Promise.all([n.e(869),n.e(839),n.e(583)]).then(n.bind(n,9269)),"@site/src/pages/index.tsx",9269],"29cb046e":[()=>n.e(280).then(n.bind(n,5438)),"@site/blog/2024-07-29-welcome/index.md?truncated=true",5438],"36994c47":[()=>n.e(858).then(n.t.bind(n,5516,19)),"@generated/docusaurus-plugin-content-blog/default/__plugin.json",5516],"45d3dc74":[()=>n.e(787).then(n.bind(n,1875)),"@site/docs/advanced/exception-handling.md",1875],"4c15fca4":[()=>n.e(584).then(n.bind(n,8900)),"@site/docs/advanced/destruction.md",8900],"4d780be7":[()=>n.e(236).then(n.t.bind(n,8117,19)),"@generated/docusaurus-plugin-content-docs/default/p/strahl-docs-1ee.json",8117],"5782a49b":[()=>n.e(3).then(n.t.bind(n,7736,19)),"@generated/docusaurus-plugin-content-blog/default/p/strahl-blog-archive-391.json",7736],"5e95c892":[()=>n.e(647).then(n.bind(n,7121)),"@theme/DocsRoot",7121],"5e9f5e1a":[()=>Promise.resolve().then(n.bind(n,4784)),"@generated/docusaurus.config",4784],"814f3328":[()=>n.e(472).then(n.t.bind(n,5513,19)),"~blog/default/blog-post-list-prop-default.json",5513],"9e4087bc":[()=>n.e(711).then(n.bind(n,9331)),"@theme/BlogArchivePage",9331],a6aa9e1f:[()=>Promise.all([n.e(869),n.e(554),n.e(667),n.e(643)]).then(n.bind(n,2052)),"@theme/BlogListPage",2052],a7456010:[()=>n.e(235).then(n.t.bind(n,8552,19)),"@generated/docusaurus-plugin-content-pages/default/__plugin.json",8552],a7bd4aaa:[()=>n.e(98).then(n.bind(n,4532)),"@theme/DocVersionRoot",4532],a94703ab:[()=>Promise.all([n.e(869),n.e(48)]).then(n.bind(n,2559)),"@theme/DocRoot",2559],aba21aa0:[()=>n.e(742).then(n.t.bind(n,7093,19)),"@generated/docusaurus-plugin-content-docs/default/__plugin.json",7093],ac58617a:[()=>n.e(603).then(n.t.bind(n,3205,19)),"@generated/docusaurus-plugin-content-docs/default/p/strahl-docs-category-advanced-407.json",3205],acecf23e:[()=>n.e(903).then(n.t.bind(n,1912,19)),"~blog/default/blogMetadata-default.json",1912],ad7bf0bc:[()=>n.e(616).then(n.bind(n,4541)),"@site/docs/advanced/view-projection.md",4541],b2aa2ce5:[()=>n.e(361).then(n.t.bind(n,1276,19)),"@generated/docusaurus-plugin-content-blog/default/p/strahl-blog-5a2.json",1276],ccc49370:[()=>Promise.all([n.e(869),n.e(554),n.e(667),n.e(249)]).then(n.bind(n,3858)),"@theme/BlogPostPage",3858],fb713178:[()=>n.e(206).then(n.bind(n,5627)),"@site/docs/advanced/theory.md",5627]};var l=n(4848);function s(e){let{error:t,retry:n,pastDelay:r}=e;return t?(0,l.jsxs)("div",{style:{textAlign:"center",color:"#fff",backgroundColor:"#fa383e",borderColor:"#fa383e",borderStyle:"solid",borderRadius:"0.25rem",borderWidth:"1px",boxSizing:"border-box",display:"block",padding:"1rem",flex:"0 0 50%",marginLeft:"25%",marginRight:"25%",marginTop:"5rem",maxWidth:"50%",width:"100%"},children:[(0,l.jsx)("p",{children:String(t)}),(0,l.jsx)("div",{children:(0,l.jsx)("button",{type:"button",onClick:n,children:"Retry"})})]}):r?(0,l.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,l.jsx)("svg",{id:"loader",style:{width:128,height:110,position:"absolute",top:"calc(100vh - 64%)"},viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",stroke:"#61dafb",children:(0,l.jsxs)("g",{fill:"none",fillRule:"evenodd",transform:"translate(1 1)",strokeWidth:"2",children:[(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"1.5s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"1.5s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"1.5s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"3s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"3s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"3s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsx)("circle",{cx:"22",cy:"22",r:"8",children:(0,l.jsx)("animate",{attributeName:"r",begin:"0s",dur:"1.5s",values:"6;1;2;3;4;5;6",calcMode:"linear",repeatCount:"indefinite"})})]})})}):null}var u=n(6921),c=n(3102);function d(e,t){if("*"===e)return a()({loading:s,loader:()=>n.e(237).then(n.bind(n,2237)),modules:["@theme/NotFound"],webpack:()=>[2237],render(e,t){const n=e.default;return(0,l.jsx)(c.W,{value:{plugin:{name:"native",id:"default"}},children:(0,l.jsx)(n,{...t})})}});const r=o[`${e}-${t}`],d={},p=[],f=[],m=(0,u.A)(r);return Object.entries(m).forEach((e=>{let[t,n]=e;const r=i[n];r&&(d[t]=r[0],p.push(r[1]),f.push(r[2]))})),a().Map({loading:s,loader:d,modules:p,webpack:()=>f,render(t,n){const a=JSON.parse(JSON.stringify(r));Object.entries(t).forEach((t=>{let[n,r]=t;const o=r.default;if(!o)throw new Error(`The page component at ${e} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);"object"!=typeof o&&"function"!=typeof o||Object.keys(r).filter((e=>"default"!==e)).forEach((e=>{o[e]=r[e]}));let i=a;const l=n.split(".");l.slice(0,-1).forEach((e=>{i=i[e]})),i[l[l.length-1]]=o}));const o=a.__comp;delete a.__comp;const i=a.__context;delete a.__context;const s=a.__props;return delete a.__props,(0,l.jsx)(c.W,{value:i,children:(0,l.jsx)(o,{...a,...s,...n})})}})}const p=[{path:"/strahl/blog",component:d("/strahl/blog","6e3"),exact:!0},{path:"/strahl/blog/archive",component:d("/strahl/blog/archive","1d9"),exact:!0},{path:"/strahl/blog/welcome",component:d("/strahl/blog/welcome","6f0"),exact:!0},{path:"/strahl/docs",component:d("/strahl/docs","e0a"),routes:[{path:"/strahl/docs",component:d("/strahl/docs","b33"),routes:[{path:"/strahl/docs",component:d("/strahl/docs","14d"),routes:[{path:"/strahl/docs/advanced/destruction",component:d("/strahl/docs/advanced/destruction","8eb"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/advanced/exception-handling",component:d("/strahl/docs/advanced/exception-handling","b12"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/advanced/theory",component:d("/strahl/docs/advanced/theory","c5b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/advanced/view-projection",component:d("/strahl/docs/advanced/view-projection","b84"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/category/advanced",component:d("/strahl/docs/category/advanced","97b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/intro",component:d("/strahl/docs/intro","96e"),exact:!0,sidebar:"tutorialSidebar"},{path:"/strahl/docs/tutorial-basic",component:d("/strahl/docs/tutorial-basic","c63"),exact:!0,sidebar:"tutorialSidebar"}]}]}]},{path:"/strahl/",component:d("/strahl/","10b"),exact:!0},{path:"*",component:d("*")}]},6125:(e,t,n)=>{"use strict";n.d(t,{o:()=>o,x:()=>i});var r=n(6540),a=n(4848);const o=r.createContext(!1);function i(e){let{children:t}=e;const[n,i]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{i(!0)}),[]),(0,a.jsx)(o.Provider,{value:n,children:t})}},8536:(e,t,n)=>{"use strict";var r=n(6540),a=n(5338),o=n(545),i=n(4625),l=n(4784),s=n(8193);const u=[n(119),n(6134),n(6294),n(1043)];var c=n(8328),d=n(6347),p=n(2831),f=n(4848);function m(e){let{children:t}=e;return(0,f.jsx)(f.Fragment,{children:t})}var h=n(5260),g=n(4586),y=n(6025),b=n(6342),v=n(1213),w=n(2131),k=n(4090),x=n(2967),S=n(440),E=n(1463);function C(){const{i18n:{currentLocale:e,defaultLocale:t,localeConfigs:n}}=(0,g.A)(),r=(0,w.o)(),a=n[e].htmlLang,o=e=>e.replace("-","_");return(0,f.jsxs)(h.A,{children:[Object.entries(n).map((e=>{let[t,{htmlLang:n}]=e;return(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:n},t)})),(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:"x-default"}),(0,f.jsx)("meta",{property:"og:locale",content:o(a)}),Object.values(n).filter((e=>a!==e.htmlLang)).map((e=>(0,f.jsx)("meta",{property:"og:locale:alternate",content:o(e.htmlLang)},`meta-og-${e.htmlLang}`)))]})}function _(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,g.A)(),r=function(){const{siteConfig:{url:e,baseUrl:t,trailingSlash:n}}=(0,g.A)(),{pathname:r}=(0,d.zy)();return e+(0,S.applyTrailingSlash)((0,y.Ay)(r),{trailingSlash:n,baseUrl:t})}(),a=t?`${n}${t}`:r;return(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{property:"og:url",content:a}),(0,f.jsx)("link",{rel:"canonical",href:a})]})}function A(){const{i18n:{currentLocale:e}}=(0,g.A)(),{metadata:t,image:n}=(0,b.p)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,f.jsx)("body",{className:k.w})]}),n&&(0,f.jsx)(v.be,{image:n}),(0,f.jsx)(_,{}),(0,f.jsx)(C,{}),(0,f.jsx)(E.A,{tag:x.Cy,locale:e}),(0,f.jsx)(h.A,{children:t.map(((e,t)=>(0,f.jsx)("meta",{...e},t)))})]})}const T=new Map;var j=n(6125),N=n(6988),L=n(205);function R(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>a.forEach((e=>e?.()))}const P=function(e){let{children:t,location:n,previousLocation:r}=e;return(0,L.A)((()=>{r!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,a=t.hash===n.hash,o=t.search===n.search;if(r&&a&&!o)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:r}),R("onRouteDidUpdate",{previousLocation:r,location:n}))}),[r,n]),t};function O(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,p.u)(c.A,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class D extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=s.A.canUseDOM?R("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=R("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),O(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return(0,f.jsx)(P,{previousLocation:this.previousLocation,location:t,children:(0,f.jsx)(d.qh,{location:t,render:()=>e})})}}const I=D,M="__docusaurus-base-url-issue-banner-container",F="__docusaurus-base-url-issue-banner",z="__docusaurus-base-url-issue-banner-suggestion-container";function B(e){return`\ndocument.addEventListener('DOMContentLoaded', function maybeInsertBanner() {\n var shouldInsert = typeof window['docusaurus'] === 'undefined';\n shouldInsert && insertBanner();\n});\n\nfunction insertBanner() {\n var bannerContainer = document.createElement('div');\n bannerContainer.id = '${M}';\n var bannerHtml = ${JSON.stringify(function(e){return`\n
\n

Your Docusaurus site did not load properly.

\n

A very common reason is a wrong site baseUrl configuration.

\n

Current configured baseUrl = ${e} ${"/"===e?" (default value)":""}

\n

We suggest trying baseUrl =

\n
\n`}(e)).replace(/{let{route:t}=e;return!0===t.exact})))return T.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return T.set(e.pathname,t),{...e,pathname:t}}((0,d.zy)());return(0,f.jsx)(I,{location:e,children:W})}function K(){return(0,f.jsx)(H.A,{children:(0,f.jsx)(N.l,{children:(0,f.jsxs)(j.x,{children:[(0,f.jsxs)(m,{children:[(0,f.jsx)(q,{}),(0,f.jsx)(A,{}),(0,f.jsx)(U,{}),(0,f.jsx)(Q,{})]}),(0,f.jsx)(V,{})]})})})}var Y=n(4054);const Z=function(e){try{return document.createElement("link").relList.supports(e)}catch{return!1}}("prefetch")?function(e){return new Promise(((t,n)=>{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const a=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;a?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var X=n(6921);const J=new Set,ee=new Set,te=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,ne={prefetch:e=>{if(!(e=>!te()&&!ee.has(e)&&!J.has(e))(e))return!1;J.add(e);const t=(0,p.u)(c.A,e).flatMap((e=>{return t=e.route.path,Object.entries(Y).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,X.A)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?Z(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!te()&&!ee.has(e))(e)&&(ee.add(e),O(e))},re=Object.freeze(ne);function ae(e){let{children:t}=e;return"hash"===l.default.future.experimental_router?(0,f.jsx)(i.I9,{children:t}):(0,f.jsx)(i.Kd,{children:t})}const oe=Boolean(!0);if(s.A.canUseDOM){window.docusaurus=re;const e=document.getElementById("__docusaurus"),t=(0,f.jsx)(o.vd,{children:(0,f.jsx)(ae,{children:(0,f.jsx)(K,{})})}),n=(e,t)=>{console.error("Docusaurus React Root onRecoverableError:",e,t)},i=()=>{if(window.docusaurusRoot)window.docusaurusRoot.render(t);else if(oe)window.docusaurusRoot=a.hydrateRoot(e,t,{onRecoverableError:n});else{const r=a.createRoot(e,{onRecoverableError:n});r.render(t),window.docusaurusRoot=r}};O(window.location.pathname).then((()=>{(0,r.startTransition)(i)}))}},6988:(e,t,n)=>{"use strict";n.d(t,{o:()=>d,l:()=>p});var r=n(6540),a=n(4784);const o=JSON.parse('{"docusaurus-plugin-content-docs":{"default":{"path":"/strahl/docs","versions":[{"name":"current","label":"Next","isLast":true,"path":"/strahl/docs","mainDocId":"intro","docs":[{"id":"advanced/destruction","path":"/strahl/docs/advanced/destruction","sidebar":"tutorialSidebar"},{"id":"advanced/exception-handling","path":"/strahl/docs/advanced/exception-handling","sidebar":"tutorialSidebar"},{"id":"advanced/theory","path":"/strahl/docs/advanced/theory","sidebar":"tutorialSidebar"},{"id":"advanced/view-projection","path":"/strahl/docs/advanced/view-projection","sidebar":"tutorialSidebar"},{"id":"intro","path":"/strahl/docs/intro","sidebar":"tutorialSidebar"},{"id":"tutorial-basic","path":"/strahl/docs/tutorial-basic","sidebar":"tutorialSidebar"},{"id":"/category/advanced","path":"/strahl/docs/category/advanced","sidebar":"tutorialSidebar"}],"draftIds":[],"sidebars":{"tutorialSidebar":{"link":{"path":"/strahl/docs/intro","label":"intro"}}}}],"breadcrumbs":true}}}'),i=JSON.parse('{"defaultLocale":"en","locales":["en"],"path":"i18n","currentLocale":"en","localeConfigs":{"en":{"label":"English","direction":"ltr","htmlLang":"en","calendar":"gregory","path":"en"}}}');var l=n(2654);const s=JSON.parse('{"docusaurusVersion":"3.4.0","siteVersion":"0.0.0","pluginVersions":{"docusaurus-plugin-content-docs":{"type":"package","name":"@docusaurus/plugin-content-docs","version":"3.4.0"},"docusaurus-plugin-content-blog":{"type":"package","name":"@docusaurus/plugin-content-blog","version":"3.4.0"},"docusaurus-plugin-content-pages":{"type":"package","name":"@docusaurus/plugin-content-pages","version":"3.4.0"},"docusaurus-plugin-sitemap":{"type":"package","name":"@docusaurus/plugin-sitemap","version":"3.4.0"},"docusaurus-theme-classic":{"type":"package","name":"@docusaurus/theme-classic","version":"3.4.0"}}}');var u=n(4848);const c={siteConfig:a.default,siteMetadata:s,globalData:o,i18n:i,codeTranslations:l},d=r.createContext(c);function p(e){let{children:t}=e;return(0,u.jsx)(d.Provider,{value:c,children:t})}},7489:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var r=n(6540),a=n(8193),o=n(5260),i=n(440),l=n(781),s=n(3102),u=n(4848);function c(e){let{error:t,tryAgain:n}=e;return(0,u.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",minHeight:"100vh",width:"100%",maxWidth:"80ch",fontSize:"20px",margin:"0 auto",padding:"1rem"},children:[(0,u.jsx)("h1",{style:{fontSize:"3rem"},children:"This page crashed"}),(0,u.jsx)("button",{type:"button",onClick:n,style:{margin:"1rem 0",fontSize:"2rem",cursor:"pointer",borderRadius:20,padding:"1rem"},children:"Try again"}),(0,u.jsx)(d,{error:t})]})}function d(e){let{error:t}=e;const n=(0,i.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,u.jsx)("p",{style:{whiteSpace:"pre-wrap"},children:n})}function p(e){let{children:t}=e;return(0,u.jsx)(s.W,{value:{plugin:{name:"docusaurus-core-error-boundary",id:"default"}},children:t})}function f(e){let{error:t,tryAgain:n}=e;return(0,u.jsx)(p,{children:(0,u.jsxs)(h,{fallback:()=>(0,u.jsx)(c,{error:t,tryAgain:n}),children:[(0,u.jsx)(o.A,{children:(0,u.jsx)("title",{children:"Page Error"})}),(0,u.jsx)(l.A,{children:(0,u.jsx)(c,{error:t,tryAgain:n})})]})})}const m=e=>(0,u.jsx)(f,{...e});class h extends r.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){a.A.canUseDOM&&this.setState({error:e})}render(){const{children:e}=this.props,{error:t}=this.state;if(t){const e={error:t,tryAgain:()=>this.setState({error:null})};return(this.props.fallback??m)(e)}return e??null}}},8193:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r="undefined"!=typeof window&&"document"in window&&"createElement"in window.document,a={canUseDOM:r,canUseEventListeners:r&&("addEventListener"in window||"attachEvent"in window),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&"screen"in window}},5260:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);var r=n(545),a=n(4848);function o(e){return(0,a.jsx)(r.mg,{...e})}},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(6540),a=n(4625),o=n(440),i=n(4586),l=n(6654),s=n(8193),u=n(3427),c=n(6025),d=n(4848);function p(e,t){let{isNavLink:n,to:p,href:f,activeClassName:m,isActive:h,"data-noBrokenLinkCheck":g,autoAddBaseUrl:y=!0,...b}=e;const{siteConfig:v}=(0,i.A)(),{trailingSlash:w,baseUrl:k}=v,x=v.future.experimental_router,{withBaseUrl:S}=(0,c.hH)(),E=(0,u.A)(),C=(0,r.useRef)(null);(0,r.useImperativeHandle)(t,(()=>C.current));const _=p||f;const A=(0,l.A)(_),T=_?.replace("pathname://","");let j=void 0!==T?(N=T,y&&(e=>e.startsWith("/"))(N)?S(N):N):void 0;var N;"hash"===x&&j?.startsWith("./")&&(j=j?.slice(1)),j&&A&&(j=(0,o.applyTrailingSlash)(j,{trailingSlash:w,baseUrl:k}));const L=(0,r.useRef)(!1),R=n?a.k2:a.N_,P=s.A.canUseIntersectionObserver,O=(0,r.useRef)(),D=()=>{L.current||null==j||(window.docusaurus.preload(j),L.current=!0)};(0,r.useEffect)((()=>(!P&&A&&null!=j&&window.docusaurus.prefetch(j),()=>{P&&O.current&&O.current.disconnect()})),[O,j,P,A]);const I=j?.startsWith("#")??!1,M=!b.target||"_self"===b.target,F=!j||!A||!M;return g||!I&&F||E.collectLink(j),b.id&&E.collectAnchor(b.id),F?(0,d.jsx)("a",{ref:C,href:j,..._&&!A&&{target:"_blank",rel:"noopener noreferrer"},...b}):(0,d.jsx)(R,{...b,onMouseEnter:D,onTouchStart:D,innerRef:e=>{C.current=e,P&&e&&A&&(O.current=new window.IntersectionObserver((t=>{t.forEach((t=>{e===t.target&&(t.isIntersecting||t.intersectionRatio>0)&&(O.current.unobserve(e),O.current.disconnect(),null!=j&&window.docusaurus.prefetch(j))}))})),O.current.observe(e))},to:j,...n&&{isActive:h,activeClassName:m}})}const f=r.forwardRef(p)},418:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=()=>null},1312:(e,t,n)=>{"use strict";n.d(t,{A:()=>u,T:()=>s});var r=n(6540),a=n(4848);function o(e,t){const n=e.split(/(\{\w+\})/).map(((e,n)=>{if(n%2==1){const n=t?.[e.slice(1,-1)];if(void 0!==n)return n}return e}));return n.some((e=>(0,r.isValidElement)(e)))?n.map(((e,t)=>(0,r.isValidElement)(e)?r.cloneElement(e,{key:t}):e)).filter((e=>""!==e)):n.join("")}var i=n(2654);function l(e){let{id:t,message:n}=e;if(void 0===t&&void 0===n)throw new Error("Docusaurus translation declarations must have at least a translation id or a default translation message");return i[t??n]??n??t}function s(e,t){let{message:n,id:r}=e;return o(l({message:n,id:r}),t)}function u(e){let{children:t,id:n,values:r}=e;if(t&&"string"!=typeof t)throw console.warn("Illegal children",t),new Error("The Docusaurus component only accept simple string values");const i=l({message:t,id:n});return(0,a.jsx)(a.Fragment,{children:o(i,r)})}},7065:(e,t,n)=>{"use strict";n.d(t,{W:()=>r});const r="default"},6654:(e,t,n)=>{"use strict";function r(e){return/^(?:\w*:|\/\/)/.test(e)}function a(e){return void 0!==e&&!r(e)}n.d(t,{A:()=>a,z:()=>r})},6025:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>l,hH:()=>i});var r=n(6540),a=n(4586),o=n(6654);function i(){const{siteConfig:e}=(0,a.A)(),{baseUrl:t,url:n}=e,i=e.future.experimental_router,l=(0,r.useCallback)(((e,r)=>function(e){let{siteUrl:t,baseUrl:n,url:r,options:{forcePrependBaseUrl:a=!1,absolute:i=!1}={},router:l}=e;if(!r||r.startsWith("#")||(0,o.z)(r))return r;if("hash"===l)return r.startsWith("/")?`.${r}`:`./${r}`;if(a)return n+r.replace(/^\//,"");if(r===n.replace(/\/$/,""))return n;const s=r.startsWith(n)?r:n+r.replace(/^\//,"");return i?t+s:s}({siteUrl:n,baseUrl:t,url:e,options:r,router:i})),[n,t,i]);return{withBaseUrl:l}}function l(e,t){void 0===t&&(t={});const{withBaseUrl:n}=i();return n(e,t)}},3427:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(6540);n(4848);const a=r.createContext({collectAnchor:()=>{},collectLink:()=>{}}),o=()=>(0,r.useContext)(a);function i(){return o()}},4586:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540),a=n(6988);function o(){return(0,r.useContext)(a.o)}},2303:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540),a=n(6125);function o(){return(0,r.useContext)(a.o)}},205:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(6540);const a=n(8193).A.canUseDOM?r.useLayoutEffect:r.useEffect},6803:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540),a=n(3102);function o(){const e=r.useContext(a.o);if(!e)throw new Error("Unexpected: no Docusaurus route context found");return e}},6921:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r=e=>"object"==typeof e&&!!e&&Object.keys(e).length>0;function a(e){const t={};return function e(n,a){Object.entries(n).forEach((n=>{let[o,i]=n;const l=a?`${a}.${o}`:o;r(i)?e(i,l):t[l]=i}))}(e),t}},3102:(e,t,n)=>{"use strict";n.d(t,{W:()=>i,o:()=>o});var r=n(6540),a=n(4848);const o=r.createContext(null);function i(e){let{children:t,value:n}=e;const i=r.useContext(o),l=(0,r.useMemo)((()=>function(e){let{parent:t,value:n}=e;if(!t){if(!n)throw new Error("Unexpected: no Docusaurus route context found");if(!("plugin"in n))throw new Error("Unexpected: Docusaurus topmost route context has no `plugin` attribute");return n}const r={...t.data,...n?.data};return{plugin:t.plugin,data:r}}({parent:i,value:n})),[i,n]);return(0,a.jsx)(o.Provider,{value:l,children:t})}},4070:(e,t,n)=>{"use strict";n.d(t,{zK:()=>h,vT:()=>p,Gy:()=>c,HW:()=>g,ht:()=>d,r7:()=>m,jh:()=>f});var r=n(6347),a=n(4586),o=n(7065);function i(e,t){void 0===t&&(t={});const n=function(){const{globalData:e}=(0,a.A)();return e}()[e];if(!n&&t.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin.`);return n}const l=e=>e.versions.find((e=>e.isLast));function s(e,t){const n=function(e,t){const n=l(e);return[...e.versions.filter((e=>e!==n)),n].find((e=>!!(0,r.B6)(t,{path:e.path,exact:!1,strict:!1})))}(e,t),a=n?.docs.find((e=>!!(0,r.B6)(t,{path:e.path,exact:!0,strict:!1})));return{activeVersion:n,activeDoc:a,alternateDocVersions:a?function(t){const n={};return e.versions.forEach((e=>{e.docs.forEach((r=>{r.id===t&&(n[e.name]=r)}))})),n}(a.id):{}}}const u={},c=()=>i("docusaurus-plugin-content-docs")??u,d=e=>{try{return function(e,t,n){void 0===t&&(t=o.W),void 0===n&&(n={});const r=i(e),a=r?.[t];if(!a&&n.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin with id "${t}".`);return a}("docusaurus-plugin-content-docs",e,{failfast:!0})}catch(t){throw new Error("You are using a feature of the Docusaurus docs plugin, but this plugin does not seem to be enabled"+("Default"===e?"":` (pluginId=${e}`),{cause:t})}};function p(e){void 0===e&&(e={});const t=c(),{pathname:n}=(0,r.zy)();return function(e,t,n){void 0===n&&(n={});const a=Object.entries(e).sort(((e,t)=>t[1].path.localeCompare(e[1].path))).find((e=>{let[,n]=e;return!!(0,r.B6)(t,{path:n.path,exact:!1,strict:!1})})),o=a?{pluginId:a[0],pluginData:a[1]}:void 0;if(!o&&n.failfast)throw new Error(`Can't find active docs plugin for "${t}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(e).map((e=>e.path)).join(", ")}`);return o}(t,n,e)}function f(e){return d(e).versions}function m(e){const t=d(e);return l(t)}function h(e){const t=d(e),{pathname:n}=(0,r.zy)();return s(t,n)}function g(e){const t=d(e),{pathname:n}=(0,r.zy)();return function(e,t){const n=l(e);return{latestDocSuggestion:s(e,t).alternateDocVersions[n.name],latestVersionSuggestion:n}}(t,n)}},6294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(5947),a=n.n(r);a().configure({showSpinner:!1});const o={onRouteUpdate(e){let{location:t,previousLocation:n}=e;if(n&&t.pathname!==n.pathname){const e=window.setTimeout((()=>{a().start()}),200);return()=>window.clearTimeout(e)}},onRouteDidUpdate(){a().done()}}},6134:(e,t,n)=>{"use strict";n.r(t);var r=n(1765),a=n(4784);!function(e){const{themeConfig:{prism:t}}=a.default,{additionalLanguages:r}=t;globalThis.Prism=e,r.forEach((e=>{"php"===e&&n(9700),n(8692)(`./prism-${e}`)})),delete globalThis.Prism}(r.My)},1107:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});n(6540);var r=n(4164),a=n(1312),o=n(6342),i=n(8774),l=n(3427);const s={anchorWithStickyNavbar:"anchorWithStickyNavbar_LWe7",anchorWithHideOnScrollNavbar:"anchorWithHideOnScrollNavbar_WYt5"};var u=n(4848);function c(e){let{as:t,id:n,...c}=e;const d=(0,l.A)(),{navbar:{hideOnScroll:p}}=(0,o.p)();if("h1"===t||!n)return(0,u.jsx)(t,{...c,id:void 0});d.collectAnchor(n);const f=(0,a.T)({id:"theme.common.headingLinkTitle",message:"Direct link to {heading}",description:"Title for link to heading"},{heading:"string"==typeof c.children?c.children:n});return(0,u.jsxs)(t,{...c,className:(0,r.A)("anchor",p?s.anchorWithHideOnScrollNavbar:s.anchorWithStickyNavbar,c.className),id:n,children:[c.children,(0,u.jsx)(i.A,{className:"hash-link",to:`#${n}`,"aria-label":f,title:f,children:"\u200b"})]})}},3186:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);const r={iconExternalLink:"iconExternalLink_nPIU"};var a=n(4848);function o(e){let{width:t=13.5,height:n=13.5}=e;return(0,a.jsx)("svg",{width:t,height:n,"aria-hidden":"true",viewBox:"0 0 24 24",className:r.iconExternalLink,children:(0,a.jsx)("path",{fill:"currentColor",d:"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"})})}},781:(e,t,n)=>{"use strict";n.d(t,{A:()=>ft});var r=n(6540),a=n(4164),o=n(7489),i=n(1213),l=n(6347),s=n(1312),u=n(5062),c=n(4848);const d="__docusaurus_skipToContent_fallback";function p(e){e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")}function f(){const e=(0,r.useRef)(null),{action:t}=(0,l.W6)(),n=(0,r.useCallback)((e=>{e.preventDefault();const t=document.querySelector("main:first-of-type")??document.getElementById(d);t&&p(t)}),[]);return(0,u.$)((n=>{let{location:r}=n;e.current&&!r.hash&&"PUSH"===t&&p(e.current)})),{containerRef:e,onClick:n}}const m=(0,s.T)({id:"theme.common.skipToMainContent",description:"The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",message:"Skip to main content"});function h(e){const t=e.children??m,{containerRef:n,onClick:r}=f();return(0,c.jsx)("div",{ref:n,role:"region","aria-label":m,children:(0,c.jsx)("a",{...e,href:`#${d}`,onClick:r,children:t})})}var g=n(7559),y=n(4090);const b={skipToContent:"skipToContent_fXgn"};function v(){return(0,c.jsx)(h,{className:b.skipToContent})}var w=n(6342),k=n(5041);function x(e){let{width:t=21,height:n=21,color:r="currentColor",strokeWidth:a=1.2,className:o,...i}=e;return(0,c.jsx)("svg",{viewBox:"0 0 15 15",width:t,height:n,...i,children:(0,c.jsx)("g",{stroke:r,strokeWidth:a,children:(0,c.jsx)("path",{d:"M.75.75l13.5 13.5M14.25.75L.75 14.25"})})})}const S={closeButton:"closeButton_CVFx"};function E(e){return(0,c.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.AnnouncementBar.closeButtonAriaLabel",message:"Close",description:"The ARIA label for close button of announcement bar"}),...e,className:(0,a.A)("clean-btn close",S.closeButton,e.className),children:(0,c.jsx)(x,{width:14,height:14,strokeWidth:3.1})})}const C={content:"content_knG7"};function _(e){const{announcementBar:t}=(0,w.p)(),{content:n}=t;return(0,c.jsx)("div",{...e,className:(0,a.A)(C.content,e.className),dangerouslySetInnerHTML:{__html:n}})}const A={announcementBar:"announcementBar_mb4j",announcementBarPlaceholder:"announcementBarPlaceholder_vyr4",announcementBarClose:"announcementBarClose_gvF7",announcementBarContent:"announcementBarContent_xLdY"};function T(){const{announcementBar:e}=(0,w.p)(),{isActive:t,close:n}=(0,k.M)();if(!t)return null;const{backgroundColor:r,textColor:a,isCloseable:o}=e;return(0,c.jsxs)("div",{className:A.announcementBar,style:{backgroundColor:r,color:a},role:"banner",children:[o&&(0,c.jsx)("div",{className:A.announcementBarPlaceholder}),(0,c.jsx)(_,{className:A.announcementBarContent}),o&&(0,c.jsx)(E,{onClick:n,className:A.announcementBarClose})]})}var j=n(9876),N=n(3104);var L=n(9532),R=n(5600);const P=r.createContext(null);function O(e){let{children:t}=e;const n=function(){const e=(0,j.M)(),t=(0,R.YL)(),[n,a]=(0,r.useState)(!1),o=null!==t.component,i=(0,L.ZC)(o);return(0,r.useEffect)((()=>{o&&!i&&a(!0)}),[o,i]),(0,r.useEffect)((()=>{o?e.shown||a(!0):a(!1)}),[e.shown,o]),(0,r.useMemo)((()=>[n,a]),[n])}();return(0,c.jsx)(P.Provider,{value:n,children:t})}function D(e){if(e.component){const t=e.component;return(0,c.jsx)(t,{...e.props})}}function I(){const e=(0,r.useContext)(P);if(!e)throw new L.dV("NavbarSecondaryMenuDisplayProvider");const[t,n]=e,a=(0,r.useCallback)((()=>n(!1)),[n]),o=(0,R.YL)();return(0,r.useMemo)((()=>({shown:t,hide:a,content:D(o)})),[a,o,t])}function M(e){let{header:t,primaryMenu:n,secondaryMenu:r}=e;const{shown:o}=I();return(0,c.jsxs)("div",{className:"navbar-sidebar",children:[t,(0,c.jsxs)("div",{className:(0,a.A)("navbar-sidebar__items",{"navbar-sidebar__items--show-secondary":o}),children:[(0,c.jsx)("div",{className:"navbar-sidebar__item menu",children:n}),(0,c.jsx)("div",{className:"navbar-sidebar__item menu",children:r})]})]})}var F=n(5293),z=n(2303);function B(e){return(0,c.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,c.jsx)("path",{fill:"currentColor",d:"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"})})}function $(e){return(0,c.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,c.jsx)("path",{fill:"currentColor",d:"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"})})}const U={toggle:"toggle_vylO",toggleButton:"toggleButton_gllP",darkToggleIcon:"darkToggleIcon_wfgR",lightToggleIcon:"lightToggleIcon_pyhR",toggleButtonDisabled:"toggleButtonDisabled_aARS"};function q(e){let{className:t,buttonClassName:n,value:r,onChange:o}=e;const i=(0,z.A)(),l=(0,s.T)({message:"Switch between dark and light mode (currently {mode})",id:"theme.colorToggle.ariaLabel",description:"The ARIA label for the navbar color mode toggle"},{mode:"dark"===r?(0,s.T)({message:"dark mode",id:"theme.colorToggle.ariaLabel.mode.dark",description:"The name for the dark color mode"}):(0,s.T)({message:"light mode",id:"theme.colorToggle.ariaLabel.mode.light",description:"The name for the light color mode"})});return(0,c.jsx)("div",{className:(0,a.A)(U.toggle,t),children:(0,c.jsxs)("button",{className:(0,a.A)("clean-btn",U.toggleButton,!i&&U.toggleButtonDisabled,n),type:"button",onClick:()=>o("dark"===r?"light":"dark"),disabled:!i,title:l,"aria-label":l,"aria-live":"polite",children:[(0,c.jsx)(B,{className:(0,a.A)(U.toggleIcon,U.lightToggleIcon)}),(0,c.jsx)($,{className:(0,a.A)(U.toggleIcon,U.darkToggleIcon)})]})})}const H=r.memo(q),G={darkNavbarColorModeToggle:"darkNavbarColorModeToggle_X3D1"};function V(e){let{className:t}=e;const n=(0,w.p)().navbar.style,r=(0,w.p)().colorMode.disableSwitch,{colorMode:a,setColorMode:o}=(0,F.G)();return r?null:(0,c.jsx)(H,{className:t,buttonClassName:"dark"===n?G.darkNavbarColorModeToggle:void 0,value:a,onChange:o})}var W=n(3465);function Q(){return(0,c.jsx)(W.A,{className:"navbar__brand",imageClassName:"navbar__logo",titleClassName:"navbar__title text--truncate"})}function K(){const e=(0,j.M)();return(0,c.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.docs.sidebar.closeSidebarButtonAriaLabel",message:"Close navigation bar",description:"The ARIA label for close button of mobile sidebar"}),className:"clean-btn navbar-sidebar__close",onClick:()=>e.toggle(),children:(0,c.jsx)(x,{color:"var(--ifm-color-emphasis-600)"})})}function Y(){return(0,c.jsxs)("div",{className:"navbar-sidebar__brand",children:[(0,c.jsx)(Q,{}),(0,c.jsx)(V,{className:"margin-right--md"}),(0,c.jsx)(K,{})]})}var Z=n(8774),X=n(6025),J=n(6654);function ee(e,t){return void 0!==e&&void 0!==t&&new RegExp(e,"gi").test(t)}var te=n(3186);function ne(e){let{activeBasePath:t,activeBaseRegex:n,to:r,href:a,label:o,html:i,isDropdownLink:l,prependBaseUrlToHref:s,...u}=e;const d=(0,X.Ay)(r),p=(0,X.Ay)(t),f=(0,X.Ay)(a,{forcePrependBaseUrl:!0}),m=o&&a&&!(0,J.A)(a),h=i?{dangerouslySetInnerHTML:{__html:i}}:{children:(0,c.jsxs)(c.Fragment,{children:[o,m&&(0,c.jsx)(te.A,{...l&&{width:12,height:12}})]})};return a?(0,c.jsx)(Z.A,{href:s?f:a,...u,...h}):(0,c.jsx)(Z.A,{to:d,isNavLink:!0,...(t||n)&&{isActive:(e,t)=>n?ee(n,t.pathname):t.pathname.startsWith(p)},...u,...h})}function re(e){let{className:t,isDropdownItem:n=!1,...r}=e;const o=(0,c.jsx)(ne,{className:(0,a.A)(n?"dropdown__link":"navbar__item navbar__link",t),isDropdownLink:n,...r});return n?(0,c.jsx)("li",{children:o}):o}function ae(e){let{className:t,isDropdownItem:n,...r}=e;return(0,c.jsx)("li",{className:"menu__list-item",children:(0,c.jsx)(ne,{className:(0,a.A)("menu__link",t),...r})})}function oe(e){let{mobile:t=!1,position:n,...r}=e;const a=t?ae:re;return(0,c.jsx)(a,{...r,activeClassName:r.activeClassName??(t?"menu__link--active":"navbar__link--active")})}var ie=n(1422),le=n(9169),se=n(4586);const ue={dropdownNavbarItemMobile:"dropdownNavbarItemMobile_S0Fm"};function ce(e,t){return e.some((e=>function(e,t){return!!(0,le.ys)(e.to,t)||!!ee(e.activeBaseRegex,t)||!(!e.activeBasePath||!t.startsWith(e.activeBasePath))}(e,t)))}function de(e){let{items:t,position:n,className:o,onClick:i,...l}=e;const s=(0,r.useRef)(null),[u,d]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("focusin",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("focusin",e)}}),[s]),(0,c.jsxs)("div",{ref:s,className:(0,a.A)("navbar__item","dropdown","dropdown--hoverable",{"dropdown--right":"right"===n,"dropdown--show":u}),children:[(0,c.jsx)(ne,{"aria-haspopup":"true","aria-expanded":u,role:"button",href:l.to?void 0:"#",className:(0,a.A)("navbar__link",o),...l,onClick:l.to?void 0:e=>e.preventDefault(),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d(!u))},children:l.children??l.label}),(0,c.jsx)("ul",{className:"dropdown__menu",children:t.map(((e,t)=>(0,r.createElement)(Ce,{isDropdownItem:!0,activeClassName:"dropdown__link--active",...e,key:t})))})]})}function pe(e){let{items:t,className:n,position:o,onClick:i,...s}=e;const u=function(){const{siteConfig:{baseUrl:e}}=(0,se.A)(),{pathname:t}=(0,l.zy)();return t.replace(e,"/")}(),d=ce(t,u),{collapsed:p,toggleCollapsed:f,setCollapsed:m}=(0,ie.u)({initialState:()=>!d});return(0,r.useEffect)((()=>{d&&m(!d)}),[u,d,m]),(0,c.jsxs)("li",{className:(0,a.A)("menu__list-item",{"menu__list-item--collapsed":p}),children:[(0,c.jsx)(ne,{role:"button",className:(0,a.A)(ue.dropdownNavbarItemMobile,"menu__link menu__link--sublist menu__link--sublist-caret",n),...s,onClick:e=>{e.preventDefault(),f()},children:s.children??s.label}),(0,c.jsx)(ie.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:p,children:t.map(((e,t)=>(0,r.createElement)(Ce,{mobile:!0,isDropdownItem:!0,onClick:i,activeClassName:"menu__link--active",...e,key:t})))})]})}function fe(e){let{mobile:t=!1,...n}=e;const r=t?pe:de;return(0,c.jsx)(r,{...n})}var me=n(2131);function he(e){let{width:t=20,height:n=20,...r}=e;return(0,c.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:n,"aria-hidden":!0,...r,children:(0,c.jsx)("path",{fill:"currentColor",d:"M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"})})}const ge="iconLanguage_nlXk";var ye=n(418);const be={navbarSearchContainer:"navbarSearchContainer_Bca1"};function ve(e){let{children:t,className:n}=e;return(0,c.jsx)("div",{className:(0,a.A)(n,be.navbarSearchContainer),children:t})}var we=n(4070),ke=n(1754);var xe=n(5597);const Se=e=>e.docs.find((t=>t.id===e.mainDocId));const Ee={default:oe,localeDropdown:function(e){let{mobile:t,dropdownItemsBefore:n,dropdownItemsAfter:r,queryString:a="",...o}=e;const{i18n:{currentLocale:i,locales:u,localeConfigs:d}}=(0,se.A)(),p=(0,me.o)(),{search:f,hash:m}=(0,l.zy)(),h=[...n,...u.map((e=>{const n=`${`pathname://${p.createUrl({locale:e,fullyQualified:!1})}`}${f}${m}${a}`;return{label:d[e].label,lang:d[e].htmlLang,to:n,target:"_self",autoAddBaseUrl:!1,className:e===i?t?"menu__link--active":"dropdown__link--active":""}})),...r],g=t?(0,s.T)({message:"Languages",id:"theme.navbar.mobileLanguageDropdown.label",description:"The label for the mobile language switcher dropdown"}):d[i].label;return(0,c.jsx)(fe,{...o,mobile:t,label:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(he,{className:ge}),g]}),items:h})},search:function(e){let{mobile:t,className:n}=e;return t?null:(0,c.jsx)(ve,{className:n,children:(0,c.jsx)(ye.A,{})})},dropdown:fe,html:function(e){let{value:t,className:n,mobile:r=!1,isDropdownItem:o=!1}=e;const i=o?"li":"div";return(0,c.jsx)(i,{className:(0,a.A)({navbar__item:!r&&!o,"menu__list-item":r},n),dangerouslySetInnerHTML:{__html:t}})},doc:function(e){let{docId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,we.zK)(r),i=(0,ke.QB)(t,r),l=o?.path===i?.path;return null===i||i.unlisted&&!l?null:(0,c.jsx)(oe,{exact:!0,...a,isActive:()=>l||!!o?.sidebar&&o.sidebar===i.sidebar,label:n??i.id,to:i.path})},docSidebar:function(e){let{sidebarId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,we.zK)(r),i=(0,ke.fW)(t,r).link;if(!i)throw new Error(`DocSidebarNavbarItem: Sidebar with ID "${t}" doesn't have anything to be linked to.`);return(0,c.jsx)(oe,{exact:!0,...a,isActive:()=>o?.sidebar===t,label:n??i.label,to:i.path})},docsVersion:function(e){let{label:t,to:n,docsPluginId:r,...a}=e;const o=(0,ke.Vd)(r)[0],i=t??o.label,l=n??(e=>e.docs.find((t=>t.id===e.mainDocId)))(o).path;return(0,c.jsx)(oe,{...a,label:i,to:l})},docsVersionDropdown:function(e){let{mobile:t,docsPluginId:n,dropdownActiveClassDisabled:r,dropdownItemsBefore:a,dropdownItemsAfter:o,...i}=e;const{search:u,hash:d}=(0,l.zy)(),p=(0,we.zK)(n),f=(0,we.jh)(n),{savePreferredVersionName:m}=(0,xe.g1)(n),h=[...a,...f.map((e=>{const t=p.alternateDocVersions[e.name]??Se(e);return{label:e.label,to:`${t.path}${u}${d}`,isActive:()=>e===p.activeVersion,onClick:()=>m(e.name)}})),...o],g=(0,ke.Vd)(n)[0],y=t&&h.length>1?(0,s.T)({id:"theme.navbar.mobileVersionsDropdown.label",message:"Versions",description:"The label for the navbar versions dropdown on mobile view"}):g.label,b=t&&h.length>1?void 0:Se(g).path;return h.length<=1?(0,c.jsx)(oe,{...i,mobile:t,label:y,to:b,isActive:r?()=>!1:void 0}):(0,c.jsx)(fe,{...i,mobile:t,label:y,to:b,items:h,isActive:r?()=>!1:void 0})}};function Ce(e){let{type:t,...n}=e;const r=function(e,t){return e&&"default"!==e?e:"items"in t?"dropdown":"default"}(t,n),a=Ee[r];if(!a)throw new Error(`No NavbarItem component found for type "${t}".`);return(0,c.jsx)(a,{...n})}function _e(){const e=(0,j.M)(),t=(0,w.p)().navbar.items;return(0,c.jsx)("ul",{className:"menu__list",children:t.map(((t,n)=>(0,r.createElement)(Ce,{mobile:!0,...t,onClick:()=>e.toggle(),key:n})))})}function Ae(e){return(0,c.jsx)("button",{...e,type:"button",className:"clean-btn navbar-sidebar__back",children:(0,c.jsx)(s.A,{id:"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel",description:"The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)",children:"\u2190 Back to main menu"})})}function Te(){const e=0===(0,w.p)().navbar.items.length,t=I();return(0,c.jsxs)(c.Fragment,{children:[!e&&(0,c.jsx)(Ae,{onClick:()=>t.hide()}),t.content]})}function je(){const e=(0,j.M)();var t;return void 0===(t=e.shown)&&(t=!0),(0,r.useEffect)((()=>(document.body.style.overflow=t?"hidden":"visible",()=>{document.body.style.overflow="visible"})),[t]),e.shouldRender?(0,c.jsx)(M,{header:(0,c.jsx)(Y,{}),primaryMenu:(0,c.jsx)(_e,{}),secondaryMenu:(0,c.jsx)(Te,{})}):null}const Ne={navbarHideable:"navbarHideable_m1mJ",navbarHidden:"navbarHidden_jGov"};function Le(e){return(0,c.jsx)("div",{role:"presentation",...e,className:(0,a.A)("navbar-sidebar__backdrop",e.className)})}function Re(e){let{children:t}=e;const{navbar:{hideOnScroll:n,style:o}}=(0,w.p)(),i=(0,j.M)(),{navbarRef:l,isNavbarVisible:d}=function(e){const[t,n]=(0,r.useState)(e),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),i=(0,r.useCallback)((e=>{null!==e&&(o.current=e.getBoundingClientRect().height)}),[]);return(0,N.Mq)(((t,r)=>{let{scrollY:i}=t;if(!e)return;if(i=l?n(!1):i+u{if(!e)return;const r=t.location.hash;if(r?document.getElementById(r.substring(1)):void 0)return a.current=!0,void n(!1);n(!0)})),{navbarRef:i,isNavbarVisible:t}}(n);return(0,c.jsxs)("nav",{ref:l,"aria-label":(0,s.T)({id:"theme.NavBar.navAriaLabel",message:"Main",description:"The ARIA label for the main navigation"}),className:(0,a.A)("navbar","navbar--fixed-top",n&&[Ne.navbarHideable,!d&&Ne.navbarHidden],{"navbar--dark":"dark"===o,"navbar--primary":"primary"===o,"navbar-sidebar--show":i.shown}),children:[t,(0,c.jsx)(Le,{onClick:i.toggle}),(0,c.jsx)(je,{})]})}var Pe=n(440);const Oe={errorBoundaryError:"errorBoundaryError_a6uf",errorBoundaryFallback:"errorBoundaryFallback_VBag"};function De(e){return(0,c.jsx)("button",{type:"button",...e,children:(0,c.jsx)(s.A,{id:"theme.ErrorPageContent.tryAgain",description:"The label of the button to try again rendering when the React error boundary captures an error",children:"Try again"})})}function Ie(e){let{error:t}=e;const n=(0,Pe.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,c.jsx)("p",{className:Oe.errorBoundaryError,children:n})}class Me extends r.Component{componentDidCatch(e,t){throw this.props.onError(e,t)}render(){return this.props.children}}const Fe="right";function ze(e){let{width:t=30,height:n=30,className:r,...a}=e;return(0,c.jsx)("svg",{className:r,width:t,height:n,viewBox:"0 0 30 30","aria-hidden":"true",...a,children:(0,c.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"})})}function Be(){const{toggle:e,shown:t}=(0,j.M)();return(0,c.jsx)("button",{onClick:e,"aria-label":(0,s.T)({id:"theme.docs.sidebar.toggleSidebarButtonAriaLabel",message:"Toggle navigation bar",description:"The ARIA label for hamburger menu button of mobile navigation"}),"aria-expanded":t,className:"navbar__toggle clean-btn",type:"button",children:(0,c.jsx)(ze,{})})}const $e={colorModeToggle:"colorModeToggle_DEke"};function Ue(e){let{items:t}=e;return(0,c.jsx)(c.Fragment,{children:t.map(((e,t)=>(0,c.jsx)(Me,{onError:t=>new Error(`A theme navbar item failed to render.\nPlease double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:\n${JSON.stringify(e,null,2)}`,{cause:t}),children:(0,c.jsx)(Ce,{...e})},t)))})}function qe(e){let{left:t,right:n}=e;return(0,c.jsxs)("div",{className:"navbar__inner",children:[(0,c.jsx)("div",{className:"navbar__items",children:t}),(0,c.jsx)("div",{className:"navbar__items navbar__items--right",children:n})]})}function He(){const e=(0,j.M)(),t=(0,w.p)().navbar.items,[n,r]=function(e){function t(e){return"left"===(e.position??Fe)}return[e.filter(t),e.filter((e=>!t(e)))]}(t),a=t.find((e=>"search"===e.type));return(0,c.jsx)(qe,{left:(0,c.jsxs)(c.Fragment,{children:[!e.disabled&&(0,c.jsx)(Be,{}),(0,c.jsx)(Q,{}),(0,c.jsx)(Ue,{items:n})]}),right:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Ue,{items:r}),(0,c.jsx)(V,{className:$e.colorModeToggle}),!a&&(0,c.jsx)(ve,{children:(0,c.jsx)(ye.A,{})})]})})}function Ge(){return(0,c.jsx)(Re,{children:(0,c.jsx)(He,{})})}function Ve(e){let{item:t}=e;const{to:n,href:r,label:a,prependBaseUrlToHref:o,...i}=t,l=(0,X.Ay)(n),s=(0,X.Ay)(r,{forcePrependBaseUrl:!0});return(0,c.jsxs)(Z.A,{className:"footer__link-item",...r?{href:o?s:r}:{to:l},...i,children:[a,r&&!(0,J.A)(r)&&(0,c.jsx)(te.A,{})]})}function We(e){let{item:t}=e;return t.html?(0,c.jsx)("li",{className:"footer__item",dangerouslySetInnerHTML:{__html:t.html}}):(0,c.jsx)("li",{className:"footer__item",children:(0,c.jsx)(Ve,{item:t})},t.href??t.to)}function Qe(e){let{column:t}=e;return(0,c.jsxs)("div",{className:"col footer__col",children:[(0,c.jsx)("div",{className:"footer__title",children:t.title}),(0,c.jsx)("ul",{className:"footer__items clean-list",children:t.items.map(((e,t)=>(0,c.jsx)(We,{item:e},t)))})]})}function Ke(e){let{columns:t}=e;return(0,c.jsx)("div",{className:"row footer__links",children:t.map(((e,t)=>(0,c.jsx)(Qe,{column:e},t)))})}function Ye(){return(0,c.jsx)("span",{className:"footer__link-separator",children:"\xb7"})}function Ze(e){let{item:t}=e;return t.html?(0,c.jsx)("span",{className:"footer__link-item",dangerouslySetInnerHTML:{__html:t.html}}):(0,c.jsx)(Ve,{item:t})}function Xe(e){let{links:t}=e;return(0,c.jsx)("div",{className:"footer__links text--center",children:(0,c.jsx)("div",{className:"footer__links",children:t.map(((e,n)=>(0,c.jsxs)(r.Fragment,{children:[(0,c.jsx)(Ze,{item:e}),t.length!==n+1&&(0,c.jsx)(Ye,{})]},n)))})})}function Je(e){let{links:t}=e;return function(e){return"title"in e[0]}(t)?(0,c.jsx)(Ke,{columns:t}):(0,c.jsx)(Xe,{links:t})}var et=n(1122);const tt={footerLogoLink:"footerLogoLink_BH7S"};function nt(e){let{logo:t}=e;const{withBaseUrl:n}=(0,X.hH)(),r={light:n(t.src),dark:n(t.srcDark??t.src)};return(0,c.jsx)(et.A,{className:(0,a.A)("footer__logo",t.className),alt:t.alt,sources:r,width:t.width,height:t.height,style:t.style})}function rt(e){let{logo:t}=e;return t.href?(0,c.jsx)(Z.A,{href:t.href,className:tt.footerLogoLink,target:t.target,children:(0,c.jsx)(nt,{logo:t})}):(0,c.jsx)(nt,{logo:t})}function at(e){let{copyright:t}=e;return(0,c.jsx)("div",{className:"footer__copyright",dangerouslySetInnerHTML:{__html:t}})}function ot(e){let{style:t,links:n,logo:r,copyright:o}=e;return(0,c.jsx)("footer",{className:(0,a.A)("footer",{"footer--dark":"dark"===t}),children:(0,c.jsxs)("div",{className:"container container-fluid",children:[n,(r||o)&&(0,c.jsxs)("div",{className:"footer__bottom text--center",children:[r&&(0,c.jsx)("div",{className:"margin-bottom--sm",children:r}),o]})]})})}function it(){const{footer:e}=(0,w.p)();if(!e)return null;const{copyright:t,links:n,logo:r,style:a}=e;return(0,c.jsx)(ot,{style:a,links:n&&n.length>0&&(0,c.jsx)(Je,{links:n}),logo:r&&(0,c.jsx)(rt,{logo:r}),copyright:t&&(0,c.jsx)(at,{copyright:t})})}const lt=r.memo(it),st=(0,L.fM)([F.a,k.o,N.Tv,xe.VQ,i.Jx,function(e){let{children:t}=e;return(0,c.jsx)(R.y_,{children:(0,c.jsx)(j.e,{children:(0,c.jsx)(O,{children:t})})})}]);function ut(e){let{children:t}=e;return(0,c.jsx)(st,{children:t})}var ct=n(1107);function dt(e){let{error:t,tryAgain:n}=e;return(0,c.jsx)("main",{className:"container margin-vert--xl",children:(0,c.jsx)("div",{className:"row",children:(0,c.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,c.jsx)(ct.A,{as:"h1",className:"hero__title",children:(0,c.jsx)(s.A,{id:"theme.ErrorPageContent.title",description:"The title of the fallback page when the page crashed",children:"This page crashed."})}),(0,c.jsx)("div",{className:"margin-vert--lg",children:(0,c.jsx)(De,{onClick:n,className:"button button--primary shadow--lw"})}),(0,c.jsx)("hr",{}),(0,c.jsx)("div",{className:"margin-vert--md",children:(0,c.jsx)(Ie,{error:t})})]})})})}const pt={mainWrapper:"mainWrapper_z2l0"};function ft(e){const{children:t,noFooter:n,wrapperClassName:r,title:l,description:s}=e;return(0,y.J)(),(0,c.jsxs)(ut,{children:[(0,c.jsx)(i.be,{title:l,description:s}),(0,c.jsx)(v,{}),(0,c.jsx)(T,{}),(0,c.jsx)(Ge,{}),(0,c.jsx)("div",{id:d,className:(0,a.A)(g.G.wrapper.main,pt.mainWrapper,r),children:(0,c.jsx)(o.A,{fallback:e=>(0,c.jsx)(dt,{...e}),children:t})}),!n&&(0,c.jsx)(lt,{})]})}},3465:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});n(6540);var r=n(8774),a=n(6025),o=n(4586),i=n(6342),l=n(1122),s=n(4848);function u(e){let{logo:t,alt:n,imageClassName:r}=e;const o={light:(0,a.Ay)(t.src),dark:(0,a.Ay)(t.srcDark||t.src)},i=(0,s.jsx)(l.A,{className:t.className,sources:o,height:t.height,width:t.width,alt:n,style:t.style});return r?(0,s.jsx)("div",{className:r,children:i}):i}function c(e){const{siteConfig:{title:t}}=(0,o.A)(),{navbar:{title:n,logo:l}}=(0,i.p)(),{imageClassName:c,titleClassName:d,...p}=e,f=(0,a.Ay)(l?.href||"/"),m=n?"":t,h=l?.alt??m;return(0,s.jsxs)(r.A,{to:f,...p,...l?.target&&{target:l.target},children:[l&&(0,s.jsx)(u,{logo:l,alt:h,imageClassName:c}),null!=n&&(0,s.jsx)("b",{className:d,children:n})]})}},1463:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);var r=n(5260),a=n(4848);function o(e){let{locale:t,version:n,tag:o}=e;const i=t;return(0,a.jsxs)(r.A,{children:[t&&(0,a.jsx)("meta",{name:"docusaurus_locale",content:t}),n&&(0,a.jsx)("meta",{name:"docusaurus_version",content:n}),o&&(0,a.jsx)("meta",{name:"docusaurus_tag",content:o}),i&&(0,a.jsx)("meta",{name:"docsearch:language",content:i}),n&&(0,a.jsx)("meta",{name:"docsearch:version",content:n}),o&&(0,a.jsx)("meta",{name:"docsearch:docusaurus_tag",content:o})]})}},1122:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(6540),a=n(4164),o=n(2303),i=n(5293);const l={themedComponent:"themedComponent_mlkZ","themedComponent--light":"themedComponent--light_NVdE","themedComponent--dark":"themedComponent--dark_xIcU"};var s=n(4848);function u(e){let{className:t,children:n}=e;const u=(0,o.A)(),{colorMode:c}=(0,i.G)();return(0,s.jsx)(s.Fragment,{children:(u?"dark"===c?["dark"]:["light"]:["light","dark"]).map((e=>{const o=n({theme:e,className:(0,a.A)(t,l.themedComponent,l[`themedComponent--${e}`])});return(0,s.jsx)(r.Fragment,{children:o},e)}))})}function c(e){const{sources:t,className:n,alt:r,...a}=e;return(0,s.jsx)(u,{className:n,children:e=>{let{theme:n,className:o}=e;return(0,s.jsx)("img",{src:t[n],alt:r,className:o,...a})}})}},1422:(e,t,n)=>{"use strict";n.d(t,{N:()=>y,u:()=>u});var r=n(6540),a=n(8193),o=n(205),i=n(3109),l=n(4848);const s="ease-in-out";function u(e){let{initialState:t}=e;const[n,a]=(0,r.useState)(t??!1),o=(0,r.useCallback)((()=>{a((e=>!e))}),[]);return{collapsed:n,setCollapsed:a,toggleCollapsed:o}}const c={display:"none",overflow:"hidden",height:"0px"},d={display:"block",overflow:"visible",height:"auto"};function p(e,t){const n=t?c:d;e.style.display=n.display,e.style.overflow=n.overflow,e.style.height=n.height}function f(e){let{collapsibleRef:t,collapsed:n,animation:a}=e;const o=(0,r.useRef)(!1);(0,r.useEffect)((()=>{const e=t.current;function r(){const t=e.scrollHeight,n=a?.duration??function(e){if((0,i.O)())return 1;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}(t);return{transition:`height ${n}ms ${a?.easing??s}`,height:`${t}px`}}function l(){const t=r();e.style.transition=t.transition,e.style.height=t.height}if(!o.current)return p(e,n),void(o.current=!0);return e.style.willChange="height",function(){const t=requestAnimationFrame((()=>{n?(l(),requestAnimationFrame((()=>{e.style.height=c.height,e.style.overflow=c.overflow}))):(e.style.display="block",requestAnimationFrame((()=>{l()})))}));return()=>cancelAnimationFrame(t)}()}),[t,n,a])}function m(e){if(!a.A.canUseDOM)return e?c:d}function h(e){let{as:t="div",collapsed:n,children:a,animation:o,onCollapseTransitionEnd:i,className:s,disableSSRStyle:u}=e;const c=(0,r.useRef)(null);return f({collapsibleRef:c,collapsed:n,animation:o}),(0,l.jsx)(t,{ref:c,style:u?void 0:m(n),onTransitionEnd:e=>{"height"===e.propertyName&&(p(c.current,n),i?.(n))},className:s,children:a})}function g(e){let{collapsed:t,...n}=e;const[a,i]=(0,r.useState)(!t),[s,u]=(0,r.useState)(t);return(0,o.A)((()=>{t||i(!0)}),[t]),(0,o.A)((()=>{a&&u(t)}),[a,t]),a?(0,l.jsx)(h,{...n,collapsed:s}):null}function y(e){let{lazy:t,...n}=e;const r=t?g:h;return(0,l.jsx)(r,{...n})}},5041:(e,t,n)=>{"use strict";n.d(t,{M:()=>h,o:()=>m});var r=n(6540),a=n(2303),o=n(679),i=n(9532),l=n(6342),s=n(4848);const u=(0,o.Wf)("docusaurus.announcement.dismiss"),c=(0,o.Wf)("docusaurus.announcement.id"),d=()=>"true"===u.get(),p=e=>u.set(String(e)),f=r.createContext(null);function m(e){let{children:t}=e;const n=function(){const{announcementBar:e}=(0,l.p)(),t=(0,a.A)(),[n,o]=(0,r.useState)((()=>!!t&&d()));(0,r.useEffect)((()=>{o(d())}),[]);const i=(0,r.useCallback)((()=>{p(!0),o(!0)}),[]);return(0,r.useEffect)((()=>{if(!e)return;const{id:t}=e;let n=c.get();"annoucement-bar"===n&&(n="announcement-bar");const r=t!==n;c.set(t),r&&p(!1),!r&&d()||o(!1)}),[e]),(0,r.useMemo)((()=>({isActive:!!e&&!n,close:i})),[e,n,i])}();return(0,s.jsx)(f.Provider,{value:n,children:t})}function h(){const e=(0,r.useContext)(f);if(!e)throw new i.dV("AnnouncementBarProvider");return e}},5293:(e,t,n)=>{"use strict";n.d(t,{G:()=>y,a:()=>g});var r=n(6540),a=n(8193),o=n(9532),i=n(679),l=n(6342),s=n(4848);const u=r.createContext(void 0),c="theme",d=(0,i.Wf)(c),p={light:"light",dark:"dark"},f=e=>e===p.dark?p.dark:p.light,m=e=>a.A.canUseDOM?f(document.documentElement.getAttribute("data-theme")):f(e),h=e=>{d.set(f(e))};function g(e){let{children:t}=e;const n=function(){const{colorMode:{defaultMode:e,disableSwitch:t,respectPrefersColorScheme:n}}=(0,l.p)(),[a,o]=(0,r.useState)(m(e));(0,r.useEffect)((()=>{t&&d.del()}),[t]);const i=(0,r.useCallback)((function(t,r){void 0===r&&(r={});const{persist:a=!0}=r;t?(o(t),a&&h(t)):(o(n?window.matchMedia("(prefers-color-scheme: dark)").matches?p.dark:p.light:e),d.del())}),[n,e]);(0,r.useEffect)((()=>{document.documentElement.setAttribute("data-theme",f(a))}),[a]),(0,r.useEffect)((()=>{if(t)return;const e=e=>{if(e.key!==c)return;const t=d.get();null!==t&&i(f(t))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[t,i]);const s=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(t&&!n)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{window.matchMedia("print").matches||s.current?s.current=window.matchMedia("print").matches:i(null)};return e.addListener(r),()=>e.removeListener(r)}),[i,t,n]),(0,r.useMemo)((()=>({colorMode:a,setColorMode:i,get isDarkTheme(){return a===p.dark},setLightTheme(){i(p.light)},setDarkTheme(){i(p.dark)}})),[a,i])}();return(0,s.jsx)(u.Provider,{value:n,children:t})}function y(){const e=(0,r.useContext)(u);if(null==e)throw new o.dV("ColorModeProvider","Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.");return e}},5597:(e,t,n)=>{"use strict";n.d(t,{VQ:()=>y,g1:()=>v});var r=n(6540),a=n(4070),o=n(7065),i=n(6342),l=n(1754),s=n(9532),u=n(679),c=n(4848);const d=e=>`docs-preferred-version-${e}`,p={save:(e,t,n)=>{(0,u.Wf)(d(e),{persistence:t}).set(n)},read:(e,t)=>(0,u.Wf)(d(e),{persistence:t}).get(),clear:(e,t)=>{(0,u.Wf)(d(e),{persistence:t}).del()}},f=e=>Object.fromEntries(e.map((e=>[e,{preferredVersionName:null}])));const m=r.createContext(null);function h(){const e=(0,a.Gy)(),t=(0,i.p)().docs.versionPersistence,n=(0,r.useMemo)((()=>Object.keys(e)),[e]),[o,l]=(0,r.useState)((()=>f(n)));(0,r.useEffect)((()=>{l(function(e){let{pluginIds:t,versionPersistence:n,allDocsData:r}=e;function a(e){const t=p.read(e,n);return r[e].versions.some((e=>e.name===t))?{preferredVersionName:t}:(p.clear(e,n),{preferredVersionName:null})}return Object.fromEntries(t.map((e=>[e,a(e)])))}({allDocsData:e,versionPersistence:t,pluginIds:n}))}),[e,t,n]);return[o,(0,r.useMemo)((()=>({savePreferredVersion:function(e,n){p.save(e,t,n),l((t=>({...t,[e]:{preferredVersionName:n}})))}})),[t])]}function g(e){let{children:t}=e;const n=h();return(0,c.jsx)(m.Provider,{value:n,children:t})}function y(e){let{children:t}=e;return l.C5?(0,c.jsx)(g,{children:t}):(0,c.jsx)(c.Fragment,{children:t})}function b(){const e=(0,r.useContext)(m);if(!e)throw new s.dV("DocsPreferredVersionContextProvider");return e}function v(e){void 0===e&&(e=o.W);const t=(0,a.ht)(e),[n,i]=b(),{preferredVersionName:l}=n[e];return{preferredVersion:t.versions.find((e=>e.name===l))??null,savePreferredVersionName:(0,r.useCallback)((t=>{i.savePreferredVersion(e,t)}),[i,e])}}},6588:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,t:()=>u});var r=n(6540),a=n(9532),o=n(4848);const i=Symbol("EmptyContext"),l=r.createContext(i);function s(e){let{children:t,name:n,items:a}=e;const i=(0,r.useMemo)((()=>n&&a?{name:n,items:a}:null),[n,a]);return(0,o.jsx)(l.Provider,{value:i,children:t})}function u(){const e=(0,r.useContext)(l);if(e===i)throw new a.dV("DocsSidebarProvider");return e}},2252:(e,t,n)=>{"use strict";n.d(t,{n:()=>l,r:()=>s});var r=n(6540),a=n(9532),o=n(4848);const i=r.createContext(null);function l(e){let{children:t,version:n}=e;return(0,o.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(null===e)throw new a.dV("DocsVersionProvider");return e}},9876:(e,t,n)=>{"use strict";n.d(t,{e:()=>f,M:()=>m});var r=n(6540),a=n(5600),o=n(4581),i=n(6347),l=n(9532);function s(e){!function(e){const t=(0,i.W6)(),n=(0,l._q)(e);(0,r.useEffect)((()=>t.block(((e,t)=>n(e,t)))),[t,n])}(((t,n)=>{if("POP"===n)return e(t,n)}))}var u=n(6342),c=n(4848);const d=r.createContext(void 0);function p(){const e=function(){const e=(0,a.YL)(),{items:t}=(0,u.p)().navbar;return 0===t.length&&!e.component}(),t=(0,o.l)(),n=!e&&"mobile"===t,[i,l]=(0,r.useState)(!1);s((()=>{if(i)return l(!1),!1}));const c=(0,r.useCallback)((()=>{l((e=>!e))}),[]);return(0,r.useEffect)((()=>{"desktop"===t&&l(!1)}),[t]),(0,r.useMemo)((()=>({disabled:e,shouldRender:n,toggle:c,shown:i})),[e,n,c,i])}function f(e){let{children:t}=e;const n=p();return(0,c.jsx)(d.Provider,{value:n,children:t})}function m(){const e=r.useContext(d);if(void 0===e)throw new l.dV("NavbarMobileSidebarProvider");return e}},5600:(e,t,n)=>{"use strict";n.d(t,{GX:()=>u,YL:()=>s,y_:()=>l});var r=n(6540),a=n(9532),o=n(4848);const i=r.createContext(null);function l(e){let{children:t}=e;const n=(0,r.useState)({component:null,props:null});return(0,o.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(!e)throw new a.dV("NavbarSecondaryMenuContentProvider");return e[0]}function u(e){let{component:t,props:n}=e;const o=(0,r.useContext)(i);if(!o)throw new a.dV("NavbarSecondaryMenuContentProvider");const[,l]=o,s=(0,a.Be)(n);return(0,r.useEffect)((()=>{l({component:t,props:s})}),[l,t,s]),(0,r.useEffect)((()=>()=>l({component:null,props:null})),[l]),null}},4090:(e,t,n)=>{"use strict";n.d(t,{w:()=>a,J:()=>o});var r=n(6540);const a="navigation-with-keyboard";function o(){(0,r.useEffect)((()=>{function e(e){"keydown"===e.type&&"Tab"===e.key&&document.body.classList.add(a),"mousedown"===e.type&&document.body.classList.remove(a)}return document.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{document.body.classList.remove(a),document.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}}),[])}},4581:(e,t,n)=>{"use strict";n.d(t,{l:()=>l});var r=n(6540),a=n(8193);const o={desktop:"desktop",mobile:"mobile",ssr:"ssr"},i=996;function l(e){let{desktopBreakpoint:t=i}=void 0===e?{}:e;const[n,l]=(0,r.useState)((()=>"ssr"));return(0,r.useEffect)((()=>{function e(){l(function(e){if(!a.A.canUseDOM)throw new Error("getWindowSize() should only be called after React hydration");return window.innerWidth>e?o.desktop:o.mobile}(t))}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[t]),n}},7559:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});const r={page:{blogListPage:"blog-list-page",blogPostPage:"blog-post-page",blogTagsListPage:"blog-tags-list-page",blogTagPostListPage:"blog-tags-post-list-page",docsDocPage:"docs-doc-page",docsTagsListPage:"docs-tags-list-page",docsTagDocListPage:"docs-tags-doc-list-page",mdxPage:"mdx-page"},wrapper:{main:"main-wrapper",blogPages:"blog-wrapper",docsPages:"docs-wrapper",mdxPages:"mdx-wrapper"},common:{editThisPage:"theme-edit-this-page",lastUpdated:"theme-last-updated",backToTopButton:"theme-back-to-top-button",codeBlock:"theme-code-block",admonition:"theme-admonition",unlistedBanner:"theme-unlisted-banner",admonitionType:e=>`theme-admonition-${e}`},layout:{},docs:{docVersionBanner:"theme-doc-version-banner",docVersionBadge:"theme-doc-version-badge",docBreadcrumbs:"theme-doc-breadcrumbs",docMarkdown:"theme-doc-markdown",docTocMobile:"theme-doc-toc-mobile",docTocDesktop:"theme-doc-toc-desktop",docFooter:"theme-doc-footer",docFooterTagsRow:"theme-doc-footer-tags-row",docFooterEditMetaRow:"theme-doc-footer-edit-meta-row",docSidebarContainer:"theme-doc-sidebar-container",docSidebarMenu:"theme-doc-sidebar-menu",docSidebarItemCategory:"theme-doc-sidebar-item-category",docSidebarItemLink:"theme-doc-sidebar-item-link",docSidebarItemCategoryLevel:e=>`theme-doc-sidebar-item-category-level-${e}`,docSidebarItemLinkLevel:e=>`theme-doc-sidebar-item-link-level-${e}`},blog:{blogFooterTagsRow:"theme-blog-footer-tags-row",blogFooterEditMetaRow:"theme-blog-footer-edit-meta-row"},pages:{pageFooterEditMetaRow:"theme-pages-footer-edit-meta-row"}}},3109:(e,t,n)=>{"use strict";function r(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}n.d(t,{O:()=>r})},1754:(e,t,n)=>{"use strict";n.d(t,{d1:()=>A,Nr:()=>m,w8:()=>b,C5:()=>p,$S:()=>h,cC:()=>f,B5:()=>_,Vd:()=>S,QB:()=>C,fW:()=>E,OF:()=>x,Y:()=>w});var r=n(6540),a=n(6347),o=n(2831),i=n(4070),l=n(5597),s=n(2252),u=n(6588);function c(e){return Array.from(new Set(e))}var d=n(9169);const p=!!i.Gy;function f(e){const t=(0,s.r)();if(!e)return;const n=t.docs[e];if(!n)throw new Error(`no version doc found by id=${e}`);return n}function m(e){return"link"!==e.type||e.unlisted?"category"===e.type?function(e){if(e.href&&!e.linkUnlisted)return e.href;for(const t of e.items){const e=m(t);if(e)return e}}(e):void 0:e.href}function h(){const{pathname:e}=(0,a.zy)(),t=(0,u.t)();if(!t)throw new Error("Unexpected: cant find current sidebar in context");const n=k({sidebarItems:t.items,pathname:e,onlyCategories:!0}).slice(-1)[0];if(!n)throw new Error(`${e} is not associated with a category. useCurrentSidebarCategory() should only be used on category index pages.`);return n}const g=(e,t)=>void 0!==e&&(0,d.ys)(e,t),y=(e,t)=>e.some((e=>b(e,t)));function b(e,t){return"link"===e.type?g(e.href,t):"category"===e.type&&(g(e.href,t)||y(e.items,t))}function v(e,t){switch(e.type){case"category":return b(e,t)||e.items.some((e=>v(e,t)));case"link":return!e.unlisted||b(e,t);default:return!0}}function w(e,t){return(0,r.useMemo)((()=>e.filter((e=>v(e,t)))),[e,t])}function k(e){let{sidebarItems:t,pathname:n,onlyCategories:r=!1}=e;const a=[];return function e(t){for(const o of t)if("category"===o.type&&((0,d.ys)(o.href,n)||e(o.items))||"link"===o.type&&(0,d.ys)(o.href,n)){return r&&"category"!==o.type||a.unshift(o),!0}return!1}(t),a}function x(){const e=(0,u.t)(),{pathname:t}=(0,a.zy)(),n=(0,i.vT)()?.pluginData.breadcrumbs;return!1!==n&&e?k({sidebarItems:e.items,pathname:t}):null}function S(e){const{activeVersion:t}=(0,i.zK)(e),{preferredVersion:n}=(0,l.g1)(e),a=(0,i.r7)(e);return(0,r.useMemo)((()=>c([t,n,a].filter(Boolean))),[t,n,a])}function E(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.sidebars?Object.entries(e.sidebars):[])),r=t.find((t=>t[0]===e));if(!r)throw new Error(`Can't find any sidebar with id "${e}" in version${n.length>1?"s":""} ${n.map((e=>e.name)).join(", ")}".\nAvailable sidebar ids are:\n- ${t.map((e=>e[0])).join("\n- ")}`);return r[1]}),[e,n])}function C(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.docs)),r=t.find((t=>t.id===e));if(!r){if(n.flatMap((e=>e.draftIds)).includes(e))return null;throw new Error(`Couldn't find any doc with id "${e}" in version${n.length>1?"s":""} "${n.map((e=>e.name)).join(", ")}".\nAvailable doc ids are:\n- ${c(t.map((e=>e.id))).join("\n- ")}`)}return r}),[e,n])}function _(e){let{route:t}=e;const n=(0,a.zy)(),r=(0,s.r)(),i=t.routes,l=i.find((e=>(0,a.B6)(n.pathname,e)));if(!l)return null;const u=l.sidebar,c=u?r.docsSidebars[u]:void 0;return{docElement:(0,o.v)(i),sidebarName:u,sidebarItems:c}}function A(e){return e.filter((e=>!("category"===e.type||"link"===e.type)||!!m(e)))}},1213:(e,t,n)=>{"use strict";n.d(t,{e3:()=>p,be:()=>c,Jx:()=>f});var r=n(6540),a=n(4164),o=n(5260),i=n(6803),l=n(6025),s=n(4586);var u=n(4848);function c(e){let{title:t,description:n,keywords:r,image:a,children:i}=e;const c=function(e){const{siteConfig:t}=(0,s.A)(),{title:n,titleDelimiter:r}=t;return e?.trim().length?`${e.trim()} ${r} ${n}`:n}(t),{withBaseUrl:d}=(0,l.hH)(),p=a?d(a,{absolute:!0}):void 0;return(0,u.jsxs)(o.A,{children:[t&&(0,u.jsx)("title",{children:c}),t&&(0,u.jsx)("meta",{property:"og:title",content:c}),n&&(0,u.jsx)("meta",{name:"description",content:n}),n&&(0,u.jsx)("meta",{property:"og:description",content:n}),r&&(0,u.jsx)("meta",{name:"keywords",content:Array.isArray(r)?r.join(","):r}),p&&(0,u.jsx)("meta",{property:"og:image",content:p}),p&&(0,u.jsx)("meta",{name:"twitter:image",content:p}),i]})}const d=r.createContext(void 0);function p(e){let{className:t,children:n}=e;const i=r.useContext(d),l=(0,a.A)(i,t);return(0,u.jsxs)(d.Provider,{value:l,children:[(0,u.jsx)(o.A,{children:(0,u.jsx)("html",{className:l})}),n]})}function f(e){let{children:t}=e;const n=(0,i.A)(),r=`plugin-${n.plugin.name.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi,"")}`;const o=`plugin-id-${n.plugin.id}`;return(0,u.jsx)(p,{className:(0,a.A)(r,o),children:t})}},9532:(e,t,n)=>{"use strict";n.d(t,{Be:()=>u,ZC:()=>l,_q:()=>i,dV:()=>s,fM:()=>c});var r=n(6540),a=n(205),o=n(4848);function i(e){const t=(0,r.useRef)(e);return(0,a.A)((()=>{t.current=e}),[e]),(0,r.useCallback)((function(){return t.current(...arguments)}),[])}function l(e){const t=(0,r.useRef)();return(0,a.A)((()=>{t.current=e})),t.current}class s extends Error{constructor(e,t){super(),this.name="ReactContextError",this.message=`Hook ${this.stack?.split("\n")[1]?.match(/at (?:\w+\.)?(?\w+)/)?.groups.name??""} is called outside the <${e}>. ${t??""}`}}function u(e){const t=Object.entries(e);return t.sort(((e,t)=>e[0].localeCompare(t[0]))),(0,r.useMemo)((()=>e),t.flat())}function c(e){return t=>{let{children:n}=t;return(0,o.jsx)(o.Fragment,{children:e.reduceRight(((e,t)=>(0,o.jsx)(t,{children:e})),n)})}}},9169:(e,t,n)=>{"use strict";n.d(t,{Dt:()=>l,ys:()=>i});var r=n(6540),a=n(8328),o=n(4586);function i(e,t){const n=e=>(!e||e.endsWith("/")?e:`${e}/`)?.toLowerCase();return n(e)===n(t)}function l(){const{baseUrl:e}=(0,o.A)().siteConfig;return(0,r.useMemo)((()=>function(e){let{baseUrl:t,routes:n}=e;function r(e){return e.path===t&&!0===e.exact}function a(e){return e.path===t&&!e.exact}return function e(t){if(0===t.length)return;return t.find(r)||e(t.filter(a).flatMap((e=>e.routes??[])))}(n)}({routes:a.A,baseUrl:e})),[e])}},3104:(e,t,n)=>{"use strict";n.d(t,{Mq:()=>p,Tv:()=>u,gk:()=>f});var r=n(6540),a=n(8193),o=n(2303),i=(n(205),n(9532)),l=n(4848);const s=r.createContext(void 0);function u(e){let{children:t}=e;const n=function(){const e=(0,r.useRef)(!0);return(0,r.useMemo)((()=>({scrollEventsEnabledRef:e,enableScrollEvents:()=>{e.current=!0},disableScrollEvents:()=>{e.current=!1}})),[])}();return(0,l.jsx)(s.Provider,{value:n,children:t})}function c(){const e=(0,r.useContext)(s);if(null==e)throw new i.dV("ScrollControllerProvider");return e}const d=()=>a.A.canUseDOM?{scrollX:window.pageXOffset,scrollY:window.pageYOffset}:null;function p(e,t){void 0===t&&(t=[]);const{scrollEventsEnabledRef:n}=c(),a=(0,r.useRef)(d()),o=(0,i._q)(e);(0,r.useEffect)((()=>{const e=()=>{if(!n.current)return;const e=d();o(e,a.current),a.current=e},t={passive:!0};return e(),window.addEventListener("scroll",e,t),()=>window.removeEventListener("scroll",e,t)}),[o,n,...t])}function f(){const e=(0,r.useRef)(null),t=(0,o.A)()&&"smooth"===getComputedStyle(document.documentElement).scrollBehavior;return{startScroll:n=>{e.current=t?function(e){return window.scrollTo({top:e,behavior:"smooth"}),()=>{}}(n):function(e){let t=null;const n=document.documentElement.scrollTop>e;return function r(){const a=document.documentElement.scrollTop;(n&&a>e||!n&&at&&cancelAnimationFrame(t)}(n)},cancelScroll:()=>e.current?.()}}},2967:(e,t,n)=>{"use strict";n.d(t,{Cy:()=>r,tU:()=>a});n(4586);const r="default";function a(e,t){return`docs-${e}-${t}`}},679:(e,t,n)=>{"use strict";n.d(t,{Wf:()=>u});n(6540);const r=JSON.parse('{"N":"localStorage","M":""}'),a=r.N;function o(e){let{key:t,oldValue:n,newValue:r,storage:a}=e;if(n===r)return;const o=document.createEvent("StorageEvent");o.initStorageEvent("storage",!1,!1,t,n,r,window.location.href,a),window.dispatchEvent(o)}function i(e){if(void 0===e&&(e=a),"undefined"==typeof window)throw new Error("Browser storage is not available on Node.js/Docusaurus SSR process.");if("none"===e)return null;try{return window[e]}catch(n){return t=n,l||(console.warn("Docusaurus browser storage is not available.\nPossible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.",t),l=!0),null}var t}let l=!1;const s={get:()=>null,set:()=>{},del:()=>{},listen:()=>()=>{}};function u(e,t){const n=`${e}${r.M}`;if("undefined"==typeof window)return function(e){function t(){throw new Error(`Illegal storage API usage for storage key "${e}".\nDocusaurus storage APIs are not supposed to be called on the server-rendering process.\nPlease only call storage APIs in effects and event handlers.`)}return{get:t,set:t,del:t,listen:t}}(n);const a=i(t?.persistence);return null===a?s:{get:()=>{try{return a.getItem(n)}catch(e){return console.error(`Docusaurus storage error, can't get key=${n}`,e),null}},set:e=>{try{const t=a.getItem(n);a.setItem(n,e),o({key:n,oldValue:t,newValue:e,storage:a})}catch(t){console.error(`Docusaurus storage error, can't set ${n}=${e}`,t)}},del:()=>{try{const e=a.getItem(n);a.removeItem(n),o({key:n,oldValue:e,newValue:null,storage:a})}catch(e){console.error(`Docusaurus storage error, can't delete key=${n}`,e)}},listen:e=>{try{const t=t=>{t.storageArea===a&&t.key===n&&e(t)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}catch(t){return console.error(`Docusaurus storage error, can't listen for changes of key=${n}`,t),()=>{}}}}}},2131:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});var r=n(4586),a=n(6347),o=n(440);function i(){const{siteConfig:{baseUrl:e,url:t,trailingSlash:n},i18n:{defaultLocale:i,currentLocale:l}}=(0,r.A)(),{pathname:s}=(0,a.zy)(),u=(0,o.applyTrailingSlash)(s,{trailingSlash:n,baseUrl:e}),c=l===i?e:e.replace(`/${l}/`,"/"),d=u.replace(e,"");return{createUrl:function(e){let{locale:n,fullyQualified:r}=e;return`${r?t:""}${function(e){return e===i?`${c}`:`${c}${e}/`}(n)}${d}`}}}},5062:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(6540),a=n(6347),o=n(9532);function i(e){const t=(0,a.zy)(),n=(0,o.ZC)(t),i=(0,o._q)(e);(0,r.useEffect)((()=>{n&&t!==n&&i({location:t,previousLocation:n})}),[i,t,n])}},6342:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var r=n(4586);function a(){return(0,r.A)().siteConfig.themeConfig}},2983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeTrailingSlash=t.addLeadingSlash=t.addTrailingSlash=void 0;const r=n(2566);function a(e){return e.endsWith("/")?e:`${e}/`}function o(e){return(0,r.removeSuffix)(e,"/")}t.addTrailingSlash=a,t.default=function(e,t){const{trailingSlash:n,baseUrl:r}=t;if(e.startsWith("#"))return e;if(void 0===n)return e;const[i]=e.split(/[#?]/),l="/"===i||i===r?i:(s=i,n?a(s):o(s));var s;return e.replace(i,l)},t.addLeadingSlash=function(e){return(0,r.addPrefix)(e,"/")},t.removeTrailingSlash=o},253:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=void 0,t.getErrorCausalChain=function e(t){return t.cause?[t,...e(t.cause)]:[t]}},440:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=t.removePrefix=t.addSuffix=t.removeSuffix=t.addPrefix=t.removeTrailingSlash=t.addLeadingSlash=t.addTrailingSlash=t.applyTrailingSlash=t.blogPostContainerID=void 0,t.blogPostContainerID="__blog-post-container";var a=n(2983);Object.defineProperty(t,"applyTrailingSlash",{enumerable:!0,get:function(){return r(a).default}}),Object.defineProperty(t,"addTrailingSlash",{enumerable:!0,get:function(){return a.addTrailingSlash}}),Object.defineProperty(t,"addLeadingSlash",{enumerable:!0,get:function(){return a.addLeadingSlash}}),Object.defineProperty(t,"removeTrailingSlash",{enumerable:!0,get:function(){return a.removeTrailingSlash}});var o=n(2566);Object.defineProperty(t,"addPrefix",{enumerable:!0,get:function(){return o.addPrefix}}),Object.defineProperty(t,"removeSuffix",{enumerable:!0,get:function(){return o.removeSuffix}}),Object.defineProperty(t,"addSuffix",{enumerable:!0,get:function(){return o.addSuffix}}),Object.defineProperty(t,"removePrefix",{enumerable:!0,get:function(){return o.removePrefix}});var i=n(253);Object.defineProperty(t,"getErrorCausalChain",{enumerable:!0,get:function(){return i.getErrorCausalChain}})},2566:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removePrefix=t.addSuffix=t.removeSuffix=t.addPrefix=void 0,t.addPrefix=function(e,t){return e.startsWith(t)?e:`${t}${e}`},t.removeSuffix=function(e,t){return""===t?e:e.endsWith(t)?e.slice(0,-t.length):e},t.addSuffix=function(e,t){return e.endsWith(t)?e:`${e}${t}`},t.removePrefix=function(e,t){return e.startsWith(t)?e.slice(t.length):e}},1513:(e,t,n)=>{"use strict";n.d(t,{zR:()=>w,TM:()=>_,yJ:()=>f,sC:()=>T,AO:()=>p});var r=n(8168);function a(e){return"/"===e.charAt(0)}function o(e,t){for(var n=t,r=n+1,a=e.length;r=0;p--){var f=i[p];"."===f?o(i,p):".."===f?(o(i,p),d++):d&&(o(i,p),d--)}if(!u)for(;d--;d)i.unshift("..");!u||""===i[0]||i[0]&&a(i[0])||i.unshift("");var m=i.join("/");return n&&"/"!==m.substr(-1)&&(m+="/"),m};var l=n(1561);function s(e){return"/"===e.charAt(0)?e:"/"+e}function u(e){return"/"===e.charAt(0)?e.substr(1):e}function c(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function d(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function p(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function f(e,t,n,a){var o;"string"==typeof e?(o=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),o.state=t):(void 0===(o=(0,r.A)({},e)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(l){throw l instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):l}return n&&(o.key=n),a?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=i(o.pathname,a.pathname)):o.pathname=a.pathname:o.pathname||(o.pathname="/"),o}function m(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,a):a(!0):a(!1!==o)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,a):n.push(a),d({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",a=f(e,t,h(),w.location);c.confirmTransitionTo(a,r,n,(function(e){e&&(w.entries[w.index]=a,d({action:r,location:a}))}))},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(e){var t=w.index+e;return t>=0&&t{"use strict";var r=n(4363),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},l={};function s(e){return r.isMemo(e)?i:l[e.$$typeof]||a}l[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l[r.Memo]=i;var u=Object.defineProperty,c=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(m){var a=f(n);a&&a!==m&&e(t,a,r)}var i=c(n);d&&(i=i.concat(d(n)));for(var l=s(t),h=s(n),g=0;g{"use strict";e.exports=function(e,t,n,r,a,o,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,a,o,i,l],c=0;(s=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}},4634:e=>{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},119:(e,t,n)=>{"use strict";n.r(t)},1043:(e,t,n)=>{"use strict";n.r(t)},5947:function(e,t,n){var r,a;r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function a(e,t,n){return en?n:e}function o(e){return 100*(-1+e)}function i(e,t,n){var a;return(a="translate3d"===r.positionUsing?{transform:"translate3d("+o(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+o(e)+"%,0)"}:{"margin-left":o(e)+"%"}).transition="all "+t+"ms "+n,a}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=a(e,r.minimum,1),n.status=1===e?null:e;var o=n.render(!t),u=o.querySelector(r.barSelector),c=r.speed,d=r.easing;return o.offsetWidth,l((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(u,i(e,c,d)),1===e?(s(o,{transition:"none",opacity:1}),o.offsetWidth,setTimeout((function(){s(o,{transition:"all "+c+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),c)}),c)):setTimeout(t,c)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*a(Math.random()*t,.1,.95)),t=a(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");c(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var a,i=t.querySelector(r.barSelector),l=e?"-100":o(n.status||0),u=document.querySelector(r.parent);return s(i,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(a=t.querySelector(r.spinnerSelector))&&f(a),u!=document.body&&c(u,"nprogress-custom-parent"),u.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&f(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var l=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),s=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,a=e.length,o=t.charAt(0).toUpperCase()+t.slice(1);a--;)if((r=e[a]+o)in n)return r;return t}function a(e){return e=n(e),t[e]||(t[e]=r(e))}function o(e,t,n){t=a(t),e.style[t]=n}return function(e,t){var n,r,a=arguments;if(2==a.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&o(e,n,r);else o(e,a[1],a[2])}}();function u(e,t){return("string"==typeof e?e:p(e)).indexOf(" "+t+" ")>=0}function c(e,t){var n=p(e),r=n+t;u(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=p(e);u(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function p(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function f(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n},void 0===(a="function"==typeof r?r.call(t,n,t,e):r)||(e.exports=a)},5302:(e,t,n)=>{var r=n(4634);e.exports=f,e.exports.parse=o,e.exports.compile=function(e,t){return l(o(e,t),t)},e.exports.tokensToFunction=l,e.exports.tokensToRegExp=p;var a=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function o(e,t){for(var n,r=[],o=0,i=0,l="",c=t&&t.delimiter||"/";null!=(n=a.exec(e));){var d=n[0],p=n[1],f=n.index;if(l+=e.slice(i,f),i=f+d.length,p)l+=p[1];else{var m=e[i],h=n[2],g=n[3],y=n[4],b=n[5],v=n[6],w=n[7];l&&(r.push(l),l="");var k=null!=h&&null!=m&&m!==h,x="+"===v||"*"===v,S="?"===v||"*"===v,E=n[2]||c,C=y||b;r.push({name:g||o++,prefix:h||"",delimiter:E,optional:S,repeat:x,partial:k,asterisk:!!w,pattern:C?u(C):w?".*":"[^"+s(E)+"]+?"})}}return i{e.exports&&(e.exports={core:{meta:{path:"components/prism-core.js",option:"mandatory"},core:"Core"},themes:{meta:{path:"themes/{id}.css",link:"index.html?theme={id}",exclusive:!0},prism:{title:"Default",option:"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{title:"Okaidia",owner:"ocodia"},"prism-twilight":{title:"Twilight",owner:"remybach"},"prism-coy":{title:"Coy",owner:"tshedor"},"prism-solarizedlight":{title:"Solarized Light",owner:"hectormatos2011 "},"prism-tomorrow":{title:"Tomorrow Night",owner:"Rosey"}},languages:{meta:{path:"components/prism-{id}",noCSS:!0,examplesPath:"examples/prism-{id}",addCheckAll:!0},markup:{title:"Markup",alias:["html","xml","svg","mathml","ssml","atom","rss"],aliasTitles:{html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",atom:"Atom",rss:"RSS"},option:"default"},css:{title:"CSS",option:"default",modify:"markup"},clike:{title:"C-like",option:"default"},javascript:{title:"JavaScript",require:"clike",modify:"markup",optional:"regex",alias:"js",option:"default"},abap:{title:"ABAP",owner:"dellagustin"},abnf:{title:"ABNF",owner:"RunDevelopment"},actionscript:{title:"ActionScript",require:"javascript",modify:"markup",owner:"Golmote"},ada:{title:"Ada",owner:"Lucretia"},agda:{title:"Agda",owner:"xy-ren"},al:{title:"AL",owner:"RunDevelopment"},antlr4:{title:"ANTLR4",alias:"g4",owner:"RunDevelopment"},apacheconf:{title:"Apache Configuration",owner:"GuiTeK"},apex:{title:"Apex",require:["clike","sql"],owner:"RunDevelopment"},apl:{title:"APL",owner:"ngn"},applescript:{title:"AppleScript",owner:"Golmote"},aql:{title:"AQL",owner:"RunDevelopment"},arduino:{title:"Arduino",require:"cpp",alias:"ino",owner:"dkern"},arff:{title:"ARFF",owner:"Golmote"},armasm:{title:"ARM Assembly",alias:"arm-asm",owner:"RunDevelopment"},arturo:{title:"Arturo",alias:"art",optional:["bash","css","javascript","markup","markdown","sql"],owner:"drkameleon"},asciidoc:{alias:"adoc",title:"AsciiDoc",owner:"Golmote"},aspnet:{title:"ASP.NET (C#)",require:["markup","csharp"],owner:"nauzilus"},asm6502:{title:"6502 Assembly",owner:"kzurawel"},asmatmel:{title:"Atmel AVR Assembly",owner:"cerkit"},autohotkey:{title:"AutoHotkey",owner:"aviaryan"},autoit:{title:"AutoIt",owner:"Golmote"},avisynth:{title:"AviSynth",alias:"avs",owner:"Zinfidel"},"avro-idl":{title:"Avro IDL",alias:"avdl",owner:"RunDevelopment"},awk:{title:"AWK",alias:"gawk",aliasTitles:{gawk:"GAWK"},owner:"RunDevelopment"},bash:{title:"Bash",alias:["sh","shell"],aliasTitles:{sh:"Shell",shell:"Shell"},owner:"zeitgeist87"},basic:{title:"BASIC",owner:"Golmote"},batch:{title:"Batch",owner:"Golmote"},bbcode:{title:"BBcode",alias:"shortcode",aliasTitles:{shortcode:"Shortcode"},owner:"RunDevelopment"},bbj:{title:"BBj",owner:"hyyan"},bicep:{title:"Bicep",owner:"johnnyreilly"},birb:{title:"Birb",require:"clike",owner:"Calamity210"},bison:{title:"Bison",require:"c",owner:"Golmote"},bnf:{title:"BNF",alias:"rbnf",aliasTitles:{rbnf:"RBNF"},owner:"RunDevelopment"},bqn:{title:"BQN",owner:"yewscion"},brainfuck:{title:"Brainfuck",owner:"Golmote"},brightscript:{title:"BrightScript",owner:"RunDevelopment"},bro:{title:"Bro",owner:"wayward710"},bsl:{title:"BSL (1C:Enterprise)",alias:"oscript",aliasTitles:{oscript:"OneScript"},owner:"Diversus23"},c:{title:"C",require:"clike",owner:"zeitgeist87"},csharp:{title:"C#",require:"clike",alias:["cs","dotnet"],owner:"mvalipour"},cpp:{title:"C++",require:"c",owner:"zeitgeist87"},cfscript:{title:"CFScript",require:"clike",alias:"cfc",owner:"mjclemente"},chaiscript:{title:"ChaiScript",require:["clike","cpp"],owner:"RunDevelopment"},cil:{title:"CIL",owner:"sbrl"},cilkc:{title:"Cilk/C",require:"c",alias:"cilk-c",owner:"OpenCilk"},cilkcpp:{title:"Cilk/C++",require:"cpp",alias:["cilk-cpp","cilk"],owner:"OpenCilk"},clojure:{title:"Clojure",owner:"troglotit"},cmake:{title:"CMake",owner:"mjrogozinski"},cobol:{title:"COBOL",owner:"RunDevelopment"},coffeescript:{title:"CoffeeScript",require:"javascript",alias:"coffee",owner:"R-osey"},concurnas:{title:"Concurnas",alias:"conc",owner:"jasontatton"},csp:{title:"Content-Security-Policy",owner:"ScottHelme"},cooklang:{title:"Cooklang",owner:"ahue"},coq:{title:"Coq",owner:"RunDevelopment"},crystal:{title:"Crystal",require:"ruby",owner:"MakeNowJust"},"css-extras":{title:"CSS Extras",require:"css",modify:"css",owner:"milesj"},csv:{title:"CSV",owner:"RunDevelopment"},cue:{title:"CUE",owner:"RunDevelopment"},cypher:{title:"Cypher",owner:"RunDevelopment"},d:{title:"D",require:"clike",owner:"Golmote"},dart:{title:"Dart",require:"clike",owner:"Golmote"},dataweave:{title:"DataWeave",owner:"machaval"},dax:{title:"DAX",owner:"peterbud"},dhall:{title:"Dhall",owner:"RunDevelopment"},diff:{title:"Diff",owner:"uranusjr"},django:{title:"Django/Jinja2",require:"markup-templating",alias:"jinja2",owner:"romanvm"},"dns-zone-file":{title:"DNS zone file",owner:"RunDevelopment",alias:"dns-zone"},docker:{title:"Docker",alias:"dockerfile",owner:"JustinBeckwith"},dot:{title:"DOT (Graphviz)",alias:"gv",optional:"markup",owner:"RunDevelopment"},ebnf:{title:"EBNF",owner:"RunDevelopment"},editorconfig:{title:"EditorConfig",owner:"osipxd"},eiffel:{title:"Eiffel",owner:"Conaclos"},ejs:{title:"EJS",require:["javascript","markup-templating"],owner:"RunDevelopment",alias:"eta",aliasTitles:{eta:"Eta"}},elixir:{title:"Elixir",owner:"Golmote"},elm:{title:"Elm",owner:"zwilias"},etlua:{title:"Embedded Lua templating",require:["lua","markup-templating"],owner:"RunDevelopment"},erb:{title:"ERB",require:["ruby","markup-templating"],owner:"Golmote"},erlang:{title:"Erlang",owner:"Golmote"},"excel-formula":{title:"Excel Formula",alias:["xlsx","xls"],owner:"RunDevelopment"},fsharp:{title:"F#",require:"clike",owner:"simonreynolds7"},factor:{title:"Factor",owner:"catb0t"},false:{title:"False",owner:"edukisto"},"firestore-security-rules":{title:"Firestore security rules",require:"clike",owner:"RunDevelopment"},flow:{title:"Flow",require:"javascript",owner:"Golmote"},fortran:{title:"Fortran",owner:"Golmote"},ftl:{title:"FreeMarker Template Language",require:"markup-templating",owner:"RunDevelopment"},gml:{title:"GameMaker Language",alias:"gamemakerlanguage",require:"clike",owner:"LiarOnce"},gap:{title:"GAP (CAS)",owner:"RunDevelopment"},gcode:{title:"G-code",owner:"RunDevelopment"},gdscript:{title:"GDScript",owner:"RunDevelopment"},gedcom:{title:"GEDCOM",owner:"Golmote"},gettext:{title:"gettext",alias:"po",owner:"RunDevelopment"},gherkin:{title:"Gherkin",owner:"hason"},git:{title:"Git",owner:"lgiraudel"},glsl:{title:"GLSL",require:"c",owner:"Golmote"},gn:{title:"GN",alias:"gni",owner:"RunDevelopment"},"linker-script":{title:"GNU Linker Script",alias:"ld",owner:"RunDevelopment"},go:{title:"Go",require:"clike",owner:"arnehormann"},"go-module":{title:"Go module",alias:"go-mod",owner:"RunDevelopment"},gradle:{title:"Gradle",require:"clike",owner:"zeabdelkhalek-badido18"},graphql:{title:"GraphQL",optional:"markdown",owner:"Golmote"},groovy:{title:"Groovy",require:"clike",owner:"robfletcher"},haml:{title:"Haml",require:"ruby",optional:["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],owner:"Golmote"},handlebars:{title:"Handlebars",require:"markup-templating",alias:["hbs","mustache"],aliasTitles:{mustache:"Mustache"},owner:"Golmote"},haskell:{title:"Haskell",alias:"hs",owner:"bholst"},haxe:{title:"Haxe",require:"clike",optional:"regex",owner:"Golmote"},hcl:{title:"HCL",owner:"outsideris"},hlsl:{title:"HLSL",require:"c",owner:"RunDevelopment"},hoon:{title:"Hoon",owner:"matildepark"},http:{title:"HTTP",optional:["csp","css","hpkp","hsts","javascript","json","markup","uri"],owner:"danielgtaylor"},hpkp:{title:"HTTP Public-Key-Pins",owner:"ScottHelme"},hsts:{title:"HTTP Strict-Transport-Security",owner:"ScottHelme"},ichigojam:{title:"IchigoJam",owner:"BlueCocoa"},icon:{title:"Icon",owner:"Golmote"},"icu-message-format":{title:"ICU Message Format",owner:"RunDevelopment"},idris:{title:"Idris",alias:"idr",owner:"KeenS",require:"haskell"},ignore:{title:".ignore",owner:"osipxd",alias:["gitignore","hgignore","npmignore"],aliasTitles:{gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore"}},inform7:{title:"Inform 7",owner:"Golmote"},ini:{title:"Ini",owner:"aviaryan"},io:{title:"Io",owner:"AlesTsurko"},j:{title:"J",owner:"Golmote"},java:{title:"Java",require:"clike",owner:"sherblot"},javadoc:{title:"JavaDoc",require:["markup","java","javadoclike"],modify:"java",optional:"scala",owner:"RunDevelopment"},javadoclike:{title:"JavaDoc-like",modify:["java","javascript","php"],owner:"RunDevelopment"},javastacktrace:{title:"Java stack trace",owner:"RunDevelopment"},jexl:{title:"Jexl",owner:"czosel"},jolie:{title:"Jolie",require:"clike",owner:"thesave"},jq:{title:"JQ",owner:"RunDevelopment"},jsdoc:{title:"JSDoc",require:["javascript","javadoclike","typescript"],modify:"javascript",optional:["actionscript","coffeescript"],owner:"RunDevelopment"},"js-extras":{title:"JS Extras",require:"javascript",modify:"javascript",optional:["actionscript","coffeescript","flow","n4js","typescript"],owner:"RunDevelopment"},json:{title:"JSON",alias:"webmanifest",aliasTitles:{webmanifest:"Web App Manifest"},owner:"CupOfTea696"},json5:{title:"JSON5",require:"json",owner:"RunDevelopment"},jsonp:{title:"JSONP",require:"json",owner:"RunDevelopment"},jsstacktrace:{title:"JS stack trace",owner:"sbrl"},"js-templates":{title:"JS Templates",require:"javascript",modify:"javascript",optional:["css","css-extras","graphql","markdown","markup","sql"],owner:"RunDevelopment"},julia:{title:"Julia",owner:"cdagnino"},keepalived:{title:"Keepalived Configure",owner:"dev-itsheng"},keyman:{title:"Keyman",owner:"mcdurdin"},kotlin:{title:"Kotlin",alias:["kt","kts"],aliasTitles:{kts:"Kotlin Script"},require:"clike",owner:"Golmote"},kumir:{title:"KuMir (\u041a\u0443\u041c\u0438\u0440)",alias:"kum",owner:"edukisto"},kusto:{title:"Kusto",owner:"RunDevelopment"},latex:{title:"LaTeX",alias:["tex","context"],aliasTitles:{tex:"TeX",context:"ConTeXt"},owner:"japborst"},latte:{title:"Latte",require:["clike","markup-templating","php"],owner:"nette"},less:{title:"Less",require:"css",optional:"css-extras",owner:"Golmote"},lilypond:{title:"LilyPond",require:"scheme",alias:"ly",owner:"RunDevelopment"},liquid:{title:"Liquid",require:"markup-templating",owner:"cinhtau"},lisp:{title:"Lisp",alias:["emacs","elisp","emacs-lisp"],owner:"JuanCaicedo"},livescript:{title:"LiveScript",owner:"Golmote"},llvm:{title:"LLVM IR",owner:"porglezomp"},log:{title:"Log file",optional:"javastacktrace",owner:"RunDevelopment"},lolcode:{title:"LOLCODE",owner:"Golmote"},lua:{title:"Lua",owner:"Golmote"},magma:{title:"Magma (CAS)",owner:"RunDevelopment"},makefile:{title:"Makefile",owner:"Golmote"},markdown:{title:"Markdown",require:"markup",optional:"yaml",alias:"md",owner:"Golmote"},"markup-templating":{title:"Markup templating",require:"markup",owner:"Golmote"},mata:{title:"Mata",owner:"RunDevelopment"},matlab:{title:"MATLAB",owner:"Golmote"},maxscript:{title:"MAXScript",owner:"RunDevelopment"},mel:{title:"MEL",owner:"Golmote"},mermaid:{title:"Mermaid",owner:"RunDevelopment"},metafont:{title:"METAFONT",owner:"LaeriExNihilo"},mizar:{title:"Mizar",owner:"Golmote"},mongodb:{title:"MongoDB",owner:"airs0urce",require:"javascript"},monkey:{title:"Monkey",owner:"Golmote"},moonscript:{title:"MoonScript",alias:"moon",owner:"RunDevelopment"},n1ql:{title:"N1QL",owner:"TMWilds"},n4js:{title:"N4JS",require:"javascript",optional:"jsdoc",alias:"n4jsd",owner:"bsmith-n4"},"nand2tetris-hdl":{title:"Nand To Tetris HDL",owner:"stephanmax"},naniscript:{title:"Naninovel Script",owner:"Elringus",alias:"nani"},nasm:{title:"NASM",owner:"rbmj"},neon:{title:"NEON",owner:"nette"},nevod:{title:"Nevod",owner:"nezaboodka"},nginx:{title:"nginx",owner:"volado"},nim:{title:"Nim",owner:"Golmote"},nix:{title:"Nix",owner:"Golmote"},nsis:{title:"NSIS",owner:"idleberg"},objectivec:{title:"Objective-C",require:"c",alias:"objc",owner:"uranusjr"},ocaml:{title:"OCaml",owner:"Golmote"},odin:{title:"Odin",owner:"edukisto"},opencl:{title:"OpenCL",require:"c",modify:["c","cpp"],owner:"Milania1"},openqasm:{title:"OpenQasm",alias:"qasm",owner:"RunDevelopment"},oz:{title:"Oz",owner:"Golmote"},parigp:{title:"PARI/GP",owner:"Golmote"},parser:{title:"Parser",require:"markup",owner:"Golmote"},pascal:{title:"Pascal",alias:"objectpascal",aliasTitles:{objectpascal:"Object Pascal"},owner:"Golmote"},pascaligo:{title:"Pascaligo",owner:"DefinitelyNotAGoat"},psl:{title:"PATROL Scripting Language",owner:"bertysentry"},pcaxis:{title:"PC-Axis",alias:"px",owner:"RunDevelopment"},peoplecode:{title:"PeopleCode",alias:"pcode",owner:"RunDevelopment"},perl:{title:"Perl",owner:"Golmote"},php:{title:"PHP",require:"markup-templating",owner:"milesj"},phpdoc:{title:"PHPDoc",require:["php","javadoclike"],modify:"php",owner:"RunDevelopment"},"php-extras":{title:"PHP Extras",require:"php",modify:"php",owner:"milesj"},"plant-uml":{title:"PlantUML",alias:"plantuml",owner:"RunDevelopment"},plsql:{title:"PL/SQL",require:"sql",owner:"Golmote"},powerquery:{title:"PowerQuery",alias:["pq","mscript"],owner:"peterbud"},powershell:{title:"PowerShell",owner:"nauzilus"},processing:{title:"Processing",require:"clike",owner:"Golmote"},prolog:{title:"Prolog",owner:"Golmote"},promql:{title:"PromQL",owner:"arendjr"},properties:{title:".properties",owner:"Golmote"},protobuf:{title:"Protocol Buffers",require:"clike",owner:"just-boris"},pug:{title:"Pug",require:["markup","javascript"],optional:["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],owner:"Golmote"},puppet:{title:"Puppet",owner:"Golmote"},pure:{title:"Pure",optional:["c","cpp","fortran"],owner:"Golmote"},purebasic:{title:"PureBasic",require:"clike",alias:"pbfasm",owner:"HeX0R101"},purescript:{title:"PureScript",require:"haskell",alias:"purs",owner:"sriharshachilakapati"},python:{title:"Python",alias:"py",owner:"multipetros"},qsharp:{title:"Q#",require:"clike",alias:"qs",owner:"fedonman"},q:{title:"Q (kdb+ database)",owner:"Golmote"},qml:{title:"QML",require:"javascript",owner:"RunDevelopment"},qore:{title:"Qore",require:"clike",owner:"temnroegg"},r:{title:"R",owner:"Golmote"},racket:{title:"Racket",require:"scheme",alias:"rkt",owner:"RunDevelopment"},cshtml:{title:"Razor C#",alias:"razor",require:["markup","csharp"],optional:["css","css-extras","javascript","js-extras"],owner:"RunDevelopment"},jsx:{title:"React JSX",require:["markup","javascript"],optional:["jsdoc","js-extras","js-templates"],owner:"vkbansal"},tsx:{title:"React TSX",require:["jsx","typescript"]},reason:{title:"Reason",require:"clike",owner:"Golmote"},regex:{title:"Regex",owner:"RunDevelopment"},rego:{title:"Rego",owner:"JordanSh"},renpy:{title:"Ren'py",alias:"rpy",owner:"HyuchiaDiego"},rescript:{title:"ReScript",alias:"res",owner:"vmarcosp"},rest:{title:"reST (reStructuredText)",owner:"Golmote"},rip:{title:"Rip",owner:"ravinggenius"},roboconf:{title:"Roboconf",owner:"Golmote"},robotframework:{title:"Robot Framework",alias:"robot",owner:"RunDevelopment"},ruby:{title:"Ruby",require:"clike",alias:"rb",owner:"samflores"},rust:{title:"Rust",owner:"Golmote"},sas:{title:"SAS",optional:["groovy","lua","sql"],owner:"Golmote"},sass:{title:"Sass (Sass)",require:"css",optional:"css-extras",owner:"Golmote"},scss:{title:"Sass (SCSS)",require:"css",optional:"css-extras",owner:"MoOx"},scala:{title:"Scala",require:"java",owner:"jozic"},scheme:{title:"Scheme",owner:"bacchus123"},"shell-session":{title:"Shell session",require:"bash",alias:["sh-session","shellsession"],owner:"RunDevelopment"},smali:{title:"Smali",owner:"RunDevelopment"},smalltalk:{title:"Smalltalk",owner:"Golmote"},smarty:{title:"Smarty",require:"markup-templating",optional:"php",owner:"Golmote"},sml:{title:"SML",alias:"smlnj",aliasTitles:{smlnj:"SML/NJ"},owner:"RunDevelopment"},solidity:{title:"Solidity (Ethereum)",alias:"sol",require:"clike",owner:"glachaud"},"solution-file":{title:"Solution file",alias:"sln",owner:"RunDevelopment"},soy:{title:"Soy (Closure Template)",require:"markup-templating",owner:"Golmote"},sparql:{title:"SPARQL",require:"turtle",owner:"Triply-Dev",alias:"rq"},"splunk-spl":{title:"Splunk SPL",owner:"RunDevelopment"},sqf:{title:"SQF: Status Quo Function (Arma 3)",require:"clike",owner:"RunDevelopment"},sql:{title:"SQL",owner:"multipetros"},squirrel:{title:"Squirrel",require:"clike",owner:"RunDevelopment"},stan:{title:"Stan",owner:"RunDevelopment"},stata:{title:"Stata Ado",require:["mata","java","python"],owner:"RunDevelopment"},iecst:{title:"Structured Text (IEC 61131-3)",owner:"serhioromano"},stylus:{title:"Stylus",owner:"vkbansal"},supercollider:{title:"SuperCollider",alias:"sclang",owner:"RunDevelopment"},swift:{title:"Swift",owner:"chrischares"},systemd:{title:"Systemd configuration file",owner:"RunDevelopment"},"t4-templating":{title:"T4 templating",owner:"RunDevelopment"},"t4-cs":{title:"T4 Text Templates (C#)",require:["t4-templating","csharp"],alias:"t4",owner:"RunDevelopment"},"t4-vb":{title:"T4 Text Templates (VB)",require:["t4-templating","vbnet"],owner:"RunDevelopment"},tap:{title:"TAP",owner:"isaacs",require:"yaml"},tcl:{title:"Tcl",owner:"PeterChaplin"},tt2:{title:"Template Toolkit 2",require:["clike","markup-templating"],owner:"gflohr"},textile:{title:"Textile",require:"markup",optional:"css",owner:"Golmote"},toml:{title:"TOML",owner:"RunDevelopment"},tremor:{title:"Tremor",alias:["trickle","troy"],owner:"darach",aliasTitles:{trickle:"trickle",troy:"troy"}},turtle:{title:"Turtle",alias:"trig",aliasTitles:{trig:"TriG"},owner:"jakubklimek"},twig:{title:"Twig",require:"markup-templating",owner:"brandonkelly"},typescript:{title:"TypeScript",require:"javascript",optional:"js-templates",alias:"ts",owner:"vkbansal"},typoscript:{title:"TypoScript",alias:"tsconfig",aliasTitles:{tsconfig:"TSConfig"},owner:"dkern"},unrealscript:{title:"UnrealScript",alias:["uscript","uc"],owner:"RunDevelopment"},uorazor:{title:"UO Razor Script",owner:"jaseowns"},uri:{title:"URI",alias:"url",aliasTitles:{url:"URL"},owner:"RunDevelopment"},v:{title:"V",require:"clike",owner:"taggon"},vala:{title:"Vala",require:"clike",optional:"regex",owner:"TemplarVolk"},vbnet:{title:"VB.Net",require:"basic",owner:"Bigsby"},velocity:{title:"Velocity",require:"markup",owner:"Golmote"},verilog:{title:"Verilog",owner:"a-rey"},vhdl:{title:"VHDL",owner:"a-rey"},vim:{title:"vim",owner:"westonganger"},"visual-basic":{title:"Visual Basic",alias:["vb","vba"],aliasTitles:{vba:"VBA"},owner:"Golmote"},warpscript:{title:"WarpScript",owner:"RunDevelopment"},wasm:{title:"WebAssembly",owner:"Golmote"},"web-idl":{title:"Web IDL",alias:"webidl",owner:"RunDevelopment"},wgsl:{title:"WGSL",owner:"Dr4gonthree"},wiki:{title:"Wiki markup",require:"markup",owner:"Golmote"},wolfram:{title:"Wolfram language",alias:["mathematica","nb","wl"],aliasTitles:{mathematica:"Mathematica",nb:"Mathematica Notebook"},owner:"msollami"},wren:{title:"Wren",owner:"clsource"},xeora:{title:"Xeora",require:"markup",alias:"xeoracube",aliasTitles:{xeoracube:"XeoraCube"},owner:"freakmaxi"},"xml-doc":{title:"XML doc (.net)",require:"markup",modify:["csharp","fsharp","vbnet"],owner:"RunDevelopment"},xojo:{title:"Xojo (REALbasic)",owner:"Golmote"},xquery:{title:"XQuery",require:"markup",owner:"Golmote"},yaml:{title:"YAML",alias:"yml",owner:"hason"},yang:{title:"YANG",owner:"RunDevelopment"},zig:{title:"Zig",owner:"RunDevelopment"}},plugins:{meta:{path:"plugins/{id}/prism-{id}",link:"plugins/{id}/"},"line-highlight":{title:"Line Highlight",description:"Highlights specific lines and/or line ranges."},"line-numbers":{title:"Line Numbers",description:"Line number at the beginning of code lines.",owner:"kuba-kubula"},"show-invisibles":{title:"Show Invisibles",description:"Show hidden characters such as tabs and line breaks.",optional:["autolinker","data-uri-highlight"]},autolinker:{title:"Autolinker",description:"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},wpd:{title:"WebPlatform Docs",description:'Makes tokens link to WebPlatform.org documentation. The links open in a new tab.'},"custom-class":{title:"Custom Class",description:"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.",owner:"dvkndn",noCSS:!0},"file-highlight":{title:"File Highlight",description:"Fetch external files and highlight them with Prism. Used on the Prism website itself.",noCSS:!0},"show-language":{title:"Show Language",description:"Display the highlighted language in code blocks (inline code does not show the label).",owner:"nauzilus",noCSS:!0,require:"toolbar"},"jsonp-highlight":{title:"JSONP Highlight",description:"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",noCSS:!0,owner:"nauzilus"},"highlight-keywords":{title:"Highlight Keywords",description:"Adds special CSS classes for each keyword for fine-grained highlighting.",owner:"vkbansal",noCSS:!0},"remove-initial-line-feed":{title:"Remove initial line feed",description:"Removes the initial line feed in code blocks.",owner:"Golmote",noCSS:!0},"inline-color":{title:"Inline color",description:"Adds a small inline preview for colors in style sheets.",require:"css-extras",owner:"RunDevelopment"},previewers:{title:"Previewers",description:"Previewers for angles, colors, gradients, easing and time.",require:"css-extras",owner:"Golmote"},autoloader:{title:"Autoloader",description:"Automatically loads the needed languages to highlight the code blocks.",owner:"Golmote",noCSS:!0},"keep-markup":{title:"Keep Markup",description:"Prevents custom markup from being dropped out during highlighting.",owner:"Golmote",optional:"normalize-whitespace",noCSS:!0},"command-line":{title:"Command Line",description:"Display a command line with a prompt and, optionally, the output/response from the commands.",owner:"chriswells0"},"unescaped-markup":{title:"Unescaped Markup",description:"Write markup without having to escape anything."},"normalize-whitespace":{title:"Normalize Whitespace",description:"Supports multiple operations to normalize whitespace in code blocks.",owner:"zeitgeist87",optional:"unescaped-markup",noCSS:!0},"data-uri-highlight":{title:"Data-URI Highlight",description:"Highlights data-URI contents.",owner:"Golmote",noCSS:!0},toolbar:{title:"Toolbar",description:"Attach a toolbar for plugins to easily register buttons on the top of a code block.",owner:"mAAdhaTTah"},"copy-to-clipboard":{title:"Copy to Clipboard Button",description:"Add a button that copies the code block to the clipboard when clicked.",owner:"mAAdhaTTah",require:"toolbar",noCSS:!0},"download-button":{title:"Download Button",description:"A button in the toolbar of a code block adding a convenient way to download a code file.",owner:"Golmote",require:"toolbar",noCSS:!0},"match-braces":{title:"Match braces",description:"Highlights matching braces.",owner:"RunDevelopment"},"diff-highlight":{title:"Diff Highlight",description:"Highlights the code inside diff blocks.",owner:"RunDevelopment",require:"diff"},"filter-highlight-all":{title:"Filter highlightAll",description:"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.",owner:"RunDevelopment",noCSS:!0},treeview:{title:"Treeview",description:"A language with special styles to highlight file system tree structures.",owner:"Golmote"}}})},8722:(e,t,n)=>{const r=n(6969),a=n(8380),o=new Set;function i(e){void 0===e?e=Object.keys(r.languages).filter((e=>"meta"!=e)):Array.isArray(e)||(e=[e]);const t=[...o,...Object.keys(Prism.languages)];a(r,e,t).load((e=>{if(!(e in r.languages))return void(i.silent||console.warn("Language does not exist: "+e));const t="./prism-"+e;delete n.c[n(3157).resolve(t)],delete Prism.languages[e],n(3157)(t),o.add(e)}))}i.silent=!1,e.exports=i},9700:()=>{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(a,(function(e){if("function"==typeof o&&!o(e))return e;for(var a,l=i.length;-1!==n.code.indexOf(a=t(r,l));)++l;return i[l]=e,a})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var a=0,o=Object.keys(n.tokenStack);!function i(l){for(var s=0;s=o.length);s++){var u=l[s];if("string"==typeof u||u.content&&"string"==typeof u.content){var c=o[a],d=n.tokenStack[c],p="string"==typeof u?u:u.content,f=t(r,c),m=p.indexOf(f);if(m>-1){++a;var h=p.substring(0,m),g=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),y=p.substring(m+f.length),b=[];h&&b.push.apply(b,i([h])),b.push(g),y&&b.push.apply(b,i([y])),"string"==typeof u?l.splice.apply(l,[s,1].concat(b)):u.content=b}}else u.content&&i(u.content)}return l}(n.tokens)}}}})}(Prism)},8692:(e,t,n)=>{var r={"./":8722};function a(e){var t=o(e);return n(t)}function o(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}a.keys=function(){return Object.keys(r)},a.resolve=o,e.exports=a,a.id=8692},3157:(e,t,n)=>{var r={"./":8722};function a(e){var t=o(e);return n(t)}function o(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}a.keys=function(){return Object.keys(r)},a.resolve=o,e.exports=a,a.id=3157},8380:e=>{"use strict";var t=function(){var e=function(){};function t(e,t){Array.isArray(e)?e.forEach(t):null!=e&&t(e,0)}function n(e){for(var t={},n=0,r=e.length;n "));var l={},s=e[r];if(s){function u(t){if(!(t in e))throw new Error(r+" depends on an unknown component "+t);if(!(t in l))for(var i in a(t,o),l[t]=!0,n[t])l[i]=!0}t(s.require,u),t(s.optional,u),t(s.modify,u)}n[r]=l,o.pop()}}return function(e){var t=n[e];return t||(a(e,r),t=n[e]),t}}function a(e){for(var t in e)return!0;return!1}return function(o,i,l){var s=function(e){var t={};for(var n in e){var r=e[n];for(var a in r)if("meta"!=a){var o=r[a];t[a]="string"==typeof o?{title:o}:o}}return t}(o),u=function(e){var n;return function(r){if(r in e)return r;if(!n)for(var a in n={},e){var o=e[a];t(o&&o.alias,(function(t){if(t in n)throw new Error(t+" cannot be alias for both "+a+" and "+n[t]);if(t in e)throw new Error(t+" cannot be alias of "+a+" because it is a component.");n[t]=a}))}return n[r]||r}}(s);i=i.map(u),l=(l||[]).map(u);var c=n(i),d=n(l);i.forEach((function e(n){var r=s[n];t(r&&r.require,(function(t){t in d||(c[t]=!0,e(t))}))}));for(var p,f=r(s),m=c;a(m);){for(var h in p={},m){var g=s[h];t(g&&g.modify,(function(e){e in d&&(p[e]=!0)}))}for(var y in d)if(!(y in c))for(var b in f(y))if(b in c){p[y]=!0;break}for(var v in m=p)c[v]=!0}var w={getIds:function(){var e=[];return w.load((function(t){e.push(t)})),e},load:function(t,n){return function(t,n,r,a){var o=a?a.series:void 0,i=a?a.parallel:e,l={},s={};function u(e){if(e in l)return l[e];s[e]=!0;var a,c=[];for(var d in t(e))d in n&&c.push(d);if(0===c.length)a=r(e);else{var p=i(c.map((function(e){var t=u(e);return delete s[e],t})));o?a=o(p,(function(){return r(e)})):r(e)}return l[e]=a}for(var c in n)u(c);var d=[];for(var p in s)d.push(l[p]);return i(d)}(f,c,t,n)}};return w}}();e.exports=t},2694:(e,t,n)=>{"use strict";var r=n(6925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,i){if(i!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},2551:(e,t,n)=>{"use strict";var r=n(6540),a=n(9982);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n