PageSourceSearch

https://www.yannesidibe.com/_next/static/chunks/2yq9paqhjh7df.js

js yannesidibe.com collected 2026-10-06 13:13:33 UTC 101,904 bytes, 36 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,34482,e=>{"use strict";var t=e.i(71645);function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var s,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)s=a[i],t.indexOf(s)>=0||(r[s]=e[s]);return r}var r={curtains:null,subscriptions:{onAfterResize:[],onContextLost:[],onContextRestored:[],onError:[],onSuccess:[],onRender:[],onScroll:[]}},a=(0,t.createContext)(r);function n(e){var i=e.children,n=(0,t.useReducer)(function(e,t){switch(t.type){case"SET_CURTAINS":return s({},e,{curtains:t.curtains});case"ADD_SUBSCRIPTION":var i=s({},e),r=t.addSubscription;return i.subscriptions[r.event].find(function(e){return e.id===r.id})||i.subscriptions[r.event].push(r),i;case"REMOVE_SUBSCRIPTION":var a=s({},e),n=t.removeSubscription;return a.subscriptions[n.event]=a.subscriptions[n.event].filter(function(e){return e.id!==n.id}),a;default:throw Error()}},r),h=n[0],o=n[1];return t.default.createElement(a.Provider,{value:{state:h,dispatch:o}},i)}let h=0;function o(){if(!(h>100)){if(100===h)console.warn("Curtains: too many warnings thrown, stop logging.");else{let e=Array.prototype.slice.call(arguments);console.warn.apply(console,e)}h++}}function l(){let e=Array.prototype.slice.call(arguments);console.error.apply(console,e)}function d(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16).toUpperCase()})}function u(e){return(e&e-1)==0}class c{constructor(e){if(this.type="Scene",e&&"Renderer"===e.type){if(!e.gl)return void l(this.type+": Renderer WebGL context is undefined",e)}else l(this.type+": Renderer not passed as first argument",e);this.renderer=e,this.gl=e.gl,this.initStacks()}initStacks(){this.stacks={pingPong:[],renderTargets:[],opaque:[],transparent:[],renderPasses:[],scenePasses:[]}}resetPlaneStacks(){this.stacks.pingPong=[],this.stacks.renderTargets=[],this.stacks.opaque=[],this.stacks.transparent=[];for(let e=0;e<this.renderer.planes.length;e++)this.addPlane(this.renderer.planes[e])}resetShaderPassStacks(){this.stacks.scenePasses=[],this.stacks.renderPasses=[];for(let e=0;e<this.renderer.shaderPasses.length;e++)this.renderer.shaderPasses[e].index=e,this.renderer.shaderPasses[e]._isScenePass?this.stacks.scenePasses.push(this.renderer.shaderPasses[e]):this.stacks.renderPasses.push(this.renderer.shaderPasses[e]);0===this.stacks.scenePasses.length&&(this.renderer.state.scenePassIndex=null)}addToRenderTargetsStack(e){let t=this.renderer.planes.filter(t=>"PingPongPlane"!==t.type&&t.target&&t.uuid!==e.uuid),s=-1;if(e.target._depth){for(let i=t.length-1;i>=0;i--)if(t[i].target.uuid===e.target.uuid){s=i+1;break}}else s=t.findIndex(t=>t.target.uuid===e.target.uuid);s=Math.max(0,s),t.splice(s,0,e),e.target._depth?(t.sort((e,t)=>e.index-t.index),t.sort((e,t)=>t.renderOrder-e.renderOrder)):(t.sort((e,t)=>t.index-e.index),t.sort((e,t)=>e.renderOrder-t.renderOrder)),t.sort((e,t)=>e.target.index-t.target.index),this.stacks.renderTargets=t}addToRegularPlaneStack(e){let t=this.renderer.planes.filter(t=>"PingPongPlane"!==t.type&&!t.target&&t._transparent===e._transparent&&t.uuid!==e.uuid),s=-1;for(let i=t.length-1;i>=0;i--)if(t[i]._geometry.definition.id===e._geometry.definition.id){s=i+1;break}return s=Math.max(0,s),t.splice(s,0,e),t.sort((e,t)=>e.index-t.index),t}addPlane(e){if("PingPongPlane"===e.type)this.stacks.pingPong.push(e);else if(e.target)this.addToRenderTargetsStack(e);else if(e._transparent){let t=this.addToRegularPlaneStack(e);t.sort((e,t)=>t.relativeTranslation.z-e.relativeTranslation.z),t.sort((e,t)=>t.renderOrder-e.renderOrder),this.stacks.transparent=t}else{let t=this.addToRegularPlaneStack(e);t.sort((e,t)=>t.renderOrder-e.renderOrder),this.stacks.opaque=t}}removePlane(e){"PingPongPlane"===e.type?this.stacks.pingPong=this.stacks.pingPong.filter(t=>t.uuid!==e.uuid):e.target?this.stacks.renderTargets=this.stacks.renderTargets.filter(t=>t.uuid!==e.uuid):e._transparent?this.stacks.transparent=this.stacks.transparent.filter(t=>t.uuid!==e.uuid):this.stacks.opaque=this.stacks.opaque.filter(t=>t.uuid!==e.uuid)}setPlaneRenderOrder(e){if("ShaderPass"===e.type)this.sortShaderPassStack(e._isScenePass?this.stacks.scenePasses:this.stacks.renderPasses);else if("PingPongPlane"===e.type)return;if(e.target)e.target._depth?(this.stacks.renderTargets.sort((e,t)=>
1e.index-t.index),this.stacks.renderTargets.sort((e,t)=>t.renderOrder-e.renderOrder)):(this.stacks.renderTargets.sort((e,t)=>t.index-e.index),this.stacks.renderTargets.sort((e,t)=>e.renderOrder-t.renderOrder)),this.stacks.renderTargets.sort((e,t)=>e.target.index-t.target.index);else{let t=e._transparent?this.stacks.transparent:this.stacks.opaque,s=this.stacks.scenePasses.find((e,t)=>e._isScenePass&&!e._depth&&0===t);!this.renderer.depth||s?(t.sort((e,t)=>t.index-e.index),e._transparent&&t.sort((e,t)=>e.relativeTranslation.z-t.relativeTranslation.z),t.sort((e,t)=>e.renderOrder-t.renderOrder)):(t.sort((e,t)=>e.index-t.index),e._transparent&&t.sort((e,t)=>t.relativeTranslation.z-e.relativeTranslation.z),t.sort((e,t)=>t.renderOrder-e.renderOrder))}}addShaderPass(e){e._isScenePass?(this.stacks.scenePasses.push(e),this.sortShaderPassStack(this.stacks.scenePasses)):(this.stacks.renderPasses.push(e),this.sortShaderPassStack(this.stacks.renderPasses))}removeShaderPass(e){this.resetShaderPassStacks()}sortShaderPassStack(e){e.sort((e,t)=>e.index-t.index),e.sort((e,t)=>e.renderOrder-t.renderOrder)}enableShaderPass(){this.stacks.scenePasses.length&&0===this.stacks.renderPasses.length&&this.renderer.planes.length&&(this.renderer.state.scenePassIndex=0,this.renderer.bindFrameBuffer(this.stacks.scenePasses[0].target))}drawRenderPasses(){this.stacks.scenePasses.length&&this.stacks.renderPasses.length&&this.renderer.planes.length&&(this.renderer.state.scenePassIndex=0,this.renderer.bindFrameBuffer(this.stacks.scenePasses[0].target));for(let e=0;e<this.stacks.renderPasses.length;e++)this.stacks.renderPasses[e]._startDrawing(),this.renderer.clearDepth()}drawScenePasses(){for(let e=0;e<this.stacks.scenePasses.length;e++)this.stacks.scenePasses[e]._startDrawing()}drawPingPongStack(){for(let e=0;e<this.stacks.pingPong.length;e++){let t=this.stacks.pingPong[e];t&&t._startDrawing()}}drawStack(e){for(let t=0;t<this.stacks[e].length;t++){let s=this.stacks[e][t];s&&s._startDrawing()}}draw(){this.drawPingPongStack(),this.enableShaderPass(),this.drawStack("renderTargets"),this.drawRenderPasses(),this.renderer.setBlending(!1),this.drawStack("opaque"),this.stacks.transparent.length&&(this.renderer.setBlending(!0),this.drawStack("transparent")),this.drawScenePasses()}}class p{constructor(){this.geometries=[],this.clear()}clear(){this.textures=[],this.programs=[]}getGeometryFromID(e){return this.geometries.find(t=>t.id===e)}addGeometry(e,t,s){this.geometries.push({id:e,vertices:t,uvs:s})}isSameShader(e,t){return 0===e.localeCompare(t)}getProgramFromShaders(e,t){return this.programs.find(s=>this.isSameShader(s.vsCode,e)&&this.isSameShader(s.fsCode,t))}addProgram(e){this.programs.push(e)}getTextureFromSource(e){let t="string"==typeof e?e:e.src;return this.textures.find(e=>e.source&&e.source.src===t)}addTexture(e){this.getTextureFromSource(e.source)||this.textures.push(e)}removeTexture(e){this.textures=this.textures.filter(t=>t.uuid!==e.uuid)}}class g{constructor(){this.clear()}clear(){this.queue=[]}add(e,t=!1){let s={callback:e,keep:t,timeout:null};return s.timeout=setTimeout(()=>{this.queue.push(s)},0),s}execute(){this.queue.map(e=>{e.callback&&e.callback(),clearTimeout(this.queue.timeout)}),this.queue=this.queue.filter(e=>e.keep)}}class m{constructor({alpha:e,antialias:t,premultipliedAlpha:s,depth:i,failIfMajorPerformanceCaveat:r,preserveDrawingBuffer:a,stencil:n,container:h,pixelRatio:l,renderingScale:d,production:u,onError:c,onSuccess:p,onContextLost:g,onContextRestored:m,onDisposed:_,onSceneChange:f}){this.type="Renderer",this.alpha=e,this.antialias=t,this.premultipliedAlpha=s,this.depth=i,this.failIfMajorPerformanceCaveat=r,this.preserveDrawingBuffer=a,this.stencil=n,this.container=h,this.pixelRatio=l,this._renderingScale=d,this.production=u,this.onError=c,this.onSuccess=p,this.onContextLost=g,this.onContextRestored=m,this.onDisposed=_,this.onSceneChange=f,this.initState(),this.canvas=document.createElement("canvas");const x={alpha:this.alpha,premultipliedAlpha:this.premultipliedAlpha,antialias:this.antialias,depth:this.depth,failIfMajorPerformanceCaveat:this.failIfMajorPerformanceCaveat,preserveDrawingBuffer:this.preserveDrawingBuffer,stencil:this.stencil};if(this.gl=this.canvas.getContext("webgl2",x),this._isWebGL2=!!this.gl,this.gl||(this.gl=this.canvas.getContext("webgl",x)||this.canvas.getContext("experimental-webgl",x)),this.gl)this.onSuccess&&this.onSuccess();else{this.production||o(this.type+": WebGL context could not be created"),this.state.isActive=!1,this.onError&&this.onError();return}this.initRenderer()}initState(){this.state={isActive:!0,isContextLost:!0,drawingEnabled:!0,forceRender:!1,currentProgramID:null,currentGeometryID:null,forceBufferUpdate:!1,depthTest:null,blending:null,cullFace:null,frameBufferID:null,scenePassIndex:null,activeTexture:null,unpackAlignment:null,flipY:null,premultiplyAlpha:null}}initCallbackQueueManager(){this.nextRender=new g}initRenderer(){this.planes=[],this.renderTargets=[],this.shaderPasses=[],this.state.isContextLost=!1,this.initCallbackQueueManager(),this.setBlendFunc(),this.setDepthFunc(),this.setDepthTest(!0),this.cache=new p,this.scene=new c(this),this.getExtensions(),this._contextLostHandler=this.contextLost.bind(this),this.canvas.addEventListener("webglcontextlost",this._contextLostHandler,!1),this._contextRestoredHandler=this.contextRestored.bind(this),this.canvas.addEventListener("webglcontextrestored",this._contextRestoredHandler,!1)}getExtensions(){this.extensions=[],this._isWebGL2?(this.extensions.EXT_color_buffer_float=this.gl.getExtension("EXT_color_buffer_float"),this.extensions.OES_texture_float_linear=this.gl.getExtension("OES_texture_float_linear"),this.extensions.EXT_texture_filter_anisotropic=this.gl.getExtension("EXT_texture_filter_anisotropic")):(this.extensions.OES_vertex_array_object=this.gl.getExtension("OES_vertex_array_object"),this.extensions.OES_texture_float=this.gl.getExtension("OES_texture_float"),this.extensions.OES_texture_float_linear=this.gl.getExtension("OES_texture_float_linear"),this.extensions.OES_texture_half_float=this.gl.getExtension("OES_texture_half_float"),this.extensions.OES_texture_half_float_linear=this.gl.getExtension("OES_texture_half_float_linear"),this.extensions.EXT_texture_filter_anisotropic=this.gl.getExtension("EXT_texture_filter_anisotropic"),this.extensions.OES_element_index_uint=this.gl.getExtension("OES_element_index_uint"),this.extensions.OES_standard_derivatives=this.gl.getExtension("OES_standard_derivatives"),this.extensions.EXT_sRGB=this.gl.getExtension("EXT_sRGB"),this.extensions.WEBGL_depth_texture=this.gl.getExtension("WEBGL_depth_texture"),this.extensions.WEBGL_draw_buffers=this.gl.getExtension("WEBGL_draw_buffers")),this.extensions.WEBGL_lose_context=this.gl.getExtension("WEBGL_lose_context")}contextLost(e){this.state.isContextLost=!0,this.state.isActive&&(e.preventDefault(),this.nextRender.add(()=>this.onContextLost&&this.onContextLost()))}restoreContext(){this.state.isActive&&(this.initState(),this.gl&&this.extensions.WEBGL_lose_context?this.extensions.WEBGL_lose_context.restoreContext():(this.gl||this.production?this.extensions.WEBGL_lose_context||this.production||o(this.type+": Could not restore the context because the restore context extension is not defined"):o(this.type+": Could not restore the context because the context is not defined"),this.onError&&this.onError()))}isContextexFullyRestored(){let e=!0;for(let t=0;t<this.renderTargets.length;t++){this.renderTargets[t].textures[0]._canDraw||(e=!1);break}if(e)for(let t=0;t<this.planes.length;t++)if(this.planes[t]._canDraw){for(let s=0;s<this.planes[t].textures.length;s++)if(!this.planes[t].textures[s]._canDraw){e=!1;break}}else{e=!1;break}if(e)for(let t=0;t<this.shaderPasses.length;t++)if(this.shaderPasses[t]._canDraw){for(let s=0;s<this.shaderPasses[t].textures.length;s++)if(!this.shaderPasses[t].textures[s]._canDraw){e=!1;break}}else{e=!1;break}return e}contextRestored(){this.getExtensions(),this.setBlendFunc(),this.setDepthFunc(),this.setDepthTest(!0),this.cache.clear(),this.scene.initStacks();for(let e=0;e<this.renderTargets.length;e++)this.renderTargets[e]._restoreContext();for(let e=0;e<this.planes.length;e++)this.planes[e]._restoreContext();for(let e=0;e<this.shaderPasses.length;e++)this.shaderPasses[e]._restoreContext();let e=this.nextRender.add(()=>{this.isContextexFullyRestored()&&(e.keep=!1,this.state.isContextLost=!1,this.onContextRestored&&this.onContextRestored(),this.onSceneChange(),this.needRender())},!0)}setPixelRatio(e){this.pixelRatio=e}setSize(){if(!this.gl)return;let e=this.container.getBoundingClientRect();this._boundingRect={width:e.width*this.pixelRatio,height:e.height*this.pixelRatio,top:e.top*this.pixelRatio,left:e.left*this.pixelRatio};let t=!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;t&&s&&(this._boundingRect.top=function(e){let t=0;for(;e&&!isNaN(e.offsetTop);)t+=e.offsetTop-e.scrollTop,e=e.offsetParent;return t}(this.container)*this.pixelRatio),this.canvas.style.width=Math.floor(this._boundingRect.width/this.pixelRatio)+"px",this.canvas.style.height=Math.floor(this._boundingRect.height/this.pixelRatio)+"px",this.canvas.width=Math.floor(this._boundingRect.width*this._renderingScale),this.canvas.height=Math.floor(this._boundingRect.height*this._renderingScale),this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}resize(){for(let e=0;e<this.planes.length;e++)this.planes[e]._canDraw&&this.planes[e].resize();for(let e=0;e<this.shaderPasses.length;e++)this.shaderPasses[e]._canDraw&&this.shaderPasses[e].resize();for(let e=0;e<this.renderTargets.length;e++)this.renderTargets[e].resize();this.needRender()}clear(){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}clearDepth(){this.gl.clear(this.gl.DEPTH_BUFFER_BIT)}clearColor(){this.gl.clear(this.gl.COLOR_BUFFER_BIT)}bindFrameBuffer(e,t){let s=null;e?(s=e.index)!==this.state.frameBufferID&&(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e._frameBuffer),this.gl.viewport(0,0,e._size.width,e._size.height),e._shouldClear&&!t&&this.clear()):null!==this.state.frameBufferID&&(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)),this.state.frameBufferID=s}setDepthTest(e){e&&!this.state.depthTest?(this.state.depthTest=e,this.gl.enable(this.gl.DEPTH_TEST)):!e&&this.state.depthTest&&(this.state.depthTest=e,this.gl.disable(this.gl.DEPTH_TEST))}setDepthFunc(){this.gl.depthFunc(this.gl.LEQUAL)}setBlending(e=!1){e&&!this.state.blending?(this.state.blending=e,this.gl.enable(this.gl.BLEND)):!e&&this.state.blending&&(this.state.blending=e,this.gl.disable(this.gl.BLEND))}setBlendFunc(){this.gl.enable(this.gl.BLEND),this.premultipliedAlpha?this.gl.blendFuncSeparate(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.blendFuncSeparate(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA)}setFaceCulling(e){if(this.state.cullFace!==e)if(this.state.cullFace=e,"none"===e)this.gl.disable(this.gl.CULL_FACE);else{let t="front"===e?this.gl.FRONT:this.gl.BACK;this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(t)}}useProgram(e){(null===this.state.currentProgramID||this.state.currentProgramID!==e.id)&&(this.gl.useProgram(e.program),this.state.currentProgramID=e.id)}removePlane(e){this.gl&&(this.planes=this.planes.filter(t=>t.uuid!==e.uuid),this.scene.removePlane(e),e=null,this.gl&&this.clear(),this.onSceneChange())}removeRenderTarget(e){if(!this.gl)return;let t=this.planes.find(t=>"PingPongPlane"!==t.type&&t.target&&t.target.uuid===e.uuid);for(let t=0;t<this.planes.length;t++)this.planes[t].target&&this.planes[t].target.uuid===e.uuid&&(this.planes[t].target=null);this.renderTargets=this.renderTargets.filter(t=>t.uuid!==e.uuid);for(let e=0;e<this.renderTargets.length;e++)this.renderTargets[e].index=e;e=null,this.gl&&this.clear(),t&&this.scene.resetPlaneStacks(),this.onSceneChange()}removeShaderPass(e){this.gl&&(this.shaderPasses=this.shaderPasses.filter(t=>t.uuid!==e.uuid),this.scene.removeShaderPass(e),e=null,this.gl&&this.clear(),this.onSceneChange())}enableDrawing(){this.state.drawingEnabled=!0}disableDrawing(){this.state.drawingEnabled=!1}needRender(){this.state.forceRender=!0}render(){this.gl&&(this.clear(),this.state.currentGeometryID=null,this.scene.draw())}deletePrograms(){for(let e=0;e<this.cache.programs.length;e++){let t=this.cache.programs[e];this.gl.deleteProgram(t.program)}}dispose(){if(!this.gl)return;for(this.state.isActive=!1;this.planes.length>0;)this.removePlane(this.planes[0]);for(;this.shaderPasses.length>0;)this.removeShaderPass(this.shaderPasses[0]);for(;this.renderTargets.length>0;)this.removeRenderTarget(this.renderTargets[0]);let e=this.nextRender.add(()=>{0===this.planes.length&&0===this.shaderPasses.length&&0===this.renderTargets.length&&(e.keep=!1,this.deletePrograms(),this.clear(),this.canvas.removeEventListener("webgllost",this._contextLostHandler,!1),this.canvas.removeEventListener("webglrestored",this._contextRestoredHandler,!1),this.gl&&this.extensions.WEBGL_lose_context&&this.extensions.WEBGL_lose_context.loseContext(),this.canvas.width=this.canvas.width,this.gl=null,this.container.removeChild(this.canvas),this.container=null,this.canvas=null,this.onDisposed&&this.onDisposed())},!0)}}class _{constructor({xOffset:e=0,yOffset:t=0,lastXDelta:s=0,lastYDelta:i=0,shouldWatch:r=!0,onScroll:a=()=>{}}={}){this.xOffset=e,this.yOffset=t,this.lastXDelta=s,this.lastYDelta=i,this.shouldWatch=r,this.onScroll=a,this.handler=this.scroll.bind(this,!0),this.shouldWatch&&window.addEventListener("scroll",this.handler,{passive:!0})}scroll(){this.updateScrollValues(window.pageXOffset,window.pageYOffset)}updateScrollValues(e,t){let s=this.xOffset;this.xOffset=e,this.lastXDelta=s-this.xOffset;let i=this.yOffset;this.yOffset=t,this.lastYDelta=i-this.yOffset,this.onScroll&&this.onScroll(this.lastXDelta,this.lastYDelta)}dispose(){this.shouldWatch&&window.removeEventListener("scroll",this.handler,{passive:!0})}}class f{constructor({container:e,alpha:t=!0,premultipliedAlpha:s=!1,antialias:i=!0,depth:r=!0,failIfMajorPerformanceCaveat:a=!0,preserveDrawingBuffer:n=!1,stencil:h=!1,autoResize:l=!0,autoRender:d=!0,watchScroll:u=!0,pixelRatio:c=window.devicePixelRatio||1,renderingScale:p=1,production:g=!1}={}){this.type="Curtains",this._autoResize=l,this._autoRender=d,this._watchScroll=u,this.pixelRatio=c,p=isNaN(p)?1:parseFloat(p),this._renderingScale=Math.max(.25,Math.min(1,p)),this.premultipliedAlpha=s,this.alpha=t,this.antialias=i,this.depth=r,this.failIfMajorPerformanceCaveat=a,this.preserveDrawingBuffer=n,this.stencil=h,this.production=g,this.errors=!1,e?this.setContainer(e):this.production||o(this.type+": no container provided in the initial parameters. Use setContainer() method to set one later and initialize the WebGL context")}setContainer(e){if(e)if("string"==typeof e)if(e=document.getElementById(e))this.container=e;else{let e=document.createElement("div");e.setAttribute("id","curtains-canvas"),document.body.appendChild(e),this.container=e,this.production||o('Curtains: no valid container HTML element or ID provided, created a div with "curtains-canvas" ID instead')}else e instanceof Element&&(this.container=e);else{let e=document.createElement("div");e.setAttribute("id","curtains-canvas"),document.body.appendChild(e),this.container=e,this.production||o('Curtains: no valid container HTML element or ID provided, created a div with "curtains-canvas" ID instead')}this._initCurtains()}_initCurtains(){this.planes=[],this.renderTargets=[],this.shaderPasses=[],this._initRenderer(),this.gl&&(this._initScroll(),this._setSize(),this._addListeners(),this.container.appendChild(this.canvas),console.log("curtains.js - v8.1.0"),this._animationFrameID=null,this._autoRender&&this._animate())}_initRenderer(){this.renderer=new m({alpha:this.alpha,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,depth:this.depth,failIfMajorPerformanceCaveat:this.failIfMajorPerformanceCaveat,preserveDrawingBuffer:this.preserveDrawingBuffer,stencil:this.stencil,container:this.container,pixelRatio:this.pixelRatio,renderingScale:this._renderingScale,production:this.production,onError:()=>this._onRendererError(),onSuccess:()=>this._onRendererSuccess(),o
1nContextLost:()=>this._onRendererContextLost(),onContextRestored:()=>this._onRendererContextRestored(),onDisposed:()=>this._onRendererDisposed(),onSceneChange:()=>this._keepSync()}),this.gl=this.renderer.gl,this.canvas=this.renderer.canvas}restoreContext(){this.renderer.restoreContext()}_animate(){this.render(),this._animationFrameID=window.requestAnimationFrame(this._animate.bind(this))}enableDrawing(){this.renderer.enableDrawing()}disableDrawing(){this.renderer.disableDrawing()}needRender(){this.renderer.needRender()}nextRender(e,t=!1){return this.renderer.nextRender.add(e,t)}clear(){this.renderer&&this.renderer.clear()}clearDepth(){this.renderer&&this.renderer.clearDepth()}clearColor(){this.renderer&&this.renderer.clearColor()}isWebGL2(){return!!this.gl&&this.renderer._isWebGL2}render(){this.renderer.nextRender.execute(),(this.renderer.state.drawingEnabled||this.renderer.state.forceRender)&&(this.renderer.state.forceRender&&(this.renderer.state.forceRender=!1),this._onRenderCallback&&this._onRenderCallback(),this.renderer.render())}_addListeners(){this._resizeHandler=null,this._autoResize&&(this._resizeHandler=this.resize.bind(this,!0),window.addEventListener("resize",this._resizeHandler,!1))}setPixelRatio(e,t){this.pixelRatio=parseFloat(Math.max(e,1))||1,this.renderer.setPixelRatio(e),this.resize(t)}_setSize(){this.renderer.setSize(),this._scrollManager.shouldWatch&&(this._scrollManager.xOffset=window.pageXOffset,this._scrollManager.yOffset=window.pageYOffset)}getBoundingRect(){return this.renderer._boundingRect}resize(e){this.gl&&(this._setSize(),this.renderer.resize(),this.nextRender(()=>{this._onAfterResizeCallback&&e&&this._onAfterResizeCallback()}))}_initScroll(){this._scrollManager=new _({xOffset:window.pageXOffset,yOffset:window.pageYOffset,lastXDelta:0,lastYDelta:0,shouldWatch:this._watchScroll,onScroll:(e,t)=>this._updateScroll(e,t)})}_updateScroll(e,t){for(let s=0;s<this.planes.length;s++)this.planes[s].watchScroll&&this.planes[s].updateScrollPosition(e,t);this.renderer.needRender(),this._onScrollCallback&&this._onScrollCallback()}updateScrollValues(e,t){this._scrollManager.updateScrollValues(e,t)}getScrollDeltas(){return{x:this._scrollManager.lastXDelta,y:this._scrollManager.lastYDelta}}getScrollValues(){return{x:this._scrollManager.xOffset,y:this._scrollManager.yOffset}}_keepSync(){this.planes=this.renderer.planes,this.shaderPasses=this.renderer.shaderPasses,this.renderTargets=this.renderer.renderTargets}lerp(e,t,s){return(1-s)*e+s*t}onAfterResize(e){return e&&(this._onAfterResizeCallback=e),this}onError(e){return e&&(this._onErrorCallback=e),this}_onRendererError(){setTimeout(()=>{this._onErrorCallback&&!this.errors&&this._onErrorCallback(),this.errors=!0},0)}onSuccess(e){return e&&(this._onSuccessCallback=e),this}_onRendererSuccess(){setTimeout(()=>{this._onSuccessCallback&&this._onSuccessCallback()},0)}onContextLost(e){return e&&(this._onContextLostCallback=e),this}_onRendererContextLost(){this._onContextLostCallback&&this._onContextLostCallback()}onContextRestored(e){return e&&(this._onContextRestoredCallback=e),this}_onRendererContextRestored(){this._onContextRestoredCallback&&this._onContextRestoredCallback()}onRender(e){return e&&(this._onRenderCallback=e),this}onScroll(e){return e&&(this._onScrollCallback=e),this}dispose(){this.renderer.dispose()}_onRendererDisposed(){this._animationFrameID&&window.cancelAnimationFrame(this._animationFrameID),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler,!1),this._scrollManager&&this._scrollManager.dispose()}}class x{constructor(e,t,s){if(this.type="Uniforms",e&&"Renderer"===e.type){if(!e.gl)return void l(this.type+": Renderer WebGL context is undefined",e)}else l(this.type+": Renderer not passed as first argument",e);if(this.renderer=e,this.gl=e.gl,this.program=t,this.uniforms={},s)for(const e in s){const t=s[e];this.uniforms[e]={name:t.name,type:t.type,value:t.value.clone&&"function"==typeof t.value.clone?t.value.clone():t.value,update:null}}}handleUniformSetting(e){switch(e.type){case"1i":e.update=this.setUniform1i.bind(this);break;case"1iv":e.update=this.setUniform1iv.bind(this);break;case"1f":e.update=this.setUniform1f.bind(this);break;case"1fv":e.update=this.setUniform1fv.bind(this);break;case"2i":e.update=this.setUniform2i.bind(this);break;case"2iv":e.update=this.setUniform2iv.bind(this);break;case"2f":e.update=this.setUniform2f.bind(this);break;case"2fv":e.update=this.setUniform2fv.bind(this);break;case"3i":e.update=this.setUniform3i.bind(this);break;case"3iv":e.update=this.setUniform3iv.bind(this);break;case"3f":e.update=this.setUniform3f.bind(this);break;case"3fv":e.update=this.setUniform3fv.bind(this);break;case"4i":e.update=this.setUniform4i.bind(this);break;case"4iv":e.update=this.setUniform4iv.bind(this);break;case"4f":e.update=this.setUniform4f.bind(this);break;case"4fv":e.update=this.setUniform4fv.bind(this);break;case"mat2":e.update=this.setUniformMatrix2fv.bind(this);break;case"mat3":e.update=this.setUniformMatrix3fv.bind(this);break;case"mat4":e.update=this.setUniformMatrix4fv.bind(this);break;default:this.renderer.production||o(this.type+": This uniform type is not handled : ",e.type)}}setInternalFormat(e){"Vec2"===e.value.type?(e._internalFormat="Vec2",e.lastValue=e.value.clone()):"Vec3"===e.value.type?(e._internalFormat="Vec3",e.lastValue=e.value.clone()):"Mat4"===e.value.type?(e._internalFormat="Mat4",e.lastValue=e.value.clone()):"Quat"===e.value.type?(e._internalFormat="Quat",e.lastValue=e.value.clone()):Array.isArray(e.value)?(e._internalFormat="array",e.lastValue=Array.from(e.value)):(e.value.constructor===Float32Array?e._internalFormat="mat":e._internalFormat="float",e.lastValue=e.value)}setUniforms(){if(this.uniforms)for(let e in this.uniforms){let t=this.uniforms[e];t.location=this.gl.getUniformLocation(this.program,t.name),t._internalFormat||this.setInternalFormat(t),!t.type&&("Vec2"===t._internalFormat?t.type="2f":"Vec3"===t._internalFormat?t.type="3f":"Mat4"===t._internalFormat?t.type="mat4":"array"===t._internalFormat?4===t.value.length?(t.type="4f",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a 4f (array of 4 floats) uniform type")):3===t.value.length?(t.type="3f",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a 3f (array of 3 floats) uniform type")):2===t.value.length&&(t.type="2f",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a 2f (array of 2 floats) uniform type")):"mat"===t._internalFormat?16===t.value.length?(t.type="mat4",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a mat4 (4x4 matrix array) uniform type")):9===t.value.length?(t.type="mat3",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a mat3 (3x3 matrix array) uniform type")):4===t.value.length&&(t.type="mat2",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a mat2 (2x2 matrix array) uniform type")):(t.type="1f",this.renderer.production||o(this.type+": No uniform type declared for "+t.name+", applied a 1f (float) uniform type"))),this.handleUniformSetting(t),t.update&&t.update(t)}}updateUniforms(){if(this.uniforms)for(let e in this.uniforms){let t=this.uniforms[e],s=!1;"Vec2"===t._internalFormat||"Vec3"===t._internalFormat||"Quat"===t._internalFormat?t.value.equals(t.lastValue)||(s=!0,t.lastValue.copy(t.value)):t.value.length?JSON.stringify(t.value)!==JSON.stringify(t.lastValue)&&(s=!0,t.lastValue=Array.from(t.value)):t.value!==t.lastValue&&(s=!0,t.lastValue=t.value),s&&t.update&&t.update(t)}}setUniform1i(e){this.gl.uniform1i(e.location,e.value)}setUniform1iv(e){this.gl.uniform1iv(e.location,e.value)}setUniform1f(e){this.gl.uniform1f(e.location,e.value)}setUniform1fv(e){this.gl.uniform1fv(e.location,e.value)}setUniform2i(e){"Vec2"===e._internalFormat?this.gl.uniform2i(e.location,e.value.x,e.value.y):this.gl.uniform2i(e.location,e.value[0],e.value[1])}setUniform2iv(e){"Vec2"===e._internalFormat?this.gl.uniform2iv(e.location,[e.value.x,e.value.y]):this.gl.uniform2iv(e.location,e.value)}setUniform2f(e){"Vec2"===e._internalFormat?this.gl.uniform2f(e.location,e.value.x,e.value.y):this.gl.uniform2f(e.location,e.value[0],e.value[1])}setUniform2fv(e){"Vec2"===e._internalFormat?this.gl.uniform2fv(e.location,[e.value.x,e.value.y]):this.gl.uniform2fv(e.location,e.value)}setUniform3i(e){"Vec3"===e._internalFormat?this.gl.uniform3i(e.location,e.value.x,e.value.y,e.value.z):this.gl.uniform3i(e.location,e.value[0],e.value[1],e.value[2])}setUniform3iv(e){"Vec3"===e._internalFormat?this.gl.uniform3iv(e.location,[e.value.x,e.value.y,e.value.z]):this.gl.uniform3iv(e.location,e.value)}setUniform3f(e){"Vec3"===e._internalFormat?this.gl.uniform3f(e.location,e.value.x,e.value.y,e.value.z):this.gl.uniform3f(e.location,e.value[0],e.value[1],e.value[2])}setUniform3fv(e){"Vec3"===e._internalFormat?this.gl.uniform3fv(e.location,[e.value.x,e.value.y,e.value.z]):this.gl.uniform3fv(e.location,e.value)}setUniform4i(e){"Quat"===e._internalFormat?this.gl.uniform4i(e.location,e.value.elements[0],e.value.elements[1],e.value.elements[2],e.value[3]):this.gl.uniform4i(e.location,e.value[0],e.value[1],e.value[2],e.value[3])}setUniform4iv(e){"Quat"===e._internalFormat?this.gl.uniform4iv(e.location,[e.value.elements[0],e.value.elements[1],e.value.elements[2],e.value[3]]):this.gl.uniform4iv(e.location,e.value)}setUniform4f(e){"Quat"===e._internalFormat?this.gl.uniform4f(e.location,e.value.elements[0],e.value.elements[1],e.value.elements[2],e.value[3]):this.gl.uniform4f(e.location,e.value[0],e.value[1],e.value[2],e.value[3])}setUniform4fv(e){"Quat"===e._internalFormat?this.gl.uniform4fv(e.location,[e.value.elements[0],e.value.elements[1],e.value.elements[2],e.value[3]]):this.gl.uniform4fv(e.location,e.value)}setUniformMatrix2fv(e){this.gl.uniformMatrix2fv(e.location,!1,e.value)}setUniformMatrix3fv(e){this.gl.uniformMatrix3fv(e.location,!1,e.value)}setUniformMatrix4fv(e){"Mat4"===e._internalFormat?this.gl.uniformMatrix4fv(e.location,!1,e.value.elements):this.gl.uniformMatrix4fv(e.location,!1,e.value)}}var b=`
2precision mediump float;
3`.replace(/\n/g,""),y=`
4attribute vec3 aVertexPosition;
5attribute vec2 aTextureCoord;
6`.replace(/\n/g,""),v=`
7varying vec3 vVertexPosition;
8varying vec2 vTextureCoord;
9`.replace(/\n/g,""),R=(b+y+v+`
10uniform mat4 uMVMatrix;
11uniform mat4 uPMatrix;
12
13void main() {
14    vTextureCoord = aTextureCoord;
15    vVertexPosition = aVertexPosition;
16    
17    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0
17);
18}
19`).replace(/\n/g,""),w=(b+v+`
20void main() {
21    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
22}
23`).replace(/\n/g,""),S=(b+y+v+`
24void main() {
25    vTextureCoord = aTextureCoord;
26    vVertexPosition = aVertexPosition;
27    
28    gl_Position = vec4(aVertexPosition, 1.0);
29}
30`).replace(/\n/g,""),T=(b+v+`
31uniform sampler2D uRenderTexture;
32
33void main() {
34    gl_FragColor = texture2D(uRenderTexture, vTextureCoord);
35}
36`).replace(/\n/g,"");let P=0;class E{constructor(e,{parent:t,vertexShader:s,fragmentShader:i}={}){if(this.type="Program",e&&"Renderer"===e.type){if(!e.gl)return void l(this.type+": Renderer WebGL context is undefined",e)}else l(this.type+": Renderer not passed as first argument",e);this.renderer=e,this.gl=this.renderer.gl,this.parent=t,this.defaultVsCode="Plane"===this.parent.type?R:S,this.defaultFsCode="Plane"===this.parent.type?w:T,s?this.vsCode=s:(this.renderer.production||"Plane"!==this.parent.type||o(this.parent.type+": No vertex shader provided, will use a default one"),this.vsCode=this.defaultVsCode),i?this.fsCode=i:(this.renderer.production||o(this.parent.type+": No fragment shader provided, will use a default one"),this.fsCode=this.defaultFsCode),this.compiled=!0,this.setupProgram()}createShader(e,t){let s=this.gl.createShader(t);if(this.gl.shaderSource(s,e),this.gl.compileShader(s),!this.renderer.production&&!this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)){let e=t===this.gl.VERTEX_SHADER?"vertex shader":"fragment shader",i=this.gl.getShaderSource(s).split("\n");for(let e=0;e<i.length;e++)i[e]=e+1+": "+i[e];return i=i.join("\n"),o(this.type+": Errors occurred while compiling the",e,":\n",this.gl.getShaderInfoLog(s)),l(i),o(this.type+": Will use a default",e),this.createShader(t===this.gl.VERTEX_SHADER?this.defaultVsCode:this.defaultFsCode,t)}return s}useNewShaders(){this.vertexShader=this.createShader(this.vsCode,this.gl.VERTEX_SHADER),this.fragmentShader=this.createShader(this.fsCode,this.gl.FRAGMENT_SHADER),this.vertexShader&&this.fragmentShader||this.renderer.production||o(this.type+": Unable to find or compile the vertex or fragment shader")}setupProgram(){let e=this.renderer.cache.getProgramFromShaders(this.vsCode,this.fsCode);e?(this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.activeUniforms=e.activeUniforms,this.createProgram()):(this.useNewShaders(),this.compiled&&(this.createProgram(),this.renderer.cache.addProgram(this)))}createProgram(){if(P++,this.id=P,this.program=this.gl.createProgram(),this.gl.attachShader(this.program,this.vertexShader),this.gl.attachShader(this.program,this.fragmentShader),this.gl.linkProgram(this.program),!this.renderer.production&&!this.gl.getProgramParameter(this.program,this.gl.LINK_STATUS)){o(this.type+": Unable to initialize the shader program: "+this.gl.getProgramInfoLog(this.program)),o(this.type+": Will use default vertex and fragment shaders"),this.vertexShader=this.createShader(this.defaultVsCode,this.gl.VERTEX_SHADER),this.fragmentShader=this.createShader(this.defaultFsCode,this.gl.FRAGMENT_SHADER),this.createProgram();return}if(this.gl.deleteShader(this.vertexShader),this.gl.deleteShader(this.fragmentShader),!this.activeUniforms){this.activeUniforms={textures:[],textureMatrices:[]};let e=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_UNIFORMS);for(let t=0;t<e;t++){let e=this.gl.getActiveUniform(this.program,t);e.type===this.gl.SAMPLER_2D&&this.activeUniforms.textures.push(e.name),e.type===this.gl.FLOAT_MAT4&&"uMVMatrix"!==e.name&&"uPMatrix"!==e.name&&this.activeUniforms.textureMatrices.push(e.name)}}}createUniforms(e){this.uniformsManager=new x(this.renderer,this.program,e),this.setUniforms()}setUniforms(){this.renderer.useProgram(this),this.uniformsManager.setUniforms()}updateUniforms(){this.renderer.useProgram(this),this.uniformsManager.updateUniforms()}}class C{constructor(e,{program:t=null,width:s=1,height:i=1}={}){if(this.type="Geometry",e&&"Renderer"===e.type){if(!e.gl)return void l(this.type+": Renderer WebGL context is undefined",e)}else l(this.type+": Renderer not passed as first argument",e);this.renderer=e,this.gl=this.renderer.gl,this.definition={id:s*i+s,width:s,height:i},this.setDefaultAttributes(),this.setVerticesUVs()}restoreContext(e){this.program=null,this.setDefaultAttributes(),this.setVerticesUVs(),this.setProgram(e)}setDefaultAttributes(){this.attributes={vertexPosition:{name:"aVertexPosition",size:3},textureCoord:{name:"aTextureCoord",size:3}}}setVerticesUVs(){let e=this.renderer.cache.getGeometryFromID(this.definition.id);e?(this.attributes.vertexPosition.array=e.vertices,this.attributes.textureCoord.array=e.uvs):(this.computeVerticesUVs(),this.renderer.cache.addGeometry(this.definition.id,this.attributes.vertexPosition.array,this.attributes.textureCoord.array))}setProgram(e){this.program=e.program,this.initAttributes(),this.renderer._isWebG
36L2?(this._vao=this.gl.createVertexArray(),this.gl.bindVertexArray(this._vao)):this.renderer.extensions.OES_vertex_array_object&&(this._vao=this.renderer.extensions.OES_vertex_array_object.createVertexArrayOES(),this.renderer.extensions.OES_vertex_array_object.bindVertexArrayOES(this._vao)),this.initializeBuffers()}initAttributes(){for(let e in this.attributes)this.attributes[e].location=this.gl.getAttribLocation(this.program,this.attributes[e].name),this.attributes[e].buffer=this.gl.createBuffer(),this.attributes[e].numberOfItems=this.definition.width*this.definition.height*this.attributes[e].size*2}computeVerticesUVs(){this.attributes.vertexPosition.array=[],this.attributes.textureCoord.array=[];let e=this.attributes.vertexPosition.array,t=this.attributes.textureCoord.array;for(let s=0;s<this.definition.height;s++){let i=s/this.definition.height;for(let s=0;s<this.definition.width;s++){let r=s/this.definition.width;t.push(r),t.push(i),t.push(0),e.push((r-.5)*2),e.push((i-.5)*2),e.push(0),t.push(r+1/this.definition.width),t.push(i),t.push(0),e.push((r+1/this.definition.width-.5)*2),e.push((i-.5)*2),e.push(0),t.push(r),t.push(i+1/this.definition.height),t.push(0),e.push((r-.5)*2),e.push((i+1/this.definition.height-.5)*2),e.push(0),t.push(r),t.push(i+1/this.definition.height),t.push(0),e.push((r-.5)*2),e.push((i+1/this.definition.height-.5)*2),e.push(0),t.push(r+1/this.definition.width),t.push(i),t.push(0),e.push((r+1/this.definition.width-.5)*2),e.push((i-.5)*2),e.push(0),t.push(r+1/this.definition.width),t.push(i+1/this.definition.height),t.push(0),e.push((r+1/this.definition.width-.5)*2),e.push((i+1/this.definition.height-.5)*2),e.push(0)}}}initializeBuffers(){if(this.attributes){for(let e in this.attributes)this.gl.enableVertexAttribArray(this.attributes[e].location),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.attributes[e].buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.attributes[e].array),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.attributes[e].location,this.attributes[e].size,this.gl.FLOAT,!1,0,0);this.renderer.state.currentGeometryID=this.definition.id}}bindBuffers(){if(this._vao)this.renderer._isWebGL2?this.gl.bindVertexArray(this._vao):this.renderer.extensions.OES_vertex_array_object.bindVertexArrayOES(this._vao);else for(let e in this.attributes)this.gl.enableVertexAttribArray(this.attributes[e].location),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.attributes[e].buffer),this.gl.vertexAttribPointer(this.attributes[e].location,this.attributes[e].size,this.gl.FLOAT,!1,0,0);this.renderer.state.currentGeometryID=this.definition.id}draw(){this.gl.drawArrays(this.gl.TRIANGLES,0,this.attributes.vertexPosition.numberOfItems)}dispose(){for(let e in this._vao&&(this.renderer._isWebGL2?this.gl.deleteVertexArray(this._vao):this.renderer.extensions.OES_vertex_array_object.deleteVertexArrayOES(this._vao)),this.attributes)this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.attributes[e].buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,1,this.gl.STATIC_DRAW),this.gl.deleteBuffer(this.attributes[e].buffer);this.attributes=null,this.renderer.state.currentGeometryID=null}}class M{constructor(e=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){this.type="Mat4",this.elements=e}setFromArray(e){for(let t=0;t<this.elements.length;t++)this.elements[t]=e[t];return this}copy(e){let t=e.elements;return this.elements[0]=t[0],this.elements[1]=t[1],this.elements[2]=t[2],this.elements[3]=t[3],this.elements[4]=t[4],this.elements[5]=t[5],this.elements[6]=t[6],this.elements[7]=t[7],this.elements[8]=t[8],this.elements[9]=t[9],this.elements[10]=t[10],this.elements[11]=t[11],this.elements[12]=t[12],this.elements[13]=t[13],this.elements[14]=t[14],this.elements[15]=t[15],this}clone(){return new M().copy(this)}multiply(e){let t=this.elements,s=e.elements,i=new M;return i.elements[0]=s[0]*t[0]+s[1]*t[4]+s[2]*t[8]+s[3]*t[12],i.elements[1]=s[0]*t[1]+s[1]*t[5]+s[2]*t[9]+s[3]*t[13],i.elements[2]=s[0]*t[2]+s[1]*t[6]+s[2]*t[10]+s[3]*t[14],i.elements[3]=s[0]*t[3]+s[1]*t[7]+s[2]*t[11]+s[3]*t[15],i.elements[4]=s[4]*t[0]+s[5]*t[4]+s[6]*t[8]+s[7]*t[12],i.elements[5]=s[4]*t[1]+s[5]*t[5]+s[6]*t[9]+s[7]*t[13],i.elements[6]=s[4]*t[2]+s[5]*t[6]+s[6]*t[10]+s[7]*t[14],i.elements[7]=s[4]*t[3]+s[5]*t[7]+s[6]*t[11]+s[7]*t[15],i.elements[8]=s[8]*t[0]+s[9]*t[4]+s[10]*t[8]+s[11]*t[12],i.elements[9]=s[8]*t[1]+s[9]*t[5]+s[10]*t[9]+s[11]*t[13],i.elements[10]=s[8]*t[2]+s[9]*t[6]+s[10]*t[10]+s[11]*t[14],i.elements[11]=s[8]*t[3]+s[9]*t[7]+s[10]*t[11]+s[11]*t[15],i.elements[12]=s[12]*t[0]+s[13]*t[4]+s[14]*t[8]+s[15]*t[12],i.elements[13]=s[12]*t[1]+s[13]*t[5]+s[14]*t[9]+s[15]*t[13],i.elements[14]=s[12]*t[2]+s[13]*t[6]+s[14]*t[10]+s[15]*t[14],i.elements[15]=s[12]*t[3]+s[13]*t[7]+s[14]*t[11]+s[15]*t[15],i}getInverse(){let e=this.elements,t=new M,s=t.elements,i=e[0],r=e[1],a=e[2],n=e[3],h=e[4],o=e[5],l=e[6],d=e[7],u=e[8],c=e[9],p=e[10],g=e[11],m=e[12],_=e[13],f=e[14],x=e[15],b=i*o-r*h,y=i*l-a*h,v=i*d-n*h,R=r*l-a*o,w=r*d-n*o,S=a*d-n*l,T=u*_-c*m,P=u*f-p*m,E=u*x-g*m,C=c*f-p*_,A=c*x-g*_,k=p*x-g*f,F=b*k-y*A+v*C+R*E-w*P+S*T;return F?(F=1/F,s[0]=(o*k-l*A+d*C)*F,s[1]=(a*A-r*k-n*C)*F,s[2]=(_*S-f*w+x*R)*F,s[3]=(p*w-c*S-g*R)*F,s[4]=(l*E-h*k-d*P)*F,s[5]=(i*k-a*E+n*P)*F,s[6]=(f*v-m*S-x*y)*F,s[7]=(u*S-p*v+g*y)*F,s[8]=(h*A-o*E+d*T)*F,s[9]=(r*E-i*A-n*T)*F,s[10]=(m*w-_*v+x*b)*F,s[11]=(c*v-u*w-g*b)*F,s[12]=(o*P-h*C-l*T)*F,s[13]=(i*C-r*P+a*T)*F,s[14]=(_*y-m*R-f*b)*F,s[15]=(u*R-c*y+p*b)*F,t):null}scale(e){let t=this.elements;return t[0]*=e.x,t[1]*=e.x,t[2]*=e.x,t[3]*=e.x,t[4]*=e.y,t[5]*=e.y,t[6]*=e.y,t[7]*=e.y,t[8]*=e.z,t[9]*=e.z,t[10]*=e.z,t[11]*=e.z,this}compose(e,t,s){let i=this.elements,r=t.elements[0],a=t.elements[1],n=t.elements[2],h=t.elements[3],o=r+r,l=a+a,d=n+n,u=r*o,c=r*l,p=r*d,g=a*l,m=a*d,_=n*d,f=h*o,x=h*l,b=h*d,y=s.x,v=s.y,R=s.z;return i[0]=(1-(g+_))*y,i[1]=(c+b)*y,i[2]=(p-x)*y,i[3]=0,i[4]=(c-b)*v,i[5]=(1-(u+_))*v,i[6]=(m+f)*v,i[7]=0,i[8]=(p+x)*R,i[9]=(m-f)*R,i[10]=(1-(u+g))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}composeFromOrigin(e,t,s,i){let r=this.elements,a=t.elements[0],n=t.elements[1],h=t.elements[2],o=t.elements[3],l=a+a,d=n+n,u=h+h,c=a*l,p=a*d,g=a*u,m=n*d,_=n*u,f=h*u,x=o*l,b=o*d,y=o*u,v=s.x,R=s.y,w=s.z,S=i.x,T=i.y,P=i.z,E=(1-(m+f))*v,C=(p+y)*v,M=(g-b)*v,A=(p-y)*R,k=(1-(c+f))*R,F=(_+x)*R,L=(g+b)*w,O=(_-x)*w,D=(1-(c+m))*w;return r[0]=E,r[1]=C,r[2]=M,r[3]=0,r[4]=A,r[5]=k,r[6]=F,r[7]=0,r[8]=L,r[9]=O,r[10]=D,r[11]=0,r[12]=e.x+S-(E*S+A*T+L*P),r[13]=e.y+T-(C*S+k*T+O*P),r[14]=e.z+P-(M*S+F*T+D*P),r[15]=1,this}}class A{constructor(e=0,t=e){this.type="Vec2",this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}set x(e){let t=e!==this._x;this._x=e,t&&this._onChangeCallback&&this._onChangeCallback()}set y(e){let t=e!==this._y;this._y=e,t&&this._onChangeCallback&&this._onChangeCallback()}onChange(e){return e&&(this._onChangeCallback=e),this}set(e,t){return this._x=e,this._y=t,this}add(e){return this._x+=e.x,this._y+=e.y,this}addScalar(e){return this._x+=e,this._y+=e,this}sub(e){return this._x-=e.x,this._y-=e.y,this}subScalar(e){return this._x-=e,this._y-=e,this}
36multiply(e){return this._x*=e.x,this._y*=e.y,this}multiplyScalar(e){return this._x*=e,this._y*=e,this}copy(e){return this._x=e.x,this._y=e.y,this}clone(){return new A(this._x,this._y)}sanitizeNaNValuesWith(e){return this._x=isNaN(this._x)?e.x:parseFloat(this._x),this._y=isNaN(this._y)?e.y:parseFloat(this._y),this}max(e){return this._x=Math.max(this._x,e.x),this._y=Math.max(this._y,e.y),this}min(e){return this._x=Math.min(this._x,e.x),this._y=Math.min(this._y,e.y),this}equals(e){return this._x===e.x&&this._y===e.y}normalize(){let e=this._x*this._x+this._y*this._y;return e>0&&(e=1/Math.sqrt(e)),this._x*=e,this._y*=e,this}dot(e){return this._x*e.x+this._y*e.y}}class k{constructor(e=0,t=e,s=e){this.type="Vec3",this._x=e,this._y=t,this._z=s}get x(){return this._x}get y(){return this._y}get z(){return this._z}set x(e){let t=e!==this._x;this._x=e,t&&this._onChangeCallback&&this._onChangeCallback()}set y(e){let t=e!==this._y;this._y=e,t&&this._onChangeCallback&&this._onChangeCallback()}set z(e){let t=e!==this._z;this._z=e,t&&this._onChangeCallback&&this._onChangeCallback()}onChange(e){return e&&(this._onChangeCallback=e),this}set(e,t,s){return this._x=e,this._y=t,this._z=s,this}add(e){return this._x+=e.x,this._y+=e.y,this._z+=e.z,this}addScalar(e){return this._x+=e,this._y+=e,this._z+=e,this}sub(e){return this._x-=e.x,this._y-=e.y,this._z-=e.z,this}subScalar(e){return this._x-=e,this._y-=e,this._z-=e,this}multiply(e){return this._x*=e.x,this._y*=e.y,this._z*=e.z,this}multiplyScalar(e){return this._x*=e,this._y*=e,this._z*=e,this}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this}clone(){return new k(this._x,this._y,this._z)}sanitizeNaNValuesWith(e){return this._x=isNaN(this._x)?e.x:parseFloat(this._x),this._y=isNaN(this._y)?e.y:parseFloat(this._y),this._z=isNaN(this._z)?e.z:parseFloat(this._z),this}max(e){return this._x=Math.max(this._x,e.x),this._y=Math.max(this._y,e.y),this._z=Math.max(this._z,e.z),this}min(e){return this._x=Math.min(this._x,e.x),this._y=Math.min(this._y,e.y),this._z=Math.min(this._z,e.z),this}equals(e){return this._x===e.x&&this._y===e.y&&this._z===e.z}normalize(){let e=this._x*this._x+this._y*this._y+this._z*this._z;return e>0&&(e=1/Math.sqrt(e)),this._x*=e,this._y*=e,this._z*=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z}applyMat4(e){let t=this._x,s=this._y,i=this._z,r=e.elements,a=r[3]*t+r[7]*s+r[11]*i+r[15];return a=a||1,this._x=(r[0]*t+r[4]*s+r[8]*i+r[12])/a,this._y=(r[1]*t+r[5]*s+r[9]*i+r[13])/a,this._z=(r[2]*t+r[6]*s+r[10]*i+r[14])/a,this}applyQuat(e){let t=this._x,s=this._y,i=this._z,r=e.elements[0],a=e.elements[1],n=e.elements[2],h=e.elements[3],o=h*t+a*i-n*s,l=h*s+n*t-r*i,d=h*i+r*s-a*t,u=-r*t-a*s-n*i;return this._x=o*h+-(u*r)+-(l*n)- -(d*a),this._y=l*h+-(u*a)+-(d*r)- -(o*n),this._z=d*h+-(u*n)+-(o*a)- -(l*r),this}project(e){return this.applyMat4(e.viewMatrix).applyMat4(e.projectionMatrix),this}unproject(e){return this.applyMat4(e.projectionMatrix.getInverse()).applyMat4(e.worldMatrix),this}}let F=new A,L=new k,O=new M;class D{constructor(e,{isFBOTexture:t=!1,fromTexture:s=!1,loader:i,sampler:r,floatingPoint:a="none",premultiplyAlpha:n=!1,anisotropy:h=1,generateMipmap:o=null,wrapS:u,wrapT:c,minFilter:p,magFilter:g}={}){if(this.type="Texture",(e=e&&e.renderer||e)&&"Renderer"===e.type){if(!e.gl){e.production||l(this.type+": Unable to create a "+this.type+" because the Renderer WebGL context is not defined");return}}else l(this.type+": Renderer not passed as first argument",e);if(this.renderer=e,this.gl=this.renderer.gl,this.uuid=d(),this._globalParameters={unpackAlignment:4,flipY:!t,premultiplyAlpha:!1,shouldPremultiplyAlpha:n,floatingPoint:a,type:this.gl.UNSIGNED_BYTE,internalFormat:this.gl.RGBA,format:this.gl.RGBA},this.parameters={anisotropy:h,generateMipmap:o,wrapS:u||this.gl.CLAMP_TO_EDGE,wrapT:c||this.gl.CLAMP_TO_EDGE,minFilter:p||this.gl.LINEAR,magFilter:g||this.gl.LINEAR,_shouldUpdate:!0},this._initState(),this.sourceType=t?"fbo":"empty",this._useCache=!0,this._samplerName=r,this._sampler={isActive:!1,isTextureBound:!1,texture:this.gl.createTexture()},this._textureMatrix={matrix:new M,isActive:!1},this._size={width:1,height:1},this.scale=new A(1),this.scale.onChange(()=>this.resize()),this.offset=new A,this.offset.onChange(()=>this.resize()),this._loader=i,this._sourceLoaded=!1,this._uploaded=!1,this._willUpdate=!1,this.shouldUpdate=!1,this._forceUpdate=!1,this.userData={},this._canDraw=!1,s){this._copyOnInit=!0,this._copiedFrom=s;return}this._copyOnInit=!1,this._initTexture()}_initState(){this._state={anisotropy:1,generateMipmap:!1,wrapS:null,wrapT:null,minFilter:null,magFilter:this.gl.LINEAR}}_initTexture(){this.gl.bindTexture(this.gl.TEXTURE_2D,this._sampler.texture),"empty"===this.sourceType&&(this._globalParameters.flipY=!1,this._updateGlobalTexParameters(),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),this._canDraw=!0)}_restoreFromTexture(){this._copyOnInit||this._initTexture(),this._parent&&(this._setTextureUniforms(),this._setSize()),this.copy(this._copiedFrom),this._canDraw=!0}_restoreContext(){if(this._canDraw=!1,this._sampler.isActive=!1,this._initState(),this._state.generateMipmap=!1,this.parameters._shouldUpdate=!0,this._copiedFrom){let e=this.renderer.nextRender.add(()=>{this._copiedFrom._canDraw&&(this._restoreFromTexture(),e.keep=!1)},!0)}else this._initTexture(),this._parent&&this._setParent(),this.source&&(this.setSource(this.source),"image"===this.sourceType?this.renderer.cache.addTexture(this):this.needUpdate()),this._canDraw=!0}addParent(e){if(!e||"Plane"!==e.type&&"PingPongPlane"!==e.type&&"ShaderPass"!==e.type&&"RenderTarget"!==e.type){this.renderer.production||o(this.type+": cannot add texture as a child of ",e," because it is not a valid parent");return}this._parent=e,this.index=this._parent.textures.length,this._parent.textures.push(this),this._setParent()}_setParent(){if(this._sampler.name=this._samplerName||"uSampler"+this.index,this._textureMatrix.name=this._samplerName?this._samplerName+"Matrix":"uTextureMatrix"+this.index,this._parent._program){if(!this._parent._program.compiled){this.renderer.production||o(this.type+": Unable to create the texture because the program is not val
36id");return}if(this._setTextureUniforms(),this._copyOnInit){let e=this.renderer.nextRender.add(()=>{this._copiedFrom._canDraw&&this._copiedFrom._uploaded&&(this.copy(this._copiedFrom),e.keep=!1)},!0);return}this.source?this._parent.loader&&this._parent.loader._addSourceToParent(this.source,this.sourceType):this._size={width:this._parent._boundingRect.document.width,height:this._parent._boundingRect.document.height},this._setSize()}else"RenderTarget"===this._parent.type&&(this._size={width:this._parent._size&&this._parent._size.width||this.renderer._boundingRect.width,height:this._parent._size&&this._parent._size.height||this.renderer._boundingRect.height},this._upload(),this._updateTexParameters(),this._canDraw=!0)}hasParent(){return!!this._parent}_setTextureUniforms(){let e=this._parent._program.activeUniforms;for(let t=0;t<e.textures.length;t++)e.textures[t]===this._sampler.name&&(this._sampler.isActive=!0,this.renderer.useProgram(this._parent._program),this._sampler.location=this.gl.getUniformLocation(this._parent._program.program,this._sampler.name),e.textureMatrices.find(e=>e===this._textureMatrix.name)&&(this._textureMatrix.isActive=!0,this._textureMatrix.location=this.gl.getUniformLocation(this._parent._program.program,this._textureMatrix.name)),this.gl.uniform1i(this._sampler.location,this.index))}copy(e){if(!e||"Texture"!==e.type){this.renderer.production||o(this.type+": Unable to set the texture from texture:",e);return}this._globalParameters=e._globalParameters,this._state=e._state,this._size=e._size,!this._sourceLoaded&&e._sourceLoaded&&this._onSourceLoadedCallback&&this._onSourceLoadedCallback(),this._sourceLoaded=e._sourceLoaded,!this._uploaded&&e._uploaded&&this._onSourceUploadedCallback&&this._onSourceUploadedCallback(),this._uploaded=e._uploaded,this.sourceType=e.sourceType,this.source=e.source,this._videoFrameCallbackID=e._videoFrameCallbackID,this._sampler.texture=e._sampler.texture,this._copiedFrom=e,this._parent&&this._parent._program&&(!this._canDraw||!this._textureMatrix.matrix)&&(this._setSize(),this._canDraw=!0),this.renderer.needRender()}setSource(e){this._sourceLoaded||this.renderer.nextRender.add(()=>this._onSourceLoadedCallback&&this._onSourceLoadedCallback());let t="IMG"===e.tagName.toUpperCase()?"image":e.tagName.toLowerCase();if(("video"===t||"canvas"===t)&&(this._useCache=!1),this._useCache){let t=this.renderer.cache.getTextureFromSource(e);if(t&&t.uuid!==this.uuid){this._uploaded||(this.renderer.nextRender.add(()=>this._onSourceUploadedCallback&&this._onSourceUploadedCallback()),this._uploaded=!0),this.copy(t),this.resize();return}}if("empty"===this.sourceType||this.sourceType!==t)if("video"===t)this._willUpdate=!1,this.shouldUpdate=!0;else if("canvas"===t)this._willUpdate=!0,this.shouldUpdate=!0;else if("image"===t)this._willUpdate=!1,this.shouldUpdate=!1;else{this.renderer.production||o(this.type+": this HTML tag could not be converted into a texture:",e.tagName);return}this.source=e,this.sourceType=t,this._size={width:this.source.naturalWidth||this.source.width||this.source.videoWidth,height:this.source.naturalHeight||this.source.height||this.source.videoHeight},this._sourceLoaded=!0,this.gl.bindTexture(this.gl.TEXTURE_2D,this._sampler.texture),this.resize(),this._globalParameters.flipY=!0,this._globalParameters.premultiplyAlpha=this._globalParameters.shouldPremultiplyAlpha,"image"===this.sourceType&&(this.parameters.generateMipmap=this.parameters.generateMipmap||null===this.parameters.generateMipmap,this.parameters._shouldUpdate=this.parameters.generateMipmap,this._state.generateMipmap=!1,this._upload()),this.renderer.needRender()}_updateGlobalTexParameters(){this.renderer.state.unpackAlignment!==this._globalParameters.unpackAlignment&&(this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,this._globalParameters.unpackAlignment),this.renderer.state.unpackAlignment=this._globalParameters.unpackAlignment),this.renderer.state.flipY!==this._globalParameters.flipY&&(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,this._globalParameters.flipY),this.renderer.state.flipY=this._globalParameters.flipY),this.renderer.state.premultiplyAlpha!==this._globalParameters.premultiplyAlpha&&(this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._globalParameters.premultiplyAlpha),this.renderer.state.premultiplyAlpha=this._globalParameters.premultiplyAlpha),"half-float"===this._globalParameters.floatingPoint?this.renderer._isWebG
36L2&&this.renderer.extensions.EXT_color_buffer_float?(this._globalParameters.internalFormat=this.gl.RGBA16F,this._globalParameters.type=this.gl.HALF_FLOAT):this.renderer.extensions.OES_texture_half_float?this._globalParameters.type=this.renderer.extensions.OES_texture_half_float.HALF_FLOAT_OES:this.renderer.production||o(this.type+": could not use half-float textures because the extension is not available"):"float"===this._globalParameters.floatingPoint&&(this.renderer._isWebGL2&&this.renderer.extensions.EXT_color_buffer_float?(this._globalParameters.internalFormat=this.gl.RGBA16F,this._globalParameters.type=this.gl.FLOAT):this.renderer.extensions.OES_texture_float?this._globalParameters.type=this.renderer.extensions.OES_texture_half_float.FLOAT:this.renderer.production||o(this.type+": could not use float textures because the extension is not available"))}_updateTexParameters(){this.index&&this.renderer.state.activeTexture!==this.index&&this._bindTexture(),this.parameters.wrapS!==this._state.wrapS&&(this.renderer._isWebGL2||u(this._size.width)&&u(this._size.height)||(this.parameters.wrapS=this.gl.CLAMP_TO_EDGE),this.parameters.wrapS!==this.gl.REPEAT&&this.parameters.wrapS!==this.gl.CLAMP_TO_EDGE&&this.parameters.wrapS!==this.gl.MIRRORED_REPEAT&&(this.renderer.production||o(this.type+": Wrong wrapS value",this.parameters.wrapS,"for this texture:",this,"\ngl.CLAMP_TO_EDGE wrapping will be used instead"),this.parameters.wrapS=this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.parameters.wrapS),this._state.wrapS=this.parameters.wrapS),this.parameters.wrapT!==this._state.wrapT&&(this.renderer._isWebGL2||u(this._size.width)&&u(this._size.height)||(this.parameters.wrapT=this.gl.CLAMP_TO_EDGE),this.parameters.wrapT!==this.gl.REPEAT&&this.parameters.wrapT!==this.gl.CLAMP_TO_EDGE&&this.parameters.wrapT!==this.gl.MIRRORED_REPEAT&&(this.renderer.production||o(this.type+": Wrong wrapT value",this.parameters.wrapT,"for this texture:",this,"\ngl.CLAMP_TO_EDGE wrapping will be used instead"),this.parameters.wrapT=this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.parameters.wrapT),this._state.wrapT=this.parameters.wrapT),this.parameters.generateMipmap&&!this._state.generateMipmap&&this.source&&(this.renderer._isWebGL2||u(this._size.width)&&u(this._size.height)?this.gl.generateMipmap(this.gl.TEXTURE_2D):this.parameters.generateMipmap=!1,this._state.generateMipmap=this.parameters.generateMipmap),this.parameters.minFilter!==this._state.minFilter&&(this.renderer._isWebGL2||u(this._size.width)&&u(this._size.height)||(this.parameters.minFilter=this.gl.LINEAR),this.parameters.generateMipmap||null===this.parameters.generateMipmap||(this.parameters.minFilter=this.gl.LINEAR),this.parameters.minFilter!==this.gl.LINEAR&&this.parameters.minFilter!==this.gl.NEAREST&&this.parameters.minFilter!==this.gl.NEAREST_MIPMAP_NEAREST&&this.parameters.minFilter!==this.gl.LINEAR_MIPMAP_NEAREST&&this.parameters.minFilter!==this.gl.NEAREST_MIPMAP_LINEAR&&this.parameters.minFilter!==this.gl.LINEAR_MIPMAP_LINEAR&&(this.renderer.production||o(this.type+": Wrong minFilter value",this.parameters.minFilter,"for this texture:",this,"\ngl.LINEAR filtering will be used instead"),this.parameters.minFilter=this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.parameters.minFilter),this._state.minFilter=this.parameters.minFilter),this.parameters.magFilter!==this._state.magFilter&&(this.renderer._isWebGL2||u(this._size.width)&&u(this._size.height)||(this.parameters.magFilter=this.gl.LINEAR),this.parameters.magFilter!==this.gl.LINEAR&&this.parameters.magFilter!==this.gl.NEAREST&&(this.renderer.production||o(this.type+": Wrong magFilter value",this.parameters.magFilter,"for this texture:",this,"\ngl.LINEAR filtering will be used instead"),this.parameters.magFilter=this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.parameters.magFilter),this._state.magFilter=this.parameters.magFilter);let e=this.renderer.extensions.EXT_texture_filter_anisotropic;if(e&&this.parameters.anisotropy!==this._state.anisotropy){let t=this.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.parameters.anisotropy=Math.max(1,Math.min(this.parameters.anisotropy,t)),this.gl.texParameterf(this.gl.TEXTURE_2D,e.TEXTURE_MAX_ANISOTROPY_EXT,this.parameters.anisotropy),this._state.anisotropy=this.parameters.anisotropy}}setWrapS(e){this.parameters.wrapS!==e&&(this.parameters.wrapS=e,this.parameters._shouldUpdate=!0)}setWrapT(e){this.parameters.wrapT!==e&&(this.parameters.wrapT=e,this.parameters._shouldUpdate=!0)}setMinFilter(e){this.parameters.minFilter!==e&&(this.parameters.minFilter=e,this.parameters._shouldUpdate=!0)}setMagFilter(e){this.parameters.magFilter!==e&&(this.parameters.magFilter=e,this.parameters._shouldUpdate=!0)}setAnisotropy(e){e=isNaN(e)?this.parameters.anisotropy:e,this.parameters.anisotropy!==e&&(this.parameters.anisotropy=e,this.parameters._shouldUpdate=!0)}
36needUpdate(){this._forceUpdate=!0}_videoFrameCallback(){this._willUpdate=!0,this.source.requestVideoFrameCallback(()=>this._videoFrameCallback())}_upload(){this._updateGlobalTexParameters(),this.source?this.gl.texImage2D(this.gl.TEXTURE_2D,0,this._globalParameters.internalFormat,this._globalParameters.format,this._globalParameters.type,this.source):"fbo"===this.sourceType&&this.gl.texImage2D(this.gl.TEXTURE_2D,0,this._globalParameters.internalFormat,this._size.width,this._size.height,0,this._globalParameters.format,this._globalParameters.type,this.source||null),this._uploaded||(this.renderer.nextRender.add(()=>this._onSourceUploadedCallback&&this._onSourceUploadedCallback()),this._uploaded=!0)}_getSizes(){if("fbo"===this.sourceType)return{parentWidth:this._parent._boundingRect.document.width,parentHeight:this._parent._boundingRect.document.height,sourceWidth:this._parent._boundingRect.document.width,sourceHeight:this._parent._boundingRect.document.height,xOffset:0,yOffset:0};let e=this._parent.scale?F.set(this._parent.scale.x,this._parent.scale.y):F.set(1,1),t=this._parent._boundingRect.document.width*e.x,s=this._parent._boundingRect.document.height*e.y,i=this._size.width,r=this._size.height,a=i/r,n=t/s,h=0,o=0;return n>a?o=Math.min(0,s-1/a*t):n<a&&(h=Math.min(0,t-s*a)),{parentWidth:t,parentHeight:s,sourceWidth:i,sourceHeight:r,xOffset:h,yOffset:o}}setScale(e){if(!e.type||"Vec2"!==e.type){this.renderer.production||o(this.type+": Cannot set scale because the parameter passed is not of Vec2 type:",e);return}e.sanitizeNaNValuesWith(this.scale).max(F.set(.001,.001)),e.equals(this.scale)||(this.scale.copy(e),this.resize())}setOffset(e){if(!e.type||"Vec2"!==e.type){this.renderer.production||o(this.type+": Cannot set offset because the parameter passed is not of Vec2 type:",scale);return}e.sanitizeNaNValuesWith(this.offset),e.equals(this.offset)||(this.offset.copy(e),this.resize())}_setSize(){if(this._parent&&this._parent._program){let e=this._getSizes();this._updateTextureMatrix(e)}}resize(){"fbo"===this.sourceType?(this._size={width:this._parent._size&&this._parent._size.width||this._parent._boundingRect.document.width,height:this._parent._size&&this._parent._size.height||this._parent._boundingRect.document.height},this._copiedFrom||(this.gl.bindTexture(this.gl.TEXTURE_2D,this._sampler.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this._globalParameters.internalFormat,this._size.width,this._size.height,0,this._globalParameters.format,this._globalParameters.type,null))):this.source&&(this._size={width:this.source.naturalWidth||this.source.width||this.source.videoWidth,height:this.source.naturalHeight||this.source.height||this.source.videoHeight}),this._setSize()}_updateTextureMatrix(e){let t=L.set(e.parentWidth/(e.parentWidth-e.xOffset),e.parentHeight/(e.parentHeight-e.yOffset),1);t.x/=this.scale.x,t.y/=this.scale.y,this._textureMatrix.matrix=O.setFromArray([t.x,0,0,0,0,t.y,0,0,0,0,1,0,(1-t.x)/2+this.offset.x,(1-t.y)/2+this.offset.y,0,1]),this._updateMatrixUniform()}_updateMatrixUniform(){this._textureMatrix.isActive&&(this.renderer.useProgram(this._parent._program),this.gl.uniformMatrix4fv(this._textureMatrix.location,!1,this._textureMatrix.matrix.elements))}_onSourceLoaded(e){this.setSource(e),"image"===this.sourceType&&this.renderer.cache.addTexture(this)}_bindTexture(){this._canDraw&&(this.renderer.state.activeTexture!==this.index&&(this.gl.activeTexture(this.gl.TEXTURE0+this.index),this.renderer.state.activeTexture=this.index),this.gl.bindTexture(this.gl.TEXTURE_2D,this._sampler.texture),!this._sampler.isTextureBound&&(this._sampler.isTextureBound=!!this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._sampler.isTextureBound&&this.renderer.needRender()))}_draw(){this._sampler.isActive&&(this._bindTexture(),"video"===this.sourceType&&this.source&&!this._videoFrameCallbackID&&this.source.readyState>=this.source.HAVE_CURRENT_DATA&&!this.source.paused&&(this._willUpdate=!0),(this._forceUpdate||this._willUpdate&&this.shouldUpdate)&&(this._state.generateMipmap=!1,this._upload()),"video"===this.sourceType&&(this._willUpdate=!1),this._forceUpdate=!1),this.parameters._shouldUpdate&&(this._updateTexParameters(),this.parameters._shouldUpdate=!1)}onSourceLoaded(e){return e&&(this._onSourceLoadedCallback=e),this}onSourceUploaded(e){return e&&(this._onSourceUploadedCallback=e),this}_dispose(e=!1){"video"!==this.sourceType&&("image"!==this.sourceType||this.renderer.state.isActive)?"canvas"===this.sourceType&&(this.source.width=this.source.width,this.source=null):(this._loader&&this._loader._removeSource(this),this.source=null),this._parent=null,this.gl&&!this._copiedFrom&&(e||"image"!==this.sourceType||!this.renderer.state.isActive)&&(this._canDraw=!1,this.renderer.cache.removeTexture(this),this.gl.activeTexture(this.gl.TEXTURE0+this.index),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.gl.deleteTexture(this._sampler.texture))}}
36class U{constructor(e,t="anonymous"){if(this.type="TextureLoader",(e=e&&e.renderer||e)&&"Renderer"===e.type){if(!e.gl)return void l(this.type+": Renderer WebGL context is undefined",e)}else l(this.type+": Renderer not passed as first argument",e);this.renderer=e,this.gl=this.renderer.gl,this.crossOrigin=t,this.elements=[]}_addElement(e,t,s,i){let r={source:e,texture:t,load:this._sourceLoaded.bind(this,e,t,s),error:this._sourceLoadError.bind(this,e,i)};return this.elements.push(r),r}_sourceLoadError(e,t,s){t&&t(e,s)}_sourceLoaded(e,t,s){!t._sourceLoaded&&(t._onSourceLoaded(e),this._parent&&(this._increment&&this._increment(),this.renderer.nextRender.add(()=>this._parent._onLoadingCallback&&this._parent._onLoadingCallback(t))),s&&s(t))}_getSourceType(e){let t;return"string"==typeof e?null!==e.match(/\.(jpeg|jpg|jfif|pjpeg|pjp|gif|bmp|png|webp|svg|avif|apng)$/)?t="image":null!==e.match(/\.(webm|mp4|mpg|mpeg|avi|ogg|ogm|ogv|mov|av1)$/)&&(t="video"):"IMG"===e.tagName.toUpperCase()?t="image":"VIDEO"===e.tagName.toUpperCase()?t="video":"CANVAS"===e.tagName.toUpperCase()&&(t="canvas"),t}_createImage(e){if("string"!=typeof e&&e.hasAttribute("crossOrigin"))return e;{let t=new Image;return t.crossOrigin=this.crossOrigin,"string"==typeof e?t.src=e:(t.src=e.src,e.hasAttribute("data-sampler")&&t.setAttribute("data-sampler",e.getAttribute("data-sampler"))),t}}_createVideo(e){if("string"!=typeof e&&null!==e.getAttribute("crossOrigin"))return e;{let t=document.createElement("video");return t.crossOrigin=this.crossOrigin,"string"==typeof e?t.src=e:(t.src=e.src,e.hasAttribute("data-sampler")&&t.setAttribute("data-sampler",e.getAttribute("data-sampler"))),t}}loadSource(e,t,s,i){switch(this._getSourceType(e)){case"image":this.loadImage(e,t,s,i);break;case"video":this.loadVideo(e,t,s,i);break;case"canvas":this.loadCanvas(e,t,s);break;default:this._sourceLoadError(e,i,"this source could not be converted into a texture: "+e)}}loadSources(e,t,s,i){for(let r=0;r<e.length;r++)this.loadSource(e[r],t,s,i)}loadImage(e,t={},s,i){let r=this.renderer.cache.getTextureFromSource(e),a=Object.assign({},t);if(this._parent&&(a=Object.assign(a,this._parent._texturesOptions)),a.loader=this,r){a.sampler="string"!=typeof e&&e.hasAttribute("data-sampler")?e.getAttribute("data-sampler"):a.sampler,a.fromTexture=r;let t=new D(this.renderer,a);this._sourceLoaded(r.source,t,s),this._parent&&this._addToParent(t,r.source,"image");return}let n=this._createImage(e);a.sampler=n.hasAttribute("data-sampler")?n.getAttribute("data-sampler"):a.sampler;let h=new D(this.renderer,a),o=this._addElement(n,h,s,i);n.complete?this._sourceLoaded(n,h,s):n.decode?n.decode().then(this._sourceLoaded.bind(this,n,h,s)).catch(()=>{n.addEventListener("load",o.load,!1),n.addEventListener("error",o.error,!1)}):(n.addEventListener("load",o.load,!1),n.addEventListener("error",o.error,!1)),this._parent&&this._addToParent(h,n,"image")}loadImages(e,t,s,i){for(let r=0;r<e.length;r++)this.loadImage(e[r],t,s,i)}loadVideo(e,t={},s,i){let r=this._createVideo(e);r.preload=!0,r.muted=!0,r.loop=!0,r.setAttribute("playsinline",""),r.crossOrigin=this.crossOrigin;let a=Object.assign({},t);this._parent&&(a=Object.assign(t,this._parent._texturesOptions)),a.loader=this,a.sampler=r.hasAttribute("data-sampler")?r.getAttribute("data-sampler"):a.sampler;let n=new D(this.renderer,a),h=this._addElement(r,n,s,i);r.addEventListener("canplaythrough",h.load,!1),r.addEventListener("error",h.error,!1),r.readyState>=r.HAVE_FUTURE_DATA&&s&&this._sourceLoaded(r,n,s),r.load(),this._addToParent&&this._addToParent(n,r,"video"),"requestVideoFrameCallback"in HTMLVideoElement.prototype&&(h.videoFrameCallback=n._videoFrameCallback.bind(n),n._videoFrameCallbackID=r.requestVideoFrameCallback(h.videoFrameCallback))}loadVideos(e,t,s,i){for(let r=0;r<e.length;r++)this.loadVideo(e[r],t,s,i)}loadCanvas(e,t={},s){let i=Object.assign({},t);this._parent&&(i=Object.assign(t,this._parent._texturesOptions)),i.loader=this,i.sampler=e.hasAttribute("data-sampler")?e.getAttribute("data-sampler"):i.sampler;let r=new D(this.renderer,i);this._addElement(e,r,s,null),this._sourceLoaded(e,r,s),this._parent&&this._addToParent(r,e,"canvas")}loadCanvases(e,t,s){for(let i=0;i<e.length;i++)this.loadCanvas(e[i],t,s)}_removeSource(e){let t=this.elements.find(t=>t.texture.uuid===e.uuid);t&&("image"===e.sourceType?t.source.removeEventListener("load",t.load,!1):"video"===e.sourceType&&(t.videoFrameCallback&&e._videoFrameCallbackID&&t.source.cancelVideoFrameCallback(e._videoFrameCallbackID),t.source.removeEventListener("canplaythrough",t.load,!1),t.source.pause(),t.source.removeAttribute("src"),t.source.load()),t.source.removeEventListener("error",t.error,!1))}}class z extends U{constructor(e,t,{sourcesLoaded:s=0,sourcesToLoad:i=0,complete:r=!1,onComplete:a=()=>{}}={}){super(e,t.crossOrigin),this.type="PlaneTextureLoader",this._parent=t,"Plane"!==this._parent.type&&"PingPongPlane"!==this._parent.type&&"ShaderPass"!==this._parent.type&&(o(this.type+": Wrong parent type assigned to this loader"),this._parent=null),this.sourcesLoaded=s,this.sourcesToLoad=i,this.complete=r,this.onComplete=a}_setLoaderSize(e){this.sourcesToLoad=e,0===this.sourcesToLoad&&(this.complete=!0,this.renderer.nextRender.add(()=>this.onComplete&&this.onComplete()))}_increment(){this.sourcesLoaded++,this.sourcesLoaded>=this.sourcesToLoad&&!this.complete&&(this.complete=!0,this.renderer.nextRender.add(()=>this.onComplete&&this.onComplete()))}_addSourceToParent(e,t){if("image"===t){let t=this._parent.images;t.find(t=>
36t.src===e.src)||t.push(e)}else if("video"===t){let t=this._parent.videos;t.find(t=>t.src===e.src)||t.push(e)}else if("canvas"===t){let t=this._parent.canvases;t.find(t=>t.isSameNode(e))||t.push(e)}}_addToParent(e,t,s){this._addSourceToParent(t,s),this._parent&&e.addParent(this._parent)}}class I{constructor(e,t="Mesh",{vertexShaderID:s,fragmentShaderID:i,vertexShader:r,fragmentShader:a,uniforms:n={},widthSegments:h=1,heightSegments:o=1,renderOrder:d=0,depthTest:u=!0,cullFace:c="back",texturesOptions:p={},crossOrigin:g="anonymous"}={}){if(this.type=t,(e=e&&e.renderer||e)&&"Renderer"===e.type||(l(this.type+": Curtains not passed as first argument or Curtains Renderer is missing",e),setTimeout(()=>{this._onErrorCallback&&this._onErrorCallback()},0)),this.renderer=e,this.gl=this.renderer.gl,!this.gl){this.renderer.production||l(this.type+": Unable to create a "+this.type+" because the Renderer WebGL context is not defined"),setTimeout(()=>{this._onErrorCallback&&this._onErrorCallback()},0);return}this._canDraw=!1,this.renderOrder=d,this._depthTest=u,this.cullFace=c,"back"!==this.cullFace&&"front"!==this.cullFace&&"none"!==this.cullFace&&(this.cullFace="back"),this.textures=[],this._texturesOptions=Object.assign({premultiplyAlpha:!1,anisotropy:1,floatingPoint:"none",wrapS:this.gl.CLAMP_TO_EDGE,wrapT:this.gl.CLAMP_TO_EDGE,minFilter:this.gl.LINEAR,magFilter:this.gl.LINEAR},p),this.crossOrigin=g,!r&&s&&document.getElementById(s)&&(r=document.getElementById(s).innerHTML),!a&&i&&document.getElementById(i)&&(a=document.getElementById(i).innerHTML),this._initMesh(),h=parseInt(h),o=parseInt(o),this._geometry=new C(this.renderer,{width:h,height:o}),this._program=new E(this.renderer,{parent:this,vertexShader:r,fragmentShader:a}),this._program.compiled?(this._program.createUniforms(n),this.uniforms=this._program.uniformsManager.uniforms,this._geometry.setProgram(this._program),this.renderer.onSceneChange()):this.renderer.nextRender.add(()=>this._onErrorCallback&&this._onErrorCallback())}_initMesh(){this.uuid=d(),this.loader=new z(this.renderer,this,{sourcesLoaded:0,initSourcesToLoad:0,complete:!1,onComplete:()=>{this._onReadyCallback&&this._onReadyCallback(),this.renderer.needRender()}}),this.images=[],this.videos=[],this.canvases=[],this.userData={},this._canDraw=!0}_restoreContext(){this._canDraw=!1,this._matrices&&(this._matrices=null),this._program=new E(this.renderer,{parent:this,vertexShader:this._program.vsCode,fragmentShader:this._program.fsCode}),this._program.compiled&&(this._geometry.restoreContext(this._program),this._program.createUniforms(this.uniforms),this.uniforms=this._program.uniformsManager.uniforms,this._programRestored())}setRenderTarget(e){if(!e||"RenderTarget"!==e.type){this.renderer.production||o(this.type+": Could not set the render target because the argument passed is not a RenderTarget class object",e);return}"Plane"===this.type&&this.renderer.scene.removePlane(this),this.target=e,"Plane"===this.type&&this.renderer.scene.addPlane(this)}setRenderOrder(e=0){(e=isNaN(e)?this.renderOrder:parseInt(e))!==this.renderOrder&&(this.renderOrder=e,this.renderer.scene.setPlaneRenderOrder(this))}createTexture(e={}){let t=new D(this.renderer,Object.assign(this._texturesOptions,e));return t.addParent(this),t}addTexture(e){if(!e||"Texture"!==e.type){this.renderer.production||o(this.type+": cannot add ",e," to this "+this.type+" because it is not a valid texture");return}e.addParent(this)}loadSources(e,t={},s,i){for(let r=0;r<e.length;r++)this.loadSource(e[r],t,s,i)}loadSource(e,t={},s,i){this.loader.loadSource(e,Object.assign(t,this._texturesOptions),e=>{s&&s(e)},(e,t)=>{this.renderer.production||o(this.type+": this HTML tag could not be converted into a texture:",e.tagName),i&&i(e,t)})}loadImage(e,t={},s,i){this.loader.loadImage(e,Object.assign(t,this._texturesOptions),e=>{s&&s(e)},(e,t)=>{this.renderer.production||o(this.type+": There has been an error:\n",t,"\nwhile loading this image:\n",e),i&&i(e,t)})}loadVideo(e,t={},s,i){this.loader.loadVideo(e,Object.assign(t,this._texturesOptions),e=>{s&&s(e)},(e,t)=>{this.renderer.production||o(this.type+": There has been an error:\n",t,"\nwhile loading this video:\n",e),i&&i(e,t)})}loadCanvas(e,t={},s){this.loader.loadCanvas(e,Object.assign(t,this._texturesOptions),e=>{s&&s(e)})}loadImages(e,t={},s,i){for(let r=0;r<e.length;r++)this.loadImage(e[r],t,s,i)}loadVideos(e,t={},s,i){for(let r=0;r<e.length;r++)this.loadVideo(e[r],t,s,i)}loadCanvases(e,t={},s){for(let i=0;i<e.length;i++)this.loadCanvas(e[i],t,s)}playVideos(){for(let e=0;e<this.textures.length;e++){let t=this.textures[e];if("video"===t.sourceType){let e=t.source.play();void 0!==e&&e.catch(e=>{this.renderer.production||o(this.type+": Could not play the video : ",e)})}}}_draw(){this.renderer.setDepthTest(this._depthTest),this.renderer.setFaceCulling(this.cullFace),this._program.updateUniforms(),this._geometry.bindBuffers(),this.renderer.state.forceBufferUpdate=!1;for(let e=0;e<this.textures.length;e++)if(this.textures[e]._draw(),this.textures[e]._sampler.isActive&&!this.textures[e]._sampler.isTextureBound)return;this._geometry.draw(),this.renderer.state.activeTexture=null,this._onAfterRenderCallback&&this._onAfterRenderCallback()}onError(e){return e&&(this._onErrorCallback=e),this}onLoading(e){return e&&(this._onLoadingCallback=e),this}onReady(e){return e&&(this._onReadyCallback=e),this}onRender(e){return e&&(this._onRenderCallback=e),this}onAfterRender(e){return e&&(this._onAfterRenderCallback=e),this}remove(){this._canDraw=!1,this.target&&this.renderer.bindFrameBuffer(null),this._dispose(),"Plane"===this.type?this.renderer.removePlane(this):"ShaderPass"===this.type&&(this.target&&(this.target._shaderPass=null,this.target.remove(),this.target=null),this.renderer.removeShaderPass(this))}_dispose(){if(this.gl){this._geometry&&this._geometry.dispose(),this.target&&"ShaderPass"===this.type&&(this.renderer.removeRenderTarget(this.target),this.textures.shift());for(let e=0;e<this.textures.length;e++)this.textures[e]._dispose();this.textures=[]}}}let V=new A,N=new A;class B extends I{constructor(e,t,s="DOMMesh",{widthSegments:i,heightSegments:r,renderOrder:a,depthTest:n,cullFace:h,uniforms:l,vertexShaderID:d,fragmentShaderID:u,vertexShader:c,fragmentShader:p,texturesOptions:g,crossOrigin:m}={}){if(super(e,s,{widthSegments:i,heightSegments:r,renderOrder:a,depthTest:n,cullFace:h,uniforms:l,vertexShaderID:d=d||t&&t.getAttribute("data-vs-id"),fragmentShaderID:u=u||t&&t.getAttribute("data-fs-id"),vertexShader:c,fragmentShader:p,texturesOptions:g,crossOrigin:m}),!this.gl)return;this.htmlElement=t,this.htmlElement&&0!==this.htmlElement.length||this.renderer.production||o(this.type+": The HTML element you specified does not currently exists in the DOM"),this._setDocumentSizes()}_setDocumentSizes(){let e=this.htmlElement.getBoundingClientRect();this._boundingRect||(this._boundingRect={}),this._boundingRect.document={width:e.width*this.renderer.pixelRatio,height:e.height*this.renderer.pixelRatio,top:e.top*this.renderer.pixelRatio,left:e.left*this.renderer.pixelRatio}}
36getBoundingRect(){return{width:this._boundingRect.document.width,height:this._boundingRect.document.height,top:this._boundingRect.document.top,left:this._boundingRect.document.left,right:this._boundingRect.document.left+this._boundingRect.document.width,bottom:this._boundingRect.document.top+this._boundingRect.document.height}}resize(){this._setDocumentSizes(),"Plane"===this.type&&(this.setPerspective(this.camera.fov,this.camera.near,this.camera.far),this._setWorldSizes(),this._applyWorldPositions());for(let e=0;e<this.textures.length;e++)this.textures[e].resize();this.renderer.nextRender.add(()=>this._onAfterResizeCallback&&this._onAfterResizeCallback())}mouseToPlaneCoords(e){let t=this.scale?this.scale:N.set(1,1),s=V.set((this._boundingRect.document.width-this._boundingRect.document.width*t.x)/2,(this._boundingRect.document.height-this._boundingRect.document.height*t.y)/2),i={width:this._boundingRect.document.width*t.x/this.renderer.pixelRatio,height:this._boundingRect.document.height*t.y/this.renderer.pixelRatio,top:(this._boundingRect.document.top+s.y)/this.renderer.pixelRatio,left:(this._boundingRect.document.left+s.x)/this.renderer.pixelRatio};return V.set((e.x-i.left)/i.width*2-1,1-(e.y-i.top)/i.height*2)}onAfterResize(e){return e&&(this._onAfterResizeCallback=e),this}}class W{constructor({fov:e=50,near:t=.1,far:s=150,width:i,height:r,pixelRatio:a=1}={}){this.position=new k,this.projectionMatrix=new M,this.worldMatrix=new M,this.viewMatrix=new M,this._shouldUpdate=!1,this.setSize(),this.setPerspective(e,t,s,i,r,a)}setFov(e){(e=Math.max(1,Math.min(e=isNaN(e)?this.fov:parseFloat(e),179)))!==this.fov&&(this.fov=e,this.setPosition(),this._shouldUpdate=!0),this.setCSSPerspective()}setNear(e){(e=Math.max(e=isNaN(e)?this.near:parseFloat(e),.01))!==this.near&&(this.near=e,this._shouldUpdate=!0)}setFar(e){(e=Math.max(e=isNaN(e)?this.far:parseFloat(e),50))!==this.far&&(this.far=e,this._shouldUpdate=!0)}setPixelRatio(e){e!==this.pixelRatio&&(this._shouldUpdate=!0),this.pixelRatio=e}setSize(e,t){(e!==this.width||t!==this.height)&&(this._shouldUpdate=!0),this.width=e,this.height=t}setPerspective(e,t,s,i,r,a){this.setPixelRatio(a),this.setSize(i,r),this.setFov(e),this.setNear(t),this.setFar(s),this._shouldUpdate&&this.updateProjectionMatrix()}setPosition(){this.position.set(0,0,1),this.worldMatrix.setFromArray([1,0,0,0,0,1,0,0,0,0,1,0,this.position.x,this.position.y,this.position.z,1]),this.viewMatrix=this.viewMatrix.copy(this.worldMatrix).getInverse()}setCSSPerspective(){this.CSSPerspective=Math.pow(Math.pow(this.width/(2*this.pixelRatio),2)+Math.pow(this.height/(2*this.pixelRatio),2),.5)/Math.tan(.5*this.fov*Math.PI/180)}getScreenRatiosFromFov(e=0){let t=this.position.z;e<t?e-=t:e+=t;let s=2*Math.tan(this.fov*Math.PI/180/2)*Math.abs(e);return{width:s*this.width/this.height,height:s}}updateProjectionMatrix(){let e=this.width/this.height,t=this.near*Math.tan(Math.PI/180*.5*this.fov),s=2*t,i=e*s,r=-.5*i,a=r+i,n=t-s,h=2*this.near/(a-r),o=2*this.near/(t-n),l=-(this.far+this.near)/(this.far-this.near),d=-2*this.far*this.near/(this.far-this.near);this.projectionMatrix.setFromArray([h,0,0,0,0,o,0,0,(a+r)/(a-r),(t+n)/(t-n),l,-1,0,0,d,0])}forceUpdate(){this._shouldUpdate=!0}cancelUpdate(){this._shouldUpdate=!1}}class G{constructor(e=new Float32Array([0,0,0,1]),t="XYZ"){this.type="Quat",this.elements=e,this.axisOrder=t}setFromArray(e){return this.elements[0]=e[0],this.elements[1]=e[1],this.elements[2]=e[2],this.elements[3]=e[3],this}setAxisOrder(e){switch(e=e.toUpperCase()){case"XYZ":case"YXZ":case"ZXY":case"ZYX":case"YZX":case"XZY":this.axisOrder=e;break;default:this.axisOrder="XYZ"}return this}copy(e){return this.elements=e.elements,this.axisOrder=e.axisOrder,this}clone(){return new G().copy(this)}equals(e){return this.elements[0]===e.elements[0]&&this.elements[1]===e.elements[1]&&this.elements[2]===e.elements[2]&&this.elements[3]===e.elements[3]&&this.axisOrder===e.axisOrder}setFromVec3(e){let t=.5*e.x,s=.5*e.y,i=.5*e.z,r=Math.cos(t),a=Math.cos(s),n=Math.cos(i),h=Math.sin(t),o=Math.sin(s),l=Math.sin(i);return"XYZ"===this.axisOrder?(this.elements[0]=h*a*n+r*o*l,this.elements[1]=r*o*n-
36h*a*l,this.elements[2]=r*a*l+h*o*n,this.elements[3]=r*a*n-h*o*l):"YXZ"===this.axisOrder?(this.elements[0]=h*a*n+r*o*l,this.elements[1]=r*o*n-h*a*l,this.elements[2]=r*a*l-h*o*n,this.elements[3]=r*a*n+h*o*l):"ZXY"===this.axisOrder?(this.elements[0]=h*a*n-r*o*l,this.elements[1]=r*o*n+h*a*l,this.elements[2]=r*a*l+h*o*n,this.elements[3]=r*a*n-h*o*l):"ZYX"===this.axisOrder?(this.elements[0]=h*a*n-r*o*l,this.elements[1]=r*o*n+h*a*l,this.elements[2]=r*a*l-h*o*n,this.elements[3]=r*a*n+h*o*l):"YZX"===this.axisOrder?(this.elements[0]=h*a*n+r*o*l,this.elements[1]=r*o*n+h*a*l,this.elements[2]=r*a*l-h*o*n,this.elements[3]=r*a*n-h*o*l):"XZY"===this.axisOrder&&(this.elements[0]=h*a*n-r*o*l,this.elements[1]=r*o*n-h*a*l,this.elements[2]=r*a*l+h*o*n,this.elements[3]=r*a*n+h*o*l),this}}let X=new A,j=new k,H=new k,Y=new k,q=new k,Q=new k,Z=new k,K=new k,J=new k,$=new G,ee=new k(.5,.5,0),et=new k,es=new k,ei=new k,er=new k,ea=new A;class en extends B{constructor(e,t,{widthSegments:s,heightSegments:i,renderOrder:r,depthTest:a,cullFace:n,uniforms:h,vertexShaderID:o,fragmentShaderID:l,vertexShader:d,fragmentShader:u,texturesOptions:c,crossOrigin:p,alwaysDraw:g=!1,visible:m=!0,transparent:_=!1,drawCheckMargins:f={top:0,right:0,bottom:0,left:0},autoloadSources:x=!0,watchScroll:b=!0,fov:y=50}={}){if(super(e,t,"Plane",{widthSegments:s,heightSegments:i,renderOrder:r,depthTest:a,cullFace:n,uniforms:h,vertexShaderID:o,fragmentShaderID:l,vertexShader:d,fragmentShader:u,texturesOptions:c,crossOrigin:p}),!this.gl)return;this.index=this.renderer.planes.length,this.target=null,this.alwaysDraw=g,this._shouldDraw=!0,this.visible=m,this._transparent=_,this.drawCheckMargins=f,this.autoloadSources=x,this.watchScroll=b,this._updateMVMatrix=!1,this.camera=new W({fov:y,width:this.renderer._boundingRect.width,height:this.renderer._boundingRect.height,pixelRatio:this.renderer.pixelRatio}),this._program.compiled&&(this._initPlane(),this.renderer.scene.addPlane(this),this.renderer.planes.push(this))}_programRestored(){this.target&&this.setRenderTarget(this.renderer.renderTargets[this.target.index]),this._initMatrices(),this.setPerspective(this.camera.fov,this.camera.near,this.camera.far),this._setWorldSizes(),this._applyWorldPositions(),this.renderer.scene.addPlane(this);for(let e=0;e<this.textures.length;e++)this.textures[e]._parent=this,this.textures[e]._restoreContext();this._canDraw=!0}_initPlane(){this._initTransformValues(),this._initPositions(),this.setPerspective(this.camera.fov,this.camera.near,this.camera.far),this._initSources()}_initTransformValues(){this.rotation=new k,this.rotation.onChange(()=>this._applyRotation()),this.quaternion=new G,this.relativeTranslation=new k,this.relativeTranslation.onChange(()=>this._setTranslation()),this._translation=new k,this.scale=new k(1),this.scale.onChange(()=>{this.scale.z=1,this._applyScale()}),this.transformOrigin=new k(.5,.5,0),this.transformOrigin.onChange(()=>{this._setWorldTransformOrigin(),this._updateMVMatrix=!0})}resetPlane(e){this._initTransformValues(),this._setWorldTransformOrigin(),null!==e&&e?(this.htmlElement=e,this.resize()):e||this.renderer.production||o(this.type+": You are trying to reset a plane with a HTML element that does not exist. The old HTML element will be kept instead.")}removeRenderTarget(){this.target&&(this.renderer.scene.removePlane(this),this.target=null,this.renderer.scene.addPlane(this))}_initPositions(){this._initMatrices(),this._setWorldSizes(),this._applyWorldPositions()}_initMatrices(){let e=new M;this._matrices={world:{matrix:e},modelView:{name:"uMVMatrix",matrix:e,location:this.gl.getUniformLocation(this._program.program,"uMVMatrix")},projection:{name:"uPMatrix",matrix:e,location:this.gl.getUniformLocation(this._program.program,"uPMatrix")},modelViewProjection:{matrix:e}}}_setPerspectiveMatrix(){this.camera._shouldUpdate&&(this.renderer.useProgram(this._program),this.gl.uniformMatrix4fv(this._matrices.projection.location,!1,this._matrices.projection.matrix.elements)),this.camera.cancelUpdate()}setPerspective(e,t,s){this.camera.setPerspective(e,t,s,this.renderer._boundingRect.width,this.renderer._boundingRect.height,this.renderer.pixelRatio),this.renderer.state.isContextLost&&this.camera.forceUpdate(),this._matrices.projection.matrix=this.camera.projectionMatrix,this.camera._shouldUpdate&&(this._setWorldSizes(),this._applyWorldPositions(),this._translation.z=this.relativeTranslation.z/this.camera.CSSPerspective),this._updateMVMatrix=this.camera._shouldUpdate}_setMVMatrix(){this._updateMVMatrix&&(this._matrices.world.matrix=this._matrices.world.matrix.composeFromOrigin(this._translation,this.quaternion,this.scale,this._boundingRect.world.transformOrigin),this._matrices.world.matrix.scale({x:this._boundingRect.world.width,y:this._boundingRect.world.height,z:1}),this._matrices.modelView.matrix.copy(this._matrices.world.matrix
36),this._matrices.modelView.matrix.elements[14]-=this.camera.position.z,this._matrices.modelViewProjection.matrix=this._matrices.projection.matrix.multiply(this._matrices.modelView.matrix),this.alwaysDraw||this._shouldDrawCheck(),this.renderer.useProgram(this._program),this.gl.uniformMatrix4fv(this._matrices.modelView.location,!1,this._matrices.modelView.matrix.elements)),this._updateMVMatrix=!1}_setWorldTransformOrigin(){this._boundingRect.world.transformOrigin=new k((2*this.transformOrigin.x-1)*this._boundingRect.world.width,-(2*this.transformOrigin.y-1)*this._boundingRect.world.height,this.transformOrigin.z)}_documentToWorldSpace(e){return H.set(e.x*this.renderer.pixelRatio/this.renderer._boundingRect.width*this._boundingRect.world.ratios.width,-(e.y*this.renderer.pixelRatio/this.renderer._boundingRect.height)*this._boundingRect.world.ratios.height,e.z)}_setWorldSizes(){let e=this.camera.getScreenRatiosFromFov();this._boundingRect.world={width:this._boundingRect.document.width/this.renderer._boundingRect.width*e.width/2,height:this._boundingRect.document.height/this.renderer._boundingRect.height*e.height/2,ratios:e},this._setWorldTransformOrigin()}_setWorldPosition(){let e={x:this._boundingRect.document.width/2+this._boundingRect.document.left,y:this._boundingRect.document.height/2+this._boundingRect.document.top},t={x:this.renderer._boundingRect.width/2+this.renderer._boundingRect.left,y:this.renderer._boundingRect.height/2+this.renderer._boundingRect.top};this._boundingRect.world.top=(t.y-e.y)/this.renderer._boundingRect.height*this._boundingRect.world.ratios.height,this._boundingRect.world.left=(e.x-t.x)/this.renderer._boundingRect.width*this._boundingRect.world.ratios.width}setScale(e){if(!e.type||"Vec2"!==e.type){this.renderer.production||o(this.type+": Cannot set scale because the parameter passed is not of Vec2 type:",e);return}e.sanitizeNaNValuesWith(this.scale).max(X.set(.001,.001)),(e.x!==this.scale.x||e.y!==this.scale.y)&&(this.scale.set(e.x,e.y,1),this._applyScale())}_applyScale(){for(let e=0;e<this.textures.length;e++)this.textures[e].resize();this._updateMVMatrix=!0}setRotation(e){if(!e.type||"Vec3"!==e.type){this.renderer.production||o(this.type+": Cannot set rotation because the parameter passed is not of Vec3 type:",e);return}e.sanitizeNaNValuesWith(this.rotation),e.equals(this.rotation)||(this.rotation.copy(e),this._applyRotation())}_applyRotation(){this.quaternion.setFromVec3(this.rotation),this._updateMVMatrix=!0}setTransformOrigin(e){if(!e.type||"Vec3"!==e.type){this.renderer.production||o(this.type+": Cannot set transform origin because the parameter passed is not of Vec3 type:",e);return}e.sanitizeNaNValuesWith(this.transformOrigin),e.equals(this.transformOrigin)||(this.transformOrigin.copy(e),this._setWorldTransformOrigin(),this._updateMVMatrix=!0)}_setTranslation(){let e=j.set(0,0,0);this.relativeTranslation.equals(e)||(e=this._documentToWorldSpace(this.relativeTranslation)),this._translation.set(this._boundingRect.world.left+e.x,this._boundingRect.world.top+e.y,this.relativeTranslation.z/this.camera.CSSPerspective),this._updateMVMatrix=!0}setRelativeTranslation(e){if(!e.type||"Vec3"!==e.type){this.renderer.production||o(this.type+": Cannot set translation because the parameter passed is not of Vec3 type:",e);return}e.sanitizeNaNValuesWith(this.relativeTranslation),e.equals(this.relativeTranslation)||(this.relativeTranslation.copy(e),this._setTranslation())}_applyWorldPositions(){this._setWorldPosition(),this._setTranslation()}updatePosition(){this._setDocumentSizes(),this._applyWorldPositions()}updateScrollPosition(e,t){(e||t)&&(this._boundingRect.document.top+=t*this.renderer.pixelRatio,this._boundingRect.document.left+=e*this.renderer.pixelRatio,this._applyWorldPositions())}_getIntersection(e,t){let s=t.clone().sub(e),i=e.clone();for(;i.z>-1;)i.add(s);return i}_getNearPlaneIntersections(e,t,s){let i=this._matrices.modelViewProjection.matrix;if(1===s.length)0===s[0]?(t[0]=this._getIntersection(t[1],K.set(.95,1,0).applyMat4(i)),t.push(this._getIntersection(t[3],J.set(-1,-.95,0).applyMat4(i)))):1===s[0]?(t[1]=this._getIntersection(t[0],K.set(-.95,1,0).applyMat4(i)),t.push(this._getIntersection(t[2],J.set(1,-.95,0).applyMat4(i)))):2===s[0]?(t[2]=this._getIntersection(t[3],K.set(-.95,-1,0).applyMat4(i)),t.push(this._getIntersection(t[1],J.set(1,.95,0).applyMat4(i)))):3===s[0]&&(t[3]=this._getIntersection(t[2],K.set(.95,-1,0).applyMat4(i)),t.push(this._getIntersection(t[0],J.set(-1,.95,0).applyMat4(i))));else if(2===s.length)0===s[0]&&1===s[1]?(t[0]=this._getIntersection(t[3],K.set(-1,-.95,0).applyMat4(i)),t[1]=this._getIntersection(t[2],J.set(1,-.95,0).applyMat4(i))):1===s[0]&&2===s[1]?(t[1]=this._getIntersection(t[0],K.set(-.95,1,0).applyMat4(i)),t[2]=this._getIntersection(t[3],J.set(-.95,-1,0).applyMat4(i))):2===s[0]&&3===s[1]?(t[2]=this._getIntersection(t[1],K.set(1,.95,0).applyMat4(i)),t[3]=this._getIntersection(t[0],J.set(-1,.95,0).applyMat4(i))):0===s[0]&&3===s[1]&&(t[0]=this._getIntersection(t[1],K.set(.95,1,0).applyMat4(i)),t[3]=this._getIntersection(t[2],J.set(.95,-1,0).applyMat4(i)));else if(3===s.length){let r=0;for(let t=0;t<e.length;t++)s.includes(t)||(r=t);t=[t[r]],0===r?(t.push(this._getIntersection(t[0],K.set(-.95,1,0).applyMat4(i))),t.push(this._getIntersection(t[0],J.set(-1,.95,0).applyMat4(i)))):1===r?(t.push(this._getIntersection(t[0],K.set(.95,1,0).applyMat4(i))),t.push(this._getIntersection(t[0],J.set(1,.95,0).applyMat4(i)))):2===r?(t.push(this._getIntersection(t[0],K.set(.95,-1,0).applyMat4(i))),t.push(this._getIntersection(t[0],J.set(1,-.95,0).applyMat4(i)))):3===r&&(t.push(this._getIntersection(t[0],K.set(-.95,-1,0).applyMat4(i))),t.push(this._getIntersection(t[0],J.set(-1.95,0).applyMat4(i))))}else for(let s=0;s<e.length;s++)t[s][0]=1e4,t[s][1]=1e4;return t}_getWorldCoords(){let e=[Y.set(-1,1,0),q.set(1,1,0),Q.set(1,-1,0),Z.set(-1,-1,0)],t=[],s=[];for(let i=0;i<e.length;i++){let r=e[i].applyMat4(this._matrices.modelViewProjection.matrix
36);t.push(r),Math.abs(r.z)>1&&s.push(i)}s.length&&(t=this._getNearPlaneIntersections(e,t,s));let i=1/0,r=-1/0,a=1/0,n=-1/0;for(let e=0;e<t.length;e++){let s=t[e];s.x<i&&(i=s.x),s.x>r&&(r=s.x),s.y<a&&(a=s.y),s.y>n&&(n=s.y)}return{top:n,right:r,bottom:a,left:i}}_computeWebGLBoundingRect(){let e=this._getWorldCoords(),t={top:1-(e.top+1)/2,right:(e.right+1)/2,bottom:1-(e.bottom+1)/2,left:(e.left+1)/2};t.width=t.right-t.left,t.height=t.bottom-t.top,this._boundingRect.worldToDocument={width:t.width*this.renderer._boundingRect.width,height:t.height*this.renderer._boundingRect.height,top:t.top*this.renderer._boundingRect.height+this.renderer._boundingRect.top,left:t.left*this.renderer._boundingRect.width+this.renderer._boundingRect.left,right:t.left*this.renderer._boundingRect.width+this.renderer._boundingRect.left+t.width*this.renderer._boundingRect.width,bottom:t.top*this.renderer._boundingRect.height+this.renderer._boundingRect.top+t.height*this.renderer._boundingRect.height}}getWebGLBoundingRect(){return this._matrices.modelViewProjection?((!this._boundingRect.worldToDocument||this.alwaysDraw)&&this._computeWebGLBoundingRect
36(),this._boundingRect.worldToDocument):this._boundingRect.document}_getWebGLDrawRect(){return this._computeWebGLBoundingRect(),{top:this._boundingRect.worldToDocument.top-this.drawCheckMargins.top,right:this._boundingRect.worldToDocument.right+this.drawCheckMargins.right,bottom:this._boundingRect.worldToDocument.bottom+this.drawCheckMargins.bottom,left:this._boundingRect.worldToDocument.left-this.drawCheckMargins.left}}_shouldDrawCheck(){let e=this._getWebGLDrawRect();Math.round(e.right)<=this.renderer._boundingRect.left||Math.round(e.left)>=this.renderer._boundingRect.left+this.renderer._boundingRect.width||Math.round(e.bottom)<=this.renderer._boundingRect.top||Math.round(e.top)>=this.renderer._boundingRect.top+this.renderer._boundingRect.height?this._shouldDraw&&(this._shouldDraw=!1,this.renderer.nextRender.add(()=>this._onLeaveViewCallback&&this._onLeaveViewCallback())):(this._shouldDraw||this.renderer.nextRender.add(()=>this._onReEnterViewCallback&&this._onReEnterViewCallback()),this._shouldDraw=!0)}isDrawn(){return this._canDraw&&this.visible&&(this._shouldDraw||this.alwaysDraw)}enableDepthTest(e){this._depthTest=e}_initSources(){let e=0;if(this.autoloadSources){let t=[];for(let e=0;e<this.htmlElement.getElementsByTagName("img").length;e++)t.push(this.htmlElement.getElementsByTagName("img")[e]);t.length>0&&this.loadImages(t);let s=[];for(let e=0;e<this.htmlElement.getElementsByTagName("video").length;e++)s.push(this.htmlElement.getElementsByTagName("video")[e]);s.length>0&&this.loadVideos(s);let i=[];for(let e=0;e<this.htmlElement.getElementsByTagName("canvas").length;e++)i.push(this.htmlElement.getElementsByTagName("canvas")[e]);i.length>0&&this.loadCanvases(i),e=t.length+s.length+i.length}this.loader._setLoaderSize(e),this._canDraw=!0}_startDrawing(){this._canDraw&&(this._onRenderCallback&&this._onRenderCallback(),this.target?this.renderer.bindFrameBuffer(this.target):null===this.renderer.state.scenePassIndex&&this.renderer.bindFrameBuffer(null),this._setPerspectiveMatrix(),this._setMVMatrix(),(this.alwaysDraw||this._shouldDraw)&&this.visible&&this._draw())}mouseToPlaneCoords(e){if($.setAxisOrder(this.quaternion.axisOrder),$.equals(this.quaternion)&&ee.equals(this.transformOrigin))return super.mouseToPlaneCoords(e);{let t={x:2*(e.x/(this.renderer._boundingRect.width/this.renderer.pixelRatio))-1,y:2*(1-e.y/(this.renderer._boundingRect.height/this.renderer.pixelRatio))-1},s=this.camera.position.clone(),i=et.set(t.x,t.y,-.5);i.unproject(this.camera),i.sub(s).normalize();let r=es.set(0,0,-1);r.applyQuat(this.quaternion).normalize();let a=er.set(0,0,0),n=r.dot(i);if(Math.abs(n)>=1e-4){let e=this._matrices.world.matrix.getInverse().multiply(this.camera.viewMatrix),t=this._boundingRect.world.transformOrigin.clone().add(this._translation),h=ei.set(this._translation.x-t.x,this._translation.y-t.y,this._translation.z-t.z);h.applyQuat(this.quaternion),t.add(h);let o=r.dot(t.clone().sub(s))/n;a.copy(s.add(i.multiplyScalar(o))),a.applyMat4(e)}else a.set(1/0,1/0,1/0);return ea.set(a.x,a.y)}}onReEnterView(e){return e&&(this._onReEnterViewCallback=e),this}onLeaveView(e){return e&&(this._onLeaveViewCallback=e),this}}function eh(e){var r,n=(0,t.useContext)(a),h=n.state,o=n.dispatch,l=(0,t.useRef)(null),d=(0,t.useRef)(null),u=e.alpha,c=e.antialias,p=e.premultipliedAlpha,g=e.depth,m=e.preserveDrawingBuffer,_=e.failIfMajorPerformanceCaveat,x=e.stencil,b=e.autoRender,y=e.autoResize,v=e.pixelRatio,R=e.renderingScale,w=e.watchScroll,S=e.production,T=e.onAfterResize,P=e.onContextLost,E=e.onContextRestored,C=e.onError,M=e.onSuccess,A=e.onRender,k=e.onScroll,F=i(e,["alpha","antialias","premultipliedAlpha","depth","preserveDrawingBuffer","failIfMajorPerformanceCaveat","stencil","autoRender","autoResize","pixelRatio","renderingScale","watchScroll","production","onAfterResize","onContextLost","onContextRestored","onError","onSuccess","onRender","onScroll"]);return(0,t.useLayoutEffect)(function(){"u">typeof window&&window.document&&window.document.createElement&&!h.curtains&&!d.current&&(d.current=new f({container:l.current,production:!S||S,alph
36a:u,antialias:c,premultipliedAlpha:p,depth:g,preserveDrawingBuffer:m,failIfMajorPerformanceCaveat:_,stencil:x,autoRender:b,autoResize:y,pixelRatio:v,renderingScale:R,watchScroll:w}),o({type:"SET_CURTAINS",curtains:d.current}));var e=d.current;return function(){e&&e.dispose()}},[]),r=function(){d.current&&d.current.onAfterResize(function(){T&&T(d.current),h.subscriptions.onAfterResize.forEach(function(e){e.callback&&e.callback(d.current)})}).onContextLost(function(){P&&P(d.current),h.subscriptions.onContextLost.forEach(function(e){e.callback&&e.callback(d.current)})}).onContextRestored(function(){E&&E(d.current),h.subscriptions.onContextRestored.forEach(function(e){e.callback&&e.callback(d.current)})}).onSuccess(function(){M&&M(d.current),h.subscriptions.onSuccess.forEach(function(e){e.callback&&e.callback(d.current)})}).onError(function(){C&&C(d.current),h.subscriptions.onError.forEach(function(e){e.callback&&e.callback(d.current)})}).onRender(function(){A&&A(d.current),h.subscriptions.onRender.forEach(function(e){e.callback&&e.callback(d.current)})}).onScroll(function(){k&&k(d.current),h.subscriptions.onScroll.forEach(function(e){e.callback&&e.callback(d.current)})})},(0,t.useLayoutEffect)(r,[h]),F.className=F.className||"curtains-canvas",F.children=null,t.default.createElement(t.default.Fragment,null,e.children,t.default.createElement("div",s({},F,{ref:l})))}function eo(e,s){void 0===s&&(s=[]);var i=(0,t.useContext)(a).state;(0,t.useEffect)(function(){var t;return i.curtains&&!i.curtains.errors&&e&&(t=e(i.curtains)),function(){t&&"function"==typeof t&&t()}},[i.curtains].concat(s))}e.s(["Curtains",0,function(e){return t.default.createElement(n,null,t.default.createElement(eh,e))},"Plane",0,function(e){var r=e.vertexShader,a=e.vertexShaderID,n=e.fragmentShader,h=e.fragmentShaderID,o=e.widthSegments,l=e.heightSegments,d=e.renderOrder,u=e.depthTest,c=e.transparent,p=e.cullFace,g=e.alwaysDraw,m=e.visible,_=e.drawCheckMargins,f=e.watchScroll,x=e.autoloadSources,b=e.texturesOptions,y=e.crossOrigin,v=e.fov,R=e.uniforms,w=e.target,S=e.relativeTranslation,T=e.rotation,P=e.scale,E=e.transformOrigin,C=e.onAfterRender,M=e.onAfterResize,F=e.onError,L=e.onLeaveView,O=e.onLoading,D=e.onReady,U=e.onReEnterView,z=e.onRender,I=e.onBeforeCreate,V=e.onBeforeRemove,N=i(e,["vertexShader","vertexShaderID","fragmentShader","fragmentShaderID","widthSegments","heightSegments","renderOrder","depthTest","transparent","cullFace","alwaysDraw","visible","drawCheckMargins","watchScroll","autoloadSources","texturesOptions","crossOrigin","fov","uniforms","target","relativeTranslation","rotation","scale","transformOrigin","onAfterRender","onAfterResize","onError","onLeaveView","onLoading","onReady","onReEnterView","onRender","onBeforeCreate","onBeforeRemove"]),B=(0,t.useRef)(),W=(0,t.useRef)();return eo(function(e){W.current||(I&&I(),W.current=new en(e,B.current,{vertexShader:r,vertexShaderID:a,fragmentShader:n,fragmentShaderID:h,widthSegments:o,heightSegments:l,renderOrder:d,depthTest:u,transparent:c,cullFace:p,alwaysDraw:g,visible:m,drawCheckMargins:_,watchScroll:f,autoloadSources:x,texturesOptions:b,crossOrigin:y,fov:v,uniforms:R}).onAfterRender(function(){C&&C(W.current)}).onAfterResize(function(){M&&M(W.current)}).onError(function(){F&&F(W.current)}).onLeaveView(function(){L&&L(W.current)}).onLoading(function(e){O&&O(W.current,e)}).onReady(function(){D&&D(W.current)}).onReEnterView(function(){U&&U(W.current)}).onRender(function(){z&&z(W.current)}));var t=W.current;return function(){t&&(V&&V(t),t.remove())}}),(0,t.useEffect)(function(){if(W.current){if(void 0!==g&&(W.current.alwaysDraw=g),void 0!==p&&(W.current.cullFace=p),void 0!==_&&(W.current.drawCheckMargins=_),void 0!==m&&(W.current.visible=m),void 0!==f&&(W.current.watchScroll=f),void 0!==u&&W.current.enableDepthTest(u),void 0!==w&&W.current.setRenderTarget(w),void 0!==d&&W.current.setRenderOrder(d),S){var e=new k;S.length>=3&&e.set(S[0],S[1],S[2]),W.current.setRelativeTranslation(e)}if(T){var t=new k;T.length>=3&&t.set(T[0],T[1],T[2]),W.current.setRotation(t)}if(P){var s=new A(1,1);P.length>=2&&s.set(P[0],P[1]),W.current.setScale(s)}if(E){var i=new k(.5,.5,0);E.length>=3&&i.set(E[0],E[1],E[2]),W.current.setTransformOrigin(i)}void 0!==v&&v!==W.current.camera.fov&&W.current.setPerspective(v)}},[g,p,_,m,f,d,u,w,S,T,P,E,v]),t.default.createElement("div",s({ref:B},N),e.children)},"useCurtains",0,eo,"useCurtainsEvent",0,function(e,s,i){void 0===i&&(i=[]);var r=["onAfterResize","onContextLost","onContextRestored","onError","onSuccess","onRender","onScroll"].find(function(t){return e===t}),n=(0,t.useContext)(a).dispatch,h=(0,t.useRef)({event:e,callback:s,id:"_"+Math.random().toString(36).substr(2,9)});eo(function(){h.current.callback=s.bind(i),r&&n({type:"ADD_SUBSCRIPTION",addSubscription:h.current});var e=h.current;return function(){r&&n({type:"REMOVE_SUBSCRIPTION",removeSubscription:e})}},[n,r].concat(i))}])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.