diff --git "a/assets/src-mAITpvbv.js" "b/assets/src-mAITpvbv.js" new file mode 100644--- /dev/null +++ "b/assets/src-mAITpvbv.js" @@ -0,0 +1,2943 @@ +import{A as e,B as t,C as n,Dt as r,Et as i,F as a,G as o,K as s,M as c,Mt as l,R as u,S as d,W as f,Y as p,at as m,b as h,g,k as _,kt as v,lt as y,m as b,nt as x,ot as S,q as C,u as ee,ut as te,w as ne,wt as w,x as re,xt as T}from"./vue.runtime.esm-bundler-_ZPRHVd_.js";import{$ as E,$t as D,A as O,At as ie,B as ae,Bt as k,C as oe,Ct as A,D as se,Dt as ce,E as le,Et as ue,F as j,Ft as de,G as fe,Gt as pe,H as me,Ht as he,I as ge,It as _e,J as ve,Jt as ye,K as be,Kt as M,L as xe,Lt as N,M as Se,Mt as Ce,N as we,Nt as Te,O as Ee,Ot as De,P as Oe,Pt as ke,Q as Ae,Qt as je,R as P,Rt as Me,S as Ne,St as Pe,T as Fe,Tt as Ie,U as Le,Ut as Re,V as ze,Vt as Be,W as Ve,Wt as He,X as Ue,Xt as We,Y as Ge,Yt as Ke,Z as qe,Zt as Je,_ as Ye,_t as Xe,a as Ze,an as F,at as Qe,b as $e,bt as et,c as tt,cn as nt,ct as I,d as rt,dt as it,en as at,et as ot,f as st,ft as ct,g as lt,gt as ut,h as dt,ht as ft,i as pt,in as L,it as mt,j as ht,jt as R,k as gt,kt as _t,l as vt,ln as yt,lt as bt,m as xt,mt as St,n as Ct,nn as wt,nt as Tt,o as Et,on as Dt,ot as Ot,p as kt,pt as At,q as jt,qt as Mt,rn as Nt,rt as z,s as Pt,sn as Ft,st as It,t as Lt,tn as Rt,tt as zt,u as Bt,ut as B,v as V,vt as Vt,w as Ht,wt as Ut,x as H,xt as Wt,y as Gt,yt as Kt,z as qt,zt as Jt}from"./tres-Bk8ucvrj.js";import{o as Yt}from"./widgets-C0YByt49.js";import{t as Xt}from"./src-DYQXbDgu.js";import{a as Zt,i as Qt}from"./resettable-CbXzRviW.js";import{c as $t,s as en}from"./environment-CyZLTg97.js";import{E as tn,O as nn,a as rn,f as U,h as an,i as on,l as sn,r as cn,t as ln}from"./dist-Che88T83.js";import{r as un}from"./src-C83SCWbW.js";import{r as dn}from"./browser-DY5K31Vk.js";import{C as fn,D as pn,S as mn,T as hn,_ as gn,b as _n,c as vn,d as yn,f as bn,g as xn,h as Sn,l as Cn,m as wn,n as Tn,o as En,p as Dn,s as On,u as W,v as kn,w as An,x as jn,y as Mn}from"./settings-73vyHOZs.js";import{t as Nn}from"./beat-sync-GCfX3UHH.js";import{n as Pn}from"./live2d-DukystQI.js";var Fn=e({__name:`Canvas`,props:u({width:{},height:{},resolution:{default:2}},{state:{default:`pending`},stateModifiers:{}}),emits:[`update:state`],setup(e,{expose:t}){let r=e,i=x(e,`state`),a=T(),c=T(!1),l=T(),u=T();async function d(e){i.value=`loading`,c.value=!1,On.registerTicker(xn),kn.add(gn),l.value=new Cn({width:r.width*r.resolution,height:r.height*r.resolution,backgroundAlpha:0,preserveDrawingBuffer:!0}),u.value=l.value.view,u.value.style.width=`100%`,u.value.style.height=`100%`,u.value.style.objectFit=`cover`,u.value.style.display=`block`,e.appendChild(l.value.view),c.value=!0,i.value=`mounted`}function h(){l.value&&l.value.renderer.resize(r.width,r.height)}m([()=>r.width,()=>r.height],()=>h()),m(()=>r.resolution,e=>{l.value&&e&&(l.value.renderer.resolution=e,h())}),f(async()=>a.value&&await d(a.value)),o(()=>l.value?.destroy());async function g(){return new Promise(e=>{if(!u.value||!l.value)return e(null);l.value.render(),u.value.toBlob(e)})}function _(){return u.value}return t({captureFrame:g,canvasElement:_}),(void 0)?.dispose(()=>{console.warn(`[Dev] Reload on HMR dispose is active for this component. Performing a full reload.`),window.location.reload()}),(e,t)=>(s(),ne(`div`,{ref_key:`containerRef`,ref:a,"h-full":``,"w-full":``},[c.value?p(e.$slots,`default`,{key:0,app:l.value}):n(``,!0)],512))}}),In=function(e,t){return In=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},In(e,t)};function Ln(e,t){In(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Rn=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,zn=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform float gamma; +uniform float contrast; +uniform float saturation; +uniform float brightness; +uniform float red; +uniform float green; +uniform float blue; +uniform float alpha; + +void main(void) +{ + vec4 c = texture2D(uSampler, vTextureCoord); + + if (c.a > 0.0) { + c.rgb /= c.a; + + vec3 rgb = pow(c.rgb, vec3(1. / gamma)); + rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast); + rgb.r *= red; + rgb.g *= green; + rgb.b *= blue; + c.rgb = rgb * brightness; + + c.rgb *= c.a; + } + + gl_FragColor = c * alpha; +} +`;(function(e){Ln(t,e);function t(t){var n=e.call(this,Rn,zn)||this;return n.gamma=1,n.saturation=1,n.contrast=1,n.brightness=1,n.red=1,n.green=1,n.blue=1,n.alpha=1,Object.assign(n,t),n}return t.prototype.apply=function(e,t,n,r){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,e.applyFilter(this,t,n,r)},t})(W);var Bn=function(e,t){return Bn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Bn(e,t)};function Vn(e,t){Bn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Hn=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Un=` +varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 uOffset; + +void main(void) +{ + vec4 color = vec4(0.0); + + // Sample top left pixel + color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y)); + + // Sample top right pixel + color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y)); + + // Sample bottom right pixel + color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y)); + + // Sample bottom left pixel + color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y)); + + // Average + color *= 0.25; + + gl_FragColor = color; +}`,Wn=` +varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 uOffset; +uniform vec4 filterClamp; + +void main(void) +{ + vec4 color = vec4(0.0); + + // Sample top left pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample top right pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample bottom right pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample bottom left pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Average + color *= 0.25; + + gl_FragColor = color; +} +`,Gn=function(e){Vn(t,e);function t(t,n,r){t===void 0&&(t=4),n===void 0&&(n=3),r===void 0&&(r=!1);var i=e.call(this,Hn,r?Wn:Un)||this;return i._kernels=[],i._blur=4,i._quality=3,i.uniforms.uOffset=new Float32Array(2),i._pixelSize=new Sn,i.pixelSize=1,i._clamp=r,Array.isArray(t)?i.kernels=t:(i._blur=t,i.quality=n),i}return t.prototype.apply=function(e,t,n,r){var i=this._pixelSize.x/t._frame.width,a=this._pixelSize.y/t._frame.height,o;if(this._quality===1||this._blur===0)o=this._kernels[0]+.5,this.uniforms.uOffset[0]=o*i,this.uniforms.uOffset[1]=o*a,e.applyFilter(this,t,n,r);else{for(var s=e.getFilterTexture(),c=t,l=s,u=void 0,d=this._quality-1,f=0;f0)for(var r=e,i=e/t,a=1;a0?(this._kernels=e,this._quality=e.length,this._blur=Math.max.apply(Math,e)):(this._kernels=[0],this._quality=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`clamp`,{get:function(){return this._clamp},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._pixelSize},set:function(e){typeof e==`number`?(this._pixelSize.x=e,this._pixelSize.y=e):Array.isArray(e)?(this._pixelSize.x=e[0],this._pixelSize.y=e[1]):e instanceof Sn?(this._pixelSize.x=e.x,this._pixelSize.y=e.y):(this._pixelSize.x=1,this._pixelSize.y=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._quality},set:function(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blur},set:function(e){this._blur=e,this._generateKernels()},enumerable:!1,configurable:!0}),t}(W),Kn=function(e,t){return Kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Kn(e,t)};function qn(e,t){Kn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Jn=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Yn=` +uniform sampler2D uSampler; +varying vec2 vTextureCoord; + +uniform float threshold; + +void main() { + vec4 color = texture2D(uSampler, vTextureCoord); + + // A simple & fast algorithm for getting brightness. + // It's inaccuracy , but good enought for this feature. + float _max = max(max(color.r, color.g), color.b); + float _min = min(min(color.r, color.g), color.b); + float brightness = (_max + _min) * 0.5; + + if(brightness > threshold) { + gl_FragColor = color; + } else { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + } +} +`,Xn=function(e){qn(t,e);function t(t){t===void 0&&(t=.5);var n=e.call(this,Jn,Yn)||this;return n.threshold=t,n}return Object.defineProperty(t.prototype,`threshold`,{get:function(){return this.uniforms.threshold},set:function(e){this.uniforms.threshold=e},enumerable:!1,configurable:!0}),t}(W),Zn=`uniform sampler2D uSampler; +varying vec2 vTextureCoord; + +uniform sampler2D bloomTexture; +uniform float bloomScale; +uniform float brightness; + +void main() { + vec4 color = texture2D(uSampler, vTextureCoord); + color.rgb *= brightness; + vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0); + bloomColor.rgb *= bloomScale; + gl_FragColor = color + bloomColor; +} +`;(function(e){qn(t,e);function t(n){var r=e.call(this,Jn,Zn)||this;r.bloomScale=1,r.brightness=1,r._resolution=jn.FILTER_RESOLUTION,typeof n==`number`&&(n={threshold:n});var i=Object.assign(t.defaults,n);r.bloomScale=i.bloomScale,r.brightness=i.brightness;var a=i.kernels,o=i.blur,s=i.quality,c=i.pixelSize,l=i.resolution;return r._extractFilter=new Xn(i.threshold),r._extractFilter.resolution=l,r._blurFilter=a?new Gn(a):new Gn(o,s),r.pixelSize=c,r.resolution=l,r}return t.prototype.apply=function(e,t,n,r,i){var a=e.getFilterTexture();this._extractFilter.apply(e,t,a,1,i);var o=e.getFilterTexture();this._blurFilter.apply(e,a,o,1),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=o,e.applyFilter(this,t,n,r),e.returnFilterTexture(o),e.returnFilterTexture(a)},Object.defineProperty(t.prototype,`resolution`,{get:function(){return this._resolution},set:function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`threshold`,{get:function(){return this._extractFilter.threshold},set:function(e){this._extractFilter.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`kernels`,{get:function(){return this._blurFilter.kernels},set:function(e){this._blurFilter.kernels=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blurFilter.blur},set:function(e){this._blurFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._blurFilter.quality},set:function(e){this._blurFilter.quality=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._blurFilter.pixelSize},set:function(e){this._blurFilter.pixelSize=e},enumerable:!1,configurable:!0}),t.defaults={threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:jn.FILTER_RESOLUTION},t})(W);var Qn=function(e,t){return Qn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Qn(e,t)};function $n(e,t){Qn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var er=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,tr=`varying vec2 vTextureCoord; + +uniform vec4 filterArea; +uniform float pixelSize; +uniform sampler2D uSampler; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 pixelate(vec2 coord, vec2 size) +{ + return floor( coord / size ) * size; +} + +vec2 getMod(vec2 coord, vec2 size) +{ + return mod( coord , size) / size; +} + +float character(float n, vec2 p) +{ + p = floor(p*vec2(4.0, -4.0) + 2.5); + + if (clamp(p.x, 0.0, 4.0) == p.x) + { + if (clamp(p.y, 0.0, 4.0) == p.y) + { + if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; + } + } + return 0.0; +} + +void main() +{ + vec2 coord = mapCoord(vTextureCoord); + + // get the rounded color.. + vec2 pixCoord = pixelate(coord, vec2(pixelSize)); + pixCoord = unmapCoord(pixCoord); + + vec4 color = texture2D(uSampler, pixCoord); + + // determine the character to use + float gray = (color.r + color.g + color.b) / 3.0; + + float n = 65536.0; // . + if (gray > 0.2) n = 65600.0; // : + if (gray > 0.3) n = 332772.0; // * + if (gray > 0.4) n = 15255086.0; // o + if (gray > 0.5) n = 23385164.0; // & + if (gray > 0.6) n = 15252014.0; // 8 + if (gray > 0.7) n = 13199452.0; // @ + if (gray > 0.8) n = 11512810.0; // # + + // get the mod.. + vec2 modd = getMod(coord, vec2(pixelSize)); + + gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); + +} +`;(function(e){$n(t,e);function t(t){t===void 0&&(t=8);var n=e.call(this,er,tr)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.pixelSize},set:function(e){this.uniforms.pixelSize=e},enumerable:!1,configurable:!0}),t})(W);var nr=function(e,t){return nr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},nr(e,t)};function rr(e,t){nr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ir=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,ar=`precision mediump float; + +varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; + +uniform float transformX; +uniform float transformY; +uniform vec3 lightColor; +uniform float lightAlpha; +uniform vec3 shadowColor; +uniform float shadowAlpha; + +void main(void) { + vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY); + vec4 color = texture2D(uSampler, vTextureCoord); + float light = texture2D(uSampler, vTextureCoord - transform).a; + float shadow = texture2D(uSampler, vTextureCoord + transform).a; + + color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0)); + color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0)); + gl_FragColor = vec4(color.rgb * color.a, color.a); +} +`;(function(e){rr(t,e);function t(t){var n=e.call(this,ir,ar)||this;return n._thickness=2,n._angle=0,n.uniforms.lightColor=new Float32Array(3),n.uniforms.shadowColor=new Float32Array(3),Object.assign(n,{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},t),n.padding=1,n}return t.prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},Object.defineProperty(t.prototype,`rotation`,{get:function(){return this._angle/Dn},set:function(e){this._angle=e*Dn,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightColor`,{get:function(){return _n(this.uniforms.lightColor)},set:function(e){Mn(e,this.uniforms.lightColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightAlpha`,{get:function(){return this.uniforms.lightAlpha},set:function(e){this.uniforms.lightAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowColor`,{get:function(){return _n(this.uniforms.shadowColor)},set:function(e){Mn(e,this.uniforms.shadowColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowAlpha`,{get:function(){return this.uniforms.shadowAlpha},set:function(e){this.uniforms.shadowAlpha=e},enumerable:!1,configurable:!0}),t})(W);var or=function(e,t){return or=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},or(e,t)};function sr(e,t){or(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var cr=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float uAlpha; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; +} +`,lr=function(e){sr(t,e);function t(t){t===void 0&&(t=1);var n=e.call(this,`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,cr,{uAlpha:1})||this;return n.alpha=t,n}return Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e},enumerable:!1,configurable:!0}),t}(W),ur=function(e,t){return ur=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},ur(e,t)};function dr(e,t){ur(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var fr=` + attribute vec2 aVertexPosition; + + uniform mat3 projectionMatrix; + + uniform float strength; + + varying vec2 vBlurTexCoords[%size%]; + + uniform vec4 inputSize; + uniform vec4 outputFrame; + + vec4 filterVertexPosition( void ) + { + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); + } + + vec2 filterTextureCoord( void ) + { + return aVertexPosition * (outputFrame.zw * inputSize.zw); + } + + void main(void) + { + gl_Position = filterVertexPosition(); + + vec2 textureCoord = filterTextureCoord(); + %blur% + }`;function pr(e,t){for(var n=Math.ceil(e/2),r=fr,i=``,a=t?`vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);`:`vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);`,o=0;o=n&&(o=e-s-1),c=c.replace(`%value%`,t[o].toString()),i+=c,i+=` +`}return r=r.replace(`%blur%`,i),r=r.replace(`%size%`,e.toString()),r}var _r=function(e){dr(t,e);function t(t,n,r,i,a){n===void 0&&(n=8),r===void 0&&(r=4),i===void 0&&(i=jn.FILTER_RESOLUTION),a===void 0&&(a=5);var o=this,s=pr(a,t),c=gr(a);return o=e.call(this,s,c)||this,o.horizontal=t,o.resolution=i,o._quality=0,o.quality=r,o.blur=n,o}return t.prototype.apply=function(e,t,n,r){if(n?this.horizontal?this.uniforms.strength=1/n.width*(n.width/t.width):this.uniforms.strength=1/n.height*(n.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,n,r);else{var i=e.getFilterTexture(),a=e.renderer,o=t,s=i;this.state.blend=!1,e.applyFilter(this,o,s,fn.CLEAR);for(var c=1;c 0.0) { + coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75); + } else { + coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent); + } + } + coord += center * dimensions.xy; + coord /= filterArea.xy; + vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); + vec4 color = texture2D(uSampler, clampedCoord); + if (coord != clampedCoord) { + color *= max(0.0, 1.0 - length(coord - clampedCoord)); + } + + gl_FragColor = color; +} +`;(function(e){xr(t,e);function t(n){var r=e.call(this,Sr,Cr)||this;return r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.strength},set:function(e){this.uniforms.strength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),t.defaults={center:[.5,.5],radius:100,strength:1},t})(W);var wr=function(e,t){return wr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},wr(e,t)};function Tr(e,t){wr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Er=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Dr=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform sampler2D colorMap; +uniform float _mix; +uniform float _size; +uniform float _sliceSize; +uniform float _slicePixelSize; +uniform float _sliceInnerSize; +void main() { + vec4 color = texture2D(uSampler, vTextureCoord.xy); + + vec4 adjusted; + if (color.a > 0.0) { + color.rgb /= color.a; + float innerWidth = _size - 1.0; + float zSlice0 = min(floor(color.b * innerWidth), innerWidth); + float zSlice1 = min(zSlice0 + 1.0, innerWidth); + float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize; + float s0 = xOffset + (zSlice0 * _sliceSize); + float s1 = xOffset + (zSlice1 * _sliceSize); + float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize); + vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset)); + vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset)); + float zOffset = fract(color.b * innerWidth); + adjusted = mix(slice0Color, slice1Color, zOffset); + + color.rgb *= color.a; + } + gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a); + +}`;(function(e){Tr(t,e);function t(t,n,r){n===void 0&&(n=!1),r===void 0&&(r=1);var i=e.call(this,Er,Dr)||this;return i.mix=1,i._size=0,i._sliceSize=0,i._slicePixelSize=0,i._sliceInnerSize=0,i._nearest=!1,i._scaleMode=null,i._colorMap=null,i._scaleMode=null,i.nearest=n,i.mix=r,i.colorMap=t,i}return t.prototype.apply=function(e,t,n,r){this.uniforms._mix=this.mix,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`colorSize`,{get:function(){return this._size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`colorMap`,{get:function(){return this._colorMap},set:function(e){e&&(e instanceof yn||(e=yn.from(e)),e?.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=An.OFF,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`nearest`,{get:function(){return this._nearest},set:function(e){this._nearest=e,this._scaleMode=e?hn.NEAREST:hn.LINEAR;var t=this._colorMap;t&&t.baseTexture&&(t.baseTexture._glTextures={},t.baseTexture.scaleMode=this._scaleMode,t.baseTexture.mipmap=An.OFF,t._updateID++,t.baseTexture.emit(`update`,t.baseTexture))},enumerable:!1,configurable:!0}),t.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit(`update`,e.baseTexture),this.colorMap=e)},t.prototype.destroy=function(t){t===void 0&&(t=!1),this._colorMap&&this._colorMap.destroy(t),e.prototype.destroy.call(this)},t})(W);var Or=function(e,t){return Or=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Or(e,t)};function kr(e,t){Or(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ar=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,jr=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec3 color; +uniform float alpha; + +void main(void) { + vec4 currentColor = texture2D(uSampler, vTextureCoord); + gl_FragColor = vec4(mix(currentColor.rgb, color.rgb, currentColor.a * alpha), currentColor.a); +} +`;(function(e){kr(t,e);function t(t,n){t===void 0&&(t=0),n===void 0&&(n=1);var r=e.call(this,Ar,jr)||this;return r._color=0,r._alpha=1,r.uniforms.color=new Float32Array(3),r.color=t,r.alpha=n,r}return Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.color;typeof e==`number`?(Mn(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._color=_n(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this._alpha},set:function(e){this.uniforms.alpha=e,this._alpha=e},enumerable:!1,configurable:!0}),t})(W);var Mr=function(e,t){return Mr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Mr(e,t)};function Nr(e,t){Mr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Pr=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Fr=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec3 originalColor; +uniform vec3 newColor; +uniform float epsilon; +void main(void) { + vec4 currentColor = texture2D(uSampler, vTextureCoord); + vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001)); + float colorDistance = length(colorDiff); + float doReplace = step(colorDistance, epsilon); + gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a); +} +`;(function(e){Nr(t,e);function t(t,n,r){t===void 0&&(t=16711680),n===void 0&&(n=0),r===void 0&&(r=.4);var i=e.call(this,Pr,Fr)||this;return i._originalColor=16711680,i._newColor=0,i.uniforms.originalColor=new Float32Array(3),i.uniforms.newColor=new Float32Array(3),i.originalColor=t,i.newColor=n,i.epsilon=r,i}return Object.defineProperty(t.prototype,`originalColor`,{get:function(){return this._originalColor},set:function(e){var t=this.uniforms.originalColor;typeof e==`number`?(Mn(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=_n(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`newColor`,{get:function(){return this._newColor},set:function(e){var t=this.uniforms.newColor;typeof e==`number`?(Mn(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=_n(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`epsilon`,{get:function(){return this.uniforms.epsilon},set:function(e){this.uniforms.epsilon=e},enumerable:!1,configurable:!0}),t})(W);var Ir=function(e,t){return Ir=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ir(e,t)};function Lr(e,t){Ir(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Rr=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,zr=`precision mediump float; + +varying mediump vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform vec2 texelSize; +uniform float matrix[9]; + +void main(void) +{ + vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left + vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center + vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right + + vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left + vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center + vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right + + vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left + vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center + vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right + + gl_FragColor = + c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + + c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + + c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; + + gl_FragColor.a = c22.a; +} +`;(function(e){Lr(t,e);function t(t,n,r){n===void 0&&(n=200),r===void 0&&(r=200);var i=e.call(this,Rr,zr)||this;return i.uniforms.texelSize=new Float32Array(2),i.uniforms.matrix=new Float32Array(9),t!==void 0&&(i.matrix=t),i.width=n,i.height=r,i}return Object.defineProperty(t.prototype,`matrix`,{get:function(){return this.uniforms.matrix},set:function(e){var t=this;e.forEach(function(e,n){t.uniforms.matrix[n]=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`width`,{get:function(){return 1/this.uniforms.texelSize[0]},set:function(e){this.uniforms.texelSize[0]=1/e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return 1/this.uniforms.texelSize[1]},set:function(e){this.uniforms.texelSize[1]=1/e},enumerable:!1,configurable:!0}),t})(W);var Br=function(e,t){return Br=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Br(e,t)};function Vr(e,t){Br(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Hr=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Ur=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform sampler2D uSampler; + +void main(void) +{ + float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); + + gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); + + if (lum < 1.00) + { + if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.75) + { + if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.50) + { + if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.3) + { + if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } +} +`;(function(e){Vr(t,e);function t(){return e.call(this,Hr,Ur)||this}return t})(W);var Wr=function(e,t){return Wr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Wr(e,t)};function Gr(e,t){Wr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Kr=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,qr=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec4 filterArea; +uniform vec2 dimensions; + +const float SQRT_2 = 1.414213; + +const float light = 1.0; + +uniform float curvature; +uniform float lineWidth; +uniform float lineContrast; +uniform bool verticalLine; +uniform float noise; +uniform float noiseSize; + +uniform float vignetting; +uniform float vignettingAlpha; +uniform float vignettingBlur; + +uniform float seed; +uniform float time; + +float rand(vec2 co) { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main(void) +{ + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + vec2 dir = vec2(vTextureCoord.xy * filterArea.xy / dimensions - vec2(0.5, 0.5)); + + gl_FragColor = texture2D(uSampler, vTextureCoord); + vec3 rgb = gl_FragColor.rgb; + + if (noise > 0.0 && noiseSize > 0.0) + { + pixelCoord.x = floor(pixelCoord.x / noiseSize); + pixelCoord.y = floor(pixelCoord.y / noiseSize); + float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; + rgb += _noise * noise; + } + + if (lineWidth > 0.0) + { + float _c = curvature > 0. ? curvature : 1.; + float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.; + vec2 uv = dir * k; + + float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c; + float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast; + rgb *= j; + float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.); + rgb *= 0.99 + ceil(segment) * 0.015; + } + + if (vignetting > 0.0) + { + float outter = SQRT_2 - vignetting * SQRT_2; + float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); + rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); + } + + gl_FragColor.rgb = rgb; +} +`;(function(e){Gr(t,e);function t(n){var r=e.call(this,Kr,qr)||this;return r.time=0,r.seed=0,r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`curvature`,{get:function(){return this.uniforms.curvature},set:function(e){this.uniforms.curvature=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineWidth`,{get:function(){return this.uniforms.lineWidth},set:function(e){this.uniforms.lineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineContrast`,{get:function(){return this.uniforms.lineContrast},set:function(e){this.uniforms.lineContrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`verticalLine`,{get:function(){return this.uniforms.verticalLine},set:function(e){this.uniforms.verticalLine=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},t})(W);var Jr=function(e,t){return Jr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Jr(e,t)};function Yr(e,t){Jr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Xr=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Zr=`precision mediump float; + +varying vec2 vTextureCoord; +varying vec4 vColor; + +uniform vec4 filterArea; +uniform sampler2D uSampler; + +uniform float angle; +uniform float scale; + +float pattern() +{ + float s = sin(angle), c = cos(angle); + vec2 tex = vTextureCoord * filterArea.xy; + vec2 point = vec2( + c * tex.x - s * tex.y, + s * tex.x + c * tex.y + ) * scale; + return (sin(point.x) * sin(point.y)) * 4.0; +} + +void main() +{ + vec4 color = texture2D(uSampler, vTextureCoord); + float average = (color.r + color.g + color.b) / 3.0; + gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); +} +`;(function(e){Yr(t,e);function t(t,n){t===void 0&&(t=1),n===void 0&&(n=5);var r=e.call(this,Xr,Zr)||this;return r.scale=t,r.angle=n,r}return Object.defineProperty(t.prototype,`scale`,{get:function(){return this.uniforms.scale},set:function(e){this.uniforms.scale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t})(W);var Qr=function(e,t){return Qr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Qr(e,t)};function $r(e,t){Qr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ei=function(){return ei=Object.assign||function(e){for(var t=arguments,n,r=1,i=arguments.length;r 1.0 || coord.y > 1.0) { + return; + } + + float cx = coord.x - 0.5; + float cy = (coord.y - 0.5) * aspect; + float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5; + + // displacementMap: repeat + // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny); + + // displacementMap: mirror + ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny); + + vec4 dc = texture2D(displacementMap, vec2(0.5, ny)); + + float displacement = (dc.r - dc.g) * (offset / filterArea.x); + + coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * aspect); + + if (fillMode == CLAMP) { + coord = clamp(coord, filterClamp.xy, filterClamp.zw); + } else { + if( coord.x > filterClamp.z ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.x -= filterClamp.z; + } else if (fillMode == MIRROR) { + coord.x = filterClamp.z * 2.0 - coord.x; + } + } else if( coord.x < filterClamp.x ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.x += filterClamp.z; + } else if (fillMode == MIRROR) { + coord.x *= -filterClamp.z; + } + } + + if( coord.y > filterClamp.w ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.y -= filterClamp.w; + } else if (fillMode == MIRROR) { + coord.y = filterClamp.w * 2.0 - coord.y; + } + } else if( coord.y < filterClamp.y ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.y += filterClamp.w; + } else if (fillMode == MIRROR) { + coord.y *= -filterClamp.w; + } + } + } + + gl_FragColor.r = texture2D(uSampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r; + gl_FragColor.g = texture2D(uSampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g; + gl_FragColor.b = texture2D(uSampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b; + gl_FragColor.a = texture2D(uSampler, coord).a; +} +`;(function(e){li(t,e);function t(n){var r=e.call(this,ui,di)||this;return r.offset=100,r.fillMode=t.TRANSPARENT,r.average=!1,r.seed=0,r.minSize=8,r.sampleSize=512,r._slices=0,r._offsets=new Float32Array(1),r._sizes=new Float32Array(1),r._direction=-1,r.uniforms.dimensions=new Float32Array(2),r._canvas=document.createElement(`canvas`),r._canvas.width=4,r._canvas.height=r.sampleSize,r.texture=yn.from(r._canvas,{scaleMode:hn.NEAREST}),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.aspect=o/a,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,n,r)},t.prototype._randomizeSizes=function(){var e=this._sizes,t=this._slices-1,n=this.sampleSize,r=Math.min(this.minSize/n,.9/this._slices);if(this.average){for(var i=this._slices,a=1,o=0;o0;t--){var n=Math.random()*t>>0,r=e[t];e[t]=e[n],e[n]=r}},t.prototype._randomizeOffsets=function(){for(var e=0;e0?r:0,c=r<0?-r:0;n.fillStyle=`rgba(`+s+`, `+c+`, 0, 1)`,n.fillRect(0,i>>0,e,o+1>>0),i+=o}t.baseTexture.update(),this.uniforms.displacementMap=t},Object.defineProperty(t.prototype,`sizes`,{get:function(){return this._sizes},set:function(e){for(var t=Math.min(this._slices,e.length),n=0;n>0)+1},Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.uOffset},set:function(e){this.uniforms.uOffset=e},enumerable:!1,configurable:!0}),t})(W);var Ti=function(e,t){return Ti=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ti(e,t)};function Ei(e,t){Ti(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Di=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Oi=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform float epsilon; + +const int MAX_COLORS = %maxColors%; + +uniform vec3 originalColors[MAX_COLORS]; +uniform vec3 targetColors[MAX_COLORS]; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord); + + float alpha = gl_FragColor.a; + if (alpha < 0.0001) + { + return; + } + + vec3 color = gl_FragColor.rgb / alpha; + + for(int i = 0; i < MAX_COLORS; i++) + { + vec3 origColor = originalColors[i]; + if (origColor.r < 0.0) + { + break; + } + vec3 colorDiff = origColor - color; + if (length(colorDiff) < epsilon) + { + vec3 targetColor = targetColors[i]; + gl_FragColor = vec4((targetColor + colorDiff) * alpha, alpha); + return; + } + } +} +`;(function(e){Ei(t,e);function t(t,n,r){n===void 0&&(n=.05),r===void 0&&(r=t.length);var i=e.call(this,Di,Oi.replace(/%maxColors%/g,r.toFixed(0)))||this;return i._replacements=[],i._maxColors=0,i.epsilon=n,i._maxColors=r,i.uniforms.originalColors=new Float32Array(r*3),i.uniforms.targetColors=new Float32Array(r*3),i.replacements=t,i}return Object.defineProperty(t.prototype,`replacements`,{get:function(){return this._replacements},set:function(e){var t=this.uniforms.originalColors,n=this.uniforms.targetColors,r=e.length;if(r>this._maxColors)throw Error(`Length of replacements (`+r+`) exceeds the maximum colors length (`+this._maxColors+`)`);t[r*3]=-1;for(var i=0;i 0.5) then: 1 - 2 * (1 - dst) * (1 - src) + return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)), + (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)), + (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z))); +} + + +void main() +{ + gl_FragColor = texture2D(uSampler, vTextureCoord); + vec3 color = gl_FragColor.rgb; + + if (sepia > 0.0) + { + float gray = (color.x + color.y + color.z) / 3.0; + vec3 grayscale = vec3(gray); + + color = Overlay(SEPIA_RGB, grayscale); + + color = grayscale + sepia * (color - grayscale); + } + + vec2 coord = vTextureCoord * filterArea.xy / dimensions.xy; + + if (vignetting > 0.0) + { + float outter = SQRT_2 - vignetting * SQRT_2; + vec2 dir = vec2(vec2(0.5, 0.5) - coord); + dir.y *= dimensions.y / dimensions.x; + float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); + color.rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); + } + + if (scratchDensity > seed && scratch != 0.0) + { + float phase = seed * 256.0; + float s = mod(floor(phase), 2.0); + float dist = 1.0 / scratchDensity; + float d = distance(coord, vec2(seed * dist, abs(s - seed * dist))); + if (d < seed * 0.6 + 0.4) + { + highp float period = scratchDensity * 10.0; + + float xx = coord.x * period + phase; + float aa = abs(mod(xx, 0.5) * 4.0); + float bb = mod(floor(xx / 0.5), 2.0); + float yy = (1.0 - bb) * aa + bb * (2.0 - aa); + + float kk = 2.0 * period; + float dw = scratchWidth / dimensions.x * (0.75 + seed); + float dh = dw * kk; + + float tine = (yy - (2.0 - dh)); + + if (tine > 0.0) { + float _sign = sign(scratch); + + tine = s * tine / period + scratch + 0.1; + tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5); + + color.rgb *= tine; + } + } + } + + if (noise > 0.0 && noiseSize > 0.0) + { + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + pixelCoord.x = floor(pixelCoord.x / noiseSize); + pixelCoord.y = floor(pixelCoord.y / noiseSize); + // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + seed * 512.0, 1024.0 - seed * 512.0); + // float _noise = snoise(d) * 0.5; + float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; + color += _noise * noise; + } + + gl_FragColor.rgb = color; +} +`;(function(e){Ai(t,e);function t(n,r){r===void 0&&(r=0);var i=e.call(this,ji,Mi)||this;return i.seed=0,i.uniforms.dimensions=new Float32Array(2),typeof n==`number`?(i.seed=n,n=void 0):i.seed=r,Object.assign(i,t.defaults,n),i}return t.prototype.apply=function(e,t,n,r){this.uniforms.dimensions[0]=t.filterFrame?.width,this.uniforms.dimensions[1]=t.filterFrame?.height,this.uniforms.seed=this.seed,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`sepia`,{get:function(){return this.uniforms.sepia},set:function(e){this.uniforms.sepia=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratch`,{get:function(){return this.uniforms.scratch},set:function(e){this.uniforms.scratch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchDensity`,{get:function(){return this.uniforms.scratchDensity},set:function(e){this.uniforms.scratchDensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchWidth`,{get:function(){return this.uniforms.scratchWidth},set:function(e){this.uniforms.scratchWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3},t})(W);var Ni=function(e,t){return Ni=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ni(e,t)};function Pi(e,t){Ni(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Fi=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Ii=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 thickness; +uniform vec4 outlineColor; +uniform vec4 filterClamp; + +const float DOUBLE_PI = 3.14159265358979323846264 * 2.; + +void main(void) { + vec4 ownColor = texture2D(uSampler, vTextureCoord); + vec4 curColor; + float maxAlpha = 0.; + vec2 displaced; + for (float angle = 0.; angle <= DOUBLE_PI; angle += \${angleStep}) { + displaced.x = vTextureCoord.x + thickness.x * cos(angle); + displaced.y = vTextureCoord.y + thickness.y * sin(angle); + curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw)); + maxAlpha = max(maxAlpha, curColor.a); + } + float resultAlpha = max(maxAlpha, ownColor.a); + gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha); +} +`;(function(e){Pi(t,e);function t(n,r,i){n===void 0&&(n=1),r===void 0&&(r=0),i===void 0&&(i=.1);var a=e.call(this,Fi,Ii.replace(/\$\{angleStep\}/,t.getAngleStep(i)))||this;return a._thickness=1,a.uniforms.thickness=new Float32Array([0,0]),a.uniforms.outlineColor=new Float32Array([0,0,0,1]),Object.assign(a,{thickness:n,color:r,quality:i}),a}return t.getAngleStep=function(e){var n=Math.max(e*t.MAX_SAMPLES,t.MIN_SAMPLES);return(Math.PI*2/n).toFixed(7)},t.prototype.apply=function(e,t,n,r){this.uniforms.thickness[0]=this._thickness/t._frame.width,this.uniforms.thickness[1]=this._thickness/t._frame.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`color`,{get:function(){return _n(this.uniforms.outlineColor)},set:function(e){Mn(e,this.uniforms.outlineColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this.padding=e},enumerable:!1,configurable:!0}),t.MIN_SAMPLES=1,t.MAX_SAMPLES=100,t})(W);var Li=function(e,t){return Li=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Li(e,t)};function Ri(e,t){Li(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var zi=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Bi=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform vec2 size; +uniform sampler2D uSampler; + +uniform vec4 filterArea; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 pixelate(vec2 coord, vec2 size) +{ + return floor( coord / size ) * size; +} + +void main(void) +{ + vec2 coord = mapCoord(vTextureCoord); + + coord = pixelate(coord, size); + + coord = unmapCoord(coord); + + gl_FragColor = texture2D(uSampler, coord); +} +`;(function(e){Ri(t,e);function t(t){t===void 0&&(t=10);var n=e.call(this,zi,Bi)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.size},set:function(e){typeof e==`number`&&(e=[e,e]),this.uniforms.size=e},enumerable:!1,configurable:!0}),t})(W);var Vi=function(e,t){return Vi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Vi(e,t)};function Hi(e,t){Vi(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ui=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Wi=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; + +uniform float uRadian; +uniform vec2 uCenter; +uniform float uRadius; +uniform int uKernelSize; + +const int MAX_KERNEL_SIZE = 2048; + +void main(void) +{ + vec4 color = texture2D(uSampler, vTextureCoord); + + if (uKernelSize == 0) + { + gl_FragColor = color; + return; + } + + float aspect = filterArea.y / filterArea.x; + vec2 center = uCenter.xy / filterArea.xy; + float gradient = uRadius / filterArea.x * 0.3; + float radius = uRadius / filterArea.x - gradient * 0.5; + int k = uKernelSize - 1; + + vec2 coord = vTextureCoord; + vec2 dir = vec2(center - coord); + float dist = length(vec2(dir.x, dir.y * aspect)); + + float radianStep = uRadian; + if (radius >= 0.0 && dist > radius) { + float delta = dist - radius; + float gap = gradient; + float scale = 1.0 - abs(delta / gap); + if (scale <= 0.0) { + gl_FragColor = color; + return; + } + radianStep *= scale; + } + radianStep /= float(k); + + float s = sin(radianStep); + float c = cos(radianStep); + mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c)); + + for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) { + if (i == k) { + break; + } + + coord -= center; + coord.y *= aspect; + coord = rotationMatrix * coord; + coord.y /= aspect; + coord += center; + + vec4 sample = texture2D(uSampler, coord); + + // switch to pre-multiplied alpha to correctly blur transparent images + // sample.rgb *= sample.a; + + color += sample; + } + + gl_FragColor = color / float(uKernelSize); +} +`;(function(e){Hi(t,e);function t(t,n,r,i){t===void 0&&(t=0),n===void 0&&(n=[0,0]),r===void 0&&(r=5),i===void 0&&(i=-1);var a=e.call(this,Ui,Wi)||this;return a._angle=0,a.angle=t,a.center=n,a.kernelSize=r,a.radius=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.uKernelSize=this._angle===0?0:this.kernelSize,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`angle`,{get:function(){return this._angle},set:function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t})(W);var Gi=function(e,t){return Gi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Gi(e,t)};function Ki(e,t){Gi(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var qi=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Ji=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec4 filterArea; +uniform vec4 filterClamp; +uniform vec2 dimensions; + +uniform bool mirror; +uniform float boundary; +uniform vec2 amplitude; +uniform vec2 waveLength; +uniform vec2 alpha; +uniform float time; + +float rand(vec2 co) { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main(void) +{ + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + vec2 coord = pixelCoord / dimensions; + + if (coord.y < boundary) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + + float k = (coord.y - boundary) / (1. - boundary + 0.0001); + float areaY = boundary * dimensions.y / filterArea.y; + float v = areaY + areaY - vTextureCoord.y; + float y = mirror ? v : vTextureCoord.y; + + float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x; + float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y; + float _alpha = (alpha.y - alpha.x) * k + alpha.x; + + float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude; + x = clamp(x, filterClamp.x, filterClamp.z); + + vec4 color = texture2D(uSampler, vec2(x, y)); + + gl_FragColor = color * _alpha; +} +`;(function(e){Ki(t,e);function t(n){var r=e.call(this,qi,Ji)||this;return r.time=0,r.uniforms.amplitude=new Float32Array(2),r.uniforms.waveLength=new Float32Array(2),r.uniforms.alpha=new Float32Array(2),r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){this.uniforms.dimensions[0]=t.filterFrame?.width,this.uniforms.dimensions[1]=t.filterFrame?.height,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`mirror`,{get:function(){return this.uniforms.mirror},set:function(e){this.uniforms.mirror=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`boundary`,{get:function(){return this.uniforms.boundary},set:function(e){this.uniforms.boundary=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`waveLength`,{get:function(){return this.uniforms.waveLength},set:function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.alpha},set:function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},enumerable:!1,configurable:!0}),t.defaults={mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},t})(W);var Yi=function(e,t){return Yi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Yi(e,t)};function Xi(e,t){Yi(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Zi=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Qi=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform vec4 filterArea; +uniform vec2 red; +uniform vec2 green; +uniform vec2 blue; + +void main(void) +{ + gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; + gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; + gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; + gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; +} +`;(function(e){Xi(t,e);function t(t,n,r){t===void 0&&(t=[-10,0]),n===void 0&&(n=[0,10]),r===void 0&&(r=[0,0]);var i=e.call(this,Zi,Qi)||this;return i.red=t,i.green=n,i.blue=r,i}return Object.defineProperty(t.prototype,`red`,{get:function(){return this.uniforms.red},set:function(e){this.uniforms.red=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`green`,{get:function(){return this.uniforms.green},set:function(e){this.uniforms.green=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blue`,{get:function(){return this.uniforms.blue},set:function(e){this.uniforms.blue=e},enumerable:!1,configurable:!0}),t})(W);var $i=function(e,t){return $i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},$i(e,t)};function ea(e,t){$i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ta=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,na=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; +uniform vec4 filterClamp; + +uniform vec2 center; + +uniform float amplitude; +uniform float wavelength; +// uniform float power; +uniform float brightness; +uniform float speed; +uniform float radius; + +uniform float time; + +const float PI = 3.14159; + +void main() +{ + float halfWavelength = wavelength * 0.5 / filterArea.x; + float maxRadius = radius / filterArea.x; + float currentRadius = time * speed / filterArea.x; + + float fade = 1.0; + + if (maxRadius > 0.0) { + if (currentRadius > maxRadius) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + fade = 1.0 - pow(currentRadius / maxRadius, 2.0); + } + + vec2 dir = vec2(vTextureCoord - center / filterArea.xy); + dir.y *= filterArea.y / filterArea.x; + float dist = length(dir); + + if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + + vec2 diffUV = normalize(dir); + + float diff = (dist - currentRadius) / halfWavelength; + + float p = 1.0 - pow(abs(diff), 2.0); + + // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade ); + float powDiff = 1.25 * sin(diff * PI) * p * ( amplitude * fade ); + + vec2 offset = diffUV * powDiff / filterArea.xy; + + // Do clamp : + vec2 coord = vTextureCoord + offset; + vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); + vec4 color = texture2D(uSampler, clampedCoord); + if (coord != clampedCoord) { + color *= max(0.0, 1.0 - length(coord - clampedCoord)); + } + + // No clamp : + // gl_FragColor = texture2D(uSampler, vTextureCoord + offset); + + color.rgb *= 1.0 + (brightness - 1.0) * p * fade; + + gl_FragColor = color; +} +`;(function(e){ea(t,e);function t(n,r,i){n===void 0&&(n=[0,0]),i===void 0&&(i=0);var a=e.call(this,ta,na)||this;return a.center=n,Object.assign(a,t.defaults,r),a.time=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`wavelength`,{get:function(){return this.uniforms.wavelength},set:function(e){this.uniforms.wavelength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`brightness`,{get:function(){return this.uniforms.brightness},set:function(e){this.uniforms.brightness=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`speed`,{get:function(){return this.uniforms.speed},set:function(e){this.uniforms.speed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),t.defaults={amplitude:30,wavelength:160,brightness:1,speed:500,radius:-1},t})(W);var ra=function(e,t){return ra=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ra(e,t)};function ia(e,t){ra(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var aa=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,oa=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform sampler2D uLightmap; +uniform vec4 filterArea; +uniform vec2 dimensions; +uniform vec4 ambientColor; +void main() { + vec4 diffuseColor = texture2D(uSampler, vTextureCoord); + vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions; + vec4 light = texture2D(uLightmap, lightCoord); + vec3 ambient = ambientColor.rgb * ambientColor.a; + vec3 intensity = ambient + light.rgb; + vec3 finalColor = diffuseColor.rgb * intensity; + gl_FragColor = vec4(finalColor, diffuseColor.a); +} +`;(function(e){ia(t,e);function t(t,n,r){n===void 0&&(n=0),r===void 0&&(r=1);var i=e.call(this,aa,oa)||this;return i._color=0,i.uniforms.dimensions=new Float32Array(2),i.uniforms.ambientColor=new Float32Array([0,0,0,r]),i.texture=t,i.color=n,i}return t.prototype.apply=function(e,t,n,r){this.uniforms.dimensions[0]=t.filterFrame?.width,this.uniforms.dimensions[1]=t.filterFrame?.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`texture`,{get:function(){return this.uniforms.uLightmap},set:function(e){this.uniforms.uLightmap=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.ambientColor;typeof e==`number`?(Mn(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=_n(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.ambientColor[3]},set:function(e){this.uniforms.ambientColor[3]=e},enumerable:!1,configurable:!0}),t})(W);var sa=function(e,t){return sa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},sa(e,t)};function ca(e,t){sa(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var la=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,ua=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float blur; +uniform float gradientBlur; +uniform vec2 start; +uniform vec2 end; +uniform vec2 delta; +uniform vec2 texSize; + +float random(vec3 scale, float seed) +{ + return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); +} + +void main(void) +{ + vec4 color = vec4(0.0); + float total = 0.0; + + float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); + vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); + float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; + + for (float t = -30.0; t <= 30.0; t++) + { + float percent = (t + offset - 0.5) / 30.0; + float weight = 1.0 - abs(percent); + vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); + sample.rgb *= sample.a; + color += sample * weight; + total += weight; + } + + color /= total; + color.rgb /= color.a + 0.00001; + + gl_FragColor = color; +} +`,da=function(e){ca(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this,la,ua)||this;return a.uniforms.blur=t,a.uniforms.gradientBlur=n,a.uniforms.start=r||new Sn(0,window.innerHeight/2),a.uniforms.end=i||new Sn(600,window.innerHeight/2),a.uniforms.delta=new Sn(30,30),a.uniforms.texSize=new Sn(window.innerWidth,window.innerHeight),a.updateDelta(),a}return t.prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.uniforms.blur},set:function(e){this.uniforms.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.uniforms.gradientBlur},set:function(e){this.uniforms.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.uniforms.start},set:function(e){this.uniforms.start=e,this.updateDelta()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.uniforms.end},set:function(e){this.uniforms.end=e,this.updateDelta()},enumerable:!1,configurable:!0}),t}(W),fa=function(e){ca(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=e/n,this.uniforms.delta.y=t/n},t}(da),pa=function(e){ca(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=-t/n,this.uniforms.delta.y=e/n},t}(da);(function(e){ca(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this)||this;return a.tiltShiftXFilter=new fa(t,n,r,i),a.tiltShiftYFilter=new pa(t,n,r,i),a}return t.prototype.apply=function(e,t,n,r){var i=e.getFilterTexture();this.tiltShiftXFilter.apply(e,t,i,1),this.tiltShiftYFilter.apply(e,i,n,r),e.returnFilterTexture(i)},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.tiltShiftXFilter.blur},set:function(e){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(e){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.tiltShiftXFilter.start},set:function(e){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.tiltShiftXFilter.end},set:function(e){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=e},enumerable:!1,configurable:!0}),t})(W);var ma=function(e,t){return ma=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ma(e,t)};function ha(e,t){ma(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ga=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,_a=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float radius; +uniform float angle; +uniform vec2 offset; +uniform vec4 filterArea; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 twist(vec2 coord) +{ + coord -= offset; + + float dist = length(coord); + + if (dist < radius) + { + float ratioDist = (radius - dist) / radius; + float angleMod = ratioDist * ratioDist * angle; + float s = sin(angleMod); + float c = cos(angleMod); + coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c); + } + + coord += offset; + + return coord; +} + +void main(void) +{ + + vec2 coord = mapCoord(vTextureCoord); + + coord = twist(coord); + + coord = unmapCoord(coord); + + gl_FragColor = texture2D(uSampler, coord ); + +} +`;(function(e){ha(t,e);function t(n){var r=e.call(this,ga,_a)||this;return Object.assign(r,t.defaults,n),r}return Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.offset},set:function(e){this.uniforms.offset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t.defaults={radius:200,angle:4,padding:20,offset:new Sn},t})(W);var va=function(e,t){return va=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},va(e,t)};function ya(e,t){va(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function ba(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i= 0.0 && dist > radius) { // radius < 0 means it's infinity + delta = dist - radius; + gap = gradient; + } + + if (delta > 0.0) { + float normalCount = gap / filterArea.x; + delta = (normalCount - delta) / normalCount; + countLimit *= delta; + strength *= delta; + if (countLimit < 1.0) + { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + } + + // randomize the lookup values to hide the fixed number of samples + float offset = rand(vTextureCoord, 0.0); + + float total = 0.0; + vec4 color = vec4(0.0); + + dir *= strength; + + for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) { + float percent = (t + offset) / MAX_KERNEL_SIZE; + float weight = 4.0 * (percent - percent * percent); + vec2 p = vTextureCoord + dir * percent; + vec4 sample = texture2D(uSampler, p); + + // switch to pre-multiplied alpha to correctly blur transparent images + // sample.rgb *= sample.a; + + color += sample * weight; + total += weight; + + if (t > countLimit){ + break; + } + } + + color /= total; + // switch back from pre-multiplied alpha + // color.rgb /= color.a + 0.00001; + + gl_FragColor = color; +} +`;(function(e){ya(t,e);function t(n){var r=this,i=Object.assign(t.defaults,n),a=i.maxKernelSize,o=ba(i,[`maxKernelSize`]);return r=e.call(this,xa,Sa.replace("${maxKernelSize}",a.toFixed(1)))||this,Object.assign(r,o),r}return Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.uStrength},set:function(e){this.uniforms.uStrength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`innerRadius`,{get:function(){return this.uniforms.uInnerRadius},set:function(e){this.uniforms.uInnerRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t.defaults={strength:.1,center:[0,0],innerRadius:0,radius:-1,maxKernelSize:32},t})(W),Math.PI/180,180/Math.PI;function Ca(e,t,n){return(1-n)*e+n*t}function wa(e,t){return e+Math.random()*(t-e)}var Ta=400,Ea=[[.075,800],[.11,0],[.125,0],[.14,0],[.125,0],[.05,0],[.04,0],[.03,0],[.02,0],[1,0]];for(let e=1;e=e||i{p.handled=!0}};return l(o,p),!p.handled&&p.hookedUpdate&&p.hookedUpdate.call(n,e,c)&&(p.handled=!0),l(s,p),a.value=c,p.handled}return{register:c,hookUpdate:u}}function Aa(e){return t=>{e.updateTargets(t.now);let n=t.model.getParameterValueById(`ParamAngleX`),r=t.model.getParameterValueById(`ParamAngleY`),i=t.model.getParameterValueById(`ParamAngleZ`);{let r=e.targetX.value,i=n,a=e.velocityX.value,o=(120*(r-i)-16*a)/1;e.velocityX.value=a+o*t.timeDelta,n=i+e.velocityX.value*t.timeDelta,Math.abs(r-n)<.01&&Math.abs(e.velocityX.value)<.01&&(n=r,e.velocityX.value=0)}{let n=e.targetY.value,i=r,a=e.velocityY.value,o=(120*(n-i)-16*a)/1;e.velocityY.value=a+o*t.timeDelta,r=i+e.velocityY.value*t.timeDelta,Math.abs(n-r)<.01&&Math.abs(e.velocityY.value)<.01&&(r=n,e.velocityY.value=0)}{let n=e.targetZ.value,r=i,a=e.velocityZ.value,o=(120*(n-r)-16*a)/1;e.velocityZ.value=a+o*t.timeDelta,i=r+e.velocityZ.value*t.timeDelta,Math.abs(n-i)<.01&&Math.abs(e.velocityZ.value)<.01&&(i=n,e.velocityZ.value=0)}t.model.setParameterValueById(`ParamAngleX`,n),t.model.setParameterValueById(`ParamAngleY`,r),t.model.setParameterValueById(`ParamAngleZ`,i)}}function ja(e=Oa()){return t=>{t.handled||!t.live2dIdleAnimationEnabled.value&&t.isIdleMotion&&(t.motionManager.stopAllMotions(),e.update(t.internalModel,t.now),t.internalModel.eyeBlink!=null&&t.internalModel.eyeBlink.updateParameters(t.model,t.timeDelta/1e3),t.model.setParameterValueById(`ParamEyeLOpen`,t.modelParameters.value.leftEyeOpen),t.model.setParameterValueById(`ParamEyeROpen`,t.modelParameters.value.rightEyeOpen),t.markHandled())}}function Ma(e=Oa()){return t=>{!t.isIdleMotion||t.handled||e.update(t.internalModel,t.now)}}function Na(){return e=>{!e.isIdleMotion||e.handled||(e.internalModel.eyeBlink!=null&&e.internalModel.eyeBlink.updateParameters(e.model,e.timeDelta/1e3),e.model.setParameterValueById(`ParamEyeLOpen`,e.modelParameters.value.leftEyeOpen),e.model.setParameterValueById(`ParamEyeROpen`,e.modelParameters.value.rightEyeOpen),e.markHandled())}}var Pa=e({__name:`Model`,props:u({modelSrc:{},modelId:{},app:{},mouthOpenSize:{default:0},width:{},height:{},paused:{type:Boolean,default:!1},focusAt:{default:()=>({x:0,y:0})},disableFocusAt:{type:Boolean,default:!1},xOffset:{},yOffset:{},scale:{default:1}},{state:{default:`pending`},stateModifiers:{}}),emits:u([`modelLoaded`],[`update:state`]),setup(e,{expose:t,emit:n}){let r=e,a=n,c=x(e,`state`);function l(){let e=Number.parseFloat(String(r.xOffset))||0,t=Number.parseFloat(String(r.yOffset))||0;return String(r.xOffset).endsWith(`%`)&&(e=Number.parseFloat(String(r.xOffset).replace(`%`,``))/100*r.width),String(r.yOffset).endsWith(`%`)&&(t=Number.parseFloat(String(r.yOffset).replace(`%`,``))/100*r.height),{xOffset:e,yOffset:t}}let u=i(()=>r.modelSrc),d=T(!1),g=!1,_=h(()=>l()),v=i(()=>r.app),y=i(()=>r.paused),S=i(()=>r.focusAt),C=T(),ee=T(0),te=T(0),E=h(()=>Math.max(0,Math.min(100,r.mouthOpenSize))),D=T(0),{isDark:O}=Xt(),ie=on(ln),ae=h(()=>ie.between(`sm`,`md`).value||ie.smaller(`sm`).value),k=w(new ri({alpha:.2,blur:0,distance:20,rotation:45}));function oe(){return C.value.internalModel.coreModel}function A(){if(!C.value)return;let e=2.2;ae.value&&(e=2.2);let t=r.height*.95/te.value*e,n=r.width*.95/ee.value*e,i=Math.min(t,n);C.value.scale.set(i*r.scale,i*r.scale),C.value.x=r.width/2+_.value.xOffset,C.value.y=r.height+_.value.yOffset}let se=Pn(),{currentMotion:ce,availableMotions:le,motionMap:ue,modelParameters:j}=Zt(se),{themeColorsHue:de,themeColorsHueDynamic:fe,live2dIdleAnimationEnabled:pe,live2dShadowEnabled:me}=Zt(Tn()),he=T({group:`Idle`,index:0}),ge=Nn({baseAngles:()=>({x:j.value.angleX,y:j.value.angleY,z:j.value.angleZ}),initialStyle:`sway-sine`});se.onShouldUpdateView(()=>{_e()});async function _e(){if(await tn(d).not.toBeTruthy(),d.value=!0,c.value=`loading`,!v.value||!v.value.stage)try{await tn(()=>!!v.value&&!!v.value.stage).toBeTruthy({timeout:1500})}catch{d.value=!1,c.value=`mounted`;return}if(C.value&&v.value?.stage){try{v.value.stage.removeChild(C.value),C.value.destroy()}catch(e){console.warn(`Error removing old model:`,e)}C.value=void 0}if(!u.value){console.warn(`No Live2D model source provided.`),d.value=!1,c.value=`mounted`;return}try{if(g){d.value=!1,c.value=`mounted`;return}let e=new On;await En.setupLive2DModel(e,{url:u.value,id:r.modelId},{autoInteract:!1}),le.value.forEach(e=>{e.motionName in en?ue.value[e.fileName]=e.motionName:ue.value[e.fileName]=$t}),C.value=e,v.value.stage.addChild(C.value),ee.value=C.value.width,te.value=C.value.height,C.value.anchor.set(.5,.5),A(),C.value.on(`hit`,e=>{C.value&&e.includes(`body`)&&C.value.motion(`tap_body`)});let t=C.value.internalModel,n=t.coreModel,i=t.motionManager;n.setParameterValueById(`ParamMouthOpenY`,E.value),le.value=Object.entries(i.definitions).flatMap(([e,t])=>t?.map((t,n)=>({motionName:e,motionIndex:n,fileName:t.File}))||[]).filter(Boolean);let o=localStorage.getItem(`selected-runtime-motion-group`),s=localStorage.getItem(`selected-runtime-motion-index`);if(o&&s){let e=i.groups[o];if(e!==void 0&&i.motionGroups[e]){let t=Number.parseInt(s),n=i.motionGroups[e][t];n&&n._looper&&(n._looper.loopDuration=0,console.info(`Configured motion to loop infinitely:`,o,t))}}o&&s&&pe.value&&setTimeout(()=>{console.info(`Playing selected runtime motion:`,o,s),ce.value={group:o,index:Number.parseInt(s)}},300),i.groups.idle&&i.motionGroups[i.groups.idle]?.forEach(e=>{e._motionData.curves.forEach(e=>{(e.id===`ParamEyeBallX`||e.id===`ParamEyeBallY`)&&(e.id=`_${e.id}`)})});let l=ka({internalModel:t,motionManager:i,modelParameters:j,live2dIdleAnimationEnabled:pe,lastUpdateTime:D});l.register(Aa(ge),`pre`),l.register(ja(),`pre`),l.register(Ma(),`post`),l.register(Na(),`post`);let f=i.update;i.update=function(e,t){return l.hookUpdate(e,t,f)},i.on(`motionStart`,(e,t)=>{he.value={group:e,index:t}}),i.on(`motionFinish`,()=>{let e=localStorage.getItem(`selected-runtime-motion-group`),t=localStorage.getItem(`selected-runtime-motion-index`);e&&t&&pe.value&&(console.info(`Motion finished, restarting runtime motion:`,e,t),requestAnimationFrame(()=>{ce.value={group:e,index:Number.parseInt(t)}}))}),n.setParameterValueById(`ParamAngleX`,j.value.angleX),n.setParameterValueById(`ParamAngleY`,j.value.angleY),n.setParameterValueById(`ParamAngleZ`,j.value.angleZ),n.setParameterValueById(`ParamEyeLOpen`,j.value.leftEyeOpen),n.setParameterValueById(`ParamEyeROpen`,j.value.rightEyeOpen),n.setParameterValueById(`ParamEyeSmile`,j.value.leftEyeSmile),n.setParameterValueById(`ParamBrowLX`,j.value.leftEyebrowLR),n.setParameterValueById(`ParamBrowRX`,j.value.rightEyebrowLR),n.setParameterValueById(`ParamBrowLY`,j.value.leftEyebrowY),n.setParameterValueById(`ParamBrowRY`,j.value.rightEyebrowY),n.setParameterValueById(`ParamBrowLAngle`,j.value.leftEyebrowAngle),n.setParameterValueById(`ParamBrowRAngle`,j.value.rightEyebrowAngle),n.setParameterValueById(`ParamBrowLForm`,j.value.leftEyebrowForm),n.setParameterValueById(`ParamBrowRForm`,j.value.rightEyebrowForm),n.setParameterValueById(`ParamMouthOpenY`,j.value.mouthOpen),n.setParameterValueById(`ParamMouthForm`,j.value.mouthForm),n.setParameterValueById(`ParamCheek`,j.value.cheek),n.setParameterValueById(`ParamBodyAngleX`,j.value.bodyAngleX),n.setParameterValueById(`ParamBodyAngleY`,j.value.bodyAngleY),n.setParameterValueById(`ParamBodyAngleZ`,j.value.bodyAngleZ),n.setParameterValueById(`ParamBreath`,j.value.breath),a(`modelLoaded`)}finally{d.value=!1,c.value=`mounted`}}async function ve(e,t){if(!C.value){console.warn(`Cannot set motion: model not loaded`);return}console.info(`Setting motion:`,e,`index:`,t);try{await C.value.motion(e,t,vn.FORCE),console.info(`Motion started successfully:`,e)}catch(t){console.error(`Failed to start motion:`,e,t)}}let ye=nn(A,100),be=T(),M=T(0);function xe(){if(!C.value)return;if(!me.value){C.value.filters=[];return}let e=getComputedStyle(be.value).backgroundColor;k.value.color=Number(un(e).replace(`#`,`0x`)),C.value.filters=[k.value]}m([()=>r.width,()=>r.height],()=>ye()),m(u,async()=>await _e(),{immediate:!0}),m(O,xe,{immediate:!0}),m([C,de],xe),m(me,xe),m(_,A),m(()=>r.scale,A);function N(){if(xe(),!me.value){M.value=0;return}M.value=requestAnimationFrame(N)}m([fe,me],([e,t])=>{e&&t?M.value=requestAnimationFrame(N):(cancelAnimationFrame(M.value),M.value=0)},{immediate:!0}),m(E,e=>oe().setParameterValueById(`ParamMouthOpenY`,e)),m(ce,e=>ve(e.group,e.index)),m(y,e=>e?v.value?.stop():v.value?.start()),m(()=>j.value.angleX,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamAngleX`,e)}),m(()=>j.value.angleY,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamAngleY`,e)}),m(()=>j.value.angleZ,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamAngleZ`,e)}),m(()=>j.value.leftEyeOpen,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamEyeLOpen`,e)}),m(()=>j.value.rightEyeOpen,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamEyeROpen`,e)}),m(()=>j.value.mouthOpen,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamMouthOpenY`,e)}),m(()=>j.value.mouthForm,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamMouthForm`,e)}),m(()=>j.value.cheek,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamCheek`,e)}),m(()=>j.value.bodyAngleX,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBodyAngleX`,e)}),m(()=>j.value.bodyAngleY,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBodyAngleY`,e)}),m(()=>j.value.bodyAngleZ,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBodyAngleZ`,e)}),m(()=>j.value.breath,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBreath`,e)}),m(()=>j.value.leftEyebrowLR,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowLX`,e)}),m(()=>j.value.rightEyebrowLR,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowRX`,e)}),m(()=>j.value.leftEyebrowY,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowLY`,e)}),m(()=>j.value.rightEyebrowY,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowRY`,e)}),m(()=>j.value.leftEyebrowAngle,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowLAngle`,e)}),m(()=>j.value.rightEyebrowAngle,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowRAngle`,e)}),m(()=>j.value.leftEyebrowForm,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowLForm`,e)}),m(()=>j.value.rightEyebrowForm,e=>{C.value&&C.value.internalModel.coreModel.setParameterValueById(`ParamBrowRForm`,e)}),m(pe,e=>{if(!e&&C.value){let e=C.value.internalModel;e?.motionManager&&e.motionManager.stopAllMotions()}}),m(S,e=>{C.value&&(r.disableFocusAt||C.value.focus(e.x,e.y))}),f(()=>{let e=dn(()=>ge.scheduleBeat());o(()=>e())}),f(async()=>{xe()}),o(()=>{g=!0});function Se(){return le.value}return t({setMotion:ve,listMotionGroups:Se}),(void 0)?.dispose(()=>{console.warn(`[Dev] Reload on HMR dispose is active for this component. Performing a full reload.`),window.location.reload()}),(e,t)=>(s(),ne(b,null,[re(`div`,{ref_key:`dropShadowColorComputer`,ref:be,hidden:``,bg:`primary-400 dark:primary-500`},null,512),p(e.$slots,`default`)],64))}}),Fa=e({__name:`Live2D`,props:u({modelSrc:{},modelId:{},paused:{type:Boolean,default:!1},mouthOpenSize:{default:0},focusAt:{default:()=>({x:0,y:0})},disableFocusAt:{type:Boolean}},{state:{default:`pending`},stateModifiers:{},canvasState:{default:`pending`},canvasStateModifiers:{},modelState:{default:`pending`},modelStateModifiers:{}}),emits:[`update:state`,`update:canvasState`,`update:modelState`],setup(e,{expose:t}){let n=x(e,`state`),r=x(e,`canvasState`),i=x(e,`modelState`),a=T(),{scale:o,position:c}=Zt(Pn());return m([i,r],()=>{n.value=i.value===`mounted`&&r.value===`mounted`?`mounted`:`loading`}),t({canvasElement:()=>a.value?.canvasElement()}),(t,n)=>(s(),d(Yt,{relative:``},{default:y(({width:t,height:s})=>[_(Fn,{ref_key:`live2dCanvasRef`,ref:a,state:r.value,"onUpdate:state":n[1]||=e=>r.value=e,width:t,height:s,resolution:2,"max-h":`100dvh`},{default:y(({app:r})=>[_(Pa,{state:i.value,"onUpdate:state":n[0]||=e=>i.value=e,"model-src":e.modelSrc,"model-id":e.modelId,app:r,"mouth-open-size":e.mouthOpenSize,width:t,height:s,paused:e.paused,"focus-at":e.focusAt,"x-offset":v(c).x,"y-offset":v(c).y,scale:v(o),"disable-focus-at":e.disableFocusAt},null,8,[`state`,`model-src`,`model-id`,`app`,`mouth-open-size`,`width`,`height`,`paused`,`focus-at`,`x-offset`,`y-offset`,`scale`,`disable-focus-at`])]),_:2},1032,[`state`,`width`,`height`])]),_:1}))}}),Ia=1/1e3,La=1e3,Ra=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<`u`&&document.hidden!==void 0&&(e?document.addEventListener(`visibilitychange`,this):document.removeEventListener(`visibilitychange`,this),this._autoReset=e)}get delta(){return this._delta*Ia}get fixedDelta(){return this._fixedDelta*Ia}set fixedDelta(e){this._fixedDelta=e*La}get elapsed(){return this._elapsed*Ia}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e===void 0?performance.now():e)-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},za=(()=>{let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),n=new Gt;return n.setAttribute(`position`,new V(e,3)),n.setAttribute(`uv`,new V(t,2)),n})(),Ba=class e{static get fullscreenGeometry(){return za}constructor(e=`Pass`,t=new Me,n=new Ut){this.name=e,this.renderer=null,this.scene=t,this.camera=n,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen===null?null:this.screen.material}set fullscreenMaterial(t){let n=this.screen;n===null?(n=new it(e.fullscreenGeometry,t),n.frustumCulled=!1,this.scene===null&&(this.scene=new Me),this.scene.add(n),this.screen=n):n.material=t}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=dt){}render(e,t,n,r,i){throw Error(`Render method not implemented!`)}setSize(e,t){}initialize(e,t,n){}dispose(){for(let t of Object.keys(this)){let n=this[t];(n instanceof yt||n instanceof It||n instanceof ye||n instanceof e)&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},Va=class extends Ba{constructor(){super(`ClearMaskPass`,null,null),this.needsSwap=!1}render(e,t,n,r,i){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},Ha=`#ifdef COLOR_WRITE +#include +#include +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +#endif +#ifdef DEPTH_WRITE +#include +#ifdef GL_FRAGMENT_PRECISION_HIGH +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +return unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +return texture2D(depthBuffer,uv).r; +#endif +} +#endif +#ifdef USE_WEIGHTS +uniform vec4 channelWeights; +#endif +uniform float opacity;varying vec2 vUv;void main(){ +#ifdef COLOR_WRITE +vec4 texel=texture2D(inputBuffer,vUv); +#ifdef USE_WEIGHTS +texel*=channelWeights; +#endif +gl_FragColor=opacity*texel; +#ifdef COLOR_SPACE_CONVERSION +#include +#endif +#include +#else +gl_FragColor=vec4(0.0); +#endif +#ifdef DEPTH_WRITE +gl_FragDepth=readDepth(vUv); +#endif +}`,Ua=`varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,Wa=class extends Jt{constructor(){super({name:`CopyMaterial`,defines:{DEPTH_PACKING:`0`,COLOR_WRITE:`1`},uniforms:{inputBuffer:new D(null),depthBuffer:new D(null),channelWeights:new D(null),opacity:new D(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Ha,vertexShader:Ua}),this.depthFunc=1}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){let t=e!==null;this.colorWrite!==t&&(t?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=t,this.needsUpdate=!0),this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){let t=e!==null;this.depthWrite!==t&&(t?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=t,this.depthWrite=t,this.needsUpdate=!0),this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(e){e===null?delete this.defines.USE_WEIGHTS:(this.defines.USE_WEIGHTS=`1`,this.uniforms.channelWeights.value=e),this.needsUpdate=!0}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},Ga=class extends Ba{constructor(e,t=!0){super(`CopyPass`),this.fullscreenMaterial=new Wa,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new yt(1,1,{minFilter:ot,magFilter:ot,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name=`CopyPass.Target`),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,n,r,i){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTarget.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=N):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},Ka=new H,qa=class extends Ba{constructor(e=!0,t=!0,n=!1){super(`ClearPass`,null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=n,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,n){this.color=e,this.depth=t,this.stencil=n}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,n,r,i){let a=this.overrideClearColor,o=this.overrideClearAlpha,s=e.getClearAlpha(),c=a!==null,l=o>=0;c?(e.getClearColor(Ka),e.setClearColor(a,l?o:s)):l&&e.setClearAlpha(o),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),c?e.setClearColor(Ka,s):l&&e.setClearAlpha(s)}},Ja=class extends Ba{constructor(e,t){super(`MaskPass`,e,t),this.needsSwap=!1,this.clearPass=new qa(!1,!1,!0),this.inverse=!1}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,n,r,i){let a=e.getContext(),o=e.state.buffers,s=this.scene,c=this.camera,l=this.clearPass,u=this.inverted?0:1,d=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.stencil.setFunc(a.ALWAYS,u,4294967295),o.stencil.setClear(d),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?l.render(e,null):(l.render(e,t),l.render(e,n))),this.renderToScreen?(e.setRenderTarget(null),e.render(s,c)):(e.setRenderTarget(t),e.render(s,c),e.setRenderTarget(n),e.render(s,c)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(a.EQUAL,1,4294967295),o.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),o.stencil.setLocked(!0)}},Ya=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:r=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,n,i,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new Ga,this.depthTexture=null,this.passes=[],this.timer=new Ra,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,e!==null){let t=e.getSize(new L),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===1009&&e.outputColorSpace===`srgb`&&(this.inputBuffer.texture.colorSpace=N,this.outputBuffer.texture.colorSpace=N,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(let t of this.passes)t.initialize(e,n,r)}}replaceRenderer(e,t=!0){let n=this.renderer,r=n.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(n.domElement),r.appendChild(e.domElement)),n}createDepthTexture(){let e=this.depthTexture=new se;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=le,e.type=wt):e.type=Nt,e}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,r){let i=this.renderer,a=i===null?new L:i.getDrawingBufferSize(new L),o={minFilter:ot,magFilter:ot,stencilBuffer:t,depthBuffer:e,type:n},s=new yt(a.width,a.height,o);return r>0&&(s.samples=r),n===1009&&i!==null&&i.outputColorSpace===`srgb`&&(s.texture.colorSpace=N),s.texture.name=`EffectComposer.Buffer`,s.texture.generateMipmaps=!1,s}setMainScene(e){for(let t of this.passes)t.mainScene=e}setMainCamera(e){for(let t of this.passes)t.mainCamera=e}addPass(e,t){let n=this.passes,r=this.renderer,i=r.getDrawingBufferSize(new L),a=r.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(e.setRenderer(r),e.setSize(i.width,i.height),e.initialize(r,a,o),this.autoRenderToScreen&&(n.length>0&&(n[n.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t===void 0?n.push(e):n.splice(t,0,e),this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let t=this.createDepthTexture();for(e of n)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}removePass(e){let t=this.passes,n=t.indexOf(e);n!==-1&&t.splice(n,1).length>0&&(this.depthTexture!==null&&(t.reduce((e,t)=>e||t.needsDepthTexture,!1)||(e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null),this.deleteDepthTexture())),this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0)))}removeAllPasses(){let e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,n=this.copyPass,r=this.inputBuffer,i=this.outputBuffer,a=!1,o,s,c;e===void 0&&(this.timer.update(),e=this.timer.getDelta());for(let l of this.passes)l.enabled&&(l.render(t,r,i,e,a),l.needsSwap&&(a&&(n.renderToScreen=l.renderToScreen,o=t.getContext(),s=t.state.buffers.stencil,s.setFunc(o.NOTEQUAL,1,4294967295),n.render(t,r,i,e,a),s.setFunc(o.EQUAL,1,4294967295)),c=r,r=i,i=c),l instanceof Ja?a=!0:l instanceof Va&&(a=!1))}setSize(e,t,n){let r=this.renderer,i=r.getSize(new L);(e===void 0||t===void 0)&&(e=i.width,t=i.height),(i.width!==e||i.height!==t)&&r.setSize(e,t,n);let a=r.getDrawingBufferSize(new L);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Ba.fullscreenGeometry.dispose()}},Xa={NONE:0,DEPTH:1,CONVOLUTION:2},G={FRAGMENT_HEAD:`FRAGMENT_HEAD`,FRAGMENT_MAIN_UV:`FRAGMENT_MAIN_UV`,FRAGMENT_MAIN_IMAGE:`FRAGMENT_MAIN_IMAGE`,VERTEX_HEAD:`VERTEX_HEAD`,VERTEX_MAIN_SUPPORT:`VERTEX_MAIN_SUPPORT`},Za=class{constructor(){this.shaderParts=new Map([[G.FRAGMENT_HEAD,null],[G.FRAGMENT_MAIN_UV,null],[G.FRAGMENT_MAIN_IMAGE,null],[G.VERTEX_HEAD,null],[G.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Xa.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=z}},Qa=!1,$a=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case 2:t=this.materialsFlatShadedDoubleSide;break;case 1:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case 2:t=this.materialsDoubleSide;break;case 1:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(e){if(!(e instanceof Jt))return e.clone();let t=e.uniforms,n=new Map;for(let e in t){let r=t[e].value;r.isRenderTargetTexture&&(t[e].value=null,n.set(e,r))}let r=e.clone();for(let e of n)t[e[0]].value=e[1],r.uniforms[e[0]].value=e[1];return r}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[this.cloneMaterial(e),this.cloneMaterial(e),this.cloneMaterial(e)];for(let n of t)n.uniforms=Object.assign({},e.uniforms),n.side=0;t[2].skinning=!0,this.materialsBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=1,n}),this.materialsDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=2,n}),this.materialsFlatShaded=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=1,n}),this.materialsFlatShadedDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=2,n})}}render(e,t,n){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,Qa){let r=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,n);for(let e of r)e[0].material=e[1];this.meshCount!==r.size&&r.clear()}else{let r=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,n),t.overrideMaterial=r}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Qa}static set workaroundEnabled(e){Qa=e}},eo=-1,to=class extends we{constructor(e,t=eo,n=eo,r=1){super(),this.resizable=e,this.baseSize=new L(1,1),this.preferredSize=new L(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new L,this.addEventListener(`change`,()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){let e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width===eo?t.height===eo?n.width=Math.round(e.width*r):n.width=Math.round(t.height*(e.width/Math.max(e.height,1))):n.width=t.width,t.height===eo?t.width===eo?n.height=Math.round(e.height*r):n.height=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):n.height=t.height}get width(){return this.effectiveSize.width}set width(e){this.preferredWidth=e}get height(){return this.effectiveSize.height}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferredSize.setScalar(eo),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.baseSize.width}set baseWidth(e){this.baseSize.width!==e&&(this.baseSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(e){this.baseWidth=e}get baseHeight(){return this.baseSize.height}set baseHeight(e){this.baseSize.height!==e&&(this.baseSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.baseSize.width!==e||this.baseSize.height!==t)&&(this.baseSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(e){this.preferredSize.width!==e&&(this.preferredSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferredSize.height}set preferredHeight(e){this.preferredSize.height!==e&&(this.preferredSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferredSize.width!==e||this.preferredSize.height!==t)&&(this.preferredSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(e){this.s=e.scale,this.baseSize.set(e.baseWidth,e.baseHeight),this.preferredSize.set(e.preferredWidth,e.preferredHeight),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return eo}},K={SKIP:9,SET:30,ADD:0,ALPHA:23,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},no=new Map([[K.ADD,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb,y.a),y.a*opacity);}`],[K.AVERAGE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb)*0.5,y.a),y.a*opacity);}`],[K.COLOR,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.xy,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.COLOR_BURN,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/b)),vec3(1.0),step(1.0,a));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.COLOR_DODGE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.DARKEN,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb,y.rgb),y.a),y.a*opacity);}`],[K.DIFFERENCE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(abs(x.rgb-y.rgb),y.a),y.a*opacity);}`],[K.DIVIDE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb/max(y.rgb,1e-12),y.a),y.a*opacity);}`],[K.DST,null],[K.EXCLUSION,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb-2.0*x.rgb*y.rgb),y.a),y.a*opacity);}`],[K.HARD_LIGHT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=min(x.rgb,1.0);vec3 b=min(y.rgb,1.0);vec3 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.HARD_MIX,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(step(1.0,x.rgb+y.rgb),y.a),y.a*opacity);}`],[K.HUE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.x,xHSL.yz));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.INVERT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-y.rgb,y.a),y.a*opacity);}`],[K.INVERT_RGB,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(y.rgb*(1.0-x.rgb),y.a),y.a*opacity);}`],[K.LIGHTEN,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb,y.rgb),y.a),y.a*opacity);}`],[K.LINEAR_BURN,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}`],[K.LINEAR_DODGE,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb+y.rgb,1.0),y.a),y.a*opacity);}`],[K.LINEAR_LIGHT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(2.0*y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}`],[K.LUMINOSITY,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.xy,yHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.MULTIPLY,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb*y.rgb,y.a),y.a*opacity);}`],[K.NEGATION,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-abs(1.0-x.rgb-y.rgb),y.a),y.a*opacity);}`],[K.NORMAL,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}`],[K.OVERLAY,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(2.0*y.rgb*x.rgb,1.0-2.0*(1.0-y.rgb)*(1.0-x.rgb),step(0.5,x.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.PIN_LIGHT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 y2=2.0*y.rgb;vec3 z=mix(mix(y2,x.rgb,step(0.5*x.rgb,y.rgb)),max(y2-1.0,vec3(0.0)),step(x.rgb,y2-1.0));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.REFLECT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(min(x.rgb*x.rgb/max(1.0-y.rgb,1e-12),1.0),y.rgb,step(1.0,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.SATURATION,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.x,yHSL.y,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.SCREEN,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb-min(x.rgb*y.rgb,1.0),y.a),y.a*opacity);}`],[K.SOFT_LIGHT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb;vec3 b=y.rgb;vec3 y2=2.0*b;vec3 w=step(0.5,b);vec3 c=a-(1.0-y2)*a*(1.0-a);vec3 d=mix(a+(y2-1.0)*(sqrt(a)-a),a+(y2-1.0)*a*((16.0*a-12.0)*a+3.0),w*(1.0-step(0.25,a)));vec3 z=mix(c,d,w);return mix(x,vec4(z,y.a),y.a*opacity);}`],[K.SRC,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}`],[K.SUBTRACT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb+y.rgb-1.0,0.0),y.a),y.a*opacity);}`],[K.VIVID_LIGHT,`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(max(1.0-min((1.0-x.rgb)/(2.0*y.rgb),1.0),0.0),min(x.rgb/(2.0*(1.0-y.rgb)),1.0),step(0.5,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}`]]),ro=class extends we{constructor(e,t=1){super(),this._blendFunction=e,this.opacity=new D(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this._blendFunction}set blendFunction(e){this._blendFunction=e,this.dispatchEvent({type:`change`})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return no.get(this.blendFunction)}},io=class extends we{constructor(e,t,{attributes:n=Xa.NONE,blendFunction:r=K.NORMAL,defines:i=new Map,uniforms:a=new Map,extensions:o=null,vertexShader:s=null}={}){super(),this.name=e,this.renderer=null,this.attributes=n,this.fragmentShader=t,this.vertexShader=s,this.defines=i,this.uniforms=a,this.extensions=o,this.blendMode=new ro(r),this.blendMode.addEventListener(`change`,e=>this.setChanged()),this._inputColorSpace=z,this._outputColorSpace=``}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(e){this._inputColorSpace=e,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e,this.setChanged()}set mainScene(e){}set mainCamera(e){}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:`change`})}setDepthTexture(e,t=dt){}update(e,t,n){}setSize(e,t){}initialize(e,t,n){}dispose(){for(let e of Object.keys(this)){let t=this[e];(t instanceof yt||t instanceof It||t instanceof ye||t instanceof Ba)&&this[e].dispose()}}};new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10]);var ao=class extends Ba{constructor(e,t,n=null){super(`RenderPass`,e,t),this.needsSwap=!1,this.clearPass=new qa,this.overrideMaterialManager=n===null?null:new $a(n),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e===null?null:e.material}set overrideMaterial(e){let t=this.overrideMaterialManager;e===null?t!==null&&(t.dispose(),this.overrideMaterialManager=null):t===null?this.overrideMaterialManager=new $a(e):t.setMaterial(e)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.selection,c=o.layers.mask,l=a.background,u=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;s!==null&&o.layers.set(s.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager===null?e.render(a,o):this.overrideMaterialManager.render(e,a,o),o.layers.mask=c,a.background=l,e.shadowMap.autoUpdate=u}},oo=`uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}`,so=class extends io{constructor({blendFunction:e=K.SRC,hue:t=0,saturation:n=0}={}){super(`HueSaturationEffect`,oo,{blendFunction:e,uniforms:new Map([[`hue`,new D(new F)],[`saturation`,new D(n)]])}),this.hue=t}get saturation(){return this.uniforms.get(`saturation`).value}set saturation(e){this.uniforms.get(`saturation`).value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get(`hue`).value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),n=Math.cos(e);this.uniforms.get(`hue`).value.set((2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}};Math.PI*.5;var co=`#include +#ifdef GL_FRAGMENT_PRECISION_HIGH +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +#ifdef DOWNSAMPLE_NORMALS +uniform lowp sampler2D normalBuffer; +#endif +varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +return unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +return texture2D(depthBuffer,uv).r; +#endif +}int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e,t=dt){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t}render(e,t,n,r,i){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){let r=e.getContext();if(!(r.getExtension(`EXT_color_buffer_float`)||r.getExtension(`EXT_color_buffer_half_float`)))throw Error(`Rendering to float texture is not supported.`)}},po=`#include +#include +#include +#define packFloatToRGBA(v) packDepthToRGBA(v) +#define unpackRGBAToFloat(v) unpackRGBAToDepth(v) +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +#if DEPTH_PACKING == 3201 +uniform lowp sampler2D depthBuffer; +#elif defined(GL_FRAGMENT_PRECISION_HIGH) +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +float depth=texture2D(depthBuffer,uv).r; +#endif +#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH) +float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d; +#elif defined(USE_REVERSED_DEPTH_BUFFER) +depth=1.0-depth; +#endif +return depth;}float getViewZ(const in float depth){ +#ifdef PERSPECTIVE_CAMERA +return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); +#else +return orthographicDepthToViewZ(depth,cameraNear,cameraFar); +#endif +}vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; +#ifdef ENCODE_OUTPUT +#include +#endif +#include +}`,mo=`uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}`,ho=class extends Jt{constructor(e,t,n,r,i=!1){super({name:`EffectMaterial`,defines:{THREE_REVISION:`181`.replace(/\D+/g,``),DEPTH_PACKING:`0`,ENCODE_OUTPUT:`1`},uniforms:{inputBuffer:new D(null),depthBuffer:new D(null),resolution:new D(new L),texelSize:new D(new L),cameraNear:new D(.3),cameraFar:new D(1e3),aspect:new D(1),time:new D(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:i}),e&&this.setShaderParts(e),t&&this.setDefines(t),n&&this.setUniforms(n),this.copyCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=dt){this.depthBuffer=e,this.depthPacking=t}setShaderData(e){this.setShaderParts(e.shaderParts),this.setDefines(e.defines),this.setUniforms(e.uniforms),this.setExtensions(e.extensions)}setShaderParts(e){return this.fragmentShader=po.replace(G.FRAGMENT_HEAD,e.get(G.FRAGMENT_HEAD)||``).replace(G.FRAGMENT_MAIN_UV,e.get(G.FRAGMENT_MAIN_UV)||``).replace(G.FRAGMENT_MAIN_IMAGE,e.get(G.FRAGMENT_MAIN_IMAGE)||``),this.vertexShader=mo.replace(G.VERTEX_HEAD,e.get(G.VERTEX_HEAD)||``).replace(G.VERTEX_MAIN_SUPPORT,e.get(G.VERTEX_MAIN_SUPPORT)||``),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT=`1`:delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof Ie?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let n=this.uniforms;n.resolution.value.set(e,t),n.texelSize.value.set(1/e,1/t),n.aspect.value=e/t}static get Section(){return G}};Number(`181`.replace(/\D+/g,``));var go=255/256;new Float32Array([go/256**3,go/256**2,go/256,go]),new Float32Array([go,go/256,go/256**2,1/256**3]);function _o(e,t,n){for(let r of t){let t=`$1`+e+r.charAt(0).toUpperCase()+r.slice(1),i=RegExp(`([^\\.])(\\b`+r+`\\b)`,`g`);for(let e of n.entries())e[1]!==null&&n.set(e[0],e[1].replace(i,t))}}function vo(e,t,n){let r=t.getFragmentShader(),i=t.getVertexShader(),a=r!==void 0&&/mainImage/.test(r),o=r!==void 0&&/mainUv/.test(r);if(n.attributes|=t.getAttributes(),r===void 0)throw Error(`Missing fragment shader (${t.name})`);if(o&&(n.attributes&Xa.CONVOLUTION)!==0)throw Error(`Effects that transform UVs are incompatible with convolution effects (${t.name})`);if(!a&&!o)throw Error(`Could not find mainImage or mainUv function (${t.name})`);{let s=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=n.shaderParts,l=c.get(G.FRAGMENT_HEAD)||``,u=c.get(G.FRAGMENT_MAIN_UV)||``,d=c.get(G.FRAGMENT_MAIN_IMAGE)||``,f=c.get(G.VERTEX_HEAD)||``,p=c.get(G.VERTEX_MAIN_SUPPORT)||``,m=new Set,h=new Set;if(o&&(u+=` ${e}MainUv(UV); +`,n.uvTransformation=!0),i!==null&&/mainSupport/.test(i)){let t=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);p+=` ${e}MainSupport(`,p+=t?`vUv); +`:`); +`;for(let e of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(let t of e[1].split(/\s*,\s*/))n.varyings.add(t),m.add(t),h.add(t);for(let e of i.matchAll(s))h.add(e[1])}for(let e of r.matchAll(s))h.add(e[1]);for(let e of t.defines.keys())h.add(e.replace(/\([\w\s,]*\)/g,``));for(let e of t.uniforms.keys())h.add(e);h.delete(`while`),h.delete(`for`),h.delete(`if`),t.uniforms.forEach((t,r)=>n.uniforms.set(e+r.charAt(0).toUpperCase()+r.slice(1),t)),t.defines.forEach((t,r)=>n.defines.set(e+r.charAt(0).toUpperCase()+r.slice(1),t));let g=new Map([[`fragment`,r],[`vertex`,i]]);_o(e,h,n.defines),_o(e,h,g),r=g.get(`fragment`),i=g.get(`vertex`);let _=t.blendMode;if(n.blendModes.set(_.blendFunction,_),a){t.inputColorSpace!==null&&t.inputColorSpace!==n.colorSpace&&(d+=t.inputColorSpace===`srgb`?`color0 = sRGBTransferOETF(color0); + `:`color0 = sRGBToLinear(color0); + `),t.outputColorSpace===``?t.inputColorSpace!==null&&(n.colorSpace=t.inputColorSpace):n.colorSpace=t.outputColorSpace,d+=`${e}MainImage(color0, UV, `,(n.attributes&Xa.DEPTH)!==0&&/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/.test(r)&&(d+=`depth, `,n.readDepth=!0),d+=`color1); + `;let i=e+`BlendOpacity`;n.uniforms.set(i,_.opacity),d+=`color0 = blend${_.blendFunction}(color0, color1, ${i}); + + `,l+=`uniform float ${i}; + +`}if(l+=r+` +`,i!==null&&(f+=i+` +`),c.set(G.FRAGMENT_HEAD,l),c.set(G.FRAGMENT_MAIN_UV,u),c.set(G.FRAGMENT_MAIN_IMAGE,d),c.set(G.VERTEX_HEAD,f),c.set(G.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(let e of t.extensions)n.extensions.add(e)}}var yo=class extends Ba{constructor(e,...t){super(`EffectPass`),this.fullscreenMaterial=new ho(null,null,null,e),this.listener=e=>this.handleEvent(e),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=1/0,this.timeScale=1}set mainScene(e){for(let t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(let t of this.effects)t.mainCamera=e}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(let e of this.effects)e.removeEventListener(`change`,this.listener);this.effects=e.sort((e,t)=>t.attributes-e.attributes);for(let e of this.effects)e.addEventListener(`change`,this.listener)}updateMaterial(){let e=new Za,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===K.DST)e.attributes|=n.getAttributes()&Xa.DEPTH;else if((e.attributes&n.getAttributes()&Xa.CONVOLUTION)!==0)throw Error(`Convolution effects cannot be merged (${n.name})`);else vo(`e`+ t++,n,e);let n=e.shaderParts.get(G.FRAGMENT_HEAD),r=e.shaderParts.get(G.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(G.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let t of e.blendModes.values())n+=t.getShaderCode().replace(a,`blend${t.blendFunction}`)+` +`;(e.attributes&Xa.DEPTH)===0?this.needsDepthTexture=!1:(e.readDepth&&(r=`float depth = readDepth(UV); + + `+r),this.needsDepthTexture=this.getDepthTexture()===null),e.colorSpace===`srgb`&&(r+=`color0 = sRGBToLinear(color0); + `),e.uvTransformation?(i=`vec2 transformedUv = vUv; +`+i,e.defines.set(`UV`,`transformedUv`)):e.defines.set(`UV`,`vUv`),e.shaderParts.set(G.FRAGMENT_HEAD,n),e.shaderParts.set(G.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(G.FRAGMENT_MAIN_UV,i);for(let[t,n]of e.shaderParts)n!==null&&e.shaderParts.set(t,n.trim().replace(/^#/,` +#`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=dt){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let n of this.effects)n.setDepthTexture(e,t)}render(e,t,n,r,i){for(let n of this.effects)n.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let i=this.fullscreenMaterial;i.inputBuffer=t.texture,i.time+=r*this.timeScale,e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let n of this.effects)n.setSize(e,t)}initialize(e,t,n){this.renderer=e;for(let r of this.effects)r.initialize(e,t,n);this.updateMaterial(),n!==void 0&&n!==1009&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}dispose(){super.dispose();for(let e of this.effects)e.removeEventListener(`change`,this.listener),e.dispose()}handleEvent(e){switch(e.type){case`change`:this.recompile();break}}},bo=class extends Ba{constructor(e,t,{renderTarget:n,resolutionScale:r=1,width:i=to.AUTO_SIZE,height:a=to.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`NormalPass`),this.needsSwap=!1,this.renderPass=new ao(e,t,new At);let c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;let l=c.getClearPass();l.overrideClearColor=new H(7829503),l.overrideClearAlpha=1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new yt(1,1,{minFilter:Xe,magFilter:Xe}),this.renderTarget.texture.name=`NormalPass.Target`);let u=this.resolution=new to(this,o,s,r);u.addEventListener(`change`,e=>this.setSize(u.baseWidth,u.baseHeight))}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a,a)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}};new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array(2),new Float32Array(2),new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125]),new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4]),new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3]),q(0,0,0,0),new Float32Array([0,0,0,0]),q(0,0,0,1),new Float32Array([0,0,0,1]),q(0,0,1,0),new Float32Array([0,0,1,0]),q(0,0,1,1),new Float32Array([0,0,1,1]),q(0,1,0,0),new Float32Array([0,1,0,0]),q(0,1,0,1),new Float32Array([0,1,0,1]),q(0,1,1,0),new Float32Array([0,1,1,0]),q(0,1,1,1),new Float32Array([0,1,1,1]),q(1,0,0,0),new Float32Array([1,0,0,0]),q(1,0,0,1),new Float32Array([1,0,0,1]),q(1,0,1,0),new Float32Array([1,0,1,0]),q(1,0,1,1),new Float32Array([1,0,1,1]),q(1,1,0,0),new Float32Array([1,1,0,0]),q(1,1,0,1),new Float32Array([1,1,0,1]),q(1,1,1,0),new Float32Array([1,1,1,0]),q(1,1,1,1),new Float32Array([1,1,1,1]);function xo(e,t,n){return e+(t-e)*n}function q(e,t,n,r){return xo(xo(e,t,.75),xo(n,r,.75),.875)}var So=class{static isWebGL2Available(){try{let e=document.createElement(`canvas`);return!!(window.WebGL2RenderingContext&&e.getContext(`webgl2`))}catch{return!1}}static isColorSpaceAvailable(e){try{let t=document.createElement(`canvas`),n=window.WebGL2RenderingContext&&t.getContext(`webgl2`);return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){let t={1:`WebGL`,2:`WebGL 2`},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},r=`Your $0 does not seem to support $1`,i=document.createElement(`div`);return i.id=`webglmessage`,i.style.fontFamily=`monospace`,i.style.fontSize=`13px`,i.style.fontWeight=`normal`,i.style.textAlign=`center`,i.style.background=`#fff`,i.style.color=`#000`,i.style.padding=`1.5em`,i.style.width=`400px`,i.style.margin=`5em auto 0`,r=n[e]?r.replace(`$0`,`graphics card`):r.replace(`$0`,`browser`),r=r.replace(`$1`,t[e]),i.innerHTML=r,i}},Co=Symbol(`effectComposerPmndrs`),wo=e({__name:`EffectComposerPmndrs`,props:{enabled:{type:Boolean,required:!1,default:!0},depthBuffer:{type:Boolean,required:!1,default:void 0},disableNormalPass:{type:Boolean,required:!1,default:!1},stencilBuffer:{type:Boolean,required:!1,default:void 0},resolutionScale:{type:Number,required:!1},autoClear:{type:Boolean,required:!1,default:!0},multisampling:{type:Number,required:!1,default:0},frameBufferType:{type:Number,required:!1,default:qt}},emits:[`render`],setup(e,{expose:t,emit:n}){let r=e,i=n,{scene:a,camera:s,renderer:c,sizes:l}=Et(),u=w(null),d=null,f=null;C(Co,u),t({composer:u});let g=()=>{u.value&&(f=new bo(a.value,s.activeCamera.value),f.enabled=!1,u.value.addPass(f),r.resolutionScale!==void 0&&So.isWebGL2Available()&&(d=new fo({normalBuffer:f.texture,resolutionScale:r.resolutionScale}),d.enabled=!1,u.value.addPass(d)))},_=h(()=>{let e=new Ya,t={depthBuffer:r.depthBuffer===void 0?e.inputBuffer.depthBuffer:r.depthBuffer,stencilBuffer:r.stencilBuffer===void 0?e.inputBuffer.stencilBuffer:r.stencilBuffer,multisampling:So.isWebGL2Available()?r.multisampling===void 0?e.multisampling:r.multisampling:0,frameBufferType:r.frameBufferType===void 0?qt:r.frameBufferType};return e.dispose(),t}),v=()=>{!c.instance&&!a.value&&!s.activeCamera.value||(u.value?.dispose(),u.value=new Ya(c.instance,_.value),u.value.addPass(new ao(a.value,s.activeCamera.value)),r.disableNormalPass||g())};return m([a,s.activeCamera,()=>r.disableNormalPass],()=>{!l.width.value||!l.height.value||v()}),m(()=>[l.width.value,l.height.value],([e,t])=>{!e&&!t||(u.value?u.value.setSize(e,t):v())},{immediate:!0}),c.replaceRenderFunction(e=>{if(r.enabled&&c.instance&&u.value&&l.width.value&&l.height.value){let t=c.instance.autoClear;c.instance.autoClear=r.autoClear,r.stencilBuffer&&!r.autoClear&&c.instance.clearStencil(),u.value.render(),i(`render`,u.value),c.instance.autoClear=t,e()}}),o(()=>{u.value?.dispose()}),(e,t)=>p(e.$slots,`default`)}}),To=(e,n,r)=>{let i=a(Co),s=w(null),c=w(null),{scene:l,camera:u,invalidate:d}=Ze();m(n,()=>d());let f=()=>{s.value&&i?.value?.removePass(s.value),c.value?.dispose(),s.value?.dispose()},p=t=>{!u.value||!i?.value||!l.value||(c.value=e(),s.value=new yo(u.value,c.value),i.value.addPass(s.value,t))};r&&m(()=>r.map(e=>n[e]),()=>{if(!i?.value)return;let e=i.value?.passes.findIndex(e=>e===s.value);~e&&(f(),p(e))}),S(()=>{!u.value||!c?.value||(c.value.mainCamera=u.value)});let h=S(()=>{!u.value||!i?.value||!l.value||(t(()=>h()),!c.value&&p())});return o(()=>{f()}),{pass:s,effect:c}},Eo=/([^[.\]])+/g,Do=(e,t)=>{if(t)return(Array.isArray(t)?t:t.match(Eo))?.reduce((e,t)=>e&&e[t],e)},Oo=(e,t,n)=>{let r=Array.isArray(t)?t:t.match(Eo);r&&r.reduce((e,t,i)=>(e[t]===void 0&&(e[t]={}),i===r.length-1&&(e[t]=n),e[t]),e)},ko=(e,t,n,r,i={})=>m(e,i=>{if(t.value)if(i===void 0){let e=r();Oo(t.value,n,Do(e,n)),e.dispose?.()}else Oo(t.value,n,e())},i),Ao=(e,t,n)=>e.map(([e,r])=>ko(e,t,r,n)),jo=e({__name:`HueSaturationPmndrs`,props:{saturation:{type:Number,required:!1},hue:{type:Number,required:!1},blendFunction:{type:null,required:!1}},setup(e,{expose:t}){let n=e,{pass:r,effect:i}=To(()=>new so(n),n);return t({pass:r,effect:i}),Ao([[()=>n.blendFunction,`blendMode.blendFunction`],[()=>n.hue,`hue`],[()=>n.saturation,`saturation`]],i,()=>new so),()=>{}}}),Mo=`/assets/sky_linekotsi_23_HDRI-CDfEmkGI.hdr`;const No=Qt(`modelStore`,()=>{let{post:e,data:t}=rn({name:`airi-stores-live2d`}),n=T([]),r=e=>{n.value.push(e)};function i(){e({type:`should-update-view`}),n.value.forEach(e=>e())}m(t,e=>{e.type===`should-update-view`&&n.value.forEach(e=>e())});let a=U(`settings/stage-ui-three/scale`,1),o=U(`settings/stage-ui-three/lastModelSrc`,``),s=U(`settings/stage-ui-three/modelSize`,{x:0,y:0,z:0}),c=U(`settings/stage-ui-three/modelOrigin`,{x:0,y:0,z:0}),l=U(`settings/stage-ui-three/modelOffset`,{x:0,y:0,z:0}),u=U(`settings/stage-ui-three/modelRotationY`,0),d=U(`settings/stage-ui-three/cameraFOV`,40),f=U(`settings/stage-ui-three/camera-position`,{x:0,y:0,z:-1}),p=U(`settings/stage-ui-three/cameraDistance`,0),h=U(`settings/stage-ui-three/lookAtTarget`,{x:0,y:0,z:0}),g=U(`settings/stage-ui-three/trackingMode`,`none`),_=U(`settings/stage-ui-three/eyeHeight`,0);function v(){s.value={x:0,y:0,z:0},c.value={x:0,y:0,z:0},l.value={x:0,y:0,z:0},u.value=0,d.value=40,f.value={x:0,y:0,z:0},p.value=0,h.value={x:0,y:0,z:0},g.value=`none`,_.value=0}let y=U(`settings/stage-ui-three/scenes/scene/directional-light/position`,{x:0,y:0,z:-1}),b=U(`settings/stage-ui-three/scenes/scene/directional-light/target`,{x:0,y:0,z:0}),x=U(`settings/stage-ui-three/scenes/scene/directional-light/rotation`,{x:0,y:0,z:0}),S=U(`settings/stage-ui-three/scenes/scene/directional-light/intensity`,2.02),C=U(`settings/stage-ui-three/scenes/scene/directional-light/color`,`#fffbf5`),ee=U(`settings/stage-ui-three/scenes/scene/hemisphere-light/sky-color`,`#FFFFFF`),te=U(`settings/stage-ui-three/scenes/scene/hemisphere-light/ground-color`,`#222222`),ne=U(`settings/stage-ui-three/scenes/scene/hemisphere-light/intensity`,.4),w=U(`settings/stage-ui-three/scenes/scene/ambient-light/color`,`#FFFFFF`);return{scale:a,lastModelSrc:o,modelSize:s,modelOrigin:c,modelOffset:l,modelRotationY:u,cameraFOV:d,cameraPosition:f,cameraDistance:p,directionalLightPosition:y,directionalLightTarget:b,directionalLightRotation:x,directionalLightIntensity:S,directionalLightColor:C,ambientLightIntensity:U(`settings/stage-ui-three/scenes/scene/ambient-light/intensity`,.6),ambientLightColor:w,hemisphereSkyColor:ee,hemisphereGroundColor:te,hemisphereLightIntensity:ne,lookAtTarget:h,trackingMode:g,eyeHeight:_,envSelect:U(`settings/stage-ui-three/envEnabled`,`skyBox`),skyBoxSrc:U(`settings/stage-ui-three/skyBoxUrl`,Mo),skyBoxIntensity:U(`settings/stage-ui-three/skyBoxIntensity`,.1),onShouldUpdateView:r,shouldUpdateView:i,resetModelStore:v}});var Po={type:`change`},Fo={type:`start`},Io={type:`end`},Lo=new ke,Ro=new ue,zo=Math.cos(70*I.DEG2RAD),J=new F,Y=2*Math.PI,X={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Bo=1e-6,Vo=class extends oe{constructor(e,t=null){super(e,t),this.state=X.NONE,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:Ot.ROTATE,MIDDLE:Ot.DOLLY,RIGHT:Ot.PAN},this.touches={ONE:M.ROTATE,TWO:M.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new F,this._lastQuaternion=new R,this._lastTargetPosition=new F,this._quat=new R().setFromUnitVectors(e.up,new F(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Re,this._sphericalDelta=new Re,this._scale=1,this._panOffset=new F,this._rotateStart=new L,this._rotateEnd=new L,this._rotateDelta=new L,this._panStart=new L,this._panEnd=new L,this._panDelta=new L,this._dollyStart=new L,this._dollyEnd=new L,this._dollyDelta=new L,this._dollyDirection=new F,this._mouse=new L,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Uo.bind(this),this._onPointerDown=Ho.bind(this),this._onPointerUp=Wo.bind(this),this._onContextMenu=Zo.bind(this),this._onMouseWheel=qo.bind(this),this._onKeyDown=Jo.bind(this),this._onTouchStart=Yo.bind(this),this._onTouchMove=Xo.bind(this),this._onMouseDown=Go.bind(this),this._onMouseMove=Ko.bind(this),this._interceptControlDown=Qo.bind(this),this._interceptControlUp=$o.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Po),this.update(),this.state=X.NONE}update(e=null){let t=this.object.position;J.copy(t).sub(this.target),J.applyQuaternion(this._quat),this._spherical.setFromVector3(J),this.autoRotate&&this.state===X.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Y:n>Math.PI&&(n-=Y),r<-Math.PI?r+=Y:r>Math.PI&&(r-=Y),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(J.setFromSpherical(this._spherical),J.applyQuaternion(this._quatInverse),t.copy(this.target).add(J),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=J.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new F(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new F(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=J.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(Lo.origin.copy(this.object.position),Lo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Lo.direction))Bo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Bo||this._lastTargetPosition.distanceToSquared(this.target)>Bo?(this.dispatchEvent(Po),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?Y/60/60*this.autoRotateSpeed:Y/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){J.setFromMatrixColumn(t,0),J.multiplyScalar(-e),this._panOffset.add(J)}_panUp(e,t){this.screenSpacePanning===!0?J.setFromMatrixColumn(t,1):(J.setFromMatrixColumn(t,0),J.crossVectors(this.object.up,J)),J.multiplyScalar(e),this._panOffset.add(J)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;J.copy(r).sub(this.target);let i=J.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Y*this._rotateDelta.x/t.clientHeight),this._rotateUp(Y*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Y*this._rotateDelta.x/t.clientHeight),this._rotateUp(Y*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t{y.value&&(y.value.minDistance=e.z,y.value.maxDistance=e.z*20,y.value.update())},{immediate:!0,deep:!0}),m(u,e=>{!b.value||!y.value||(b.value.position.set(e.x,e.y,e.z),b.value.updateProjectionMatrix(),y.value.update())},{immediate:!0,deep:!0}),m(d,e=>{y.value&&(y.value.target.set(e.x,e.y,e.z),y.value.update())},{immediate:!0,deep:!0}),m(h,e=>{!b.value||!y.value||(b.value.fov=e,b.value.updateProjectionMatrix(),y.value.update())},{immediate:!0}),m(g,e=>{if(!b.value||!y.value)return;let t=new F,n=y.value.target,r=new F().subVectors(b.value.position,n).normalize();t.copy(n).addScaledVector(r,e),b.value.position.set(t.x,t.y,t.z),b.value.updateProjectionMatrix(),y.value.update()}),m(s,e=>{!b.value||!y.value||(y.value.enableRotate=e,y.value.enableZoom=e)},{immediate:!0}),y.value?.addEventListener(`change`,()=>{c.value&&a(`orbitControlsCameraChanged`,{newCameraPosition:{x:b.value.position.x,y:b.value.position.y,z:b.value.position.z},newCameraDistance:y.value.getDistance()})})}return f(async()=>{if(await tn(()=>_.value&&v.domElement).toBeTruthy(),await tn(()=>i.modelLoaded).toBeTruthy(),!_.value||!v.domElement){console.warn(`Camera or Renderer initialisation failure!`);return}if(!(_.value instanceof Ie)){console.warn(`Camera is not perspective camera, type error!`);return}b.value=_.value,y.value=new Vo(b.value,v.domElement),y.value.enablePan=!1,y.value.enableZoom=!1,y.value.enableRotate=!1,y.value.mouseButtons={LEFT:Ot.ROTATE,MIDDLE:Ot.DOLLY,RIGHT:Ot.PAN},y.value.touches={ONE:M.ROTATE,TWO:M.DOLLY_PAN},x(),y.value.update(),a(`orbitControlsReady`)}),o(()=>{}),t({controls:y,getDistance:()=>y.value?.getDistance(),update:()=>y.value?.update(),setTarget:e=>{y.value&&(y.value.target.set(e.x,e.y,e.z),y.value.update())}}),(e,t)=>p(e.$slots,`default`)}}),ts=class{static fromCubeTexture(e){let t=0,n=new F,r=new F,i=new H,a=[0,0,0,0,0,0,0,0,0],o=new He,s=o.coefficients;for(let o=0;o<6;o++){let c=e.image[o],l=c.width,u=c.height,d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.drawImage(c,0,0,l,u);let p=f.getImageData(0,0,l,u),m=p.data,h=p.width,g=2/h;for(let c=0,l=m.length;c(i=s.indexOf(` +`))&&a=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+` +`;l=n(e),!1!==l;){if(c.string+=l+` +`,l.charAt(0)===`#`){c.comments+=l+` +`;continue}if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break}return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&se.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e!!u&&!!u.domElement).toBeTruthy(),d(),u.outputColorSpace=N,u.toneMapping=4;try{let t=await new is().loadAsync(e);t.mapping=303,t.generateMipmaps=!0,t.minFilter=zt,t.magFilter=ot,t.colorSpace=z,s=new Pt(u);let n=s.fromEquirectangular(t);c=n;let o=new nt(256);o.fromEquirectangularTexture(u,t);let d=await ts.fromCubeRenderTarget(u,o);a.value=t;let f=l.value;f.environment=n.texture,r.asBackground&&(f.background=n.texture),f.backgroundBlurriness=r.backgroundBlurriness,f.backgroundIntensity=r.backgroundIntensity,i(`skyBoxReady`,{irrSH:d.sh})}catch(e){console.warn(`Failed to load HDRI environment:`,e)}}return f(async()=>{await h(r.skyBoxSrc),m(()=>[r.skyBoxSrc],([e])=>{h(e)},{deep:!1})}),t({reload:async e=>await h(e)}),o(async()=>{await d()}),(e,t)=>p(e.$slots,`default`)}}),os=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Z=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),ss=class extends A{constructor(e){super(),this.weight=0,this.isBinary=!1,this.overrideBlink=`none`,this.overrideLookAt=`none`,this.overrideMouth=`none`,this._binds=[],this.name=`VRMExpression_${e}`,this.expressionName=e,this.type=`VRMExpression`,this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink===`block`?0.5?1:0:this.weight}addBind(e){this._binds.push(e)}deleteBind(e){let t=this._binds.indexOf(e);t>=0&&this._binds.splice(t,1)}applyWeight(e){let t=this.outputWeight;t*=e?.multiplier??1,this.isBinary&&t<1&&(t=0),this._binds.forEach(e=>e.applyWeight(t))}clearAppliedWeight(){this._binds.forEach(e=>e.clearAppliedWeight())}};function cs(e,t,n){let r=e.parser.json,i=r.nodes?.[t];if(i==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${t}] of glTF but the node doesn't exist`),null;let a=i.mesh;if(a==null)return null;let o=r.meshes?.[a];if(o==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${a}] of glTF but the mesh doesn't exist`),null;let s=o.primitives.length,c=[];return n.traverse(e=>{c.length{let i=cs(e,r,t);i!=null&&n.set(r,i)}),n})}var ds={Aa:`aa`,Ih:`ih`,Ou:`ou`,Ee:`ee`,Oh:`oh`,Blink:`blink`,Happy:`happy`,Angry:`angry`,Sad:`sad`,Relaxed:`relaxed`,LookUp:`lookUp`,Surprised:`surprised`,LookDown:`lookDown`,LookLeft:`lookLeft`,LookRight:`lookRight`,BlinkLeft:`blinkLeft`,BlinkRight:`blinkRight`,Neutral:`neutral`};function fs(e){return Math.max(Math.min(e,1),0)}var ps=class e{constructor(){this.blinkExpressionNames=[`blink`,`blinkLeft`,`blinkRight`],this.lookAtExpressionNames=[`lookLeft`,`lookRight`,`lookUp`,`lookDown`],this.mouthExpressionNames=[`aa`,`ee`,`ih`,`oh`,`ou`],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){let e={},t=new Set(Object.values(ds));return Object.entries(this._expressionMap).forEach(([n,r])=>{t.has(n)&&(e[n]=r)}),e}get customExpressionMap(){let e={},t=new Set(Object.values(ds));return Object.entries(this._expressionMap).forEach(([n,r])=>{t.has(n)||(e[n]=r)}),e}copy(e){return this._expressions.concat().forEach(e=>{this.unregisterExpression(e)}),e._expressions.forEach(e=>{this.registerExpression(e)}),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return new e().copy(this)}getExpression(e){return this._expressionMap[e]??null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){let t=this._expressions.indexOf(e);t===-1&&console.warn(`VRMExpressionManager: The specified expressions is not registered`),this._expressions.splice(t,1),delete this._expressionMap[e.expressionName]}getValue(e){return this.getExpression(e)?.weight??null}setValue(e,t){let n=this.getExpression(e);n&&(n.weight=fs(t))}resetValues(){this._expressions.forEach(e=>{e.weight=0})}getExpressionTrackName(e){let t=this.getExpression(e);return t?`${t.name}.weight`:null}update(){let e=this._calculateWeightMultipliers();this._expressions.forEach(e=>{e.clearAppliedWeight()}),this._expressions.forEach(t=>{let n=1,r=t.expressionName;this.blinkExpressionNames.indexOf(r)!==-1&&(n*=e.blink),this.lookAtExpressionNames.indexOf(r)!==-1&&(n*=e.lookAt),this.mouthExpressionNames.indexOf(r)!==-1&&(n*=e.mouth),t.applyWeight({multiplier:n})})}_calculateWeightMultipliers(){let e=1,t=1,n=1;return this._expressions.forEach(r=>{e-=r.overrideBlinkAmount,t-=r.overrideLookAtAmount,n-=r.overrideMouthAmount}),e=Math.max(0,e),t=Math.max(0,t),n=Math.max(0,n),{blink:e,lookAt:t,mouth:n}}},ms={Color:`color`,EmissionColor:`emissionColor`,ShadeColor:`shadeColor`,MatcapColor:`matcapColor`,RimColor:`rimColor`,OutlineColor:`outlineColor`},hs={_Color:ms.Color,_EmissionColor:ms.EmissionColor,_ShadeColor:ms.ShadeColor,_RimColor:ms.RimColor,_OutlineColor:ms.OutlineColor},gs=new H,_s=class e{constructor({material:e,type:t,targetValue:n,targetAlpha:r}){this.material=e,this.type=t,this.targetValue=n,this.targetAlpha=r??1,this._state={color:this._initColorBindState(),alpha:this._initAlphaBindState()}}applyWeight(e){let{color:t,alpha:n}=this._state;if(t!=null){let{propertyName:n,deltaValue:r}=t;this.material[n]?.add(gs.copy(r).multiplyScalar(e))}if(n!=null){let{propertyName:t,deltaValue:r}=n;this.material[t]!=null&&(this.material[t]+=r*e)}}clearAppliedWeight(){let{color:e,alpha:t}=this._state;if(e!=null){let{propertyName:t,initialValue:n}=e;this.material[t]?.copy(n)}if(t!=null){let{propertyName:e,initialValue:n}=t;this.material[e]!=null&&(this.material[e]=n)}}_initColorBindState(){let{material:e,type:t,targetValue:n}=this,r=this._getPropertyNameMap()?.[t]?.[0]??null;if(r==null)return console.warn(`Tried to add a material color bind to the material ${e.name??`(no name)`}, the type ${t} but the material or the type is not supported.`),null;let i=e[r].clone();return{propertyName:r,initialValue:i,deltaValue:new H(n.r-i.r,n.g-i.g,n.b-i.b)}}_initAlphaBindState(){let{material:e,type:t,targetAlpha:n}=this,r=this._getPropertyNameMap()?.[t]?.[1]??null;if(r==null&&n!==1)return console.warn(`Tried to add a material alpha bind to the material ${e.name??`(no name)`}, the type ${t} but the material or the type does not support alpha.`),null;if(r==null)return null;let i=e[r];return{propertyName:r,initialValue:i,deltaValue:n-i}}_getPropertyNameMap(){return Object.entries(e._propertyNameMapMap).find(([e])=>this.material[e]===!0)?.[1]??null}};_s._propertyNameMapMap={isMeshStandardMaterial:{color:[`color`,`opacity`],emissionColor:[`emissive`,null]},isMeshBasicMaterial:{color:[`color`,`opacity`]},isMToonMaterial:{color:[`color`,`opacity`],emissionColor:[`emissive`,null],outlineColor:[`outlineColorFactor`,null],matcapColor:[`matcapFactor`,null],rimColor:[`parametricRimColorFactor`,null],shadeColor:[`shadeColorFactor`,null]}};var vs=_s,ys=class{constructor({primitives:e,index:t,weight:n}){this.primitives=e,this.index=t,this.weight=n}applyWeight(e){this.primitives.forEach(t=>{t.morphTargetInfluences?.[this.index]!=null&&(t.morphTargetInfluences[this.index]+=this.weight*e)})}clearAppliedWeight(){this.primitives.forEach(e=>{e.morphTargetInfluences?.[this.index]!=null&&(e.morphTargetInfluences[this.index]=0)})}},bs=new L,xs=class e{constructor({material:t,scale:n,offset:r}){this.material=t,this.scale=n,this.offset=r;let i=Object.entries(e._propertyNamesMap).find(([e])=>t[e]===!0)?.[1];i==null?(console.warn(`Tried to add a texture transform bind to the material ${t.name??`(no name)`} but the material is not supported.`),this._properties=[]):(this._properties=[],i.forEach(e=>{let i=t[e]?.clone();if(!i)return null;t[e]=i;let a=i.offset.clone(),o=i.repeat.clone(),s=r.clone().sub(a),c=n.clone().sub(o);this._properties.push({name:e,initialOffset:a,deltaOffset:s,initialScale:o,deltaScale:c})}))}applyWeight(e){this._properties.forEach(t=>{let n=this.material[t.name];n!==void 0&&(n.offset.add(bs.copy(t.deltaOffset).multiplyScalar(e)),n.repeat.add(bs.copy(t.deltaScale).multiplyScalar(e)))})}clearAppliedWeight(){this._properties.forEach(e=>{let t=this.material[e.name];t!==void 0&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))})}};xs._propertyNamesMap={isMeshStandardMaterial:[`map`,`emissiveMap`,`bumpMap`,`normalMap`,`displacementMap`,`roughnessMap`,`metalnessMap`,`alphaMap`],isMeshBasicMaterial:[`map`,`specularMap`,`alphaMap`],isMToonMaterial:[`map`,`normalMap`,`emissiveMap`,`shadeMultiplyTexture`,`rimMultiplyTexture`,`outlineWidthMultiplyTexture`,`uvAnimationMaskTexture`]};var Ss=xs,Cs=new Set([`1.0`,`1.0-beta`]),ws=class e{get name(){return`VRMExpressionLoaderPlugin`}constructor(e){this.parser=e}afterRoot(e){return Z(this,null,function*(){e.userData.vrmExpressionManager=yield this._import(e)})}_import(e){return Z(this,null,function*(){return(yield this._v1Import(e))||(yield this._v0Import(e))||null})}_v1Import(e){return Z(this,null,function*(){let t=this.parser.json;if(t.extensionsUsed?.indexOf(`VRMC_vrm`)===-1)return null;let n=t.extensions?.VRMC_vrm;if(!n)return null;let r=n.specVersion;if(!Cs.has(r))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${r}"`),null;let i=n.expressions;if(!i)return null;let a=new Set(Object.values(ds)),o=new Map;i.preset!=null&&Object.entries(i.preset).forEach(([e,t])=>{if(t!=null){if(!a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${e}" detected. Ignoring the expression`);return}o.set(e,t)}}),i.custom!=null&&Object.entries(i.custom).forEach(([e,t])=>{if(a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${e}". Ignoring the expression`);return}o.set(e,t)});let s=new ps;return yield Promise.all(Array.from(o.entries()).map(t=>Z(this,[t],function*([t,n]){var r,i,a;let o=new ss(t);if(e.scene.add(o),o.isBinary=n.isBinary??!1,o.overrideBlink=n.overrideBlink??`none`,o.overrideLookAt=n.overrideLookAt??`none`,o.overrideMouth=n.overrideMouth??`none`,(r=n.morphTargetBinds)==null||r.forEach(t=>Z(this,null,function*(){if(t.node===void 0||t.index===void 0)return;let r=yield ls(e,t.node),i=t.index;if(!r.every(e=>Array.isArray(e.morphTargetInfluences)&&i{let n=e.material;n&&(Array.isArray(n)?t.push(...n):t.push(n))}),(i=n.materialColorBinds)==null||i.forEach(e=>Z(this,null,function*(){t.filter(t=>{let n=this.parser.associations.get(t)?.materials;return e.material===n}).forEach(t=>{o.addBind(new vs({material:t,type:e.type,targetValue:new H().fromArray(e.targetValue),targetAlpha:e.targetValue[3]}))})})),(a=n.textureTransformBinds)==null||a.forEach(e=>Z(this,null,function*(){t.filter(t=>{let n=this.parser.associations.get(t)?.materials;return e.material===n}).forEach(t=>{o.addBind(new Ss({material:t,offset:new L().fromArray(e.offset??[0,0]),scale:new L().fromArray(e.scale??[1,1])}))})}))}s.registerExpression(o)}))),s})}_v0Import(t){return Z(this,null,function*(){let n=this.parser.json,r=n.extensions?.VRM;if(!r)return null;let i=r.blendShapeMaster;if(!i)return null;let a=new ps,o=i.blendShapeGroups;if(!o)return a;let s=new Set;return yield Promise.all(o.map(r=>Z(this,null,function*(){let i=r.presetName,o=(i!=null&&e.v0v1PresetNameMap[i]||null)??r.name;if(o==null){console.warn(`VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression`);return}if(s.has(o)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${i} has duplicated entries. Ignoring the expression`);return}s.add(o);let c=new ss(o);t.scene.add(c),c.isBinary=r.isBinary??!1,r.binds&&r.binds.forEach(e=>Z(this,null,function*(){var i;if(e.mesh===void 0||e.index===void 0)return;let a=[];(i=n.nodes)==null||i.forEach((t,n)=>{t.mesh===e.mesh&&a.push(n)});let o=e.index;yield Promise.all(a.map(n=>Z(this,null,function*(){let i=yield ls(t,n);if(!i.every(e=>Array.isArray(e.morphTargetInfluences)&&o{if(e.materialName===void 0||e.propertyName===void 0||e.targetValue===void 0)return;let n=[];t.scene.traverse(t=>{if(t.material){let r=t.material;Array.isArray(r)?n.push(...r.filter(t=>(t.name===e.materialName||t.name===e.materialName+` (Outline)`)&&n.indexOf(t)===-1)):r.name===e.materialName&&n.indexOf(r)===-1&&n.push(r)}});let r=e.propertyName;n.forEach(t=>{if(r===`_MainTex_ST`){let n=new L(e.targetValue[0],e.targetValue[1]),r=new L(e.targetValue[2],e.targetValue[3]);r.y=1-r.y-n.y,c.addBind(new Ss({material:t,scale:n,offset:r}));return}let n=hs[r];if(n){c.addBind(new vs({material:t,type:n,targetValue:new H().fromArray(e.targetValue),targetAlpha:e.targetValue[3]}));return}console.warn(r+` is not supported`)})}),a.registerExpression(c)}))),a})}};ws.v0v1PresetNameMap={a:`aa`,e:`ee`,i:`ih`,o:`oh`,u:`ou`,blink:`blink`,joy:`happy`,angry:`angry`,sorrow:`sad`,fun:`relaxed`,lookup:`lookUp`,lookdown:`lookDown`,lookleft:`lookLeft`,lookright:`lookRight`,blink_l:`blinkLeft`,blink_r:`blinkRight`,neutral:`neutral`};var Ts=ws,Es=class e{constructor(t,n){this._firstPersonOnlyLayer=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=e.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=n}copy(e){if(this.humanoid!==e.humanoid)throw Error(`VRMFirstPerson: humanoid must be same in order to copy`);return this.meshAnnotations=e.meshAnnotations.map(e=>({meshes:e.meshes.concat(),type:e.type})),this}clone(){return new e(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:t=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=e.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||=(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach(e=>{e.meshes.forEach(t=>{e.type===`firstPersonOnly`?(t.layers.set(this._firstPersonOnlyLayer),t.traverse(e=>e.layers.set(this._firstPersonOnlyLayer))):e.type===`thirdPersonOnly`?(t.layers.set(this._thirdPersonOnlyLayer),t.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer))):e.type===`auto`&&this._createHeadlessModel(t)})}),!0)}_excludeTriangles(e,t,n,r){let i=0;if(t!=null&&t.length>0)for(let a=0;a0&&r.includes(u[0])||l[1]>0&&r.includes(u[1])||l[2]>0&&r.includes(u[2])||l[3]>0&&r.includes(u[3]))continue;let d=t[s],f=n[s];if(d[0]>0&&r.includes(f[0])||d[1]>0&&r.includes(f[1])||d[2]>0&&r.includes(f[2])||d[3]>0&&r.includes(f[3]))continue;let p=t[c],m=n[c];p[0]>0&&r.includes(m[0])||p[1]>0&&r.includes(m[1])||p[2]>0&&r.includes(m[2])||p[3]>0&&r.includes(m[3])||(e[i++]=o,e[i++]=s,e[i++]=c)}return i}_createErasedMesh(e,t){let n=new Be(e.geometry.clone(),e.material);n.name=`${e.name}(erase)`,n.frustumCulled=e.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);let r=n.geometry,i=r.getAttribute(`skinIndex`),a=i instanceof xe?[]:i.array,o=[];for(let e=0;e{this._isEraseTarget(e)&&n.push(t)}),!n.length){t.layers.enable(this._thirdPersonOnlyLayer),t.layers.enable(this._firstPersonOnlyLayer);return}t.layers.set(this._thirdPersonOnlyLayer);let r=this._createErasedMesh(t,n);e.add(r)}_createHeadlessModel(e){if(e.type===`Group`)if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer));else{let t=new P;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter(e=>e.type===`SkinnedMesh`).forEach(e=>{let n=e;this._createHeadlessModelForSkinnedMesh(t,n)})}else if(e.type===`SkinnedMesh`){let t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode(`head`)?!0:e.parent?this._isEraseTarget(e.parent):!1}};Es.DEFAULT_FIRSTPERSON_ONLY_LAYER=9,Es.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var Ds=Es,Os=new Set([`1.0`,`1.0-beta`]),ks=class{get name(){return`VRMFirstPersonLoaderPlugin`}constructor(e){this.parser=e}afterRoot(e){return Z(this,null,function*(){let t=e.userData.vrmHumanoid;if(t!==null){if(t===void 0)throw Error(`VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first`);e.userData.vrmFirstPerson=yield this._import(e,t)}})}_import(e,t){return Z(this,null,function*(){return t==null?null:(yield this._v1Import(e,t))||(yield this._v0Import(e,t))||null})}_v1Import(e,t){return Z(this,null,function*(){let n=this.parser.json;if(n.extensionsUsed?.indexOf(`VRMC_vrm`)===-1)return null;let r=n.extensions?.VRMC_vrm;if(!r)return null;let i=r.specVersion;if(!Os.has(i))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${i}"`),null;let a=r.firstPerson,o=[],s=yield us(e);return Array.from(s.entries()).forEach(([e,t])=>{let n=(a?.meshAnnotations)?.find(t=>t.node===e);o.push({meshes:t,type:n?.type??`auto`})}),new Ds(t,o)})}_v0Import(e,t){return Z(this,null,function*(){let n=this.parser.json,r=n.extensions?.VRM;if(!r)return null;let i=r.firstPerson;if(!i)return null;let a=[],o=yield us(e);return Array.from(o.entries()).forEach(([e,t])=>{let r=n.nodes[e],o=i.meshAnnotations?i.meshAnnotations.find(e=>e.mesh===r.mesh):void 0;a.push({meshes:t,type:this._convertV0FlagToV1Type(o?.firstPersonFlag)})}),new Ds(t,a)})}_convertV0FlagToV1Type(e){return e===`FirstPersonOnly`?`firstPersonOnly`:e===`ThirdPersonOnly`?`thirdPersonOnly`:e===`Both`?`both`:`auto`}},As=new F,js=new F,Ms=new R,Ns=class extends P{constructor(e){super(),this.vrmHumanoid=e,this._boneAxesMap=new Map,Object.values(e.humanBones).forEach(e=>{let t=new kt(1);t.matrixAutoUpdate=!1,t.material.depthTest=!1,t.material.depthWrite=!1,this.add(t),this._boneAxesMap.set(e,t)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(e=>{e.geometry.dispose(),e.material.dispose()})}updateMatrixWorld(e){Array.from(this._boneAxesMap.entries()).forEach(([e,t])=>{e.node.updateWorldMatrix(!0,!1),e.node.matrixWorld.decompose(As,Ms,js);let n=As.set(.1,.1,.1).divide(js);t.matrix.copy(e.node.matrixWorld).scale(n)}),super.updateMatrixWorld(e)}},Ps=`hips.spine.chest.upperChest.neck.head.leftEye.rightEye.jaw.leftUpperLeg.leftLowerLeg.leftFoot.leftToes.rightUpperLeg.rightLowerLeg.rightFoot.rightToes.leftShoulder.leftUpperArm.leftLowerArm.leftHand.rightShoulder.rightUpperArm.rightLowerArm.rightHand.leftThumbMetacarpal.leftThumbProximal.leftThumbDistal.leftIndexProximal.leftIndexIntermediate.leftIndexDistal.leftMiddleProximal.leftMiddleIntermediate.leftMiddleDistal.leftRingProximal.leftRingIntermediate.leftRingDistal.leftLittleProximal.leftLittleIntermediate.leftLittleDistal.rightThumbMetacarpal.rightThumbProximal.rightThumbDistal.rightIndexProximal.rightIndexIntermediate.rightIndexDistal.rightMiddleProximal.rightMiddleIntermediate.rightMiddleDistal.rightRingProximal.rightRingIntermediate.rightRingDistal.rightLittleProximal.rightLittleIntermediate.rightLittleDistal`.split(`.`),Fs={hips:null,spine:`hips`,chest:`spine`,upperChest:`chest`,neck:`upperChest`,head:`neck`,leftEye:`head`,rightEye:`head`,jaw:`head`,leftUpperLeg:`hips`,leftLowerLeg:`leftUpperLeg`,leftFoot:`leftLowerLeg`,leftToes:`leftFoot`,rightUpperLeg:`hips`,rightLowerLeg:`rightUpperLeg`,rightFoot:`rightLowerLeg`,rightToes:`rightFoot`,leftShoulder:`upperChest`,leftUpperArm:`leftShoulder`,leftLowerArm:`leftUpperArm`,leftHand:`leftLowerArm`,rightShoulder:`upperChest`,rightUpperArm:`rightShoulder`,rightLowerArm:`rightUpperArm`,rightHand:`rightLowerArm`,leftThumbMetacarpal:`leftHand`,leftThumbProximal:`leftThumbMetacarpal`,leftThumbDistal:`leftThumbProximal`,leftIndexProximal:`leftHand`,leftIndexIntermediate:`leftIndexProximal`,leftIndexDistal:`leftIndexIntermediate`,leftMiddleProximal:`leftHand`,leftMiddleIntermediate:`leftMiddleProximal`,leftMiddleDistal:`leftMiddleIntermediate`,leftRingProximal:`leftHand`,leftRingIntermediate:`leftRingProximal`,leftRingDistal:`leftRingIntermediate`,leftLittleProximal:`leftHand`,leftLittleIntermediate:`leftLittleProximal`,leftLittleDistal:`leftLittleIntermediate`,rightThumbMetacarpal:`rightHand`,rightThumbProximal:`rightThumbMetacarpal`,rightThumbDistal:`rightThumbProximal`,rightIndexProximal:`rightHand`,rightIndexIntermediate:`rightIndexProximal`,rightIndexDistal:`rightIndexIntermediate`,rightMiddleProximal:`rightHand`,rightMiddleIntermediate:`rightMiddleProximal`,rightMiddleDistal:`rightMiddleIntermediate`,rightRingProximal:`rightHand`,rightRingIntermediate:`rightRingProximal`,rightRingDistal:`rightRingIntermediate`,rightLittleProximal:`rightHand`,rightLittleIntermediate:`rightLittleProximal`,rightLittleDistal:`rightLittleIntermediate`};function Is(e){return e.invert?e.invert():e.inverse(),e}var Ls=new F,Rs=new R,zs=class{constructor(e){this.humanBones=e,this.restPose=this.getAbsolutePose()}getAbsolutePose(){let e={};return Object.keys(this.humanBones).forEach(t=>{let n=t,r=this.getBoneNode(n);r&&(Ls.copy(r.position),Rs.copy(r.quaternion),e[n]={position:Ls.toArray(),rotation:Rs.toArray()})}),e}getPose(){let e={};return Object.keys(this.humanBones).forEach(t=>{let n=t,r=this.getBoneNode(n);if(!r)return;Ls.set(0,0,0),Rs.identity();let i=this.restPose[n];i?.position&&Ls.fromArray(i.position).negate(),i?.rotation&&Is(Rs.fromArray(i.rotation)),Ls.add(r.position),Rs.premultiply(r.quaternion),e[n]={position:Ls.toArray(),rotation:Rs.toArray()}}),e}setPose(e){Object.entries(e).forEach(([e,t])=>{let n=e,r=this.getBoneNode(n);if(!r)return;let i=this.restPose[n];i&&(t?.position&&(r.position.fromArray(t.position),i.position&&r.position.add(Ls.fromArray(i.position))),t?.rotation&&(r.quaternion.fromArray(t.rotation),i.rotation&&r.quaternion.multiply(Rs.fromArray(i.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([e,t])=>{let n=this.getBoneNode(e);n&&(t?.position&&n.position.fromArray(t.position),t?.rotation&&n.quaternion.fromArray(t.rotation))})}getBone(e){return this.humanBones[e]??void 0}getBoneNode(e){return this.humanBones[e]?.node??null}},Bs=new F,Vs=new R,Hs=new F,Us=class e extends zs{static _setupTransforms(e){let t=new A;t.name=`VRMHumanoidRig`;let n={},r={},i={},a={};Ps.forEach(t=>{var o;let s=e.getBoneNode(t);if(s){let e=new F,c=new R;s.updateWorldMatrix(!0,!1),s.matrixWorld.decompose(e,c,Bs),n[t]=e,r[t]=c,i[t]=s.quaternion.clone();let l=new R;(o=s.parent)==null||o.matrixWorld.decompose(Bs,l,Bs),a[t]=l}});let o={};return Ps.forEach(r=>{let i=e.getBoneNode(r);if(i){let e=n[r],a=r,s;for(;s==null&&(a=Fs[a],a!=null);)s=n[a];let c=new A;c.name=`Normalized_`+i.name,(a?o[a]?.node:t).add(c),c.position.copy(e),s&&c.position.sub(s),o[r]={node:c}}}),{rigBones:o,root:t,parentWorldRotations:a,boneRotations:i}}constructor(t){let{rigBones:n,root:r,parentWorldRotations:i,boneRotations:a}=e._setupTransforms(t);super(n),this.original=t,this.root=r,this._parentWorldRotations=i,this._boneRotations=a}update(){Ps.forEach(e=>{let t=this.original.getBoneNode(e);if(t!=null){let n=this.getBoneNode(e),r=this._parentWorldRotations[e],i=Vs.copy(r).invert(),a=this._boneRotations[e];if(t.quaternion.copy(n.quaternion).multiply(r).premultiply(i).multiply(a),e===`hips`){let e=n.getWorldPosition(Hs);t.parent.updateWorldMatrix(!0,!1);let r=t.parent.matrixWorld,i=e.applyMatrix4(r.invert());t.position.copy(i)}}})}},Ws=class e{get restPose(){return console.warn(`VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead.`),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(e,t){this.autoUpdateHumanBones=t?.autoUpdateHumanBones??!0,this._rawHumanBones=new zs(e),this._normalizedHumanBones=new Us(this._rawHumanBones)}copy(e){return this.autoUpdateHumanBones=e.autoUpdateHumanBones,this._rawHumanBones=new zs(e.humanBones),this._normalizedHumanBones=new Us(this._rawHumanBones),this}clone(){return new e(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn(`VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead.`),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn(`VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead.`),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(e){return console.warn(`VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead.`),this.setRawPose(e)}setRawPose(e){return this._rawHumanBones.setPose(e)}setNormalizedPose(e){return this._normalizedHumanBones.setPose(e)}resetPose(){return console.warn(`VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead.`),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(e){return console.warn(`VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead.`),this.getRawBone(e)}getRawBone(e){return this._rawHumanBones.getBone(e)}getNormalizedBone(e){return this._normalizedHumanBones.getBone(e)}getBoneNode(e){return console.warn(`VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead.`),this.getRawBoneNode(e)}getRawBoneNode(e){return this._rawHumanBones.getBoneNode(e)}getNormalizedBoneNode(e){return this._normalizedHumanBones.getBoneNode(e)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},Gs={Hips:`hips`,Spine:`spine`,Head:`head`,LeftUpperLeg:`leftUpperLeg`,LeftLowerLeg:`leftLowerLeg`,LeftFoot:`leftFoot`,RightUpperLeg:`rightUpperLeg`,RightLowerLeg:`rightLowerLeg`,RightFoot:`rightFoot`,LeftUpperArm:`leftUpperArm`,LeftLowerArm:`leftLowerArm`,LeftHand:`leftHand`,RightUpperArm:`rightUpperArm`,RightLowerArm:`rightLowerArm`,RightHand:`rightHand`},Ks=new Set([`1.0`,`1.0-beta`]),qs={leftThumbProximal:`leftThumbMetacarpal`,leftThumbIntermediate:`leftThumbProximal`,rightThumbProximal:`rightThumbMetacarpal`,rightThumbIntermediate:`rightThumbProximal`},Js=class{get name(){return`VRMHumanoidLoaderPlugin`}constructor(e,t){this.parser=e,this.helperRoot=t?.helperRoot,this.autoUpdateHumanBones=t?.autoUpdateHumanBones}afterRoot(e){return Z(this,null,function*(){e.userData.vrmHumanoid=yield this._import(e)})}_import(e){return Z(this,null,function*(){return(yield this._v1Import(e))||(yield this._v0Import(e))||null})}_v1Import(e){return Z(this,null,function*(){let t=this.parser.json;if(t.extensionsUsed?.indexOf(`VRMC_vrm`)===-1)return null;let n=t.extensions?.VRMC_vrm;if(!n)return null;let r=n.specVersion;if(!Ks.has(r))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${r}"`),null;let i=n.humanoid;if(!i)return null;let a=i.humanBones.leftThumbIntermediate!=null||i.humanBones.rightThumbIntermediate!=null,o={};i.humanBones!=null&&(yield Promise.all(Object.entries(i.humanBones).map(e=>Z(this,[e],function*([e,t]){let n=e,r=t.node;if(a){let e=qs[n];e!=null&&(n=e)}let i=yield this.parser.getDependency(`node`,r);if(i==null){console.warn(`A glTF node bound to the humanoid bone ${n} (index = ${r}) does not exist`);return}o[n]={node:i}}))));let s=new Ws(this._ensureRequiredBonesExist(o),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(s.normalizedHumanBonesRoot),this.helperRoot){let e=new Ns(s);this.helperRoot.add(e),e.renderOrder=this.helperRoot.renderOrder}return s})}_v0Import(e){return Z(this,null,function*(){let t=this.parser.json.extensions?.VRM;if(!t)return null;let n=t.humanoid;if(!n)return null;let r={};n.humanBones!=null&&(yield Promise.all(n.humanBones.map(e=>Z(this,null,function*(){let t=e.bone,n=e.node;if(t==null||n==null)return;let i=yield this.parser.getDependency(`node`,n);if(i==null){console.warn(`A glTF node bound to the humanoid bone ${t} (index = ${n}) does not exist`);return}let a=qs[t]??t;if(r[a]!=null){console.warn(`Multiple bone entries for ${a} detected (index = ${n}), ignoring duplicated entries.`);return}r[a]={node:i}}))));let i=new Ws(this._ensureRequiredBonesExist(r),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(i.normalizedHumanBonesRoot),this.helperRoot){let e=new Ns(i);this.helperRoot.add(e),e.renderOrder=this.helperRoot.renderOrder}return i})}_ensureRequiredBonesExist(e){let t=Object.values(Gs).filter(t=>e[t]==null);if(t.length>0)throw Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${t.join(`, `)}`);return e}},Ys=class extends Gt{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new V(new Float32Array(195),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(189),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,e=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let e=0;e<64;e++){let t=e/63*this._currentTheta;this._attrPos.setXYZ(e+1,this._currentRadius*Math.sin(t),0,this._currentRadius*Math.cos(t))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<63;e++)this._attrIndex.setXYZ(e*3,0,e+1,e+2);this._attrIndex.needsUpdate=!0}},Xs=class extends Gt{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new F,this._currentTail=new F,this._attrPos=new V(new Float32Array(294),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},Zs=new R,Qs=new R,$s=new F,ec=new F,tc=Math.sqrt(2)/2,nc=new R(0,0,-tc,tc),rc=new F(0,1,0),ic=class extends P{constructor(e){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=e;{let e=new Ys;e.radius=.5,this._meshPitch=new it(e,new ct({color:65280,transparent:!0,opacity:.5,side:2,depthTest:!1,depthWrite:!1})),this.add(this._meshPitch)}{let e=new Ys;e.radius=.5,this._meshYaw=new it(e,new ct({color:16711680,transparent:!0,opacity:.5,side:2,depthTest:!1,depthWrite:!1})),this.add(this._meshYaw)}{let e=new Xs;e.radius=.1,this._lineTarget=new E(e,new qe({color:16777215,depthTest:!1,depthWrite:!1})),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(e){let t=I.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=t,this._meshYaw.geometry.update();let n=I.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=n,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition($s),this.vrmLookAt.getLookAtWorldQuaternion(Zs),Zs.multiply(this.vrmLookAt.getFaceFrontQuaternion(Qs)),this._meshYaw.position.copy($s),this._meshYaw.quaternion.copy(Zs),this._meshPitch.position.copy($s),this._meshPitch.quaternion.copy(Zs),this._meshPitch.quaternion.multiply(Qs.setFromAxisAngle(rc,t)),this._meshPitch.quaternion.multiply(nc);let{target:r,autoUpdate:i}=this.vrmLookAt;r!=null&&i&&(r.getWorldPosition(ec).sub($s),this._lineTarget.geometry.tail.copy(ec),this._lineTarget.geometry.update(),this._lineTarget.position.copy($s)),super.updateMatrixWorld(e)}},ac=new F,oc=new F;function sc(e,t){return e.matrixWorld.decompose(ac,t,oc),t}function cc(e){return[Math.atan2(-e.z,e.x),Math.atan2(e.y,Math.sqrt(e.x*e.x+e.z*e.z))]}function lc(e){let t=Math.round(e/2/Math.PI);return e-2*Math.PI*t}var uc=new F(0,0,1),dc=new F,fc=new F,pc=new F,mc=new R,hc=new R,gc=new R,_c=new R,vc=new Se,yc=class e{constructor(e,t){this.offsetFromHeadBone=new F,this.autoUpdate=!0,this.faceFront=new F(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new R)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn(`VRMLookAt: euler is deprecated. use getEuler() instead.`),this.getEuler(new Se)}getEuler(e){return e.set(I.DEG2RAD*this._pitch,I.DEG2RAD*this._yaw,0,`YXZ`)}copy(e){if(this.humanoid!==e.humanoid)throw Error(`VRMLookAt: humanoid must be same in order to copy`);return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new e(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){let t=this.humanoid.getRawBoneNode(`head`);return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){return sc(this.humanoid.getRawBoneNode(`head`),e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(uc)<.01)return e.copy(this._restHeadWorldQuaternion).invert();let[t,n]=cc(this.faceFront);return vc.set(0,.5*Math.PI+t,n,`YZX`),e.setFromEuler(vc).premultiply(_c.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(hc),this.getFaceFrontQuaternion(gc),e.copy(uc).applyQuaternion(hc).applyQuaternion(gc).applyEuler(this.getEuler(vc))}lookAt(e){let t=mc.copy(this._restHeadWorldQuaternion).multiply(Is(this.getLookAtWorldQuaternion(hc))),n=this.getLookAtWorldPosition(fc),r=pc.copy(e).sub(n).applyQuaternion(t).normalize(),[i,a]=cc(this.faceFront),[o,s]=cc(r),c=lc(o-i),l=lc(a-s);this._yaw=I.RAD2DEG*c,this._pitch=I.RAD2DEG*l,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(dc)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};yc.EULER_ORDER=`YXZ`;var bc=yc,xc=new F(0,0,1),Sc=new R,Cc=new R,wc=new Se(0,0,0,`YXZ`),Tc=class{constructor(e,t,n,r,i){this.humanoid=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i,this.faceFront=new F(0,0,1),this._restQuatLeftEye=new R,this._restQuatRightEye=new R,this._restLeftEyeParentWorldQuat=new R,this._restRightEyeParentWorldQuat=new R;let a=this.humanoid.getRawBoneNode(`leftEye`),o=this.humanoid.getRawBoneNode(`rightEye`);a&&(this._restQuatLeftEye.copy(a.quaternion),sc(a.parent,this._restLeftEyeParentWorldQuat)),o&&(this._restQuatRightEye.copy(o.quaternion),sc(o.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(e,t){let n=this.humanoid.getRawBoneNode(`leftEye`),r=this.humanoid.getRawBoneNode(`rightEye`),i=this.humanoid.getNormalizedBoneNode(`leftEye`),a=this.humanoid.getNormalizedBoneNode(`rightEye`);n&&(t<0?wc.x=-I.DEG2RAD*this.rangeMapVerticalDown.map(-t):wc.x=I.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?wc.y=-I.DEG2RAD*this.rangeMapHorizontalInner.map(-e):wc.y=I.DEG2RAD*this.rangeMapHorizontalOuter.map(e),Sc.setFromEuler(wc),this._getWorldFaceFrontQuat(Cc),i.quaternion.copy(Cc).multiply(Sc).multiply(Cc.invert()),Sc.copy(this._restLeftEyeParentWorldQuat),n.quaternion.copy(i.quaternion).multiply(Sc).premultiply(Sc.invert()).multiply(this._restQuatLeftEye)),r&&(t<0?wc.x=-I.DEG2RAD*this.rangeMapVerticalDown.map(-t):wc.x=I.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?wc.y=-I.DEG2RAD*this.rangeMapHorizontalOuter.map(-e):wc.y=I.DEG2RAD*this.rangeMapHorizontalInner.map(e),Sc.setFromEuler(wc),this._getWorldFaceFrontQuat(Cc),a.quaternion.copy(Cc).multiply(Sc).multiply(Cc.invert()),Sc.copy(this._restRightEyeParentWorldQuat),r.quaternion.copy(a.quaternion).multiply(Sc).premultiply(Sc.invert()).multiply(this._restQuatRightEye))}lookAt(e){console.warn(`VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.`);let t=I.RAD2DEG*e.y,n=I.RAD2DEG*e.x;this.applyYawPitch(t,n)}_getWorldFaceFrontQuat(e){if(this.faceFront.distanceToSquared(xc)<.01)return e.identity();let[t,n]=cc(this.faceFront);return wc.set(0,.5*Math.PI+t,n,`YZX`),e.setFromEuler(wc)}};Tc.type=`bone`;var Ec=class{constructor(e,t,n,r,i){this.expressions=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i}applyYawPitch(e,t){t<0?(this.expressions.setValue(`lookDown`,0),this.expressions.setValue(`lookUp`,this.rangeMapVerticalUp.map(-t))):(this.expressions.setValue(`lookUp`,0),this.expressions.setValue(`lookDown`,this.rangeMapVerticalDown.map(t))),e<0?(this.expressions.setValue(`lookLeft`,0),this.expressions.setValue(`lookRight`,this.rangeMapHorizontalOuter.map(-e))):(this.expressions.setValue(`lookRight`,0),this.expressions.setValue(`lookLeft`,this.rangeMapHorizontalOuter.map(e)))}lookAt(e){console.warn(`VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.`);let t=I.RAD2DEG*e.y,n=I.RAD2DEG*e.x;this.applyYawPitch(t,n)}};Ec.type=`expression`;var Dc=class{constructor(e,t){this.inputMaxValue=e,this.outputScale=t}map(e){return this.outputScale*fs(e/this.inputMaxValue)}},Oc=new Set([`1.0`,`1.0-beta`]),kc=.01,Ac=class{get name(){return`VRMLookAtLoaderPlugin`}constructor(e,t){this.parser=e,this.helperRoot=t?.helperRoot}afterRoot(e){return Z(this,null,function*(){let t=e.userData.vrmHumanoid;if(t===null)return;if(t===void 0)throw Error(`VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first`);let n=e.userData.vrmExpressionManager;if(n!==null){if(n===void 0)throw Error(`VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first`);e.userData.vrmLookAt=yield this._import(e,t,n)}})}_import(e,t,n){return Z(this,null,function*(){return t==null||n==null?null:(yield this._v1Import(e,t,n))||(yield this._v0Import(e,t,n))||null})}_v1Import(e,t,n){return Z(this,null,function*(){let e=this.parser.json;if(e.extensionsUsed?.indexOf(`VRMC_vrm`)===-1)return null;let r=e.extensions?.VRMC_vrm;if(!r)return null;let i=r.specVersion;if(!Oc.has(i))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${i}"`),null;let a=r.lookAt;if(!a)return null;let o=a.type===`expression`?1:10,s=this._v1ImportRangeMap(a.rangeMapHorizontalInner,o),c=this._v1ImportRangeMap(a.rangeMapHorizontalOuter,o),l=this._v1ImportRangeMap(a.rangeMapVerticalDown,o),u=this._v1ImportRangeMap(a.rangeMapVerticalUp,o),d;d=a.type===`expression`?new Ec(n,s,c,l,u):new Tc(t,s,c,l,u);let f=this._importLookAt(t,d);return f.offsetFromHeadBone.fromArray(a.offsetFromHeadBone??[0,.06,0]),f})}_v1ImportRangeMap(e,t){let n=e?.inputMaxValue??90,r=e?.outputScale??t;return n(console.error(e),console.warn(`VRMMetaLoaderPlugin: Failed to load a thumbnail image`),null))})}},Pc=class{constructor(e){this.scene=e.scene,this.meta=e.meta,this.humanoid=e.humanoid,this.expressionManager=e.expressionManager,this.firstPerson=e.firstPerson,this.lookAt=e.lookAt}update(e){this.humanoid.update(),this.lookAt&&this.lookAt.update(e),this.expressionManager&&this.expressionManager.update()}},Fc=class extends Pc{constructor(e){super(e),this.materials=e.materials,this.springBoneManager=e.springBoneManager,this.nodeConstraintManager=e.nodeConstraintManager}update(e){super.update(e),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(e),this.materials&&this.materials.forEach(t=>{t.update&&t.update(e)})}},Ic=Object.defineProperty,Lc=Object.getOwnPropertySymbols,Rc=Object.prototype.hasOwnProperty,zc=Object.prototype.propertyIsEnumerable,Bc=(e,t,n)=>t in e?Ic(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vc=(e,t)=>{for(var n in t||={})Rc.call(t,n)&&Bc(e,n,t[n]);if(Lc)for(var n of Lc(t))zc.call(t,n)&&Bc(e,n,t[n]);return e},Hc=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});function Uc(e,t){e.colorSpace=t}var Wc=class{get pending(){return Promise.all(this._pendings)}constructor(e,t){this._parser=e,this._materialParams=t,this._pendings=[]}assignPrimitive(e,t){t!=null&&(this._materialParams[e]=t)}assignColor(e,t,n){if(t!=null){let r=new H().fromArray(t);n&&r.convertSRGBToLinear(),this._materialParams[e]=r}}assignTexture(e,t,n){return Hc(this,null,function*(){let r=(()=>Hc(this,null,function*(){t!=null&&(yield this._parser.assignTexture(this._materialParams,e,t),n&&Uc(this._materialParams[e],`srgb`))}))();return this._pendings.push(r),r})}assignTextureByIndex(e,t,n){return Hc(this,null,function*(){return this.assignTexture(e,t==null?void 0:{index:t},n)})}},Gc=`// #define PHONG + +varying vec3 vViewPosition; + +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif + +#include + +// #include +#ifdef MTOON_USE_UV + varying vec2 vUv; + + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION < 151 + uniform mat3 uvTransform; + #endif +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; + #endif +#endif + +// #include +// #include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + uniform sampler2D outlineWidthMultiplyTexture; + uniform mat3 outlineWidthMultiplyTextureUvTransform; +#endif + +uniform float outlineWidthFactor; + +void main() { + + // #include + #ifdef MTOON_USE_UV + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION >= 151 + vUv = uv; + #else + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #endif + + // #include + // COMAPT: pre-r151 uses uv2 for lightMap and aoMap + #if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; + #endif + #endif + + #include + + #include + #include + #include + #include + + // we need this to compute the outline properly + objectNormal = normalize( objectNormal ); + + #include + + #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED + vNormal = normalize( transformedNormal ); + #endif + + #include + + #include + #include + // #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #ifdef OUTLINE + float worldNormalLength = length( transformedNormal ); + vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal; + + #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy; + float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g; + outlineOffset *= outlineTex; + #endif + + #ifdef OUTLINE_WIDTH_SCREEN + outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y; + #endif + + gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 ); + + gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic + #endif + + #include + // #include + #include + #include + +}`,Kc=`// #define PHONG + +uniform vec3 litFactor; + +uniform float opacity; + +uniform vec3 shadeColorFactor; +#ifdef USE_SHADEMULTIPLYTEXTURE + uniform sampler2D shadeMultiplyTexture; + uniform mat3 shadeMultiplyTextureUvTransform; +#endif + +uniform float shadingShiftFactor; +uniform float shadingToonyFactor; + +#ifdef USE_SHADINGSHIFTTEXTURE + uniform sampler2D shadingShiftTexture; + uniform mat3 shadingShiftTextureUvTransform; + uniform float shadingShiftTextureScale; +#endif + +uniform float giEqualizationFactor; + +uniform vec3 parametricRimColorFactor; +#ifdef USE_RIMMULTIPLYTEXTURE + uniform sampler2D rimMultiplyTexture; + uniform mat3 rimMultiplyTextureUvTransform; +#endif +uniform float rimLightingMixFactor; +uniform float parametricRimFresnelPowerFactor; +uniform float parametricRimLiftFactor; + +#ifdef USE_MATCAPTEXTURE + uniform vec3 matcapFactor; + uniform sampler2D matcapTexture; + uniform mat3 matcapTextureUvTransform; +#endif + +uniform vec3 emissive; +uniform float emissiveIntensity; + +uniform vec3 outlineColorFactor; +uniform float outlineLightingMixFactor; + +#ifdef USE_UVANIMATIONMASKTEXTURE + uniform sampler2D uvAnimationMaskTexture; + uniform mat3 uvAnimationMaskTextureUvTransform; +#endif + +uniform float uvAnimationScrollXOffset; +uniform float uvAnimationScrollYOffset; +uniform float uvAnimationRotationPhase; + +#include +#include +#include +#include + +// #include +#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; + #endif +#endif + +#include + +#ifdef USE_MAP + uniform mat3 mapUvTransform; +#endif + +// #include + +#include + +#include +// #include +#include + +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapUvTransform; +#endif + +// #include +// #include +// #include +#include + +// #include +// COMPAT: pre-r151 doesn't have BRDF_Lambert in +#if THREE_VRM_THREE_REVISION < 151 + vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; + } +#endif + +#include + +#include + +// #include +varying vec3 vViewPosition; + +struct MToonMaterial { + vec3 diffuseColor; + vec3 shadeColor; + float shadingShift; +}; + +float linearstep( float a, float b, float t ) { + return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 ); +} + +/** + * Convert NdotL into toon shading factor using shadingShift and shadingToony + */ +float getShading( + const in float dotNL, + const in float shadow, + const in float shadingShift +) { + float shading = dotNL; + shading = shading + shadingShift; + shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading ); + shading *= shadow; + return shading; +} + +/** + * Mix diffuseColor and shadeColor using shading factor and light color + */ +vec3 getDiffuse( + const in MToonMaterial material, + const in float shading, + in vec3 lightColor +) { + #ifdef DEBUG_LITSHADERATE + return vec3( BRDF_Lambert( shading * lightColor ) ); + #endif + + vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) ); + + // The "comment out if you want to PBR absolutely" line + #ifdef V0_COMPAT_SHADE + col = min( col, material.diffuseColor ); + #endif + + return col; +} + +// COMPAT: pre-r156 uses a struct GeometricContext +#if THREE_VRM_THREE_REVISION >= 157 + void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#else + void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#endif + +#define RE_Direct RE_Direct_MToon +#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon +#define Material_LightProbeLOD( material ) (0) + +#include +// #include + +// #include +#ifdef USE_NORMALMAP + + uniform sampler2D normalMap; + uniform mat3 normalMapUvTransform; + uniform vec2 normalScale; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 +#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + uniform mat3 normalMatrix; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) ) + + // Per-Pixel Tangent Space Normal Mapping + // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html + + // three-vrm specific change: it requires \`uv\` as an input in order to support uv scrolls + + // Temporary compat against shader change @ Three.js r126, r151 + #if THREE_VRM_THREE_REVISION >= 151 + + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = surf_norm; + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + + return mat3( T * scale, B * scale, N ); + + } + + #else + + vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + + vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); + vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = normalize( surf_norm ); + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0 + // TODO: Is this still required? Or shall I make a PR about it? + if ( length( T ) == 0.0 || length( B ) == 0.0 ) { + return surf_norm; + } + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + + } + + #endif + +#endif + +// #include +#include +#include + +// == post correction ========================================================== +void postCorrection() { + #include + #include + #include + #include + #include +} + +// == main procedure =========================================================== +void main() { + #include + + vec2 uv = vec2(0.5, 0.5); + + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + uv = vUv; + + float uvAnimMask = 1.0; + #ifdef USE_UVANIMATIONMASKTEXTURE + vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy; + uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b; + #endif + + float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask ); + float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask ); + uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5; + uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask; + #endif + + #ifdef DEBUG_UV + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + gl_FragColor = vec4( uv, 0.0, 1.0 ); + #endif + return; + #endif + + vec4 diffuseColor = vec4( litFactor, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive * emissiveIntensity; + + #include + + // #include + #ifdef USE_MAP + vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy; + vec4 sampledDiffuseColor = texture2D( map, mapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + #endif + diffuseColor *= sampledDiffuseColor; + #endif + + // #include + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + diffuseColor.rgb *= vColor; + #endif + + // #include + + #include + + // #include + + // #include + float faceDirection = gl_FrontFacing ? 1.0 : -1.0; + + #ifdef FLAT_SHADED + + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); + + #else + + vec3 normal = normalize( vNormal ); + + #ifdef DOUBLE_SIDED + + normal *= faceDirection; + + #endif + + #endif + + #ifdef USE_NORMALMAP + + vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy; + + #endif + + #ifdef USE_NORMALMAP_TANGENTSPACE + + #ifdef USE_TANGENT + + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + + #endif + + #endif + + #ifdef USE_CLEARCOAT_NORMALMAP + + #ifdef USE_TANGENT + + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + + #endif + + #endif + + // non perturbed normal for clearcoat among others + + vec3 nonPerturbedNormal = normal; + + #ifdef OUTLINE + normal *= -1.0; + #endif + + // #include + + // COMPAT: pre-r151 + // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 + #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals + + #ifdef FLIP_SIDED + + normal = - normal; + + #endif + + #ifdef DOUBLE_SIDED + + normal = normal * faceDirection; + + #endif + + normal = normalize( normalMatrix * normal ); + + // COMPAT: pre-r151 + // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 + #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP ) + + vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + + // COMPAT: pre-r151 + #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT ) + + normal = normalize( tbn * mapN ); + + #else + + normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection ); + + #endif + + #endif + + // #include + #ifdef USE_EMISSIVEMAP + vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy; + totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb; + #endif + + #ifdef DEBUG_NORMAL + gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 ); + return; + #endif + + // -- MToon: lighting -------------------------------------------------------- + // accumulation + // #include + MToonMaterial material; + + material.diffuseColor = diffuseColor.rgb; + + material.shadeColor = shadeColorFactor; + #ifdef USE_SHADEMULTIPLYTEXTURE + vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb; + #endif + + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + material.shadeColor.rgb *= vColor; + #endif + + material.shadingShift = shadingShiftFactor; + #ifdef USE_SHADINGSHIFTTEXTURE + vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale; + #endif + + // #include + + // MToon Specific changes: + // Since we want to take shadows into account of shading instead of irradiance, + // we had to modify the codes that multiplies the results of shadowmap into color of direct lights. + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + vec3 geometryPosition = - vViewPosition; + vec3 geometryNormal = normal; + vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + vec3 geometryClearcoatNormal; + + #ifdef USE_CLEARCOAT + + geometryClearcoatNormal = clearcoatNormal; + + #endif + #else + GeometricContext geometry; + + geometry.position = - vViewPosition; + geometry.normal = normal; + geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + #ifdef USE_CLEARCOAT + + geometry.clearcoatNormal = clearcoatNormal; + + #endif + #endif + + IncidentLight directLight; + + // since these variables will be used in unrolled loop, we have to define in prior + float shadow; + + #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + + pointLight = pointLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getPointLightInfo( pointLight, geometryPosition, directLight ); + #else + getPointLightInfo( pointLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + + SpotLight spotLight; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + + spotLight = spotLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #else + getSpotLightInfo( spotLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + + directionalLight = directionalLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getDirectionalLightInfo( directionalLight, directLight ); + #else + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + + // RectAreaLight rectAreaLight; + + // #pragma unroll_loop_start + // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + + // rectAreaLight = rectAreaLights[ i ]; + // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + + // } + // #pragma unroll_loop_end + + // #endif + + #if defined( RE_IndirectDiffuse ) + + vec3 iblIrradiance = vec3( 0.0 ); + + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + + // COMPAT: pre-r156 uses a struct GeometricContext + // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES + #if THREE_VRM_THREE_REVISION >= 157 + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #else + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #endif + + #if ( NUM_HEMI_LIGHTS > 0 ) + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + #else + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #endif + + // #if defined( RE_IndirectSpecular ) + + // vec3 radiance = vec3( 0.0 ); + // vec3 clearcoatRadiance = vec3( 0.0 ); + + // #endif + + #include + #include + + // modulation + #include + + vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + + #ifdef DEBUG_LITSHADERATE + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); + return; + #endif + + // -- MToon: rim lighting ----------------------------------------- + vec3 viewDir = normalize( vViewPosition ); + + #ifndef PHYSICALLY_CORRECT_LIGHTS + reflectedLight.directSpecular /= PI; + #endif + vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 ); + + vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor ); + + #ifdef USE_MATCAPTEXTURE + { + vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) ); + vec3 y = cross( viewDir, x ); // guaranteed to be normalized + vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) ); + sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy; + vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb; + rim += matcapFactor * matcap; + } + #endif + + #ifdef USE_RIMMULTIPLYTEXTURE + vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb; + #endif + + col += rimMix * rim; + + // -- MToon: Emission -------------------------------------------------------- + col += totalEmissiveRadiance; + + // #include + + // -- Almost done! ----------------------------------------------------------- + #if defined( OUTLINE ) + col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor ); + #endif + + #ifdef OPAQUE + diffuseColor.a = 1.0; + #endif + + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); +} +`,qc={None:`none`,Normal:`normal`,LitShadeRate:`litShadeRate`,UV:`uv`},Jc={None:`none`,WorldCoordinates:`worldCoordinates`,ScreenCoordinates:`screenCoordinates`};function Yc(e){return e.colorSpace}var Xc=class extends Jt{constructor(e={}){super({vertexShader:Gc,fragmentShader:Kc}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=0,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=qc.None,this._outlineWidthMode=Jc.None,this._isOutline=!1,e.transparentWithZWrite&&(e.depthWrite=!0),delete e.transparentWithZWrite,e.fog=!0,e.lights=!0,e.clipping=!0,this.uniforms=at.merge([tt.common,tt.normalmap,tt.emissivemap,tt.fog,tt.lights,{litFactor:{value:new H(1,1,1)},mapUvTransform:{value:new bt},colorAlpha:{value:1},normalMapUvTransform:{value:new bt},shadeColorFactor:{value:new H(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new bt},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new bt},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new H(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new bt},parametricRimColorFactor:{value:new H(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new bt},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new H(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new bt},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new bt},outlineWidthFactor:{value:0},outlineColorFactor:{value:new H(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new bt},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},e.uniforms??{}]),this.setValues(e),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([e,t])=>`${e}:${t}`),this.matcapTexture?`matcapTextureColorSpace:${Yc(this.matcapTexture)}`:``,this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${Yc(this.shadeMultiplyTexture)}`:``,this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${Yc(this.rimMultiplyTexture)}`:``].join(`,`),this.onBeforeCompile=e=>{let t=Object.entries(Vc(Vc({},this._generateDefines()),this.defines)).filter(([e,t])=>!!t).map(([e,t])=>`#define ${e} ${t}`).join(` +`)+` +`;e.vertexShader=t+e.vertexShader,e.fragmentShader=t+e.fragmentShader}}get color(){return this.uniforms.litFactor.value}set color(e){this.uniforms.litFactor.value=e}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get normalMap(){return this.uniforms.normalMap.value}set normalMap(e){this.uniforms.normalMap.value=e}get normalScale(){return this.uniforms.normalScale.value}set normalScale(e){this.uniforms.normalScale.value=e}get emissive(){return this.uniforms.emissive.value}set emissive(e){this.uniforms.emissive.value=e}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(e){this.uniforms.emissiveIntensity.value=e}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(e){this.uniforms.emissiveMap.value=e}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(e){this.uniforms.shadeColorFactor.value=e}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(e){this.uniforms.shadeMultiplyTexture.value=e}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(e){this.uniforms.shadingShiftFactor.value=e}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(e){this.uniforms.shadingShiftTexture.value=e}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(e){this.uniforms.shadingShiftTextureScale.value=e}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(e){this.uniforms.shadingToonyFactor.value=e}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(e){this.uniforms.giEqualizationFactor.value=e}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(e){this.uniforms.matcapFactor.value=e}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(e){this.uniforms.matcapTexture.value=e}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(e){this.uniforms.parametricRimColorFactor.value=e}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(e){this.uniforms.rimMultiplyTexture.value=e}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(e){this.uniforms.rimLightingMixFactor.value=e}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(e){this.uniforms.parametricRimFresnelPowerFactor.value=e}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(e){this.uniforms.parametricRimLiftFactor.value=e}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(e){this.uniforms.outlineWidthMultiplyTexture.value=e}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(e){this.uniforms.outlineWidthFactor.value=e}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(e){this.uniforms.outlineColorFactor.value=e}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(e){this.uniforms.outlineLightingMixFactor.value=e}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(e){this.uniforms.uvAnimationMaskTexture.value=e}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(e){this.uniforms.uvAnimationScrollXOffset.value=e}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(e){this.uniforms.uvAnimationScrollYOffset.value=e}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(e){this.uniforms.uvAnimationRotationPhase.value=e}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(e){this._ignoreVertexColor=e,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(e){this._v0CompatShade=e,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(e){this._debugMode=e,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(e){this._outlineWidthMode=e,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(e){this._isOutline=e,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(e){this._uploadUniformsWorkaround(),this._updateUVAnimation(e)}copy(e){return super.copy(e),this.map=e.map,this.normalMap=e.normalMap,this.emissiveMap=e.emissiveMap,this.shadeMultiplyTexture=e.shadeMultiplyTexture,this.shadingShiftTexture=e.shadingShiftTexture,this.matcapTexture=e.matcapTexture,this.rimMultiplyTexture=e.rimMultiplyTexture,this.outlineWidthMultiplyTexture=e.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=e.uvAnimationMaskTexture,this.normalMapType=e.normalMapType,this.uvAnimationScrollXSpeedFactor=e.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=e.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=e.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=e.ignoreVertexColor,this.v0CompatShade=e.v0CompatShade,this.debugMode=e.debugMode,this.outlineWidthMode=e.outlineWidthMode,this.isOutline=e.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(e){this.uniforms.uvAnimationScrollXOffset.value+=e*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=e*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=e*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){let e=this.outlineWidthMultiplyTexture!==null,t=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:181,OUTLINE:this._isOutline,MTOON_USE_UV:e||t,MTOON_UVS_VERTEX_ONLY:e&&!t,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode===`normal`,DEBUG_LITSHADERATE:this._debugMode===`litShadeRate`,DEBUG_UV:this._debugMode===`uv`,OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===Jc.ScreenCoordinates}}_updateTextureMatrix(e,t){e.value&&(e.value.matrixAutoUpdate&&e.value.updateMatrix(),t.value.copy(e.value.matrix))}},Zc=new Set([`1.0`,`1.0-beta`]),Qc=class e{get name(){return e.EXTENSION_NAME}constructor(e,t={}){this.parser=e,this.materialType=t.materialType??Xc,this.renderOrderOffset=t.renderOrderOffset??0,this.v0CompatShade=t.v0CompatShade??!1,this.debugMode=t.debugMode??`none`,this._mToonMaterialSet=new Set}beforeRoot(){return Hc(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return Hc(this,null,function*(){e.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(e){return this._getMToonExtension(e)?this.materialType:null}extendMaterialParams(e,t){let n=this._getMToonExtension(e);return n?this._extendMaterialParams(n,t):null}loadMesh(e){return Hc(this,null,function*(){let t=this.parser,n=t.json.meshes?.[e];if(n==null)throw Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);let r=n.primitives,i=yield t.loadMesh(e);if(r.length===1){let e=i,t=r[0].material;t!=null&&this._setupPrimitive(e,t)}else{let e=i;for(let t=0;t{this._getMToonExtension(t)&&e.extensions?.KHR_materials_unlit&&delete e.extensions.KHR_materials_unlit})}_getMToonExtension(t){let n=this.parser.json.materials?.[t];if(n==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}let r=n.extensions?.[e.EXTENSION_NAME];if(r==null)return;let i=r.specVersion;if(!Zc.has(i)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${i}"`);return}return r}_extendMaterialParams(e,t){return Hc(this,null,function*(){delete t.metalness,delete t.roughness;let n=new Wc(this.parser,t);n.assignPrimitive(`transparentWithZWrite`,e.transparentWithZWrite),n.assignColor(`shadeColorFactor`,e.shadeColorFactor),n.assignTexture(`shadeMultiplyTexture`,e.shadeMultiplyTexture,!0),n.assignPrimitive(`shadingShiftFactor`,e.shadingShiftFactor),n.assignTexture(`shadingShiftTexture`,e.shadingShiftTexture,!0),n.assignPrimitive(`shadingShiftTextureScale`,e.shadingShiftTexture?.scale),n.assignPrimitive(`shadingToonyFactor`,e.shadingToonyFactor),n.assignPrimitive(`giEqualizationFactor`,e.giEqualizationFactor),n.assignColor(`matcapFactor`,e.matcapFactor),n.assignTexture(`matcapTexture`,e.matcapTexture,!0),n.assignColor(`parametricRimColorFactor`,e.parametricRimColorFactor),n.assignTexture(`rimMultiplyTexture`,e.rimMultiplyTexture,!0),n.assignPrimitive(`rimLightingMixFactor`,e.rimLightingMixFactor),n.assignPrimitive(`parametricRimFresnelPowerFactor`,e.parametricRimFresnelPowerFactor),n.assignPrimitive(`parametricRimLiftFactor`,e.parametricRimLiftFactor),n.assignPrimitive(`outlineWidthMode`,e.outlineWidthMode),n.assignPrimitive(`outlineWidthFactor`,e.outlineWidthFactor),n.assignTexture(`outlineWidthMultiplyTexture`,e.outlineWidthMultiplyTexture,!1),n.assignColor(`outlineColorFactor`,e.outlineColorFactor),n.assignPrimitive(`outlineLightingMixFactor`,e.outlineLightingMixFactor),n.assignTexture(`uvAnimationMaskTexture`,e.uvAnimationMaskTexture,!1),n.assignPrimitive(`uvAnimationScrollXSpeedFactor`,e.uvAnimationScrollXSpeedFactor),n.assignPrimitive(`uvAnimationScrollYSpeedFactor`,e.uvAnimationScrollYSpeedFactor),n.assignPrimitive(`uvAnimationRotationSpeedFactor`,e.uvAnimationRotationSpeedFactor),n.assignPrimitive(`v0CompatShade`,this.v0CompatShade),n.assignPrimitive(`debugMode`,this.debugMode),yield n.pending})}_setupPrimitive(e,t){let n=this._getMToonExtension(t);if(n){e.renderOrder=this._parseRenderOrder(n)+this.renderOrderOffset,this._generateOutline(e),this._addToMaterialSet(e);return}}_shouldGenerateOutline(e){return typeof e.outlineWidthMode==`string`&&e.outlineWidthMode!==`none`&&typeof e.outlineWidthFactor==`number`&&e.outlineWidthFactor>0}_generateOutline(e){let t=e.material;if(!(t instanceof It)||!this._shouldGenerateOutline(t))return;e.material=[t];let n=t.clone();n.name+=` (Outline)`,n.isOutline=!0,n.side=1,e.material.push(n);let r=e.geometry,i=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,i,0),r.addGroup(0,i,1)}_addToMaterialSet(e){let t=e.material,n=new Set;Array.isArray(t)?t.forEach(e=>n.add(e)):n.add(t);for(let e of n)this._mToonMaterialSet.add(e)}_parseRenderOrder(e){return(e.transparentWithZWrite?0:19)+(e.renderQueueOffsetNumber??0)}};Qc.EXTENSION_NAME=`VRMC_materials_mtoon`;var $c=Qc,el=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),tl=class e{get name(){return e.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,t){return el(this,null,function*(){let n=this._getHDREmissiveMultiplierExtension(e);n!=null&&(console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead."),t.emissiveIntensity=n.emissiveMultiplier)})}_getHDREmissiveMultiplierExtension(t){let n=this.parser.json.materials?.[t];if(n==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}let r=n.extensions?.[e.EXTENSION_NAME];if(r!=null)return r}};tl.EXTENSION_NAME=`VRMC_materials_hdr_emissiveMultiplier`;var nl=tl,rl=Object.defineProperty,il=Object.defineProperties,al=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,sl=Object.prototype.hasOwnProperty,cl=Object.prototype.propertyIsEnumerable,ll=(e,t,n)=>t in e?rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ul=(e,t)=>{for(var n in t||={})sl.call(t,n)&&ll(e,n,t[n]);if(ol)for(var n of ol(t))cl.call(t,n)&&ll(e,n,t[n]);return e},dl=(e,t)=>il(e,al(t)),fl=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});function pl(e){return e**2.2}var ml=class{get name(){return`VRMMaterialsV0CompatPlugin`}constructor(e){this.parser=e,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;let t=this.parser.json;t.extensionsUsed=t.extensionsUsed??[],t.extensionsUsed.indexOf(`KHR_texture_transform`)===-1&&t.extensionsUsed.push(`KHR_texture_transform`)}beforeRoot(){return fl(this,null,function*(){let e=this.parser.json,t=e.extensions?.VRM?.materialProperties;t&&(this._populateRenderQueueMap(t),t.forEach((t,n)=>{let r=e.materials?.[n];if(r==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${n}] of glTF but the material doesn't exist`);return}if(t.shader===`VRM/MToon`){let i=this._parseV0MToonProperties(t,r);e.materials[n]=i}else if(t.shader?.startsWith(`VRM/Unlit`)){let i=this._parseV0UnlitProperties(t,r);e.materials[n]=i}else t.shader===`VRM_USE_GLTFSHADER`||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${t.shader}`)}))})}_parseV0MToonProperties(e,t){let n=e.keywordMap?._ALPHABLEND_ON??!1,r=e.floatProperties?._ZWrite===1&&n,i=this._v0ParseRenderQueue(e),a=e.keywordMap?._ALPHATEST_ON??!1,o=n?`BLEND`:a?`MASK`:`OPAQUE`,s=a?e.floatProperties?._Cutoff??.5:void 0,c=(e.floatProperties?._CullMode??2)===0,l=this._portTextureTransform(e),u=(e.vectorProperties?._Color??[1,1,1,1]).map((e,t)=>t===3?e:pl(e)),d=e.textureProperties?._MainTex,f=d==null?void 0:{index:d,extensions:ul({},l)},p=e.floatProperties?._BumpScale??1,m=e.textureProperties?._BumpMap,h=m==null?void 0:{index:m,scale:p,extensions:ul({},l)},g=(e.vectorProperties?._EmissionColor??[0,0,0,1]).map(pl),_=e.textureProperties?._EmissionMap,v=_==null?void 0:{index:_,extensions:ul({},l)},y=(e.vectorProperties?._ShadeColor??[.97,.81,.86,1]).map(pl),b=e.textureProperties?._ShadeTexture,x=b==null?void 0:{index:b,extensions:ul({},l)},S=e.floatProperties?._ShadeShift??0,C=e.floatProperties?._ShadeToony??.9;C=I.lerp(C,1,.5+.5*S),S=-S-(1-C);let ee=e.floatProperties?._IndirectLightIntensity??.1,te=ee?1-ee:void 0,ne=e.textureProperties?._SphereAdd,w=ne==null?void 0:[1,1,1],re=ne==null?void 0:{index:ne},T=e.floatProperties?._RimLightingMix??0,E=e.textureProperties?._RimTexture,D=E==null?void 0:{index:E,extensions:ul({},l)},O=(e.vectorProperties?._RimColor??[0,0,0,1]).map(pl),ie=e.floatProperties?._RimFresnelPower??1,ae=e.floatProperties?._RimLift??0,k=[`none`,`worldCoordinates`,`screenCoordinates`][e.floatProperties?._OutlineWidthMode??0],oe=e.floatProperties?._OutlineWidth??0;oe=.01*oe;let A=e.textureProperties?._OutlineWidthTexture,se=A==null?void 0:{index:A,extensions:ul({},l)},ce=(e.vectorProperties?._OutlineColor??[0,0,0]).map(pl),le=(e.floatProperties?._OutlineColorMode??0)===1?e.floatProperties?._OutlineLightingMix??1:0,ue=e.textureProperties?._UvAnimMaskTexture,j=ue==null?void 0:{index:ue,extensions:ul({},l)},de=e.floatProperties?._UvAnimScrollX??0,fe=e.floatProperties?._UvAnimScrollY??0;fe!=null&&(fe=-fe);let pe=e.floatProperties?._UvAnimRotation??0,me={specVersion:`1.0`,transparentWithZWrite:r,renderQueueOffsetNumber:i,shadeColorFactor:y,shadeMultiplyTexture:x,shadingShiftFactor:S,shadingToonyFactor:C,giEqualizationFactor:te,matcapFactor:w,matcapTexture:re,rimLightingMixFactor:T,rimMultiplyTexture:D,parametricRimColorFactor:O,parametricRimFresnelPowerFactor:ie,parametricRimLiftFactor:ae,outlineWidthMode:k,outlineWidthFactor:oe,outlineWidthMultiplyTexture:se,outlineColorFactor:ce,outlineLightingMixFactor:le,uvAnimationMaskTexture:j,uvAnimationScrollXSpeedFactor:de,uvAnimationScrollYSpeedFactor:fe,uvAnimationRotationSpeedFactor:pe};return dl(ul({},t),{pbrMetallicRoughness:{baseColorFactor:u,baseColorTexture:f},normalTexture:h,emissiveTexture:v,emissiveFactor:g,alphaMode:o,alphaCutoff:s,doubleSided:c,extensions:{VRMC_materials_mtoon:me}})}_parseV0UnlitProperties(e,t){let n=e.shader===`VRM/UnlitTransparentZWrite`,r=e.shader===`VRM/UnlitTransparent`||n,i=this._v0ParseRenderQueue(e),a=e.shader===`VRM/UnlitCutout`,o=r?`BLEND`:a?`MASK`:`OPAQUE`,s=a?e.floatProperties?._Cutoff??.5:void 0,c=this._portTextureTransform(e),l=(e.vectorProperties?._Color??[1,1,1,1]).map(pl),u=e.textureProperties?._MainTex,d=u==null?void 0:{index:u,extensions:ul({},c)},f={specVersion:`1.0`,transparentWithZWrite:n,renderQueueOffsetNumber:i,shadeColorFactor:l,shadeMultiplyTexture:d};return dl(ul({},t),{pbrMetallicRoughness:{baseColorFactor:l,baseColorTexture:d},alphaMode:o,alphaCutoff:s,extensions:{VRMC_materials_mtoon:f}})}_portTextureTransform(e){let t=e.vectorProperties?._MainTex;if(t==null)return{};let n=[t?.[0]??0,t?.[1]??0],r=[t?.[2]??1,t?.[3]??1];return n[1]=1-r[1]-n[1],{KHR_texture_transform:{offset:n,scale:r}}}_v0ParseRenderQueue(e){let t=e.shader===`VRM/UnlitTransparentZWrite`,n=e.keywordMap?._ALPHABLEND_ON!=null||e.shader===`VRM/UnlitTransparent`||t,r=e.floatProperties?._ZWrite===1||t,i=0;if(n){let t=e.renderQueue;t!=null&&(i=r?this._renderQueueMapTransparentZWrite.get(t):this._renderQueueMapTransparent.get(t))}return i}_populateRenderQueueMap(e){let t=new Set,n=new Set;e.forEach(e=>{let r=e.shader===`VRM/UnlitTransparentZWrite`,i=e.keywordMap?._ALPHABLEND_ON!=null||e.shader===`VRM/UnlitTransparent`||r,a=e.floatProperties?._ZWrite===1||r;if(i){let r=e.renderQueue;r!=null&&(a?n.add(r):t.add(r))}}),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),n.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${n.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(t).sort().forEach((e,n)=>{let r=Math.min(Math.max(n-t.size+1,-9),0);this._renderQueueMapTransparent.set(e,r)}),Array.from(n).sort().forEach((e,t)=>{let n=Math.min(Math.max(t,0),9);this._renderQueueMapTransparentZWrite.set(e,n)})}},hl=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),gl=new F,_l=class extends P{constructor(e){super(),this._attrPosition=new V(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(O);let t=new Gt;t.setAttribute(`position`,this._attrPosition),this._line=new Ue(t,new qe({color:16711935,depthTest:!1,depthWrite:!1})),this.add(this._line),this.constraint=e}updateMatrixWorld(e){gl.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,gl.x,gl.y,gl.z),this.constraint.source&&gl.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,gl.x,gl.y,gl.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(e)}};function vl(e,t){return t.set(e.elements[12],e.elements[13],e.elements[14])}var yl=new F,bl=new F;function xl(e,t){return e.decompose(yl,t,bl),t}function Sl(e){return e.invert?e.invert():e.inverse(),e}var Cl=class{constructor(e,t){this.destination=e,this.source=t,this.weight=1}},wl=new F,Tl=new F,El=new F,Dl=new R,Ol=new R,kl=new R,Al=class extends Cl{get aimAxis(){return this._aimAxis}set aimAxis(e){this._aimAxis=e,this._v3AimAxis.set(e===`PositiveX`?1:e===`NegativeX`?-1:0,e===`PositiveY`?1:e===`NegativeY`?-1:0,e===`PositiveZ`?1:e===`NegativeZ`?-1:0)}get dependencies(){let e=new Set([this.source]);return this.destination.parent&&e.add(this.destination.parent),e}constructor(e,t){super(e,t),this._aimAxis=`PositiveX`,this._v3AimAxis=new F(1,0,0),this._dstRestQuat=new R}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let e=Dl.identity(),t=Ol.identity();this.destination.parent&&(xl(this.destination.parent.matrixWorld,e),Sl(t.copy(e)));let n=wl.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(e),r=vl(this.source.matrixWorld,Tl).sub(vl(this.destination.matrixWorld,El)).normalize(),i=kl.setFromUnitVectors(n,r).premultiply(t).multiply(e).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}};function jl(e,t){let n=[e],r=e.parent;for(;r!==null;)n.unshift(r),r=r.parent;n.forEach(e=>{t(e)})}var Ml=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(e){this._constraints.add(e);let t=this._objectConstraintsMap.get(e.destination);t??(t=new Set,this._objectConstraintsMap.set(e.destination,t)),t.add(e)}deleteConstraint(e){this._constraints.delete(e),this._objectConstraintsMap.get(e.destination).delete(e)}setInitState(){let e=new Set,t=new Set;for(let n of this._constraints)this._processConstraint(n,e,t,e=>e.setInitState())}update(){let e=new Set,t=new Set;for(let n of this._constraints)this._processConstraint(n,e,t,e=>e.update())}_processConstraint(e,t,n,r){if(n.has(e))return;if(t.has(e))throw Error(`VRMNodeConstraintManager: Circular dependency detected while updating constraints`);t.add(e);let i=e.dependencies;for(let e of i)jl(e,e=>{let i=this._objectConstraintsMap.get(e);if(i)for(let e of i)this._processConstraint(e,t,n,r)});r(e),n.add(e)}},Nl=new R,Pl=new R,Fl=class extends Cl{get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),this._dstRestQuat=new R,this._invSrcRestQuat=new R}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Sl(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let e=Nl.copy(this._invSrcRestQuat).multiply(this.source.quaternion),t=Pl.copy(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(t,this.weight)}},Il=new F,Ll=new R,Rl=new R,zl=class extends Cl{get rollAxis(){return this._rollAxis}set rollAxis(e){this._rollAxis=e,this._v3RollAxis.set(e===`X`?1:0,e===`Y`?1:0,e===`Z`?1:0)}get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),this._rollAxis=`X`,this._v3RollAxis=new F(1,0,0),this._dstRestQuat=new R,this._invDstRestQuat=new R,this._invSrcRestQuatMulDstRestQuat=new R}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Sl(this._invDstRestQuat.copy(this._dstRestQuat)),Sl(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let e=Ll.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),t=Il.copy(this._v3RollAxis).applyQuaternion(e),n=Rl.setFromUnitVectors(t,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(n,this.weight)}},Bl=new Set([`1.0`,`1.0-beta`]),Vl=class e{get name(){return e.EXTENSION_NAME}constructor(e,t){this.parser=e,this.helperRoot=t?.helperRoot}afterRoot(e){return hl(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(t){return hl(this,null,function*(){let n=this.parser.json;if(n.extensionsUsed?.indexOf(e.EXTENSION_NAME)===-1)return null;let r=new Ml,i=yield this.parser.getDependencies(`node`);return i.forEach((t,a)=>{let o=n.nodes[a]?.extensions?.[e.EXTENSION_NAME];if(o==null)return;let s=o.specVersion;if(!Bl.has(s)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${s}"`);return}let c=o.constraint;if(c.roll!=null){let e=this._importRollConstraint(t,i,c.roll);r.addConstraint(e)}else if(c.aim!=null){let e=this._importAimConstraint(t,i,c.aim);r.addConstraint(e)}else if(c.rotation!=null){let e=this._importRotationConstraint(t,i,c.rotation);r.addConstraint(e)}}),t.scene.updateMatrixWorld(),r.setInitState(),r})}_importRollConstraint(e,t,n){let{source:r,rollAxis:i,weight:a}=n,o=t[r],s=new zl(e,o);if(i!=null&&(s.rollAxis=i),a!=null&&(s.weight=a),this.helperRoot){let e=new _l(s);this.helperRoot.add(e)}return s}_importAimConstraint(e,t,n){let{source:r,aimAxis:i,weight:a}=n,o=t[r],s=new Al(e,o);if(i!=null&&(s.aimAxis=i),a!=null&&(s.weight=a),this.helperRoot){let e=new _l(s);this.helperRoot.add(e)}return s}_importRotationConstraint(e,t,n){let{source:r,weight:i}=n,a=t[r],o=new Fl(e,a);if(i!=null&&(o.weight=i),this.helperRoot){let e=new _l(o);this.helperRoot.add(e)}return o}};Vl.EXTENSION_NAME=`VRMC_node_constraint`;var Hl=Vl,Ul=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Wl=class{},Gl=new F,Kl=new F,ql=class extends Wl{get type(){return`capsule`}constructor(e){super(),this.offset=e?.offset??new F(0,0,0),this.tail=e?.tail??new F(0,0,0),this.radius=e?.radius??0,this.inside=e?.inside??!1}calculateCollision(e,t,n,r){Gl.setFromMatrixPosition(e),Kl.subVectors(this.tail,this.offset).applyMatrix4(e),Kl.sub(Gl);let i=Kl.lengthSq();r.copy(t).sub(Gl);let a=Kl.dot(r);a<=0||(i<=a||Kl.multiplyScalar(a/i),r.sub(Kl));let o=r.length(),s=this.inside?this.radius-n-o:o-n-this.radius;return s<0&&(r.multiplyScalar(1/o),this.inside&&r.negate()),s}},Jl=new F,Yl=new bt,Xl=class extends Wl{get type(){return`plane`}constructor(e){super(),this.offset=e?.offset??new F(0,0,0),this.normal=e?.normal??new F(0,0,1)}calculateCollision(e,t,n,r){r.setFromMatrixPosition(e),r.negate().add(t),Yl.getNormalMatrix(e),Jl.copy(this.normal).applyNormalMatrix(Yl).normalize();let i=r.dot(Jl)-n;return r.copy(Jl),i}},Zl=new F,Ql=class extends Wl{get type(){return`sphere`}constructor(e){super(),this.offset=e?.offset??new F(0,0,0),this.radius=e?.radius??0,this.inside=e?.inside??!1}calculateCollision(e,t,n,r){r.subVectors(t,Zl.setFromMatrixPosition(e));let i=r.length(),a=this.inside?this.radius-n-i:i-n-this.radius;return a<0&&(r.multiplyScalar(1/i),this.inside&&r.negate()),a}},$l=new F,eu=class extends Gt{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new F,this._currentTail=new F,this._shape=e,this._attrPos=new V(new Float32Array(396),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let n=$l.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),e=!0),e&&this._buildPosition()}_buildPosition(){$l.copy(this._currentTail).sub(this._currentOffset);let e=$l.length()/this._currentRadius;for(let t=0;t<=16;t++){let n=t/16*Math.PI;this._attrPos.setXYZ(t,-Math.sin(n),-Math.cos(n),0),this._attrPos.setXYZ(17+t,e+Math.sin(n),Math.cos(n),0),this._attrPos.setXYZ(34+t,-Math.sin(n),0,-Math.cos(n)),this._attrPos.setXYZ(51+t,e+Math.sin(n),0,Math.cos(n))}for(let t=0;t<32;t++){let n=t/16*Math.PI;this._attrPos.setXYZ(68+t,0,Math.sin(n),Math.cos(n)),this._attrPos.setXYZ(100+t,e,Math.sin(n),Math.cos(n))}let t=Math.atan2($l.y,Math.sqrt($l.x*$l.x+$l.z*$l.z)),n=-Math.atan2($l.z,$l.x);this.rotateZ(t),this.rotateY(n),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){let t=(e+1)%34;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(68+e*2,34+e,34+t)}for(let e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+t),this._attrIndex.setXY(200+e*2,100+e,100+t)}this._attrIndex.needsUpdate=!0}},tu=class extends Gt{constructor(e){super(),this.worldScale=1,this._currentOffset=new F,this._currentNormal=new F,this._shape=e,this._attrPos=new V(new Float32Array(18),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},nu=class extends Gt{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new F,this._shape=e,this._attrPos=new V(new Float32Array(288),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(192),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.needsUpdate=!0}},ru=new F,iu=class extends P{constructor(e){if(super(),this.matrixAutoUpdate=!1,this.collider=e,this.collider.shape instanceof Ql)this._geometry=new nu(this.collider.shape);else if(this.collider.shape instanceof ql)this._geometry=new eu(this.collider.shape);else if(this.collider.shape instanceof Xl)this._geometry=new tu(this.collider.shape);else throw Error(`VRMSpringBoneColliderHelper: Unknown collider shape type detected`);let t=new qe({color:16711935,depthTest:!1,depthWrite:!1});this._line=new E(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let t=this.matrix.elements;this._geometry.worldScale=ru.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},au=class extends Gt{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new F,this._springBone=e,this._attrPos=new V(new Float32Array(294),3),this.setAttribute(`position`,this._attrPos),this._attrIndex=new V(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},ou=new F,su=class extends P{constructor(e){super(),this.matrixAutoUpdate=!1,this.springBone=e,this._geometry=new au(this.springBone);let t=new qe({color:16776960,depthTest:!1,depthWrite:!1});this._line=new E(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let t=this.matrix.elements;this._geometry.worldScale=ou.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},cu=class extends A{constructor(e){super(),this.colliderMatrix=new B,this.shape=e}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),lu(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function lu(e,t,n){let r=t.elements;e.copy(t),n&&(e.elements[12]=r[0]*n.x+r[4]*n.y+r[8]*n.z+r[12],e.elements[13]=r[1]*n.x+r[5]*n.y+r[9]*n.z+r[13],e.elements[14]=r[2]*n.x+r[6]*n.y+r[10]*n.z+r[14])}var uu=new B;function du(e){return e.invert?e.invert():e.getInverse(uu.copy(e)),e}var fu=class{constructor(e){this._inverseCache=new B,this._shouldUpdateInverse=!0,this.matrix=e,this._originalElements=e.elements,e.elements=new Proxy(e.elements,{set:(e,t,n)=>(this._shouldUpdateInverse=!0,e[t]=n,!0)})}get inverse(){return this._shouldUpdateInverse&&=(du(this._inverseCache.copy(this.matrix)),!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},pu=new B,mu=new F,hu=new F,gu=new F,_u=new F,vu=new B,yu=class{constructor(e,t,n={},r=[]){this._currentTail=new F,this._prevTail=new F,this._boneAxis=new F,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new B,this._initialLocalRotation=new R,this._initialLocalChildPosition=new F,this.bone=e,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:n.hitRadius??0,stiffness:n.stiffness??1,gravityPower:n.gravityPower??0,gravityDir:n.gravityDir?.clone()??new F(0,-1,0),dragForce:n.dragForce??.4},this.colliderGroups=r}get dependencies(){let e=new Set,t=this.bone.parent;t&&e.add(t);for(let t=0;t{t(e)})}function xu(e,t){e.children.forEach(e=>{t(e)||xu(e,t)})}function Su(e){let t=new Map;for(let n of e){let r=n;do{let n=(t.get(r)??0)+1;if(n===e.size)return r;t.set(r,n),r=r.parent}while(r!==null)}return null}var Cu=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn(`VRMSpringBoneManager: springBones is deprecated. use joints instead.`),this._joints}get colliderGroups(){let e=new Set;return this._joints.forEach(t=>{t.colliderGroups.forEach(t=>{e.add(t)})}),Array.from(e)}get colliders(){let e=new Set;return this.colliderGroups.forEach(t=>{t.colliders.forEach(t=>{e.add(t)})}),Array.from(e)}addJoint(e){this._joints.add(e);let t=this._objectSpringBonesMap.get(e.bone);t??(t=new Set,this._objectSpringBonesMap.set(e.bone,t)),t.add(e),this._isSortedJointsDirty=!0}addSpringBone(e){console.warn(`VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead.`),this.addJoint(e)}deleteJoint(e){this._joints.delete(e),this._objectSpringBonesMap.get(e.bone).delete(e),this._isSortedJointsDirty=!0}deleteSpringBone(e){console.warn(`VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead.`),this.deleteJoint(e)}setInitState(){this._sortJoints();for(let e=0;e(this._objectSpringBonesMap.get(e)?.size??0)>0?!0:(this._ancestors.push(e),!1))),this._isSortedJointsDirty=!1}_insertJointSort(e,t,n,r,i){if(n.has(e))return;if(t.has(e)){this._hasWarnedCircularDependency||=(console.warn(`VRMSpringBoneManager: Circular dependency detected`),!0);return}t.add(e);let a=e.dependencies;for(let e of a){let a=!1,o=null;bu(e,e=>{let s=this._objectSpringBonesMap.get(e);if(s)for(let e of s)a=!0,this._insertJointSort(e,t,n,r,i);else a||(o=e)}),o&&i.add(o)}r.push(e),n.add(e)}_relevantChildrenUpdated(e){return(this._objectSpringBonesMap.get(e)?.size??0)>0?!0:(e.updateWorldMatrix(!1,!1),!1)}},wu=`VRMC_springBone_extended_collider`,Tu=new Set([`1.0`,`1.0-beta`]),Eu=new Set([`1.0`]),Du=class e{get name(){return e.EXTENSION_NAME}constructor(e,t){this.parser=e,this.jointHelperRoot=t?.jointHelperRoot,this.colliderHelperRoot=t?.colliderHelperRoot,this.useExtendedColliders=t?.useExtendedColliders??!0}afterRoot(e){return Ul(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return Ul(this,null,function*(){return(yield this._v1Import(e))??(yield this._v0Import(e))??null})}_v1Import(t){return Ul(this,null,function*(){var n;let r=t.parser.json;if(r.extensionsUsed?.indexOf(e.EXTENSION_NAME)===-1)return null;let i=new Cu,a=yield t.parser.getDependencies(`node`),o=r.extensions?.[e.EXTENSION_NAME];if(!o)return null;let s=o.specVersion;if(!Tu.has(s))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${s}"`),null;let c=o.colliders?.map((t,n)=>{let r=a[t.node];if(r==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${n} attempted to use the node #${t.node} but not found`),null;let i=t.shape,o=t.extensions?.[wu];if(this.useExtendedColliders&&o!=null){let t=o.specVersion;if(!Eu.has(t))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${wu} specVersion "${t}". Fallbacking to the ${e.EXTENSION_NAME} definition`);else{let e=o.shape;if(e.sphere)return this._importSphereCollider(r,{offset:new F().fromArray(e.sphere.offset??[0,0,0]),radius:e.sphere.radius??0,inside:e.sphere.inside??!1});if(e.capsule)return this._importCapsuleCollider(r,{offset:new F().fromArray(e.capsule.offset??[0,0,0]),radius:e.capsule.radius??0,tail:new F().fromArray(e.capsule.tail??[0,0,0]),inside:e.capsule.inside??!1});if(e.plane)return this._importPlaneCollider(r,{offset:new F().fromArray(e.plane.offset??[0,0,0]),normal:new F().fromArray(e.plane.normal??[0,0,1])})}}if(i.sphere)return this._importSphereCollider(r,{offset:new F().fromArray(i.sphere.offset??[0,0,0]),radius:i.sphere.radius??0,inside:!1});if(i.capsule)return this._importCapsuleCollider(r,{offset:new F().fromArray(i.capsule.offset??[0,0,0]),radius:i.capsule.radius??0,tail:new F().fromArray(i.capsule.tail??[0,0,0]),inside:!1});throw Error(`VRMSpringBoneLoaderPlugin: The collider #${n} has no valid shape`)}),l=o.colliderGroups?.map((e,t)=>({colliders:(e.colliders??[]).flatMap(e=>c?.[e]??(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${t} attempted to use a collider #${e} but not found`),[])),name:e.name}));return(n=o.springs)==null||n.forEach((e,t)=>{let n=e.joints,r=e.colliderGroups?.map(e=>{let n=l?.[e];if(n==null)throw Error(`VRMSpringBoneLoaderPlugin: The spring #${t} attempted to use a colliderGroup ${e} but not found`);return n}),o=e.center==null?void 0:a[e.center],s;n.forEach(e=>{if(s){let t=a[s.node],n=a[e.node],c={hitRadius:s.hitRadius,dragForce:s.dragForce,gravityPower:s.gravityPower,stiffness:s.stiffness,gravityDir:s.gravityDir==null?void 0:new F().fromArray(s.gravityDir)},l=this._importJoint(t,n,c,r);o&&(l.center=o),i.addJoint(l)}s=e})}),i.setInitState(),i})}_v0Import(e){return Ul(this,null,function*(){let t=e.parser.json;if(t.extensionsUsed?.indexOf(`VRM`)===-1)return null;let n=t.extensions?.VRM?.secondaryAnimation;if(!n)return null;let r=n?.boneGroups;if(!r)return null;let i=new Cu,a=yield e.parser.getDependencies(`node`),o=n.colliderGroups?.map(e=>{let t=a[e.node];return{colliders:(e.colliders??[]).map((e,n)=>{let r=new F(0,0,0);return e.offset&&r.set(e.offset.x??0,e.offset.y??0,e.offset.z?-e.offset.z:0),this._importSphereCollider(t,{offset:r,radius:e.radius??0,inside:!1})})}});return r?.forEach((e,t)=>{let n=e.bones;n&&n.forEach(n=>{let r=a[n],s=new F;e.gravityDir?s.set(e.gravityDir.x??0,e.gravityDir.y??0,e.gravityDir.z??0):s.set(0,-1,0);let c=e.center==null?void 0:a[e.center],l={hitRadius:e.hitRadius,dragForce:e.dragForce,gravityPower:e.gravityPower,stiffness:e.stiffiness,gravityDir:s},u=e.colliderGroups?.map(e=>{let n=o?.[e];if(n==null)throw Error(`VRMSpringBoneLoaderPlugin: The spring #${t} attempted to use a colliderGroup ${e} but not found`);return n});r.traverse(e=>{let t=e.children[0]??null,n=this._importJoint(e,t,l,u);c&&(n.center=c),i.addJoint(n)})})}),e.scene.updateMatrixWorld(),i.setInitState(),i})}_importJoint(e,t,n,r){let i=new yu(e,t,n,r);if(this.jointHelperRoot){let e=new su(i);this.jointHelperRoot.add(e),e.renderOrder=this.jointHelperRoot.renderOrder}return i}_importSphereCollider(e,t){let n=new cu(new Ql(t));if(e.add(n),this.colliderHelperRoot){let e=new iu(n);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return n}_importCapsuleCollider(e,t){let n=new cu(new ql(t));if(e.add(n),this.colliderHelperRoot){let e=new iu(n);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return n}_importPlaneCollider(e,t){let n=new cu(new Xl(t));if(e.add(n),this.colliderHelperRoot){let e=new iu(n);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return n}};Du.EXTENSION_NAME=`VRMC_springBone`;var Ou=Du,ku=class{get name(){return`VRMLoaderPlugin`}constructor(e,t){this.parser=e;let n=t?.helperRoot,r=t?.autoUpdateHumanBones;this.expressionPlugin=t?.expressionPlugin??new Ts(e),this.firstPersonPlugin=t?.firstPersonPlugin??new ks(e),this.humanoidPlugin=t?.humanoidPlugin??new Js(e,{helperRoot:n,autoUpdateHumanBones:r}),this.lookAtPlugin=t?.lookAtPlugin??new Ac(e,{helperRoot:n}),this.metaPlugin=t?.metaPlugin??new Nc(e),this.mtoonMaterialPlugin=t?.mtoonMaterialPlugin??new $c(e),this.materialsHDREmissiveMultiplierPlugin=t?.materialsHDREmissiveMultiplierPlugin??new nl(e),this.materialsV0CompatPlugin=t?.materialsV0CompatPlugin??new ml(e),this.springBonePlugin=t?.springBonePlugin??new Ou(e,{colliderHelperRoot:n,jointHelperRoot:n}),this.nodeConstraintPlugin=t?.nodeConstraintPlugin??new Hl(e,{helperRoot:n})}beforeRoot(){return os(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return os(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)})}getMaterialType(e){return this.mtoonMaterialPlugin.getMaterialType(e)??null}extendMaterialParams(e,t){return os(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,t),yield this.mtoonMaterialPlugin.extendMaterialParams(e,t)})}afterRoot(e){return os(this,null,function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);let t=e.userData.vrmMeta,n=e.userData.vrmHumanoid;if(t&&n){let r=new Fc({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:n,lookAt:e.userData.vrmLookAt,meta:t,materials:e.userData.vrmMToonMaterials,springBoneManager:e.userData.vrmSpringBoneManager,nodeConstraintManager:e.userData.vrmNodeConstraintManager});e.userData.vrm=r}})}};function Au(e){let t=new Set;return e.traverse(e=>{if(!e.isMesh)return;let n=e;t.add(n)}),t}function ju(e,t,n){if(t.size===1){let n=t.values().next().value;if(n.weight===1)return e[n.index]}let r=new Float32Array(e[0].count*3),i=0;if(n)i=1;else for(let e of t)i+=e.weight;for(let n of t){let t=e[n.index],a=n.weight/i;for(let e=0;el.getOrCreate(e)).join(`,`)}`,u=o.get(c);u??(u=t.clone(),Bu(u,i,r),o.set(c,u)),e.geometry.setAttribute(`skinIndex`,u)}for(let e of n)e.bind(i,new B)}}function Iu(e){let t=new Set;return e.traverse(e=>{if(!e.isSkinnedMesh)return;let n=e;t.add(n)}),t}function Lu(e,t){let n=new Set;for(let r=0;rn)return!1;return!0}var Hu=class{constructor(){this._objectIndexMap=new Map,this._index=0}get(e){return this._objectIndexMap.get(e)}getOrCreate(e){let t=this._objectIndexMap.get(e);return t??(t=this._index,this._objectIndexMap.set(e,t),this._index++),t}};function Uu(e){let t=new Gt;t.name=e.name,t.setIndex(e.index);for(let[n,r]of Object.entries(e.attributes))t.setAttribute(n,r);for(let[n,r]of Object.entries(e.morphAttributes)){let e=n;t.morphAttributes[e]=r.concat()}t.morphTargetsRelative=e.morphTargetsRelative,t.groups=[];for(let n of e.groups)t.addGroup(n.start,n.count,n.materialIndex);return t.boundingSphere=e.boundingSphere?.clone()??null,t.boundingBox=e.boundingBox?.clone()??null,t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t}function Wu(e){if(Object.values(e).forEach(e=>{e?.isTexture&&e.dispose()}),e.isShaderMaterial){let t=e.uniforms;t&&Object.values(t).forEach(e=>{let t=e.value;t?.isTexture&&t.dispose()})}e.dispose()}function Gu(e){let t=e.geometry;t&&t.dispose();let n=e.skeleton;n&&n.dispose();let r=e.material;r&&(Array.isArray(r)?r.forEach(e=>Wu(e)):r&&Wu(r))}function Ku(e){e.traverse(Gu)}function qu(e,t){console.warn(`VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.`);let n=t?.experimentalSameBoneCounts??!1,r=[];e.traverse(e=>{e.type===`SkinnedMesh`&&r.push(e)});let i=new Map,a=0;for(let e of r){let t=e.geometry.getAttribute(`skinIndex`);if(i.has(t))continue;let n=new Map,r=new Map;for(let e=0;e{if(!e.isMesh)return;let n=e,r=n.geometry,i=r.index;if(i==null)return;let a=t.get(r);if(a!=null){n.geometry=a;return}let o=Object.values(r.attributes)[0].count,s=Array(o),c=0,l=i.array;for(let e=0;e{p.addGroup(e.start,e.count,e.materialIndex)}),p.boundingBox=r.boundingBox?.clone()??null,p.boundingSphere=r.boundingSphere?.clone()??null,p.setDrawRange(r.drawRange.start,r.drawRange.count),p.userData=r.userData,t.set(r,p);{let e=i.array,t=new e.constructor(e.length);for(let n=0;n{let t=r.attributes[e];if(t.isInterleavedBufferAttribute)throw Error(`removeUnnecessaryVertices: InterleavedBufferAttribute is not supported`);let n=t.array,{itemSize:i,normalized:a}=t,o=new n.constructor(d.length*i);d.forEach((e,t)=>{for(let r=0;r{for(let n=0;ne===0),p.morphAttributes[n][e]=new V(s,a,o)}}m&&(p.morphAttributes={}),n.geometry=p}),Array.from(t.keys()).forEach(e=>{e.dispose()})}function Yu(e){e.meta?.metaVersion===`0`&&(e.scene.rotation.y=Math.PI)}var Xu=class{constructor(){}};Xu.combineMorphs=Mu,Xu.combineSkeletons=Fu,Xu.deepDispose=Ku,Xu.removeUnnecessaryJoints=qu,Xu.removeUnnecessaryVertices=Ju,Xu.rotateVRM0=Yu;var Zu=` +#ifndef AIRI_DIFFUSE_VS_DECL +#define AIRI_DIFFUSE_VS_DECL +varying vec3 vWorldNormal; +#endif +`,Qu=` +#ifndef AIRI_DIFFUSE_VS_APPLY +#define AIRI_DIFFUSE_VS_APPLY +vWorldNormal = normalize( mat3( modelMatrix ) * objectNormal ); +#endif +`,$u=` +#ifndef AIRI_DIFFUSE_COMMON +#define AIRI_DIFFUSE_COMMON +uniform int uNprEnvMode; // 0=off, 2=skybox +uniform float uEnvIntensity; +uniform vec3 uSHCoeffs[9]; +varying vec3 vWorldNormal; + +// 3rd-order SH constants +const float C0=0.2820947918; +const float C1=0.4886025119; +const float C2=1.0925484306; +const float C3=0.3153915653; +const float C4=0.5462742153; + +vec3 AIRI_evalIrradianceSH(vec3 n){ + n = normalize(n); + vec3 r = uSHCoeffs[0]*C0; + r += uSHCoeffs[1]*(-C1*n.y); + r += uSHCoeffs[2]*( C1*n.z); + r += uSHCoeffs[3]*(-C1*n.x); + r += uSHCoeffs[4]*( C2*n.x*n.y); + r += uSHCoeffs[5]*(-C2*n.y*n.z); + r += uSHCoeffs[6]*( C3*(3.0*n.z*n.z-1.0)); + r += uSHCoeffs[7]*(-C2*n.x*n.z); + r += uSHCoeffs[8]*( C4*(n.x*n.x-n.y*n.y)); + return r; +} +#endif +`,ed=` +#ifndef AIRI_DIFFUSE_APPLY +#define AIRI_DIFFUSE_APPLY +if (uNprEnvMode == 2) { + vec3 I = AIRI_evalIrradianceSH(normalize(vWorldNormal)); + gl_FragColor.rgb += (gl_FragColor.rgb / PI) * I * uEnvIntensity; +} +#endif +`;function td(e){return e===`skyBox`?`skyBox`:e===`hemisphere`?`hemisphere`:`off`}function nd(e,t){if(!(!e?.uSHCoeffs||!e.uSHCoeffs.value||!Array.isArray(e.uSHCoeffs.value))&&t)for(let n=0;n<9;n++)e.uSHCoeffs.value[n]||=new F,e.uSHCoeffs.value[n].copy(t.coefficients[n])}function rd(e){let t=e.customProgramCacheKey?.()??``;e.customProgramCacheKey=()=>`${t}|airi-diffuse-ibl`;let n=e.onBeforeCompile;e.onBeforeCompile=(t,r)=>{n?.(t,r),t.vertexShader.includes(`AIRI_DIFFUSE_VS_DECL`)||(t.vertexShader=`${Zu}\n${t.vertexShader}`),t.vertexShader.includes(`#include `)&&!t.vertexShader.includes(`AIRI_DIFFUSE_VS_APPLY`)&&(t.vertexShader=t.vertexShader.replace(`#include `,`#include \n${Qu}`)),t.fragmentShader.includes(`AIRI_DIFFUSE_COMMON`)||(t.fragmentShader=t.fragmentShader.replace(`#include `,`#include \n${$u}`)),t.fragmentShader.includes(`AIRI_DIFFUSE_APPLY`)||(t.fragmentShader=t.fragmentShader.replace(`#include `,`${ed}\n#include `));let i=Array.from({length:9},()=>new F);t.uniforms.uNprEnvMode||={value:0},t.uniforms.uEnvIntensity||={value:0},t.uniforms.uSHCoeffs||={value:i},(e.userData||={}).__airiIbl=t.uniforms},`toneMapped`in e&&(e.toneMapped=!1),e.needsUpdate=!0}function id(e,t){let n=t.mode===`skyBox`?2:0;e.traverse(e=>{let r=e.material;(r?Array.isArray(r)?r:[r]:[]).forEach(e=>{let r=e?.userData?.__airiIbl;r&&(r.uNprEnvMode.value=n,r.uEnvIntensity.value=t.intensity,nd(r,t.sh??null))})})}function ad(e){let t=new Ge;t.name=`AIRI_IBL_Probe`,e.add(t);function n(e,n,r){t.intensity=e===`skyBox`?n:0,r&&t.sh.copy(r)}function r(){t.parent?.remove(t)}return{update:n,dispose:r}}var od=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Q=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),sd=class extends A{constructor(e){super(),this.weight=0,this.isBinary=!1,this.overrideBlink=`none`,this.overrideLookAt=`none`,this.overrideMouth=`none`,this._binds=[],this.name=`VRMExpression_${e}`,this.expressionName=e,this.type=`VRMExpression`,this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink===`block`?0.5?1:0:this.weight}addBind(e){this._binds.push(e)}deleteBind(e){let t=this._binds.indexOf(e);t>=0&&this._binds.splice(t,1)}applyWeight(e){let t=this.outputWeight;t*=e?.multiplier??1,this.isBinary&&t<1&&(t=0),this._binds.forEach(e=>e.applyWeight(t))}clearAppliedWeight(){this._binds.forEach(e=>e.clearAppliedWeight())}};function cd(e,t,n){let r=e.parser.json,i=r.nodes?.[t];if(i==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${t}] of glTF but the node doesn't exist`),null;let a=i.mesh;if(a==null)return null;let o=r.meshes?.[a];if(o==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${a}] of glTF but the mesh doesn't exist`),null;let s=o.primitives.length,c=[];return n.traverse(e=>{c.length{t.has(n)&&(e[n]=r)}),e}get customExpressionMap(){let e={},t=new Set(Object.values(ud));return Object.entries(this._expressionMap).forEach(([n,r])=>{t.has(n)||(e[n]=r)}),e}copy(e){return this._expressions.concat().forEach(e=>{this.unregisterExpression(e)}),e._expressions.forEach(e=>{this.registerExpression(e)}),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return new e().copy(this)}getExpression(e){return this._expressionMap[e]??null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){let t=this._expressions.indexOf(e);t===-1&&console.warn(`VRMExpressionManager: The specified expressions is not registered`),this._expressions.splice(t,1),delete this._expressionMap[e.expressionName]}getValue(e){return this.getExpression(e)?.weight??null}setValue(e,t){let n=this.getExpression(e);n&&(n.weight=dd(t))}resetValues(){this._expressions.forEach(e=>{e.weight=0})}getExpressionTrackName(e){let t=this.getExpression(e);return t?`${t.name}.weight`:null}update(){let e=this._calculateWeightMultipliers();this._expressions.forEach(e=>{e.clearAppliedWeight()}),this._expressions.forEach(t=>{let n=1,r=t.expressionName;this.blinkExpressionNames.indexOf(r)!==-1&&(n*=e.blink),this.lookAtExpressionNames.indexOf(r)!==-1&&(n*=e.lookAt),this.mouthExpressionNames.indexOf(r)!==-1&&(n*=e.mouth),t.applyWeight({multiplier:n})})}_calculateWeightMultipliers(){let e=1,t=1,n=1;return this._expressions.forEach(r=>{e-=r.overrideBlinkAmount,t-=r.overrideLookAtAmount,n-=r.overrideMouthAmount}),e=Math.max(0,e),t=Math.max(0,t),n=Math.max(0,n),{blink:e,lookAt:t,mouth:n}}},pd={Color:`color`,EmissionColor:`emissionColor`,ShadeColor:`shadeColor`,MatcapColor:`matcapColor`,RimColor:`rimColor`,OutlineColor:`outlineColor`},md={_Color:pd.Color,_EmissionColor:pd.EmissionColor,_ShadeColor:pd.ShadeColor,_RimColor:pd.RimColor,_OutlineColor:pd.OutlineColor},hd=new H,gd=class e{constructor({material:e,type:t,targetValue:n,targetAlpha:r}){this.material=e,this.type=t,this.targetValue=n,this.targetAlpha=r??1,this._state={color:this._initColorBindState(),alpha:this._initAlphaBindState()}}applyWeight(e){let{color:t,alpha:n}=this._state;if(t!=null){let{propertyName:n,deltaValue:r}=t;this.material[n]?.add(hd.copy(r).multiplyScalar(e))}if(n!=null){let{propertyName:t,deltaValue:r}=n;this.material[t]!=null&&(this.material[t]+=r*e)}}clearAppliedWeight(){let{color:e,alpha:t}=this._state;if(e!=null){let{propertyName:t,initialValue:n}=e;this.material[t]?.copy(n)}if(t!=null){let{propertyName:e,initialValue:n}=t;this.material[e]!=null&&(this.material[e]=n)}}_initColorBindState(){let{material:e,type:t,targetValue:n}=this,r=this._getPropertyNameMap()?.[t]?.[0]??null;if(r==null)return console.warn(`Tried to add a material color bind to the material ${e.name??`(no name)`}, the type ${t} but the material or the type is not supported.`),null;let i=e[r].clone();return{propertyName:r,initialValue:i,deltaValue:new H(n.r-i.r,n.g-i.g,n.b-i.b)}}_initAlphaBindState(){let{material:e,type:t,targetAlpha:n}=this,r=this._getPropertyNameMap()?.[t]?.[1]??null;if(r==null&&n!==1)return console.warn(`Tried to add a material alpha bind to the material ${e.name??`(no name)`}, the type ${t} but the material or the type does not support alpha.`),null;if(r==null)return null;let i=e[r];return{propertyName:r,initialValue:i,deltaValue:n-i}}_getPropertyNameMap(){return Object.entries(e._propertyNameMapMap).find(([e])=>this.material[e]===!0)?.[1]??null}};gd._propertyNameMapMap={isMeshStandardMaterial:{color:[`color`,`opacity`],emissionColor:[`emissive`,null]},isMeshBasicMaterial:{color:[`color`,`opacity`]},isMToonMaterial:{color:[`color`,`opacity`],emissionColor:[`emissive`,null],outlineColor:[`outlineColorFactor`,null],matcapColor:[`matcapFactor`,null],rimColor:[`parametricRimColorFactor`,null],shadeColor:[`shadeColorFactor`,null]}};var _d=gd,vd=class{constructor({primitives:e,index:t,weight:n}){this.primitives=e,this.index=t,this.weight=n}applyWeight(e){this.primitives.forEach(t=>{t.morphTargetInfluences?.[this.index]!=null&&(t.morphTargetInfluences[this.index]+=this.weight*e)})}clearAppliedWeight(){this.primitives.forEach(e=>{e.morphTargetInfluences?.[this.index]!=null&&(e.morphTargetInfluences[this.index]=0)})}},yd=new L,bd=class e{constructor({material:t,scale:n,offset:r}){this.material=t,this.scale=n,this.offset=r;let i=Object.entries(e._propertyNamesMap).find(([e])=>t[e]===!0)?.[1];i==null?(console.warn(`Tried to add a texture transform bind to the material ${t.name??`(no name)`} but the material is not supported.`),this._properties=[]):(this._properties=[],i.forEach(e=>{let i=t[e]?.clone();if(!i)return null;t[e]=i;let a=i.offset.clone(),o=i.repeat.clone(),s=r.clone().sub(a),c=n.clone().sub(o);this._properties.push({name:e,initialOffset:a,deltaOffset:s,initialScale:o,deltaScale:c})}))}applyWeight(e){this._properties.forEach(t=>{let n=this.material[t.name];n!==void 0&&(n.offset.add(yd.copy(t.deltaOffset).multiplyScalar(e)),n.repeat.add(yd.copy(t.deltaScale).multiplyScalar(e)))})}clearAppliedWeight(){this._properties.forEach(e=>{let t=this.material[e.name];t!==void 0&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))})}};bd._propertyNamesMap={isMeshStandardMaterial:[`map`,`emissiveMap`,`bumpMap`,`normalMap`,`displacementMap`,`roughnessMap`,`metalnessMap`,`alphaMap`],isMeshBasicMaterial:[`map`,`specularMap`,`alphaMap`],isMToonMaterial:[`map`,`normalMap`,`emissiveMap`,`shadeMultiplyTexture`,`rimMultiplyTexture`,`outlineWidthMultiplyTexture`,`uvAnimationMaskTexture`]};var xd=bd,Sd=new Set([`1.0`,`1.0-beta`]),Cd=class e{get name(){return`VRMExpressionLoaderPlugin`}constructor(e){this.parser=e}afterRoot(e){return Q(this,null,function*(){e.userData.vrmExpressionManager=yield this._import(e)})}_import(e){return Q(this,null,function*(){return(yield this._v1Import(e))||(yield this._v0Import(e))||null})}_v1Import(e){return Q(this,null,function*(){let t=this.parser.json;if(t.extensionsUsed?.indexOf(`VRMC_vrm`)===-1)return null;let n=t.extensions?.VRMC_vrm;if(!n)return null;let r=n.specVersion;if(!Sd.has(r))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${r}"`),null;let i=n.expressions;if(!i)return null;let a=new Set(Object.values(ud)),o=new Map;i.preset!=null&&Object.entries(i.preset).forEach(([e,t])=>{if(t!=null){if(!a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${e}" detected. Ignoring the expression`);return}o.set(e,t)}}),i.custom!=null&&Object.entries(i.custom).forEach(([e,t])=>{if(a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${e}". Ignoring the expression`);return}o.set(e,t)});let s=new fd;return yield Promise.all(Array.from(o.entries()).map(t=>Q(this,[t],function*([t,n]){var r,i,a;let o=new sd(t);if(e.scene.add(o),o.isBinary=n.isBinary??!1,o.overrideBlink=n.overrideBlink??`none`,o.overrideLookAt=n.overrideLookAt??`none`,o.overrideMouth=n.overrideMouth??`none`,(r=n.morphTargetBinds)==null||r.forEach(t=>Q(this,null,function*(){if(t.node===void 0||t.index===void 0)return;let r=yield ld(e,t.node),i=t.index;if(!r.every(e=>Array.isArray(e.morphTargetInfluences)&&i{let n=e.material;n&&(Array.isArray(n)?t.push(...n):t.push(n))}),(i=n.materialColorBinds)==null||i.forEach(e=>Q(this,null,function*(){t.filter(t=>{let n=this.parser.associations.get(t)?.materials;return e.material===n}).forEach(t=>{o.addBind(new _d({material:t,type:e.type,targetValue:new H().fromArray(e.targetValue),targetAlpha:e.targetValue[3]}))})})),(a=n.textureTransformBinds)==null||a.forEach(e=>Q(this,null,function*(){t.filter(t=>{let n=this.parser.associations.get(t)?.materials;return e.material===n}).forEach(t=>{o.addBind(new xd({material:t,offset:new L().fromArray(e.offset??[0,0]),scale:new L().fromArray(e.scale??[1,1])}))})}))}s.registerExpression(o)}))),s})}_v0Import(t){return Q(this,null,function*(){let n=this.parser.json,r=n.extensions?.VRM;if(!r)return null;let i=r.blendShapeMaster;if(!i)return null;let a=new fd,o=i.blendShapeGroups;if(!o)return a;let s=new Set;return yield Promise.all(o.map(r=>Q(this,null,function*(){let i=r.presetName,o=(i!=null&&e.v0v1PresetNameMap[i]||null)??r.name;if(o==null){console.warn(`VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression`);return}if(s.has(o)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${i} has duplicated entries. Ignoring the expression`);return}s.add(o);let c=new sd(o);t.scene.add(c),c.isBinary=r.isBinary??!1,r.binds&&r.binds.forEach(e=>Q(this,null,function*(){var i;if(e.mesh===void 0||e.index===void 0)return;let a=[];(i=n.nodes)==null||i.forEach((t,n)=>{t.mesh===e.mesh&&a.push(n)});let o=e.index;yield Promise.all(a.map(n=>Q(this,null,function*(){let i=yield ld(t,n);if(!i.every(e=>Array.isArray(e.morphTargetInfluences)&&o{if(e.materialName===void 0||e.propertyName===void 0||e.targetValue===void 0)return;let n=[];t.scene.traverse(t=>{if(t.material){let r=t.material;Array.isArray(r)?n.push(...r.filter(t=>(t.name===e.materialName||t.name===e.materialName+` (Outline)`)&&n.indexOf(t)===-1)):r.name===e.materialName&&n.indexOf(r)===-1&&n.push(r)}});let r=e.propertyName;n.forEach(t=>{if(r===`_MainTex_ST`){let n=new L(e.targetValue[0],e.targetValue[1]),r=new L(e.targetValue[2],e.targetValue[3]);r.y=1-r.y-n.y,c.addBind(new xd({material:t,scale:n,offset:r}));return}let n=md[r];if(n){c.addBind(new _d({material:t,type:n,targetValue:new H().fromArray(e.targetValue),targetAlpha:e.targetValue[3]}));return}console.warn(r+` is not supported`)})}),a.registerExpression(c)}))),a})}};Cd.v0v1PresetNameMap={a:`aa`,e:`ee`,i:`ih`,o:`oh`,u:`ou`,blink:`blink`,joy:`happy`,angry:`angry`,sorrow:`sad`,fun:`relaxed`,lookup:`lookUp`,lookdown:`lookDown`,lookleft:`lookLeft`,lookright:`lookRight`,blink_l:`blinkLeft`,blink_r:`blinkRight`,neutral:`neutral`};var wd=class e{constructor(t,n){this._firstPersonOnlyLayer=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=e.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=n}copy(e){if(this.humanoid!==e.humanoid)throw Error(`VRMFirstPerson: humanoid must be same in order to copy`);return this.meshAnnotations=e.meshAnnotations.map(e=>({meshes:e.meshes.concat(),type:e.type})),this}clone(){return new e(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:t=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=e.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||=(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach(e=>{e.meshes.forEach(t=>{e.type===`firstPersonOnly`?(t.layers.set(this._firstPersonOnlyLayer),t.traverse(e=>e.layers.set(this._firstPersonOnlyLayer))):e.type===`thirdPersonOnly`?(t.layers.set(this._thirdPersonOnlyLayer),t.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer))):e.type===`auto`&&this._createHeadlessModel(t)})}),!0)}_excludeTriangles(e,t,n,r){let i=0;if(t!=null&&t.length>0)for(let a=0;a0&&r.includes(u[0])||l[1]>0&&r.includes(u[1])||l[2]>0&&r.includes(u[2])||l[3]>0&&r.includes(u[3]))continue;let d=t[s],f=n[s];if(d[0]>0&&r.includes(f[0])||d[1]>0&&r.includes(f[1])||d[2]>0&&r.includes(f[2])||d[3]>0&&r.includes(f[3]))continue;let p=t[c],m=n[c];p[0]>0&&r.includes(m[0])||p[1]>0&&r.includes(m[1])||p[2]>0&&r.includes(m[2])||p[3]>0&&r.includes(m[3])||(e[i++]=o,e[i++]=s,e[i++]=c)}return i}_createErasedMesh(e,t){let n=new Be(e.geometry.clone(),e.material);n.name=`${e.name}(erase)`,n.frustumCulled=e.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);let r=n.geometry,i=r.getAttribute(`skinIndex`),a=i instanceof xe?[]:i.array,o=[];for(let e=0;e{this._isEraseTarget(e)&&n.push(t)}),!n.length){t.layers.enable(this._thirdPersonOnlyLayer),t.layers.enable(this._firstPersonOnlyLayer);return}t.layers.set(this._thirdPersonOnlyLayer);let r=this._createErasedMesh(t,n);e.add(r)}_createHeadlessModel(e){if(e.type===`Group`)if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer));else{let t=new P;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter(e=>e.type===`SkinnedMesh`).forEach(e=>{let n=e;this._createHeadlessModelForSkinnedMesh(t,n)})}else if(e.type===`SkinnedMesh`){let t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode(`head`)?!0:e.parent?this._isEraseTarget(e.parent):!1}};wd.DEFAULT_FIRSTPERSON_ONLY_LAYER=9,wd.DEFAULT_THIRDPERSON_ONLY_LAYER=10,new F,new F,new R;var Td={hips:null,spine:`hips`,chest:`spine`,upperChest:`chest`,neck:`upperChest`,head:`neck`,leftEye:`head`,rightEye:`head`,jaw:`head`,leftUpperLeg:`hips`,leftLowerLeg:`leftUpperLeg`,leftFoot:`leftLowerLeg`,leftToes:`leftFoot`,rightUpperLeg:`hips`,rightLowerLeg:`rightUpperLeg`,rightFoot:`rightLowerLeg`,rightToes:`rightFoot`,leftShoulder:`upperChest`,leftUpperArm:`leftShoulder`,leftLowerArm:`leftUpperArm`,leftHand:`leftLowerArm`,rightShoulder:`upperChest`,rightUpperArm:`rightShoulder`,rightLowerArm:`rightUpperArm`,rightHand:`rightLowerArm`,leftThumbMetacarpal:`leftHand`,leftThumbProximal:`leftThumbMetacarpal`,leftThumbDistal:`leftThumbProximal`,leftIndexProximal:`leftHand`,leftIndexIntermediate:`leftIndexProximal`,leftIndexDistal:`leftIndexIntermediate`,leftMiddleProximal:`leftHand`,leftMiddleIntermediate:`leftMiddleProximal`,leftMiddleDistal:`leftMiddleIntermediate`,leftRingProximal:`leftHand`,leftRingIntermediate:`leftRingProximal`,leftRingDistal:`leftRingIntermediate`,leftLittleProximal:`leftHand`,leftLittleIntermediate:`leftLittleProximal`,leftLittleDistal:`leftLittleIntermediate`,rightThumbMetacarpal:`rightHand`,rightThumbProximal:`rightThumbMetacarpal`,rightThumbDistal:`rightThumbProximal`,rightIndexProximal:`rightHand`,rightIndexIntermediate:`rightIndexProximal`,rightIndexDistal:`rightIndexIntermediate`,rightMiddleProximal:`rightHand`,rightMiddleIntermediate:`rightMiddleProximal`,rightMiddleDistal:`rightMiddleIntermediate`,rightRingProximal:`rightHand`,rightRingIntermediate:`rightRingProximal`,rightRingDistal:`rightRingIntermediate`,rightLittleProximal:`rightHand`,rightLittleIntermediate:`rightLittleProximal`,rightLittleDistal:`rightLittleIntermediate`};function Ed(e){return e.invert?e.invert():e.inverse(),e}new F,new R,new F,new R,new F,new R,new R,new F,new F;var Dd=Math.sqrt(2)/2;new R(0,0,-Dd,Dd),new F(0,1,0);var Od=new F,kd=new F;function Ad(e,t){return e.matrixWorld.decompose(Od,t,kd),t}function jd(e){return[Math.atan2(-e.z,e.x),Math.atan2(e.y,Math.sqrt(e.x*e.x+e.z*e.z))]}function Md(e){let t=Math.round(e/2/Math.PI);return e-2*Math.PI*t}var Nd=new F(0,0,1),Pd=new F,Fd=new F,Id=new F,Ld=new R,Rd=new R,zd=new R,Bd=new R,Vd=new Se,Hd=class e{constructor(e,t){this.offsetFromHeadBone=new F,this.autoUpdate=!0,this.faceFront=new F(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new R)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn(`VRMLookAt: euler is deprecated. use getEuler() instead.`),this.getEuler(new Se)}getEuler(e){return e.set(I.DEG2RAD*this._pitch,I.DEG2RAD*this._yaw,0,`YXZ`)}copy(e){if(this.humanoid!==e.humanoid)throw Error(`VRMLookAt: humanoid must be same in order to copy`);return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new e(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){let t=this.humanoid.getRawBoneNode(`head`);return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){return Ad(this.humanoid.getRawBoneNode(`head`),e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(Nd)<.01)return e.copy(this._restHeadWorldQuaternion).invert();let[t,n]=jd(this.faceFront);return Vd.set(0,.5*Math.PI+t,n,`YZX`),e.setFromEuler(Vd).premultiply(Bd.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(Rd),this.getFaceFrontQuaternion(zd),e.copy(Nd).applyQuaternion(Rd).applyQuaternion(zd).applyEuler(this.getEuler(Vd))}lookAt(e){let t=Ld.copy(this._restHeadWorldQuaternion).multiply(Ed(this.getLookAtWorldQuaternion(Rd))),n=this.getLookAtWorldPosition(Fd),r=Id.copy(e).sub(n).applyQuaternion(t).normalize(),[i,a]=jd(this.faceFront),[o,s]=jd(r),c=Md(o-i),l=Md(a-s);this._yaw=I.RAD2DEG*c,this._pitch=I.RAD2DEG*l,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(Pd)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Hd.EULER_ORDER=`YXZ`;var Ud=Hd,Wd=new F(0,0,1),Gd=new R,Kd=new R,qd=new Se(0,0,0,`YXZ`),Jd=class{constructor(e,t,n,r,i){this.humanoid=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i,this.faceFront=new F(0,0,1),this._restQuatLeftEye=new R,this._restQuatRightEye=new R,this._restLeftEyeParentWorldQuat=new R,this._restRightEyeParentWorldQuat=new R;let a=this.humanoid.getRawBoneNode(`leftEye`),o=this.humanoid.getRawBoneNode(`rightEye`);a&&(this._restQuatLeftEye.copy(a.quaternion),Ad(a.parent,this._restLeftEyeParentWorldQuat)),o&&(this._restQuatRightEye.copy(o.quaternion),Ad(o.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(e,t){let n=this.humanoid.getRawBoneNode(`leftEye`),r=this.humanoid.getRawBoneNode(`rightEye`),i=this.humanoid.getNormalizedBoneNode(`leftEye`),a=this.humanoid.getNormalizedBoneNode(`rightEye`);n&&(t<0?qd.x=-I.DEG2RAD*this.rangeMapVerticalDown.map(-t):qd.x=I.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?qd.y=-I.DEG2RAD*this.rangeMapHorizontalInner.map(-e):qd.y=I.DEG2RAD*this.rangeMapHorizontalOuter.map(e),Gd.setFromEuler(qd),this._getWorldFaceFrontQuat(Kd),i.quaternion.copy(Kd).multiply(Gd).multiply(Kd.invert()),Gd.copy(this._restLeftEyeParentWorldQuat),n.quaternion.copy(i.quaternion).multiply(Gd).premultiply(Gd.invert()).multiply(this._restQuatLeftEye)),r&&(t<0?qd.x=-I.DEG2RAD*this.rangeMapVerticalDown.map(-t):qd.x=I.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?qd.y=-I.DEG2RAD*this.rangeMapHorizontalOuter.map(-e):qd.y=I.DEG2RAD*this.rangeMapHorizontalInner.map(e),Gd.setFromEuler(qd),this._getWorldFaceFrontQuat(Kd),a.quaternion.copy(Kd).multiply(Gd).multiply(Kd.invert()),Gd.copy(this._restRightEyeParentWorldQuat),r.quaternion.copy(a.quaternion).multiply(Gd).premultiply(Gd.invert()).multiply(this._restQuatRightEye))}lookAt(e){console.warn(`VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.`);let t=I.RAD2DEG*e.y,n=I.RAD2DEG*e.x;this.applyYawPitch(t,n)}_getWorldFaceFrontQuat(e){if(this.faceFront.distanceToSquared(Wd)<.01)return e.identity();let[t,n]=jd(this.faceFront);return qd.set(0,.5*Math.PI+t,n,`YZX`),e.setFromEuler(qd)}};Jd.type=`bone`;var Yd=class{constructor(e,t,n,r,i){this.expressions=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i}applyYawPitch(e,t){t<0?(this.expressions.setValue(`lookDown`,0),this.expressions.setValue(`lookUp`,this.rangeMapVerticalUp.map(-t))):(this.expressions.setValue(`lookUp`,0),this.expressions.setValue(`lookDown`,this.rangeMapVerticalDown.map(t))),e<0?(this.expressions.setValue(`lookLeft`,0),this.expressions.setValue(`lookRight`,this.rangeMapHorizontalOuter.map(-e))):(this.expressions.setValue(`lookRight`,0),this.expressions.setValue(`lookLeft`,this.rangeMapHorizontalOuter.map(e)))}lookAt(e){console.warn(`VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.`);let t=I.RAD2DEG*e.y,n=I.RAD2DEG*e.x;this.applyYawPitch(t,n)}};Yd.type=`expression`;var Xd=180/Math.PI,Zd=new Se,Qd=class extends A{constructor(e){super(),this.vrmLookAt=e,this.type=`VRMLookAtQuaternionProxy`;let t=this.rotation._onChangeCallback;this.rotation._onChange(()=>{t(),this._applyToLookAt()});let n=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{n(),this._applyToLookAt()})}_applyToLookAt(){Zd.setFromQuaternion(this.quaternion,Ud.EULER_ORDER),this.vrmLookAt.yaw=Xd*Zd.y,this.vrmLookAt.pitch=Xd*Zd.x}};function $d(e,t,n){let r=new Map,i=new Map;for(let[r,a]of e.humanoidTracks.rotation.entries()){let e=t.getNormalizedBoneNode(r)?.name;if(e!=null){let t=new Ce(`${e}.quaternion`,a.times,a.values.map((e,t)=>n===`0`&&t%2==0?-e:e));i.set(r,t)}}for(let[i,a]of e.humanoidTracks.translation.entries()){let o=t.getNormalizedBoneNode(i)?.name;if(o!=null){let s=e.restHipsPosition.y,c=t.normalizedRestPose.hips.position[1]/s,l=a.clone();l.values=l.values.map((e,t)=>(n===`0`&&t%3!=1?-e:e)*c),l.name=`${o}.position`,r.set(i,l)}}return{translation:r,rotation:i}}function ef(e,t){let n=new Map,r=new Map;for(let[r,i]of e.expressionTracks.preset.entries()){let e=t.getExpressionTrackName(r);if(e!=null){let t=i.clone();t.name=e,n.set(r,t)}}for(let[n,i]of e.expressionTracks.custom.entries()){let e=t.getExpressionTrackName(n);if(e!=null){let t=i.clone();t.name=e,r.set(n,t)}}return{preset:n,custom:r}}function tf(e,t){if(e.lookAtTrack==null)return null;let n=e.lookAtTrack.clone();return n.name=t,n}function nf(e,t){let n=[],r=$d(e,t.humanoid,t.meta.metaVersion);if(n.push(...r.translation.values()),n.push(...r.rotation.values()),t.expressionManager!=null){let r=ef(e,t.expressionManager);n.push(...r.preset.values()),n.push(...r.custom.values())}if(t.lookAt!=null){let r=t.scene.children.find(e=>e instanceof Qd);r==null?(console.warn(`createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually`),r=new Qd(t.lookAt),r.name=`VRMLookAtQuaternionProxy`,t.scene.add(r)):r.name===``&&(console.warn(`createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually`),r.name=`VRMLookAtQuaternionProxy`);let i=tf(e,`${r.name}.quaternion`);i!=null&&n.push(i)}return new rt(`Clip`,e.duration,n)}var rf=class{constructor(){this.duration=0,this.restHipsPosition=new F,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function af(e,t){let n=e.length,r=[],i=[],a=0;for(let o=0;o{let r=t.animations[n],i=this._parseAnimation(e,r,a,o);return i.restHipsPosition=l,i});e.userData.vrmAnimations=u})}_createNodeMap(e){let t=new Map,n=new Map,r=e.humanoid?.humanBones;r&&Object.entries(r).forEach(([e,n])=>{let r=n?.node;r!=null&&t.set(r,e)});let i=e.expressions?.preset;i&&Object.entries(i).forEach(([e,t])=>{let r=t?.node;r!=null&&n.set(r,e)});let a=e.expressions?.custom;return a&&Object.entries(a).forEach(([e,t])=>{let{node:r}=t;n.set(r,e)}),{humanoidIndexToName:t,expressionsIndexToName:n,lookAtIndex:e.lookAt?.node??null}}_createBoneWorldMatrixMap(e,t){return od(this,null,function*(){e.scene.updateWorldMatrix(!1,!0);let n=yield e.parser.getDependencies(`node`),r=new Map;if(t.humanoid==null)return r;for(let[e,i]of Object.entries(t.humanoid.humanBones)){let t=i?.node;if(t!=null){let i=n[t];r.set(e,i.matrixWorld),e===`hips`&&r.set(`hipsParent`,i.parent?.matrixWorld??of)}}return r})}_parseAnimation(e,t,n,r){let i=e.tracks,a=t.channels,o=new rf;return o.duration=e.duration,a.forEach((e,t)=>{let{node:a,path:s}=e.target,c=i[t];if(a==null)return;let l=n.humanoidIndexToName.get(a);if(l!=null){let e=Td[l];for(;e!=null&&r.get(e)==null;)e=Td[e];if(e??=`hipsParent`,s===`translation`)if(l!==`hips`)console.warn(`The loading animation contains a translation track for ${l}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{let e=r.get(`hipsParent`),t=af(c.values,3).flatMap(t=>sf.fromArray(t).applyMatrix4(e).toArray()),n=c.clone();n.values=new Float32Array(t),o.humanoidTracks.translation.set(l,n)}else if(s===`rotation`){let t=r.get(l),n=r.get(e);t.decompose(sf,cf,sf),cf.invert(),n.decompose(sf,lf,sf);let i=af(c.values,4).flatMap(e=>uf.fromArray(e).premultiply(lf).multiply(cf).toArray()),a=c.clone();a.values=new Float32Array(i),o.humanoidTracks.rotation.set(l,a)}else throw Error(`Invalid path "${s}"`);return}let u=n.expressionsIndexToName.get(a);if(u!=null){if(s===`translation`){let e=c.times,t=new Float32Array(c.values.length/3);for(let e=0;e=2.0 are supported.`));return}let c=new up(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function gf(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var $={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},_f=class{constructor(e){this.parser=e,this.name=$.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},jf=class{constructor(e){this.parser=e,this.name=$.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Mf=class{constructor(e){this.parser=e,this.name=$.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Nf=class{constructor(e){this.name=$.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},Pf=class{constructor(e){this.name=$.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==Gf.TRIANGLES&&e.mode!==Gf.TRIANGLE_STRIP&&e.mode!==Gf.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new B,n=new F,a=new R,s=new F(1,1,1),c=new Le(e.geometry,e.material,r);for(let e=0;e0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var lp=new B,up=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gf,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?this.textureLoader=new Ke(this.options.manager):this.textureLoader=new ae(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Oe(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return tp(i,a,r),np(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=qf[n.magFilter]||1006,t.minFilter=qf[n.minFilter]||1008,t.wrapS=Jf[n.wrapS]||1e3,t.wrapT=Jf[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new ye(e);t.needsUpdate=!0,n(t)}),t.load(Qe.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),np(e,a),e.userData.mimeType=a.mimeType||cp(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[$.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[$.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[$.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new _t,It.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new qe,It.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return ft}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[$.KHR_MATERIALS_UNLIT]){let e=r[$.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new H(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],z),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,N)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||$f.OPAQUE;if(l===$f.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===$f.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==ct&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new L(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==ct&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==ct){let e=i.emissiveFactor;o.emissive=new H().setRGB(e[0],e[1],e[2],z)}return i.emissiveTexture!==void 0&&a!==ct&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,N)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),np(n,i),t.associations.set(n,{materials:e}),i.extensions&&tp(r,n,i),n})}createUniqueName(e){let t=ie.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[$.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return fp(n,e,t)})}let a=[];for(let n=0,o=e.length;n0&&ip(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),np(d,i),u.extensions&&tp(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n1?new P:t.length===1?t[0]:new A,o!==t[0])for(let e=0,n=t.length;e1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new P;n.name&&(i.name=r.createUniqueName(n.name)),np(i,n),n.extensions&&tp(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof It||e instanceof ye)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];Zf[i.path]===Zf.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(Zf[i.path]){case Zf.weights:c=Pe;break;case Zf.rotation:c=Ce;break;case Zf.translation:case Zf.scale:c=Dt;break;default:switch(n.itemSize){case 1:c=Pe;break;case 2:case 3:default:c=Dt;break}break}let l=r.interpolation===void 0?ve:Qf[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;enew ku(e)),pp.register(e=>new pf(e)),pp)}var hp=400,gp=[[.075,800],[.11,0],[.125,0],[.14,0],[.125,0],[.05,0],[.04,0],[.03,0],[.02,0],[1,0]];for(let e=1;ee instanceof Dt&&e.name===`${n.name}.position`);if(!(i instanceof Dt)){console.warn(`No Hips.position track of type VectorKeyframeTrack found in animation.`);return}let a=new F(i.values[0],i.values[1],i.values[2]),o=new F().subVectors(a,r);e.tracks.forEach(e=>{if(e.name.endsWith(`.position`)&&e instanceof Dt)for(let t=0;t=r.value&&(e.value=!0,t.value=0),e.value)){t.value+=a/.2;let o=Math.sin(Math.PI*t.value);i.expressionManager.setValue(`blink`,o),t.value>=1&&(e.value=!1,n.value=0,i.expressionManager.setValue(`blink`,0),r.value=Math.random()*5+1)}}return{update:i}}function Sp(){let e=-1,t=new F,n=0;function r(e){t.set(e.value.x+wa(-.25,.25),e.value.y+wa(-.25,.25),e.value.z)}function i(i,a,o){!i?.expressionManager||!i.lookAt||(n>=e?(r(a),n=0,e=_p()/1e3):t||r(a),i.lookAt.target||(i.lookAt.target=new A),i.lookAt.target?.position.lerp(t,1),i.lookAt?.update(o),n+=o)}function a(e,n){t.set(n.x,n.y,n.z),!(!e?.expressionManager||!e.lookAt)&&(e.lookAt.target||(e.lookAt.target=new A),e.lookAt.target?.position.lerp(t,1),e.lookAt?.update(.016))}return{update:i,instantUpdate:a}}async function Cp(e,t){let n=(await mp().loadAsync(e,e=>t?.onProgress?.(e))).userData;if(!n.vrm)return;let r=n.vrm;if(Xu.removeUnnecessaryVertices(r.scene),Xu.combineSkeletons(r.scene),r.scene.traverse(e=>{e.frustumCulled=!1}),t?.lookAt&&r.lookAt){let e=new Qd(r.lookAt);e.name=`lookAtQuaternionProxy`,r.scene.add(e)}let i=new P;i.add(r.scene),t?.scene&&t.scene.add(i);let a=new F(0,0,-1),o=r.lookAt,s=new R;if(o){let e=o.faceFront;s.setFromUnitVectors(e.normalize(),a.normalize()),i.quaternion.premultiply(s),i.updateMatrixWorld(!0)}else console.warn(`No look-at target found in VRM model`);r.springBoneManager?.reset(),i.updateMatrixWorld(!0);function c(e){let t=new Ye,n=new Ye;return e.updateMatrixWorld(!0),e.traverse(e=>{if(!e.visible)return;let r=e;if(!r.isMesh||!r.geometry||r.name.startsWith(`VRMC_springBone_collider`))return;let i=r.geometry;i.boundingBox||i.computeBoundingBox(),n.copy(i.boundingBox),n.applyMatrix4(r.matrixWorld),t.union(n)}),t}let l=c(r.scene),u=new F,d=new F;l.getSize(u),l.getCenter(d),d.y+=u.y/5;let f=40/2*Math.PI/180;return{_vrm:r,_vrmGroup:i,modelCenter:d,modelSize:u,initialCameraOffset:new F(u.x/16,u.y/8,-(u.y/3)/Math.tan(f))}}function wp(e){let t=T(null),n=T(!1),r=T(0),i=T(new Map),a=T(new Map),o=T(),s=(e,t,n)=>e+(t-e)*n,c=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,l=new Map([[`happy`,{expression:[{name:`happy`,value:1,duration:.3},{name:`aa`,value:.3}],blendDuration:.3}],[`sad`,{expression:[{name:`sad`,value:1},{name:`oh`,value:.2}],blendDuration:.3}],[`angry`,{expression:[{name:`angry`,value:1},{name:`ee`,value:.4}],blendDuration:.2}],[`surprised`,{expression:[{name:`Surprised`,value:1},{name:`oh`,value:.6}],blendDuration:.1}],[`neutral`,{expression:[{name:`neutral`,value:1}],blendDuration:.5}]]),u=()=>{o.value&&=(clearTimeout(o.value),void 0)},d=o=>{if(u(),!l.has(o)){console.warn(`Emotion ${o} not found`);return}let s=l.get(o);if(t.value=o,n.value=!0,r.value=0,e.expressionManager){let t=Object.keys(e.expressionManager.expressionMap);for(let n of t)e.expressionManager.setValue(n,0)}i.value.clear(),a.value.clear();for(let t of s.expression||[]){let n=e.expressionManager?.getValue(t.name)||0;i.value.set(t.name,n),a.value.set(t.name,t.value)}};return{currentEmotion:t,isTransitioning:n,setEmotion:d,setEmotionWithResetAfter:(e,t)=>{u(),d(e),o.value=setTimeout(()=>{d(`neutral`),o.value=void 0},t)},update:o=>{if(!n.value||!t.value)return;let u=l.get(t.value).blendDuration||.3;r.value+=o/u,r.value>=1&&(r.value=1,n.value=!1);for(let[t,n]of a.value){let a=s(i.value.get(t)||0,n,c(r.value));e.expressionManager?.setValue(t,a)}},addEmotionState:(e,t)=>{l.set(e,t)},removeEmotionState:e=>{l.delete(e)},dispose:()=>{u()}}}var Tp=`data:application/wasm;base64,AGFzbQEAAAABbRBgAAF/YAAAYAJ/fwBgBn9/f39/fwBgA39/fwBgAn9/AX1gA39/fQBgB39/f39/f38Bf2ABfwBgAX8Bf2AFf39/f38AYAR/f39/AGAFf39/f30AYAZ/f31/f38AYAZ/f319fX8AYAV/f399fwACDwEDZW52Bm1lbW9yeQIABAMdHAEBBwEACAAAAAkKBAsMBAINDg8FBgIGBQMDAwIGlgEXfwFB0L0OC38AQfi4BAt/AEGguQQLfwBBkDgLfwBBwDgLfwBBkAgLfwBBgAgLfwBBjAgLfwBB9LgEC38AQfA4C38AQfC4BAt/AEGguQoLfwBB0LkKC38AQYAIC38AQdC9Cgt/AEHQvQoLfwBB0L0OC38AQYAIC38AQdC9Dgt/AEGAgBALfwBBAAt/AEEBC38AQYCABAsHpAYyEV9fd2FzbV9jYWxsX2N0b3JzAAAMbG9hZF9wcm9maWxlAAIHcHJvZmlsZQMBDnByb2ZpbGVNZmNjUmF3AwIScHJlY29tcHV0ZV9wcm9maWxlAAMMcHJvZmlsZU1lYW5zAwMNcHJvZmlsZVN0ZERldgMEC3Byb2ZpbGVNZmNjAwUQZ2V0X3Byb2ZpbGVfcHRycwAEC3Byb2ZpbGVQdHJzAwYJc2V0X2lucHV0AAUQb3V0cHV0U2FtcGxlUmF0ZQMHEGlucHV0U2FtcGxlQ291bnQDCBBnZXRfaW5wdXRfYnVmZmVyAAYLaW5wdXRCdWZmZXIDCRVnZXRfaW5wdXRfYnVmZmVyX3NpemUABw5nZXRfdm9sdW1lX3B0cgAIBnZvbHVtZQMKB2V4ZWN1dGUACRBjb3B5X3JpbmdfYnVmZmVyAAoKcm1zX3ZvbHVtZQAXD2xvd19wYXNzX2ZpbHRlcgAREWRvd25fc2FtcGxlX2V4YWN0AAwLZG93bl9zYW1wbGUADQxwcmVfZW1waGFzaXMAFg5oYW1taW5nX3dpbmRvdwAPCW5vcm1hbGl6ZQAUA2ZmdAAOD21lbF9maWx0ZXJfYmFuawASC3Bvd2VyX3RvX2RiABUDZGN0AAsHbWZjY091dAMLBnNjb3JlcwMMEmNhbGNfbDFub3JtX3Njb3JlcwAZEmNhbGNfbDJub3JtX3Njb3JlcwAaHWNhbGNfY29zaW5lX3NpbWlsYXJpdHlfc2NvcmVzABgQbm9ybWFsaXplX3Njb3JlcwAbFGxvd19wYXNzX2ZpbHRlcl9pbXBsABANZ2V0X21heF92YWx1ZQATDF9fZHNvX2hhbmRsZQMNCl9fZGF0YV9lbmQDDgtfX3N0YWNrX2xvdwMPDF9fc3RhY2tfaGlnaAMQDV9fZ2xvYmFsX2Jhc2UDEQtfX2hlYXBfYmFzZQMSCl9faGVhcF9lbmQDEw1fX21lbW9yeV9iYXNlAxQMX190YWJsZV9iYXNlAxUVX193YXNtX2ZpcnN0X3BhZ2VfZW5kAxYSX193YXNtX2luaXRfbWVtb3J5AAEIAQEMAQEK7FccAgALDgBBkAhBAEHAtQr8CwALRQBBkLkEIAY2AgBBjLkEIAU2AgBBiLkEIAQ2AgBBhLkEIAM2AgBBgLkEIAI2AgBB/LgEIAE2AgBB+LgEIAA2AgBBoLkEC8QgAil/H30CQAJAQYi5BCgCACIEQQBKBEBBuDhCADcDAEGwOEIANwMAQag4QgA3AwBBoDhCADcDAEGYOEIANwMAQZA4QgA3AwBBwDhCADcDAEHIOEIANwMAQdA4QgA3AwBB2DhCADcDAEHgOEIANwMAQeg4QgA3AwAgBEEDcSECIARBAWsiBUEDTwRAIARB/P///wdxIQNBkAghAANAIABBADYCACAAQZABakEANgIAIABB4ABqQQA2AgAgAEEwakEANgIAIABBwAFqIQAgAyABQQRqIgFHDQALCyACBEAgAUEwbEGQCGohAANAIABBADYCACAAQTBqIQAgAkEBayICDQALCyAEQQNxIQJBACEBIAVBA08EQCAEQfz///8HcSEDQaQJIQADQCAAQQA2AgAgAEEwa0EANgIAIABB4ABrQQA2AgAgAEGQAWtBADYCACAAQcABaiEAIAMgAUEEaiIBRw0ACwsgAgRAIAFBMGxBlAhqIQADQCAAQQA2AgAgAEEwaiEAIAJBAWsiAg0ACwsgBEEDcSECQQAhASAFQQNPBEAgBEH8////B3EhA0GoCSEAA0AgAEEANgIAIABBMGtBADYCACAAQeAAa0EANgIAIABBkAFrQQA2AgAgAEHAAWohACADIAFBBGoiAUcNAAsLIAIEQCABQTBsQZgIaiEAA0AgAEEANgIAIABBMGohACACQQFrIgINAAsLIARBA3EhAkEAIQEgBUEDTwRAIARB/P///wdxIQNBrAkhAANAIABBADYCACAAQTBrQQA2AgAgAEHgAGtBADYCACAAQZABa0EANgIAIABBwAFqIQAgAyABQQRqIgFHDQALCyACBEAgAUEwbEGcCGohAANAIABBADYCACAAQTBqIQAgAkEBayICDQALCyAEQQNxIQJBACEBIAVBA08EQCAEQfz///8HcSEDQbAJIQADQCAAQQA2AgAgAEEwa0EANgIAIABB4ABrQQA2AgAgAEGQAWtBADYCACAAQcABaiEAIAMgAUEEaiIBRw0ACwsgAgRAIAFBMGxBoAhqIQADQCAAQQA2AgAgAEEwaiEAIAJBAWsiAg0ACwsgBEEDcSECQQAhASAFQQNPBEAgBEH8////B3EhA0G0CSEAA0AgAEEANgIAIABBMGtBADYCACAAQeAAa0EANgIAIABBkAFrQQA2AgAgAEHAAWohACADIAFBBGoiAUcNAAsLIAIEQCABQTBsQaQIaiEAA0AgAEEANgIAIABBMGohACACQQFrIgINAAsLIARBA3EhAkEAIQEgBUEDTwRAIARB/P///wdxIQNBuAkhAANAIABBADYCACAAQTBrQQA2AgAgAEHgAGtBADYCACAAQZABa0EANgIAIABBwAFqIQAgAyABQQRqIgFHDQALCyACBEAgAUEwbEGoCGohAANAIABBADYCACAAQTBqIQAgAkEBayICDQALCyAEQQNxIQJBACEBIAVBA08EQCAEQfz///8HcSEDQbwJIQADQCAAQQA2AgAgAEEwa0EANgIAIABB4ABrQQA2AgAgAEGQAWtBADYCACAAQcABaiEAIAMgAUEEaiIBRw0ACwsgAgRAIAFBMGxBrAhqIQADQCAAQQA2AgAgAEEwaiEAIAJBAWsiAg0ACwsgBEEDcSECQQAhASAFQQNPBEAgBEH8////B3EhA0HACSEAA0AgAEEANgIAIABBMGtBADYCACAAQeAAa0EANgIAIABBkAFrQQA2AgAgAEHAAWohACADIAFBBGoiAUcNAAsLIAIEQCABQTBsQbAIaiEAA0AgAEEANgIAIABBMGohACACQQFrIgINAAsLIARBA3EhAkEAIQEgBUEDTwRAIARB/P///wdxIQNBxAkhAANAIABBADYCACAAQTBrQQA2AgAgAEHgAGtBADYCACAAQZABa0EANgIAIABBwAFqIQAgAyABQQRqIgFHDQALCyACBEAgAUEwbEG0CGohAANAIABBADYCACAAQTBqIQAgAkEBayICDQALCyAEQQNxIQJBACEBIAVBA08EQCAEQfz///8HcSEDQcgJIQADQCAAQQA2AgAgAEEwa0EANgIAIABB4ABrQQA2AgAgAEGQAWtBADYCACAAQcABaiEAIAMgAUEEaiIBRw0ACwsgAgRAIAFBMGxBuAhqIQADQCAAQQA2AgAgAEEwaiEAIAJBAWsiAg0ACwsgBEEDcSECQQAhASAFQQNPBEAgBEH8////B3EhA0HMCSEAA0AgAEEANgIAIABBMGtBADYCACAAQeAAa0EANgIAIABBkAFrQQA2AgAgAEHAAWohACADIAFBBGoiAUcNAAsLIAIEQCABQTBsQbwIaiEAA0AgAEEANgIAIABBMGohACACQQFrIgINAAsLQYy5BCgCACIFQTBsIRJDAACAPyAFspUhK0G8OCoCACE8Qbg4KgIAIT1BtDgqAgAhPkGwOCoCACE/Qaw4KgIAIUBBqDgqAgAhQUGkOCoCACE4QaA4KgIAITlBnDgqAgAhOkGYOCoCACE7QZQ4KgIAISxBkDgqAgAhKUGguQQhAwNAAkAgBUEATARAIAZBDGwiAUELaiEHIAFBCmohCCABQQlqIQkgAUEIaiEKIAFBB2ohCyABQQZqIQwgAUEFaiENIAFBBGohDiABQQNyIQ8gAUECciEQIAFBAXIhEQwBCyAGQQxsIgFBAnQiE0GQCGogAUELaiIHQQJ0IhVBkAhqIRYgAUEKaiIIQQJ0IhdBkAhqIRggAUEJaiIJQQJ0IhlBkAhqIRogAUEIaiIKQQJ0IhtBkAhqIRwgAUEHaiILQQJ0Ih1BkAhqIR4gAUEGaiIMQQJ0Ih9BkAhqISAgAUEFaiINQQJ0IiFBkAhqISIgAUEEaiIOQQJ0IiNBkAhqISQgAUEDciIPQQJ0IiVBkAhqISYgAUECciIQQQJ0IgBBkAhqIScgAUEBciIRQQJ0IgJBkAhqIBMqApAIISogFSoCkAghLSAXKgKQCCEuIBkqApAIIS8gGyoCkAghMCAdKgKQCCExIB8qApAIITIgISoCkAghMyAjKgKQCCE0ICUqApAIITUgACoCkAghNiACKgKQCCE3IAMhACAFIQIDQCAqIAAqAgCSISogLSAAQSxqKgIAkiEtIC4gAEEoaioCAJIhLiAvIABBJGoqAgCSIS8gMCAAQSBqKgIAkiEwIDEgAEEcaioCAJIhMSAyIABBGGoqAgCSITIgMyAAQRRqKgIAkiEzIDQgAEEQaioCAJIhNCA1IABBDGoqAgCSITUgNiAAQQhqKgIAkiE2IDcgAEEEaioCAJIhNyAAQTBqIQAgAkEBayICDQALIDc4AgAgKjgCACAnIDY4AgAgJiA1OAIAICQgNDgCACAiIDM4AgAgICAyOAIAIB4gMTgCACAcIDA4AgAgGiAvOAIAIBggLjgCACAWIC04AgAgPCEtID0hLiA+IS8gPyEwIEAhMSBBITIgOCEzIDkhNCA6ITUgOyE2ICwhNyApISoLIBFBAnQiAiACKgKQCCArlCJDOAKQCCAQQQJ0IgIgAioCkAggK5QiRDgCkAggAUECdCICIAIqApAIICuUIkU4ApAIIA9BAnQiAiACKgKQCCArlCJGOAKQCCAOQQJ0IgIgAioCkAggK5QiRzgCkAggDUECdCICIAIqApAIICuUIkI4ApAIIAxBAnQiAiACKgKQCCArlCI4OAKQCCALQQJ0IgIgAioCkAggK5QiOTgCkAggCkECdCICIAIqApAIICuUIjo4ApAIIAlBAnQiAiACKgKQCCArlCI7OAKQCCAIQQJ0IgIgAioCkAggK5QiLDgCkAggB0ECdCICIAIqApAIICuUIik4ApAIIAMgEmohAyAtICmSIjwhLSAuICySIj0hLiAvIDuSIj4hLyAwIDqSIj8hMCAxIDmSIkAhMSAyIDiSIkEhMiAzIEKSIjghMyA0IEeSIjkhNCA1IEaSIjohNSA2IESSIjshNiA3IEOSIiwhNyAqIEWSIikhKiAEIAZBAWoiBkcNAAsMAQtBqDhCADcDAEGgOEIANwMAQZg4QgA3AwBBkDhCADcDAEHAOEIANwMAQcg4QgA3AwBB0DhCADcDAEHYOEIANwMAQeA4QgA3AwBB6DhCADcDAAwBC0G8OCA8OAIAQbg4ID04AgBBtDggPjgCAEGwOCA/OAIAQaw4IEA4AgBBqDggQTgCAEGkOCA4OAIAQaA4IDk4AgBBnDggOjgCAEGYOCA7OAIAQZQ4ICw4AgBBkDggKTgCAAtBkLkEKAIARQRAQbg4QgA3AwBBsDhCADcDAEGoOEIANwMAQaA4QgA3AwBBmDhCADcDAEGQOEIANwMAQeg4QoCAgPyDgIDAPzcDAEHgOEKAgID8g4CAwD83AwBB2DhCgICA/IOAgMA/NwMAQdA4QoCAgPyDgIDAPzcDAEHIOEKAgID8g4CAwD83AwBBwDhCgICA/IOAgMA/NwMADwtBvDggPCAEsiIqlSJCOAIAQbg4ID0gKpUiPDgCAEG0OCA+ICqVIj04AgBBsDggPyAqlSI+OAIAQaw4IEAgKpUiPzgCAEGoOCBBICqVIkA4AgBBpDggOCAqlSJBOAIAQaA4IDkgKpUiODgCAEGcOCA6ICqVIjk4AgBBmDggOyAqlSI6OAIAQZQ4ICwgKpUiOzgCAEGQOCApICqVOAIAQYy5BCgCACEDAkAgBEEATA0AQQAhBiADQQBMDQAgA0EwbCEFQcA4KgIAIS1BkDgqAgAhLEHsOCoCACEuQeg4KgIAIS9B5DgqAgAhMEHgOCoCACExQdw4KgIAITJB2DgqAgAhM0HUOCoCACE0QdA4KgIAITVBzDgqAgAhNkHIOCoCACE3QcQ4KgIAISpBoLkEIQEDQCADIQIgASEAA0AgACoCACAskyIpICmUIC2SIS0gAEEsaioCACBCkyIpICmUIC6SIS4gAEEoaioCACA8kyIpICmUIC+SIS8gAEEkaioCACA9kyIpICmUIDCSITAgAEEgaioCACA+kyIpICmUIDGSITEgAEEcaioCACA/kyIpICmUIDKSITIgAEEYaioCACBAkyIpICmUIDOSITMgAEEUaioCACBBkyIpICmUIDSSITQgAEEQaioCACA4kyIpICmUIDWSITUgAEEMaioCACA5kyIpICmUIDaSITYgAEEIaioCACA6kyIpICmUIDeSITcgAEEEaioCACA7kyIpICmUICqSISogAEEwaiEAIAJBAWsiAg0ACyABIAVqIQEgBkEBaiIGIARHDQALQew4IC44AgBB6DggLzgCAEHkOCAwOAIAQeA4IDE4AgBB3DggMjgCAEHYOCAzOAIAQdQ4IDQ4AgBB0DggNTgCAEHMOCA2OAIAQcg4IDc4AgBBxDggKjgCAEHAOCAtOAIAQYy5BCgCACEDC0MAAIA/IAMgBGyylSEsQVAhAANAIABB8DhqIgMgAyoCACAslCIpICkgKbxBgICABGtBAXVBgICAgAJqviIplSApkkMAAAA/lCIplSApkkMAAAA/lDgCACAAQQRqIgANAAsLBQBBgAgLOgBBjAggADYCAEH0uARB/LgEKAIAsiAAspRB+LgEKAIAspVDAAAAP5JDAABAS5JDAABAy5L8ADYCAAsFAEHwOAsGAEGAgAELBgBB8LgEC70GAgl/BX0jACIBIQggAUH0uAQoAgAiAUECdEEPakFwcSIDayICJABBgLkEKAIAIQVB+LgEKAIAIQQgAkHwOCAAIAFrQYCAAWpBgIABIAEQCkHwuAQgAiABEBc4AgAgBEECbSEGIAIgA2siACQAAkAgBEGMCCgCACIDTgRAIAIgASADsiAGskMAAPpDQQEQESACIAAgAUEBEAwMAQsgAyADIARtIgcgBGxGBEAgAiABIAOyIAayQwAA+kMgBxARIAIgACABIAdtIgEgBxAMDAELIAIgASADsiIKIAayQwAA+kNBARARIAIgASAAIAGyIAogBLKVIgqVu0QAAAAAAAA4Q6BEAAAAAAAAOMOg/AIiASAKEA0LIAAgAUPsUXg/EBYgACABEA8gACABQwAAgD8QFCAAIAFBAnRBD2pBcHFrIgIkACAAIAIgARAOIAIgBUECdEEPakFwcSIDayIAJAAgAiABIAAgBLIgBRASIAAgBRAVIAAgA2siASQAIAAgASAFEAsCQEGIuQQoAgAiAEEATA0AIABBAnQiAkUNAEGguQogAUEEaiAC/AoAAAsCQAJAAkACQEGEuQQoAgAOAgABAgtBoLkKQZAIQZA4QcA4QdC5CiAAEBkMAgtBoLkKQZAIQZA4QcA4QdC5CiAAEBoMAQtBoLkKQZAIQZA4QcA4QdC5CiAAEBgLQQAhAUHQuQpBiLkEKAIAEBtBiLkEKAIAIgBBAEwEQCAIJABBfw8LIABBA3EhBAJAIABBBEkEQEF/IQJDAACAvyEKDAELIABB/P///wdxIQNBfyECQwAAgL8hCkHQuQohAANAIABBDGoqAgAiCyAAQQhqKgIAIgwgAEEEaioCACINIAAqAgAiDiAKIAogDl0iBRsiCiAKIA1dIgYbIgogCiAMXSIHGyIKIAogC10iCRshCiABQQNqIAFBAmogAUEBaiABIAIgBRsgBhsgBxsgCRshAiAAQRBqIQAgAUEEaiIBIANHDQALCyAEBEAgAUECdEHQuQpqIQADQCAAKgIAIgsgCiAKIAtdIgMbIQogASACIAMbIQIgAEEEaiEAIAFBAWohASAEQQFrIgQNAAsLIAgkACACC0wBAX8gAyACIANwIgNrIgIgBCACIARIGyIFQQJ0IgIEQCAAIAEgA0ECdGogAvwKAAALIAQgBWtBAnQiAwRAIAAgAmogASAD/AoAAAsLtgECBH0DfyACBEBEGC1EVPshCUAgArijtkOD+SI+lCEFA0AgBSAHs5QhBkMAAAAAIQQgACEIQQAhCQNAQwAAAD8gBiAJs0MAAAA/kpRDAACAPpIiA0MAAEDLIAOTQwAAQEuSkiIDi5MgA5QiA4tDZWJlQpRDZ6dGQZIgA5QgCCoCAJQgBJIhBCAIQQRqIQggAiAJQQFqIglHDQALIAEgB0ECdGogBDgCACAHQQFqIgcgAkcNAAsLC+QBAQh/AkAgAkUNACACQQNxIQYgAkEETwRAIANBAnQhByADQQN0IQggA0EEdCEJIANBDGwhCiACQXxxIQsgASECIAAhBANAIAIgBCoCADgCACACQQRqIAQgB2oqAgA4AgAgAkEIaiAEIAhqKgIAOAIAIAJBDGogBCAKaioCADgCACACQRBqIQIgBCAJaiEEIAsgBUEEaiIFRw0ACwsgBkUNACADQQJ0IQcgASAFQQJ0aiECIAAgAyAFbEECdGohBANAIAIgBCoCADgCACAEIAdqIQQgAkEEaiECIAZBAWsiBg0ACwsLhQECAn8CfSADBEAgAUEBayEGQQAhAQNAIAIgACAEIAGzlCIHu0QAAAAAAADgv6BEAAAAAAAAOEOgRAAAAAAAADjDoPwCIgUgBiAFIAZIG0ECdGoqAgAgACAFQQJ0aioCACIIkyAHIAWyk5QgCJI4AgAgAkEEaiECIAMgAUEBaiIBRw0ACwsLoAgDEX8GfQJ8IwAgAkECdCIGQQ9qQXBxIgNrIgcgA2siCSELIAIEQAJAIAJnIgNBH0cEQCAGBEAgCUEAIAb8CwALQR8gA2siBkF8cSEIIAZBA3EhCiADQRxrQQNJIQwDQEEAIQVBACEDIAxFBEADQCAEIANBA2p2QQFxIAQgA0ECanZBAXRBAnEgBCADQQFqdkEBcSAEIAN2QQF0QQJxIAVBAnRyckECdHJyIQUgA0EEaiIDIAhHDQALCyAKBEAgCiEGA0AgBCADdkEBcSAFQQF0ciEFIANBAWohAyAGQQFrIgYNAAsLIAcgBEECdGogACAFQQJ0aioCADgCACAEQQFqIgQgAkcNAAsMAQsgACoCACEUIAJBAnQiAARAIAlBACAA/AsACyACQQdxIQQgAkEITwRAIAJBeHEhACAHIQMDQCADIBQ4AgAgA0EcaiAUOAIAIANBGGogFDgCACADQRRqIBQ4AgAgA0EQaiAUOAIAIANBDGogFDgCACADQQhqIBQ4AgAgA0EEaiAUOAIAIANBIGohAyAAIAVBCGoiBUcNAAsLIARFDQAgByAFQQJ0aiEDA0AgAyAUOAIAIANBBGohAyAEQQFrIgQNAAsLIAsgAkEBdiIFQQJ0QQ9qQXBxIgBrIgwgAGshDSACQQFHBEBEAAAAAAAA8D8gArijIRsgDCEDIA0hBANAIARDAAAAPyAaRBgtRFT7IRnAoiAborZDg/kiPpQiFEMAAEDLIBSTQwAAQEuSkiIVi5MgFZQiFYtDZWJlQpRDZ6dGQZIgFZQ4AgAgA0MAAAA/IBRDAACAPpIiFEMAAEDLIBSTQwAAQEuSkiIUi5MgFJQiFItDZWJlQpRDZ6dGQZIgFJQ4AgAgA0EEaiEDIARBBGohBCAaRAAAAAAAAPA/oCEaIAVBAWsiBQ0AC0EBIQgDQCAIIgBBAXQhCCAAQQBKBEAgAEEDdCEOIABBAnQhDyACIAhodkECdCERQQAhECAHIQogCSELA0AgCiEDIAshBEEAIQUgACEGA0AgBCAFIA1qKgIAIhQgAyAPaiISKgIAIhWUIAUgDGoqAgAiFiAEIA9qIhMqAgAiF5SSIhggBCoCACIZkjgCACADIBYgFZQgFCAXlJMiFCADKgIAIhWSOAIAIBMgGSAYkzgCACASIBUgFJM4AgAgA0EEaiEDIARBBGohBCAFIBFqIQUgBkEBayIGDQALIAogDmohCiALIA5qIQsgCCAQaiIQIAJJDQALCyACIAhLDQALCwNAIAEgCSoCACIUIBSUIAcqAgAiFCAUlJIiFCAUIBS8QYCAgARrQQF1QYCAgIACar4iFJUgFJJDAAAAP5QiFJUgFJJDAAAAP5Q4AgAgB0EEaiEHIAlBBGohCSABQQRqIQEgAkEBayICDQALCwuWAQICfQF/IAFBAEoEQEMAAIA/IAFBAWuzlSEDA0AgACAAKgIAQwAAAD8gBLMgA5S7RBgtRFT7IRlAorZDg/kiPpRDAACAPpIiAkMAAEDLIAKTQwAAQEuSkiICi5MgApQiAkMfheu+lCACi0NlYmVClENnp0ZBkpRDcT0KP5KUOAIAIABBBGohACABIARBAWoiBEcNAAsLC5sCAwN9Bn8BfCAEQQJOBEAgBEECbSELIANBBGohCiAFQQJ0IQwgAyAEQQJ0aiENIAK7RBgtRFT7IRlAoiEPIARBAWuzQwAAAD+UIQgDQCABIAUgCSAFb2sgBW8iBCAJaiIDSgRAIAJDAAAAPyAPIAmzIAiTu6K2IgdDg/kiPpQiBkMAAEDLIAaTQwAAQEuSkiIGi5MgBpQiBpQgBotDZWJlQpRDZ6dGQZKUIgYgBpIhBiAEQQJ0IQRDAACAPyAHlSEHA0AgACAEaiIOIAYgBCAKaioCACAEIA1qKgIAkpQgB5QgDioCAJI4AgAgBCAMaiEEIAMgBWoiAyABSA0ACwsgCkEIaiEKIABBBGohACAJQQFqIgkgC0cNAAsLC48DAwh/AX0BfCMAIAJDZmZGQJQgBJVDAABAS5JDAABAy5L8ACIIQQFxIgogCGoiByABakECdEEPakFwcWshBiAHQQJ0IgkEQCAGQQAgCfwLAAsgAUECdCILBEAgBiAJaiAAIAv8CgAACyAHQQJOBEAgB0ECbSELIAYgCEECdCAKQQJ0amohCiAGQQRqIQggBUECdCEMIAdBAWuzQwAAAD+UIQ4gAyAEkyAClSICu0QYLURU+yEZQKIhDyACIAKSIQJBACEHA0AgASAFIAcgBW9rIAVvIgYgB2oiCUoEQCACQwAAAD8gDyAHsyAOk7uitiIDQ4P5Ij6UIgRDAABAyyAEk0MAAEBLkpIiBIuTIASUIgSUIASLQ2ViZUKUQ2enRkGSlCEEIAZBAnQhBkMAAIA/IAOVIQMDQCAAIAZqIg0gBCAGIAhqKgIAIAYgCmoqAgCSlCADlCANKgIAkjgCACAGIAxqIQYgBSAJaiIJIAFIDQALCyAIQQhqIQggAEEEaiEAIAdBAWoiByALRw0ACwsLuAQCCX0FfyAEQQBKBEAgA0PnPjs6lEMAAIA/krwiD0EXdbJDq6oAw5IgD0H///8DcUGAgID8A3K+IgVDq6qqvpRDAAAAQJIgBZSSIARBAWqzlSEHIABBBGohEEMAAIA/IANDAAAAP5QgAUEBdrOVIgqVIQgDQCAOQQFqIQ9DAAAAACEDIAcgDrOUIgVDAAD+QpL8ACIAQRd0vkMAAC9ElCAFQf8AIABrspIiBUPQ9a0+lEMYBSk/kiAFlEMAAIA/kpQiBkMAAC/EkiILIAiUQwAAAD+SQwAAQEuSQwAAQMuS/AAiASAHIA5BAmqzlCIFQwAA/kKS/AAiAEEXdL5DAAAvRJQgBUH/ACAAa7KSIgVD0PWtPpRDGAUpP5IgBZRDAACAP5KUIgVDAAAvxJIiDCAIlEMAAAC/kkMAAEBLkkMAAEDLkvwAIhFIBEAgByAPs5QiA0MAAP5CkvwAIgBBF3S+QwAAL0SUIANB/wAgAGuykiIDQ9D1rT6UQxgFKT+SIAOUQwAAgD+SlCIDQwAAL8SSIAiUQwAAQEuSQwAAQMuS/AAhEiAQIAFBAnRqIQBDAACAPyAFIAaTlSEJQwAAgD8gBSADk5UhDUMAAIA/IAMgBpOVIQZDAAAAACEDA0AgACoCACAKIAFBAWoiAbKUIgUgC5MgBpQgDCAFkyANlCABIBJIG5QgCSAJkpQgA5IhAyAAQQRqIQAgASARRw0ACwsgAiAOQQJ0aiADOAIAIA8iDiAERw0ACwsLpQECAX0DfyABQQBMBEBDAAAAAA8LIAFBA3EhBAJAIAFBBEkEQAwBCyABQfz///8HcSEFIAAhAQNAIAFBDGoqAgCLIAFBCGoqAgCLIAFBBGoqAgCLIAIgASoCAIuXl5eXIQIgAUEQaiEBIAUgA0EEaiIDRw0ACwsgBARAIAAgA0ECdGohAQNAIAIgASoCAIuXIQIgAUEEaiEBIARBAWsiBA0ACwsgAgupAgIEfwJ9AkAgAUEATA0AIAFBA3EhBAJAIAFBBEkEQAwBCyABQfz///8HcSEGIAAhAwNAIANBDGoqAgCLIANBCGoqAgCLIANBBGoqAgCLIAcgAyoCAIuXl5eXIQcgA0EQaiEDIAYgBUEEaiIFRw0ACwsgBARAIAAgBUECdGohAwNAIAcgAyoCAIuXIQcgA0EEaiEDIARBAWsiBA0ACwsgB0OVv9YzXQ0AQQAhBCABQQFHBEBDAACAPyAHlSEIIAFB/v///wdxIQUgACEDA0AgAyACIAMqAgCUIAiUOAIAIANBBGoiBiACIAYqAgCUIAiUOAIAIANBCGohAyAFIARBAmoiBEcNAAsLIAFBAXFFDQAgACAEQQJ0aiIAIAIgACoCAJQgB5U4AgALC1wCAX8BfSABBEADQCAAIAAoAgAiAkEXdbJDq6oAw5IgAkH///8DcUGAgID8A3K+IgNDq6qqvpRDAAAAQJIgA5SSQ8KoQECUOAIAIABBBGohACABQQFrIgENAAsLC6EBAgJ/AX0CQCABQQBMDQAgASEDIAFBAXEEQCAAIAFBAnRqIgMgAyoCACADQQRrKgIAIAKUkzgCACABQQFrIQMLIAFBAUYNACADQQFqIQQgA0ECdCAAakEIayEBA0AgAUEEaiIAIAAqAgAiBSABKgIAIAKUkzgCACABQQhqIgAgACoCACAFIAKUkzgCACABQQhrIQEgBEECayIEQQFLDQALCwvmAQICfQR/AkAgAUUEQAwBCyABQQNxIQYCQCABQQRJBEAMAQsgAUF8cSEHIAAhBANAIARBDGoqAgAiAyADlCAEQQhqKgIAIgMgA5QgBEEEaioCACIDIAOUIAQqAgAiAyADlCACkpKSkiECIARBEGohBCAHIAVBBGoiBUcNAAsLIAZFDQAgACAFQQJ0aiEEA0AgBCoCACIDIAOUIAKSIQIgBEEEaiEEIAZBAWsiBg0ACwsgAiABs5UiAiACIAK8QYCAgARrQQF1QYCAgIACar4iApUgApJDAAAAP5QiApUgApJDAAAAP5QLrwICBn0DfyAFBEADQCAEIA1BAnRqIg5BADYCAEEAIQxDAAAAACEGQwAAAAAhCUMAAAAAIQcDQCABIAxqKgIAIAIgDGoqAgAiCJMgAyAMaioCACILlSIKIAAgDGoqAgAgCJMgC5UiCJQgCZIhCSAKIAqUIAeSIQcgCCAIlCAGkiEGIAxBBGoiDEEwRw0ACyAOIAkgByAHIAe8QYCAgARrQQF1QYCAgIACar4iB5UgB5JDAAAAP5QiB5UgB5JDAACAPpQgBiAGIAa8QYCAgARrQQF1QYCAgIACar4iBpUgBpJDAAAAP5QiBpUgBpKUlUMAAAAAlyIGIAaUIgYgBpQiBiAGIAaUIgYgBpQiBiAGlCIGlCAGIAaUlDgCACABQTBqIQEgDUEBaiINIAVHDQALCwuWBQICfQN/IAUEQANAIAQgCUECdGoiAkEANgIAIAIgACoCACABIAlBMGxqIggqAgCTIAMqAgCViyIGOAIAIAIgACoCBCAIKgIEkyADKgIElYsgBpIiBjgCACACIAAqAgggCCoCCJMgAyoCCJWLIAaSIgY4AgAgAiAAKgIMIAgqAgyTIAMqAgyViyAGkiIGOAIAIAIgACoCECAIKgIQkyADKgIQlYsgBpIiBjgCACACIAAqAhQgCCoCFJMgAyoCFJWLIAaSIgY4AgAgAiAAKgIYIAgqAhiTIAMqAhiViyAGkiIGOAIAIAIgACoCHCAIKgIckyADKgIclYsgBpIiBjgCACACIAAqAiAgCCoCIJMgAyoCIJWLIAaSIgY4AgAgAiAAKgIkIAgqAiSTIAMqAiSViyAGkiIGOAIAIAIgACoCKCAIKgIokyADKgIolYsgBpIiBjgCAAJAIAAqAiwgCCoCLJMgAyoCLJWLIAaSQ6uqqj2UIgZDAAAAAF9FBEAgBiAGj5ND6v9TQJQiB0H/ACAHQwAA/kKS/AAiCGuykiIHQ9D1rT6UQxgFKT+SIAeUQwAAgD+SIAhBF3S+lCEHIAb8ASIIBEBDAAAgQSEGA0AgByAGQwAAgD8gCEEBcRuUIQcgCEEBSyAGIAaUIQYgCEEBdiEIDQALC0MAAIA/IAeVIQcMAQsgBowiBiAGj5ND6v9TQJQiB0H/ACAHQwAA/kKS/AAiCGuykiIHQ9D1rT6UQxgFKT+SIAeUQwAAgD+SIAhBF3S+lCEHIAb8ASIIRQ0AQwAAIEEhBgNAIAcgBkMAAIA/IAhBAXEblCEHIAhBAUsgBiAGlCEGIAhBAXYhCA0ACwsgAiAHOAIAIAlBAWoiCSAFRw0ACwsL9gUCAn0DfyAFBEADQCAEIAlBAnRqIgJBADYCACACIAAqAgAgASAJQTBsaiIIKgIAkyADKgIAlSIGIAaUIgY4AgAgAiAGIAAqAgQgCCoCBJMgAyoCBJUiBiAGlJIiBjgCACACIAYgACoCCCAIKgIIkyADKgIIlSIGIAaUkiIGOAIAIAIgBiAAKgIMIAgqAgyTIAMqAgyVIgYgBpSSIgY4AgAgAiAGIAAqAhAgCCoCEJMgAyoCEJUiBiAGlJIiBjgCACACIAYgACoCFCAIKgIUkyADKgIUlSIGIAaUkiIGOAIAIAIgBiAAKgIYIAgqAhiTIAMqAhiVIgYgBpSSIgY4AgAgAiAGIAAqAhwgCCoCHJMgAyoCHJUiBiAGlJIiBjgCACACIAYgACoCICAIKgIgkyADKgIglSIGIAaUkiIGOAIAIAIgBiAAKgIkIAgqAiSTIAMqAiSVIgYgBpSSIgY4AgAgAiAGIAAqAiggCCoCKJMgAyoCKJUiBiAGlJIiBjgCAAJAIAYgACoCLCAIKgIskyADKgIslSIGIAaUkkOrqqo9lCIGIAYgBrxBgICABGtBAXVBgICAgAJqviIGlSAGkkMAAAA/lCIGlSAGkkMAAAA/lCIGQwAAAABfRQRAIAYgBo+TQ+r/U0CUIgdB/wAgB0MAAP5CkvwAIghrspIiB0PQ9a0+lEMYBSk/kiAHlEMAAIA/kiAIQRd0vpQhByAG/AEiCARAQwAAIEEhBgNAIAcgBkMAAIA/IAhBAXEblCEHIAhBAUsgBiAGlCEGIAhBAXYhCA0ACwtDAACAPyAHlSEHDAELIAaMIgYgBo+TQ+r/U0CUIgdB/wAgB0MAAP5CkvwAIghrspIiB0PQ9a0+lEMYBSk/kiAHlEMAAIA/kiAIQRd0vpQhByAG/AEiCEUNAEMAACBBIQYDQCAHIAZDAACAPyAIQQFxG5QhByAIQQFLIAYgBpQhBiAIQQF2IQgNAAsLIAIgBzgCACAJQQFqIgkgBUcNAAsLC6gCAgR/An0CQCABRQ0AIAFBA3EhAwJAIAFBBEkEQAwBCyABQXxxIQUgACECA0AgAkEMaioCACACQQhqKgIAIAJBBGoqAgAgAioCACAGkpKSkiEGIAJBEGohAiAFIARBBGoiBEcNAAsLIAMEQCAAIARBAnRqIQIDQCACKgIAIAaSIQYgAkEEaiECIANBAWsiAw0ACwsgBkMAAAAAX0UEQEEAIQMgAUEBRwRAQwAAgD8gBpUhByABQX5xIQQgACECA0AgAiACKgIAIAeUOAIAIAJBBGoiBSAFKgIAIAeUOAIAIAJBCGohAiAEIANBAmoiA0cNAAsLIAFBAXFFDQEgACADQQJ0aiIAIAAqAgAgBpU4AgAMAQsgAUECdCIBRQ0AIABBACAB/AsACwsLFwEAQYAICxAQBAAAEBwAAEAcAACAuwAAACYJcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBBWNsYW5nBjIxLjEuMQB8D3RhcmdldF9mZWF0dXJlcwcrD211dGFibGUtZ2xvYmFscysTbm9udHJhcHBpbmctZnB0b2ludCsLYnVsay1tZW1vcnkrCHNpZ24tZXh0Kw9yZWZlcmVuY2UtdHlwZXMrCm11bHRpdmFsdWUrD2J1bGstbWVtb3J5LW9wdA==`;function Ep(e,t,n,r,i){let a=2/r,o=a*i,s=1/(1+o+.48*o*o+.235*o*o*o),c=e-t,l=(n+a*c)*i;return n=(n-a*l)*s,[t+(c+l)*s,n]}var Dp={wasmModule:void 0},Op=class extends AudioWorkletNode{openCloseVelocity=0;lastTimestamp=0;weightVelocities={};minVolume=-2.5;maxVolume=-1.5;smoothness=.05;volume=0;weights={};constructor(e,t,n=Dp.wasmModule){super(e,`wlipsync-processor`,{processorOptions:{wasmModule:n,profile:t}});for(let e of t.mfccs)this.weights[e.name]=0,this.weightVelocities[e.name]=0;this.port.onmessage=this.onMessage.bind(this)}onMessage(e){let t=e.data.timestamp-this.lastTimestamp;this.lastTimestamp=e.data.timestamp;let n=Number.isNaN(e.data.volume)?0:e.data.volume,r=Math.log10(n);for(let n in r=(r-this.minVolume)/(this.maxVolume-this.minVolume),r=Math.max(Math.min(r,1),0),[this.volume,this.openCloseVelocity]=Ep(this.volume,r,this.openCloseVelocity,this.smoothness,t),this.weights){let r=n===e.data.name?1:0,i=this.weightVelocities[n];[this.weights[n],i]=Ep(this.weights[n],r,i,this.smoothness,t),this.weightVelocities[n]=i}}get blockSize(){return this.parameters.get(`blockSize`).value}set blockSize(e){this.parameters.get(`blockSize`).setValueAtTime(e,this.context.currentTime)}};new TextDecoder,Dp.wasmModule=await WebAssembly.compileStreaming(fetch(Tp));async function kp(e,t){try{return new Op(e,t)}catch{return await e.audioWorklet.addModule(new URL(`data:text/javascript;base64,dmFyIEI9bmV3IFdlYkFzc2VtYmx5Lk1lbW9yeSh7aW5pdGlhbDo0fSksWD17ZW52OnttZW1vcnk6Qn19O2NsYXNzIFUgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3J7aW5wdXRCdWZmZXJJbmRleD0tMTtpbnB1dEJ1ZmZlclB0cj0tMTtpbnB1dEJ1ZmZlclNpemU9LTE7aW5wdXRCdWZmZXI9bnVsbDtsYXN0SW5kZXg9MDt2b2x1bWVQdHI9LTE7dm9sdW1lVmlldz1udWxsO21mY2NzPVtdO2V4cG9ydHM9bnVsbDtjb25zdHJ1Y3RvcihKKXtzdXBlcigpO2NvbnN0e3dhc21Nb2R1bGU6Uyxwcm9maWxlOmt9PUoucHJvY2Vzc29yT3B0aW9ucztXZWJBc3NlbWJseS5pbnN0YW50aWF0ZShTLFgpLnRoZW4oKEcpPT57Y29uc3Qgej10aGlzLmV4cG9ydHM9Ry5leHBvcnRzLEU9ay5tZmNjcy5sZW5ndGgsVz16LmxvYWRfcHJvZmlsZShrLnRhcmdldFNhbXBsZVJhdGUsay5zYW1wbGVDb3VudCxrLm1lbEZpbHRlckJhbmtDaGFubmVscyxrLmNvbXBhcmVNZXRob2QsRSxrLm1mY2NEYXRhQ291bnQsay51c2VTdGFuZGFyZGl6YXRpb24/MTowKSxUPXRoaXMubWZjY3M9ay5tZmNjcztpZighay5tZWFucyl7Y29uc3QgSz1uZXcgRGF0YVZpZXcoQi5idWZmZXIsVyxFKmsubWZjY0RhdGFDb3VudCoxMio0KTtsZXQgRj0wO2ZvcihsZXQgTiBvZiBUKWZvcihsZXQgUSBvZiBOLm1mY2NDYWxpYnJhdGlvbkRhdGFMaXN0KWZvcihsZXQgUiBvZiBRLmFycmF5KUsuc2V0RmxvYXQzMihGLFIsITApLEYrPTQ7ei5wcmVjb21wdXRlX3Byb2ZpbGUoKX1lbHNle2NvbnN0IEs9ei5nZXRfcHJvZmlsZV9wdHJzKCksRj1uZXcgRGF0YVZpZXcoQi5idWZmZXIsSywxMiksTj1uZXcgRGF0YVZpZXcoQi5idWZmZXIsRi5nZXRJbnQzMigwLCEwKSxFKjEyKjQpO2ZvcihsZXQgQT0wO0E8RTtBKyspZm9yKGxldCBIPTA7SDwxMjtIKyspTi5zZXRGbG9hdDMyKChBKjEyK0gpKjQsVFtBXS52YWx1ZXNbSF0sITApO2NvbnN0IFE9bmV3IERhdGFWaWV3KEIuYnVmZmVyLEYuZ2V0SW50MzIoNCwhMCksNDgpLFI9bmV3IERhdGFWaWV3KEIuYnVmZmVyLEYuZ2V0SW50MzIoOCwhMCksNDgpO2ZvcihsZXQgQT0wO0E8MTI7QSsrKVEuc2V0RmxvYXQzMihBKjQsay5tZWFuc1tBXSwhMCksUi5zZXRGbG9hdDMyKEEqNCxrLnN0ZERldnNbQV0sITApfXouc2V0X2lucHV0KHNhbXBsZVJhdGUpLHRoaXMuaW5wdXRCdWZmZXJQdHI9ei5nZXRfaW5wdXRfYnVmZmVyKCksdGhpcy5pbnB1dEJ1ZmZlclNpemU9ei5nZXRfaW5wdXRfYnVmZmVyX3NpemUoKSx0aGlzLmlucHV0QnVmZmVyPW5ldyBGbG9hdDMyQXJyYXkoQi5idWZmZXIsdGhpcy5pbnB1dEJ1ZmZlclB0cix0aGlzLmlucHV0QnVmZmVyU2l6ZSksdGhpcy5pbnB1dEJ1ZmZlckluZGV4PTAsdGhpcy5sYXN0SW5kZXg9MCx0aGlzLnZvbHVtZVB0cj16LmdldF92b2x1bWVfcHRyKCksdGhpcy52b2x1bWVWaWV3PW5ldyBEYXRhVmlldyhCLmJ1ZmZlcix0aGlzLnZvbHVtZVB0ciw0KX0pfXN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKXtyZXR1cm5be25hbWU6ImJsb2NrU2l6ZSIsZGVmYXVsdFZhbHVlOjUxMixtaW5WYWx1ZToxMjgsYXV0b21hdGlvblJhdGU6ImstcmF0ZSJ9XX1wcm9jZXNzKEosUyxrKXtjb25zdCBHPUpbMF1bMF07aWYoIUcpcmV0dXJuITA7aWYodGhpcy5pbnB1dEJ1ZmZlckluZGV4PT09LTEpcmV0dXJuITA7Zm9yKGxldCB6PTA7ejxHLmxlbmd0aDt6KyspdGhpcy5pbnB1dEJ1ZmZlclt0aGlzLmlucHV0QnVmZmVySW5kZXhdPUdbel0sdGhpcy5pbnB1dEJ1ZmZlckluZGV4PSh0aGlzLmlucHV0QnVmZmVySW5kZXgrMSkldGhpcy5pbnB1dEJ1ZmZlclNpemU7aWYoKHRoaXMuaW5wdXRCdWZmZXJJbmRleCt0aGlzLmlucHV0QnVmZmVyU2l6ZS10aGlzLmxhc3RJbmRleCkldGhpcy5pbnB1dEJ1ZmZlclNpemU9PT1rLmJsb2NrU2l6ZVswXSl7Y29uc3Qgej10aGlzLmV4cG9ydHMuZXhlY3V0ZSh0aGlzLmlucHV0QnVmZmVySW5kZXgpLEU9dGhpcy52b2x1bWVWaWV3LmdldEZsb2F0MzIoMCwhMCk7dGhpcy5wb3J0LnBvc3RNZXNzYWdlKHt0aW1lc3RhbXA6Y3VycmVudFRpbWUsaW5kZXg6eixuYW1lOnRoaXMubWZjY3Nbel0ubmFtZSx2b2x1bWU6RX0pLHRoaXMubGFzdEluZGV4PXRoaXMuaW5wdXRCdWZmZXJJbmRleH1yZXR1cm4hMH19cmVnaXN0ZXJQcm9jZXNzb3IoIndsaXBzeW5jLXByb2Nlc3NvciIsVSk7Cg==`,import.meta.url)),new Op(e,t)}}var Ap={jsonPath:`/home/steamvr/projects/wLipSync/www/profile.json`,mfccNum:12,mfccDataCount:12,melFilterBankChannels:30,targetSampleRate:16e3,sampleCount:1024,useStandardization:!1,compareMethod:2,mfccs:[{name:`A`,mfccCalibrationDataList:[{array:[94.40318298339844,.32245922088623047,-65.5116195678711,-29.537851333618164,4.888294219970703,14.523965835571287,-32.6411247253418,1.6505765914916992,-9.960077285766602,-5.7025322914123535,-11.886154174804688,-24.35236358642578]},{array:[94.40318298339844,.32245922088623047,-65.5116195678711,-29.537851333618164,4.888294219970703,14.523965835571287,-32.6411247253418,1.6505765914916992,-9.960077285766602,-5.7025322914123535,-11.886154174804688,-24.35236358642578]},{array:[102.16287231445312,-3.3587560653686523,-65.58428192138672,-25.24440574645996,3.224522590637207,12.005892753601076,-29.293079376220703,.6378564834594727,-10.817683219909668,-1.3263540267944336,-14.543159484863281,-24.169780731201172]},{array:[99.35592651367188,-3.681424140930176,-65.20439910888672,-23.45950698852539,6.205645561218262,14.96288013458252,-29.882709503173828,.6733551025390625,-7.077619552612305,-3.5570802688598637,-14.42734718322754,-23.34000396728516]},{array:[99.35592651367188,-3.681424140930176,-65.20439910888672,-23.45950698852539,6.205645561218262,14.96288013458252,-29.882709503173828,.6733551025390625,-7.077619552612305,-3.5570802688598637,-14.42734718322754,-23.34000396728516]},{array:[104.24951171875,-2.832884788513184,-66.59016418457031,-22.962886810302734,5.519782066345215,16.50394058227539,-32.338768005371094,5.820473670959473,-10.59586238861084,-2.7398462295532227,-12.5281400680542,-24.459365844726562]},{array:[104.24951171875,-2.832884788513184,-66.59016418457031,-22.962886810302734,5.519782066345215,16.50394058227539,-32.338768005371094,5.820473670959473,-10.59586238861084,-2.7398462295532227,-12.5281400680542,-24.459365844726562]},{array:[95.58644104003906,-5.775191307067871,-61.220008850097656,-24.658382415771488,4.411270141601563,13.673284530639648,-25.223039627075195,-2.0546646118164062,-6.887641906738281,-5.683987617492676,-11.20918083190918,-23.215322494506836]},{array:[98.24864196777344,-3.8367862701416016,-62.34006118774414,-24.563793182373047,4.608433723449707,16.228965759277344,-28.992279052734375,2.1237001419067383,-9.07174015045166,-4.581008434295654,-10.662440299987791,-26.19581413269043]},{array:[102.7921142578125,-4.580304145812988,-62.53183746337891,-26.292770385742188,7.911410331726074,17.13638496398926,-31.118263244628906,5.196089744567871,-10.01039695739746,-.8527965545654297,-12.346561431884766,-23.580944061279297]},{array:[102.12345123291016,-1.5254135131835938,-62.21220397949219,-26.728734970092777,10.62057876586914,16.918357849121097,-28.815664291381836,3.6714258193969727,-9.67378616333008,-.7385025024414062,-9.717185020446777,-27.09702491760254]},{array:[102.12345123291016,-1.5254135131835938,-62.21220397949219,-26.728734970092777,10.62057876586914,16.918357849121097,-28.815664291381836,3.6714258193969727,-9.67378616333008,-.7385025024414062,-9.717185020446777,-27.09702491760254]}]},{name:`I`,mfccCalibrationDataList:[{array:[14.441835403442385,52.40011596679688,57.37783813476563,-33.70046615600586,-12.751934051513672,-15.709930419921877,-41.381065368652344,-12.190519332885744,-2.863154411315918,-8.727733612060547,2.6656012535095215,1.4855976104736328]},{array:[14.441835403442385,52.40011596679688,57.37783813476563,-33.70046615600586,-12.751934051513672,-15.709930419921877,-41.381065368652344,-12.190519332885744,-2.863154411315918,-8.727733612060547,2.6656012535095215,1.4855976104736328]},{array:[15.294279098510744,50.07628631591797,57.262847900390625,-31.748844146728516,-13.642471313476564,-13.48408031463623,-41.53501129150391,-16.863862991333008,-1.739903450012207,-9.32723331451416,8.31618881225586,-1.779850959777832]},{array:[15.685098648071287,49.68647766113281,58.447113037109375,-32.513519287109375,-16.664287567138672,-13.78364372253418,-40.48309326171875,-16.04582405090332,-3.5356569290161137,-8.654275894165039,10.645575523376465,-2.556441307067871]},{array:[15.685098648071287,49.68647766113281,58.447113037109375,-32.513519287109375,-16.664287567138672,-13.78364372253418,-40.48309326171875,-16.04582405090332,-3.5356569290161137,-8.654275894165039,10.645575523376465,-2.556441307067871]},{array:[15.685098648071287,49.68647766113281,58.447113037109375,-32.513519287109375,-16.664287567138672,-13.78364372253418,-40.48309326171875,-16.04582405090332,-3.5356569290161137,-8.654275894165039,10.645575523376465,-2.556441307067871]},{array:[15.225826263427736,43.872196197509766,52.844512939453125,-32.51786804199219,-17.806241989135746,-10.609650611877441,-40.13084411621094,-11.58648681640625,-5.082568168640137,-14.396997451782228,6.896979331970215,-.785430908203125]},{array:[15.571629524230955,48.63488388061524,59.5339469909668,-34.59955596923828,-21.95987129211426,-10.298498153686523,-39.11286926269531,-11.998537063598633,-8.433327674865723,-10.80599594116211,8.789299011230469,-1.884697437286377]},{array:[15.571629524230955,48.63488388061524,59.5339469909668,-34.59955596923828,-21.95987129211426,-10.298498153686523,-39.11286926269531,-11.998537063598633,-8.433327674865723,-10.80599594116211,8.789299011230469,-1.884697437286377]},{array:[15.571629524230955,48.63488388061524,59.5339469909668,-34.59955596923828,-21.95987129211426,-10.298498153686523,-39.11286926269531,-11.998537063598633,-8.433327674865723,-10.80599594116211,8.789299011230469,-1.884697437286377]},{array:[19.23290252685547,47.43399810791016,54.90937423706055,-33.7783203125,-13.836353302001953,-5.141571044921875,-39.34584045410156,-13.409493446350098,-4.945652008056641,-12.96050262451172,12.210061073303224,.5807018280029297]},{array:[19.124774932861328,46.46723937988281,53.41281509399414,-34.65093994140625,-18.181049346923828,-7.733134746551514,-45.67931365966797,-10.64135456085205,-2.624391555786133,-15.708955764770508,7.36491870880127,-5.627689361572266]}]},{name:`U`,mfccCalibrationDataList:[{array:[83.38372802734375,42.39790725708008,27.812450408935547,10.69615077972412,-13.612553596496582,-32.487091064453125,-35.2574348449707,-6.425739288330078,-4.214997291564941,-6.896385669708252,-3.49631404876709,4.997060775756836]},{array:[103.65653228759766,38.661563873291016,30.985050201416016,17.43245124816895,-14.383820533752441,-39.810001373291016,-39.63761901855469,1.2333955764770508,-4.217883110046387,-3.005303382873535,-6.272947311401367,4.751875877380371]},{array:[103.44242095947266,45.23821640014649,27.622669219970703,18.682138442993164,-16.854982376098633,-39.85029602050781,-34.15940856933594,-2.7482595443725586,-3.741057395935059,-1.0625238418579102,-4.215768814086914,6.514510154724121]},{array:[103.44242095947266,45.23821640014649,27.622669219970703,18.682138442993164,-16.854982376098633,-39.85029602050781,-34.15940856933594,-2.7482595443725586,-3.741057395935059,-1.0625238418579102,-4.215768814086914,6.514510154724121]},{array:[99.99739837646484,39.48998260498047,26.0573844909668,23.26814079284668,-16.25522804260254,-38.15496063232422,-35.70051574707031,-1.2821111679077148,-2.3941946029663086,-.15543842315673828,-4.757769584655762,2.198577880859375]},{array:[99.99739837646484,39.48998260498047,26.0573844909668,23.26814079284668,-16.25522804260254,-38.15496063232422,-35.70051574707031,-1.2821111679077148,-2.3941946029663086,-.15543842315673828,-4.757769584655762,2.198577880859375]},{array:[107.09538269042967,37.70401000976563,17.795482635498047,21.882326126098633,-14.739266395568848,-36.407527923583984,-37.95854949951172,-1.4393510818481445,-1.9593324661254885,-.7294750213623047,-7.93386173248291,3.9560585021972656]},{array:[103.5069351196289,35.08988952636719,23.21630859375,23.947580337524418,-14.157055854797363,-38.546836853027344,-39.75208282470703,.516876220703125,-2.715259552001953,-4.076820850372315,-4.716378211975098,4.662134170532227]},{array:[103.5069351196289,35.08988952636719,23.21630859375,23.947580337524418,-14.157055854797363,-38.546836853027344,-39.75208282470703,.516876220703125,-2.715259552001953,-4.076820850372315,-4.716378211975098,4.662134170532227]},{array:[103.5069351196289,35.08988952636719,23.21630859375,23.947580337524418,-14.157055854797363,-38.546836853027344,-39.75208282470703,.516876220703125,-2.715259552001953,-4.076820850372315,-4.716378211975098,4.662134170532227]},{array:[98.43344116210938,35.42580032348633,29.2958984375,24.73729133605957,-15.485936164855955,-44.67648315429688,-39.97885894775391,.5548343658447266,-2.2034664154052734,-3.485844612121582,-7.421210289001465,6.30616569519043]},{array:[94.0390625,36.81925582885742,24.73573875427246,22.579418182373047,-14.354126930236816,-37.92849349975586,-44.69046401977539,.7474861145019531,-3.3195743560791016,-3.9850082397460938,-5.991059303283691,6.134122848510742]}]},{name:`E`,mfccCalibrationDataList:[{array:[60.52040481567383,14.444153785705568,50.91899108886719,6.730878829956055,-58.12107467651367,-16.403745651245117,-25.244909286499023,5.399906158447266,-7.63681697845459,-2.496482849121094,7.271292209625244,1.732271194458008]},{array:[59.32724761962891,14.82846450805664,51.402244567871094,5.413976669311523,-55.60324096679688,-15.348665237426758,-25.923606872558597,3.0006580352783203,-4.183259963989258,-3.4587841033935547,7.941498756408691,3.449912071228028]},{array:[59.32724761962891,14.82846450805664,51.402244567871094,5.413976669311523,-55.60324096679688,-15.348665237426758,-25.923606872558597,3.0006580352783203,-4.183259963989258,-3.4587841033935547,7.941498756408691,3.449912071228028]},{array:[64.61061096191406,7.8438310623168945,54.75372695922852,11.154451370239258,-62.99680709838867,-10.397377967834473,-36.124359130859375,12.57413387298584,-6.086113452911377,-3.032306671142578,10.453157424926758,-.00012826919555664065]},{array:[59.8906135559082,13.646936416625977,53.14240646362305,11.346290588378908,-60.17724609375,-15.942718505859377,-29.547088623046875,8.241331100463867,-6.890452384948731,-3.6554131507873535,14.714229583740236,-2.811859607696533]},{array:[53.77520751953125,6.071747779846191,47.87072372436524,5.943275451660156,-51.11442184448242,-16.62527656555176,-24.84233665466309,4.076478004455566,-8.835965156555176,-4.306196689605713,13.907751083374023,-.6555676460266113]},{array:[53.77520751953125,6.071747779846191,47.87072372436524,5.943275451660156,-51.11442184448242,-16.62527656555176,-24.84233665466309,4.076478004455566,-8.835965156555176,-4.306196689605713,13.907751083374023,-.6555676460266113]},{array:[53.77520751953125,6.071747779846191,47.87072372436524,5.943275451660156,-51.11442184448242,-16.62527656555176,-24.84233665466309,4.076478004455566,-8.835965156555176,-4.306196689605713,13.907751083374023,-.6555676460266113]},{array:[62.81553649902344,6.203365325927734,48.45057678222656,8.571174621582031,-53.907508850097656,-16.376169204711918,-25.989578247070312,5.736949920654297,-8.150140762329102,-5.895424842834473,13.745902061462404,-4.22935676574707]},{array:[53.43303680419922,7.019550323486328,43.32084655761719,7.639513969421387,-49.81471633911133,-18.70837783813477,-21.690540313720703,.34458446502685547,-8.689970970153809,-3.96992826461792,11.29841423034668,-4.165286540985107]},{array:[56.29218673706055,7.115049362182617,47.741546630859375,4.102975845336914,-50.46143341064453,-18.23562622070313,-22.557659149169925,6.925202369689941,-13.170380592346191,-1.0300326347351076,8.813325881958008,-3.2347850799560547]},{array:[56.29218673706055,7.115049362182617,47.741546630859375,4.102975845336914,-50.46143341064453,-18.23562622070313,-22.557659149169925,6.925202369689941,-13.170380592346191,-1.0300326347351076,8.813325881958008,-3.2347850799560547]}]},{name:`O`,mfccCalibrationDataList:[{array:[108.1234893798828,57.48288345336914,.23154354095458984,-31.144771575927734,-38.093109130859375,-18.33026885986328,-11.25010108947754,-.7636222839355469,-1.371236801147461,-9.181392669677736,-1.6202507019042969,-7.501105308532715]},{array:[108.1234893798828,57.48288345336914,.23154354095458984,-31.144771575927734,-38.093109130859375,-18.33026885986328,-11.25010108947754,-.7636222839355469,-1.371236801147461,-9.181392669677736,-1.6202507019042969,-7.501105308532715]},{array:[120.48326873779295,61.38327026367188,-2.67855453491211,-32.3900146484375,-40.94635772705078,-12.681024551391602,-10.979912757873535,-.7160100936889648,-2.9078426361083984,-12.30073928833008,1.8719825744628908,-6.2853875160217285]},{array:[109.58128356933594,58.46321105957031,.1479501724243164,-31.080230712890625,-34.73053741455078,-17.423336029052734,-10.221624374389648,.3863086700439453,-1.2579708099365237,-7.037452220916748,-2.894855499267578,-7.0971550941467285]},{array:[109.58128356933594,58.46321105957031,.1479501724243164,-31.080230712890625,-34.73053741455078,-17.423336029052734,-10.221624374389648,.3863086700439453,-1.2579708099365237,-7.037452220916748,-2.894855499267578,-7.0971550941467285]},{array:[116.19681549072266,60.3573112487793,.07350921630859375,-32.38472747802735,-34.47290802001953,-16.37361526489258,-14.695085525512695,.3102083206176758,.28844451904296875,-8.948881149291992,-3.104994773864746,-9.900266647338867]},{array:[116.19681549072266,60.3573112487793,.07350921630859375,-32.38472747802735,-34.47290802001953,-16.37361526489258,-14.695085525512695,.3102083206176758,.28844451904296875,-8.948881149291992,-3.104994773864746,-9.900266647338867]},{array:[98.63448333740236,48.66178131103516,2.394181251525879,-28.785797119140625,-31.54886054992676,-18.37759017944336,-14.998208999633787,-1.8050260543823244,-2.018402099609375,-4.584748268127441,-5.160560607910156,-7.968695163726807]},{array:[124.25032043457033,59.27610397338867,2.7454710006713867,-36.72577667236328,-38.65552520751953,-3.116687774658203,-24.24558448791504,.5085678100585938,2.3633852005004883,-10.51361083984375,1.7447805404663088,-13.22685432434082]},{array:[87.89213562011719,45.08750534057617,4.292821884155273,-26.482845306396488,-30.386096954345703,-20.410654067993164,-11.817208290100098,-3.12704086303711,-1.1370172500610352,-6.159217357635498,-3.454045295715332,-5.7265400886535645]},{array:[87.89213562011719,45.08750534057617,4.292821884155273,-26.482845306396488,-30.386096954345703,-20.410654067993164,-11.817208290100098,-3.12704086303711,-1.1370172500610352,-6.159217357635498,-3.454045295715332,-5.7265400886535645]},{array:[87.89213562011719,45.08750534057617,4.292821884155273,-26.482845306396488,-30.386096954345703,-20.410654067993164,-11.817208290100098,-3.12704086303711,-1.1370172500610352,-6.159217357635498,-3.454045295715332,-5.7265400886535645]}]},{name:`S`,mfccCalibrationDataList:[{array:[-94.29214477539064,9.299236297607422,-21.6169376373291,4.123956203460693,1.3645498752593996,-2.339733839035034,12.92388916015625,-7.490560531616211,10.520170211791992,-5.4832611083984375,2.162111043930054,2.696177482604981]},{array:[-94.29214477539064,9.299236297607422,-21.6169376373291,4.123956203460693,1.3645498752593996,-2.339733839035034,12.92388916015625,-7.490560531616211,10.520170211791992,-5.4832611083984375,2.162111043930054,2.696177482604981]},{array:[-92.13811492919922,8.712703704833984,-17.194181442260746,4.387561798095703,2.288078784942627,-9.562786102294922,9.854814529418945,-7.843216896057129,8.969221115112305,-7.96703052520752,.38271141052246094,2.731431007385254]},{array:[-92.13811492919922,8.712703704833984,-17.194181442260746,4.387561798095703,2.288078784942627,-9.562786102294922,9.854814529418945,-7.843216896057129,8.969221115112305,-7.96703052520752,.38271141052246094,2.731431007385254]},{array:[-90.87933349609376,12.622742652893068,-12.25172233581543,6.775156497955322,6.892632007598877,-4.708589553833008,10.558273315429688,-10.19419288635254,10.907587051391602,.7259445190429688,6.631969451904297,1.2803831100463867]},{array:[-90.87933349609376,12.622742652893068,-12.25172233581543,6.775156497955322,6.892632007598877,-4.708589553833008,10.558273315429688,-10.19419288635254,10.907587051391602,.7259445190429688,6.631969451904297,1.2803831100463867]},{array:[-94.86066436767578,18.40726089477539,-5.981902599334717,7.446142196655273,11.998884201049805,1.1316719055175781,5.726372718811035,-9.411809921264648,9.966836929321287,.6692547798156738,3.0949947834014897,-.5439543724060059]},{array:[-94.86066436767578,18.40726089477539,-5.981902599334717,7.446142196655273,11.998884201049805,1.1316719055175781,5.726372718811035,-9.411809921264648,9.966836929321287,.6692547798156738,3.0949947834014897,-.5439543724060059]},{array:[-94.86066436767578,18.40726089477539,-5.981902599334717,7.446142196655273,11.998884201049805,1.1316719055175781,5.726372718811035,-9.411809921264648,9.966836929321287,.6692547798156738,3.0949947834014897,-.5439543724060059]},{array:[-100.9681396484375,15.002283096313477,-4.994745254516602,.22259855270385745,-.15606117248535156,-1.8661277294158936,1.5652005672454836,-13.30648422241211,12.554527282714844,-2.990779399871826,3.5510034561157227,5.119507312774658]},{array:[-100.9681396484375,15.002283096313477,-4.994745254516602,.22259855270385745,-.15606117248535156,-1.8661277294158936,1.5652005672454836,-13.30648422241211,12.554527282714844,-2.990779399871826,3.5510034561157227,5.119507312774658]},{array:[-101.28047943115236,14.962509155273438,-10.988410949707031,3.6384878158569336,-1.4698257446289065,-4.758091449737549,-1.3547701835632324,-12.941855430603027,3.351996183395386,-5.5131611824035645,9.386914253234863,3.8310816287994385]}]},{name:`A`,mfccCalibrationDataList:[{array:[4.20286750793457,-73.493896484375,-24.746726989746097,-41.51460266113281,36.48657989501953,-18.2531795501709,-42.99116516113281,25.61282348632813,-18.3366813659668,-15.366691589355469,-4.867555618286133,-8.545194625854492]},{array:[6.645953178405762,-70.99688720703125,-23.49920082092285,-40.70307922363281,35.09113311767578,-19.63579750061035,-41.851219177246094,26.54837036132813,-20.36124420166016,-15.091900825500488,-5.332237243652344,-7.199653625488281]},{array:[6.645953178405762,-70.99688720703125,-23.49920082092285,-40.70307922363281,35.09113311767578,-19.63579750061035,-41.851219177246094,26.54837036132813,-20.36124420166016,-15.091900825500488,-5.332237243652344,-7.199653625488281]},{array:[3.48603630065918,-73.30689239501953,-21.244325637817383,-38.72576522827149,41.22803497314453,-15.975458145141602,-42.09079360961914,27.367385864257816,-19.52243995666504,-16.397735595703125,-3.779520988464355,-4.958502292633057]},{array:[.09921550750732422,-70.22235107421875,-20.888980865478516,-33.53620910644531,48.01523208618164,-13.365336418151855,-42.88488006591797,26.45193481445313,-13.952343940734863,-16.65743064880371,-1.894343376159668,-1.8812918663024905]},{array:[.09921550750732422,-70.22235107421875,-20.888980865478516,-33.53620910644531,48.01523208618164,-13.365336418151855,-42.88488006591797,26.45193481445313,-13.952343940734863,-16.65743064880371,-1.894343376159668,-1.8812918663024905]},{array:[.09921550750732422,-70.22235107421875,-20.888980865478516,-33.53620910644531,48.01523208618164,-13.365336418151855,-42.88488006591797,26.45193481445313,-13.952343940734863,-16.65743064880371,-1.894343376159668,-1.8812918663024905]},{array:[-4.117016792297363,-72.00682830810547,-19.490331649780277,-34.48163986206055,51.383995056152344,-9.989368438720703,-41.8690185546875,23.82486724853516,-11.14547061920166,-14.500547409057617,-2.504335403442383,1.0616645812988281]},{array:[-3.077279090881348,-77.95940399169922,-21.169992446899418,-43.19057846069336,47.594181060791016,-14.239681243896484,-43.05297088623047,23.796558380126953,-16.033828735351562,-14.308491706848145,-4.90071964263916,-.6597251892089844]},{array:[-3.077279090881348,-77.95940399169922,-21.169992446899418,-43.19057846069336,47.594181060791016,-14.239681243896484,-43.05297088623047,23.796558380126953,-16.033828735351562,-14.308491706848145,-4.90071964263916,-.6597251892089844]},{array:[.27674388885498047,-74.16876220703125,-19.241043090820312,-43.69765853881836,45.94886779785156,-15.777923583984377,-40.226318359375,25.209468841552734,-19.91909408569336,-14.123311042785645,-6.749327659606934,-2.186051368713379]},{array:[1.313084602355957,-70.17343139648438,-20.149150848388672,-40.1507568359375,43.281288146972656,-17.598236083984375,-39.989742279052734,19.475574493408203,-18.73434066772461,-15.377893447875977,-3.6761083602905273,-2.372090339660645]}]},{name:`I`,mfccCalibrationDataList:[{array:[-43.23860549926758,15.659211158752441,48.96119689941406,-84.8009033203125,-2.832998275756836,-25.101383209228516,-19.283388137817383,-1.3310365676879885,-3.906793594360352,-5.55475664138794,-24.20616149902344,19.690078735351562]},{array:[-43.23860549926758,15.659211158752441,48.96119689941406,-84.8009033203125,-2.832998275756836,-25.101383209228516,-19.283388137817383,-1.3310365676879885,-3.906793594360352,-5.55475664138794,-24.20616149902344,19.690078735351562]},{array:[-43.23860549926758,15.659211158752441,48.96119689941406,-84.8009033203125,-2.832998275756836,-25.101383209228516,-19.283388137817383,-1.3310365676879885,-3.906793594360352,-5.55475664138794,-24.20616149902344,19.690078735351562]},{array:[-35.28649139404297,11.94938850402832,46.56689453125,-80.19161987304688,-5.332358360290527,-16.747013092041016,-17.014617919921875,-6.106320381164551,-3.5759763717651367,-11.297148704528809,-19.73563575744629,19.95285415649414]},{array:[-35.28649139404297,11.94938850402832,46.56689453125,-80.19161987304688,-5.332358360290527,-16.747013092041016,-17.014617919921875,-6.106320381164551,-3.5759763717651367,-11.297148704528809,-19.73563575744629,19.95285415649414]},{array:[-33.85117721557617,12.74870014190674,48.14194488525391,-75.80270385742188,-.9702749252319336,-14.077031135559082,-15.91115379333496,-4.433165073394775,-4.00740909576416,-9.756240844726564,-20.910476684570312,18.42697525024414]},{array:[-29.72378921508789,13.039468765258787,47.7448616027832,-74.11089324951172,.8275318145751953,-16.012189865112305,-17.36796760559082,-1.0376081466674805,-4.8292741775512695,-6.667880058288574,-23.82168960571289,16.03271865844727]},{array:[-29.259418487548828,11.963765144348145,41.54622268676758,-75.67298889160156,-2.0329294204711914,-20.586360931396488,-21.125045776367188,.5504961013793945,-5.419882774353027,-6.314876556396484,-25.0130615234375,14.262750625610352]},{array:[-29.259418487548828,11.963765144348145,41.54622268676758,-75.67298889160156,-2.0329294204711914,-20.586360931396488,-21.125045776367188,.5504961013793945,-5.419882774353027,-6.314876556396484,-25.0130615234375,14.262750625610352]},{array:[-28.383831024169925,13.10340976715088,39.94292449951172,-81.08953857421875,-4.134577751159668,-21.59007263183594,-23.217021942138672,-.3798789978027344,-5.072433471679688,-5.94474983215332,-26.63843536376953,16.777332305908203]},{array:[-30.04895401000977,16.33201599121094,44.49327850341797,-81.91828155517578,-4.171995162963867,-19.618621826171875,-20.534595489501953,-.9673957824707032,-3.2188777923583984,-6.572293758392334,-26.59181785583496,18.48187255859375]},{array:[-30.987979888916016,14.425168991088867,48.951114654541016,-82.33119201660156,-4.302616119384766,-17.64216995239258,-19.92198181152344,-1.7414522171020508,-1.731914520263672,-6.870545387268066,-22.85688591003418,19.475980758666992]}]},{name:`U`,mfccCalibrationDataList:[{array:[35.53300476074219,-11.371288299560549,16.69929885864258,-39.32943344116211,2.8931827545166016,-39.35669708251953,-22.81580924987793,-8.255973815917969,-7.3601884841918945,3.866161346435547,-36.18340301513672,.44779300689697266]},{array:[34.92810821533203,-12.66100025177002,19.55118560791016,-38.58994293212891,1.5609407424926758,-42.781375885009766,-22.405025482177734,-4.380008220672607,-9.27183723449707,5.952349662780762,-38.181243896484375,1.4162702560424805]},{array:[34.508079528808594,-10.0599946975708,18.88445281982422,-34.42189407348633,-.8881950378417969,-42.52379608154297,-20.37147331237793,-.6865062713623047,-8.89057731628418,6.381434440612793,-34.81671524047852,3.530543327331543]},{array:[34.508079528808594,-10.0599946975708,18.88445281982422,-34.42189407348633,-.8881950378417969,-42.52379608154297,-20.37147331237793,-.6865062713623047,-8.89057731628418,6.381434440612793,-34.81671524047852,3.530543327331543]},{array:[37.63418579101563,-14.223724365234377,21.262420654296875,-39.50825119018555,.31142520904541016,-43.201324462890625,-19.136680603027344,-.7461652755737305,-8.253379821777344,9.12716293334961,-33.483253479003906,9.34031105041504]},{array:[38.28554916381836,-15.814170837402344,19.503570556640625,-40.19694900512695,-.7106151580810547,-45.37378311157227,-20.631587982177734,-2.233296394348145,-6.609874725341797,8.43967342376709,-33.560943603515625,8.549976348876953]},{array:[38.28554916381836,-15.814170837402344,19.503570556640625,-40.19694900512695,-.7106151580810547,-45.37378311157227,-20.631587982177734,-2.233296394348145,-6.609874725341797,8.43967342376709,-33.560943603515625,8.549976348876953]},{array:[36.15192413330078,-19.43944549560547,19.22710609436035,-40.229862213134766,-1.7119722366333008,-44.58899688720703,-22.39651870727539,-4.687357902526856,-5.184035301208496,5.601207733154297,-35.31377792358399,6.856324195861816]},{array:[33.697601318359375,-19.53946304321289,18.151920318603516,-38.29360580444336,-1.9536991119384768,-39.18521881103516,-21.181903839111328,-8.092260360717773,-6.441320419311523,3.8472461700439458,-32.4590950012207,8.79825210571289]},{array:[31.76858520507813,-17.137840270996097,15.726847648620605,-36.897605895996094,-3.8221397399902344,-35.492652893066406,-19.920631408691406,-10.421395301818848,-7.471479415893555,1.7216854095458984,-25.7265739440918,12.090950965881348]},{array:[31.76858520507813,-17.137840270996097,15.726847648620605,-36.897605895996094,-3.8221397399902344,-35.492652893066406,-19.920631408691406,-10.421395301818848,-7.471479415893555,1.7216854095458984,-25.7265739440918,12.090950965881348]},{array:[32.6759033203125,-15.928326606750488,16.0853271484375,-34.126686096191406,-6.689325332641602,-33.79350662231445,-19.242847442626953,-10.59890079498291,-10.992877006530762,-2.9957642555236816,-23.329811096191406,14.23158359527588]}]},{name:`U`,mfccCalibrationDataList:[{array:[50.45172882080078,-7.723395347595215,32.29489135742188,-11.293773651123049,-22.777332305908203,-36.17817687988281,-17.044910430908203,-3.767278671264649,-14.233147621154785,-17.250513076782227,-19.240345001220703,-6.971443176269531]},{array:[53.59954071044922,-9.874463081359863,35.237457275390625,-11.929043769836426,-23.915904998779297,-38.07780838012695,-15.71041202545166,-6.737283706665039,-12.06786060333252,-14.436643600463867,-20.401880264282227,-7.594654560089111]},{array:[57.36424255371094,-14.57245922088623,35.10681915283203,-13.044787406921388,-24.196090698242188,-36.5896110534668,-16.161855697631836,-10.228910446166992,-10.43470287322998,-10.997936248779297,-20.92641830444336,-7.631929397583008]},{array:[57.65166473388672,-16.92430305480957,33.02215194702149,-12.667181968688965,-21.69562530517578,-32.90369415283203,-14.275350570678713,-10.332601547241213,-10.544659614562988,-6.801647186279297,-22.47809410095215,-8.94782543182373]},{array:[49.60702133178711,-9.94367504119873,25.04156494140625,-9.98995304107666,-21.814006805419925,-28.99759292602539,-16.792327880859375,-9.5930814743042,-11.523345947265623,-7.568509578704834,-20.688356399536136,-10.5545015335083]},{array:[53.43399047851563,-10.947863578796388,30.42605590820313,-10.506410598754885,-22.997278213500977,-31.270254135131836,-16.90880584716797,-9.606002807617188,-10.785472869873049,-9.04238510131836,-22.82281494140625,-12.42250919342041]},{array:[57.11727523803711,-14.77857780456543,33.16322326660156,-13.437588691711426,-25.450626373291016,-33.84945297241211,-17.6593017578125,-11.152002334594728,-12.203851699829102,-9.72322940826416,-26.653217315673828,-12.098143577575684]},{array:[58.65357208251953,-15.040183067321777,32.92494583129883,-12.598053932189941,-24.03311538696289,-33.4146728515625,-15.565327644348145,-11.081777572631836,-10.47522258758545,-9.327695846557617,-28.43020248413086,-11.224303245544434]},{array:[53.888484954833984,-13.592279434204102,31.6711368560791,-9.440587043762209,-23.316177368164062,-35.3663444519043,-19.26239776611328,-13.472862243652344,-11.312352180480955,-7.2335309982299805,-25.466888427734375,-8.924440383911133]},{array:[54.30769348144531,-13.31528663635254,26.960655212402344,-11.682543754577637,-23.105655670166016,-32.50704956054688,-17.88333320617676,-10.961587905883787,-11.377249717712404,-7.610130786895752,-24.95154190063477,-9.38066577911377]},{array:[57.15829849243164,-13.77165985107422,31.29568099975586,-9.493865966796877,-23.708837509155277,-33.85169982910156,-19.99985122680664,-12.555244445800781,-14.447962760925291,-7.608822822570801,-23.899951934814457,-6.755941867828369]},{array:[47.781307220458984,-14.279045104980469,23.228328704833984,-14.190330505371094,-23.399112701416016,-34.95072555541992,-21.406070709228516,-10.15461254119873,-14.686234474182127,-9.932022094726564,-22.141719818115234,-8.354757308959961]}]},{name:`E`,mfccCalibrationDataList:[{array:[7.131360054016113,-36.049346923828125,45.31159210205078,-45.00178527832031,-15.53347110748291,1.3071203231811523,2.57974910736084,-1.8762083053588867,-25.02313995361328,-22.275257110595703,-16.383546829223633,-17.868574142456055]},{array:[7.131360054016113,-36.049346923828125,45.31159210205078,-45.00178527832031,-15.53347110748291,1.3071203231811523,2.57974910736084,-1.8762083053588867,-25.02313995361328,-22.275257110595703,-16.383546829223633,-17.868574142456055]},{array:[11.067873001098633,-36.16781234741211,45.893943786621094,-43.60368347167969,-15.017866134643556,-1.2796411514282229,2.090773582458496,-2.00726318359375,-22.139572143554688,-22.111957550048828,-16.975831985473633,-17.187711715698246]},{array:[9.000146865844727,-36.58183288574219,46.39983367919922,-45.5433349609375,-15.245804786682127,-2.223395347595215,4.547385215759277,-1.7552833557128908,-24.691539764404297,-22.836109161376953,-15.247169494628908,-15.090204238891602]},{array:[6.99749755859375,-37.912235260009766,46.3832893371582,-47.18668365478516,-13.492773056030273,-2.466267585754395,5.109303951263428,-1.4368247985839844,-25.965919494628906,-23.327587127685547,-14.712173461914064,-15.369802474975586]},{array:[8.53531551361084,-38.04619598388672,47.71860885620117,-47.188323974609375,-12.696022987365724,.9119815826416016,5.812184810638428,1.9683570861816408,-28.441104888916016,-21.203857421875,-16.284610748291016,-15.28965950012207]},{array:[8.53531551361084,-38.04619598388672,47.71860885620117,-47.188323974609375,-12.696022987365724,.9119815826416016,5.812184810638428,1.9683570861816408,-28.441104888916016,-21.203857421875,-16.284610748291016,-15.28965950012207]},{array:[10.728363037109377,-37.86867141723633,48.31739044189453,-47.47754669189453,-12.409613609313965,-.4410533905029297,5.663397789001465,3.449146270751953,-27.80557632446289,-20.967662811279297,-15.19067096710205,-14.877350807189941]},{array:[10.065123558044434,-36.66007232666016,44.76460266113281,-47.56492233276367,-12.32224941253662,-2.301477432250977,3.445328712463379,3.1899805068969727,-25.73431205749512,-21.715232849121097,-13.482653617858888,-17.041053771972656]},{array:[8.782588958740234,-36.92534255981445,44.4034309387207,-46.98899841308594,-8.84085464477539,-3.2711610794067383,2.835450172424317,3.1592531204223637,-24.939672470092777,-21.54747772216797,-15.242938041687012,-17.53165054321289]},{array:[6.508709907531738,-36.80110168457031,42.792266845703125,-46.29795837402344,-6.919498443603516,-3.788252830505371,2.5329980850219727,4.23353385925293,-24.539836883544925,-21.791210174560547,-16.75529670715332,-18.159324645996097]},{array:[6.508709907531738,-36.80110168457031,42.792266845703125,-46.29795837402344,-6.919498443603516,-3.788252830505371,2.5329980850219727,4.23353385925293,-24.539836883544925,-21.791210174560547,-16.75529670715332,-18.159324645996097]}]},{name:`O`,mfccCalibrationDataList:[{array:[53.443660736083984,-12.53360652923584,-26.871780395507816,-71.98885345458984,-5.861575126647949,-1.712080001831055,-32.90825653076172,23.514209747314457,-10.125606536865236,-11.977684020996094,9.883563041687012,-5.261895179748535]},{array:[55.69048309326172,-10.316678047180176,-26.289718627929688,-74.05561828613281,-4.348355293273926,-1.1102313995361328,-32.498268127441406,22.016807556152344,-11.227481842041016,-11.753466606140137,10.583023071289064,-3.583785057067871]},{array:[55.69048309326172,-10.316678047180176,-26.289718627929688,-74.05561828613281,-4.348355293273926,-1.1102313995361328,-32.498268127441406,22.016807556152344,-11.227481842041016,-11.753466606140137,10.583023071289064,-3.583785057067871]},{array:[56.3330307006836,-9.761429786682127,-24.52502822875977,-75.67504119873047,-2.94111442565918,-1.0509262084960938,-32.58983612060547,20.397789001464844,-13.52730941772461,-10.221673965454102,8.806441307067871,-6.1672868728637695]},{array:[58.4255599975586,-13.048576354980469,-26.326568603515625,-77.33265686035156,.8971290588378906,-.13758087158203125,-34.79779052734375,22.524978637695312,-15.138383865356445,-9.027335166931152,10.94324779510498,-6.867808818817139]},{array:[57.16611099243164,-17.380069732666016,-26.70465087890625,-76.53448486328125,3.203751564025879,1.6217775344848633,-36.67759323120117,24.14405059814453,-12.52278518676758,-8.60572338104248,13.969680786132812,-4.909186840057373]},{array:[55.17543029785156,-22.491680145263672,-25.568838119506836,-74.10460662841797,2.1666202545166016,4.1397705078125,-37.21670913696289,21.99705505371094,-11.680967330932617,-8.396781921386719,13.454421997070312,-3.452665328979492]},{array:[55.18680953979492,-23.176528930664062,-23.64011573791504,-69.64533233642578,1.9893865585327148,7.129931449890137,-35.871803283691406,19.41016006469727,-13.193324089050291,-8.643393516540527,10.173726081848145,-3.2846717834472656]},{array:[55.18680953979492,-23.176528930664062,-23.64011573791504,-69.64533233642578,1.9893865585327148,7.129931449890137,-35.871803283691406,19.41016006469727,-13.193324089050291,-8.643393516540527,10.173726081848145,-3.2846717834472656]},{array:[52.92599105834961,-22.9690055847168,-25.62136459350586,-65.79485321044922,.01132965087890625,5.457650184631348,-33.96955871582031,16.389381408691406,-14.026248931884766,-7.287093162536621,11.159339904785156,-3.7541093826293945]},{array:[51.816688537597656,-22.891870498657227,-29.80591201782227,-68.66901397705078,-1.94846248626709,1.63895320892334,-33.593971252441406,17.095460891723633,-13.046170234680176,-8.923750877380371,13.052698135375977,-5.068996429443359]},{array:[54.392459869384766,-23.71658706665039,-31.424976348876953,-75.520263671875,-4.738470077514648,-.12287521362304688,-36.41456604003906,18.125713348388672,-14.02833366394043,-11.63118839263916,12.234237670898438,-4.546117782592773]}]}]};function jp(e){let{audioContext:t}=pn(),{state:n,isReady:r}=cn(kp(t,Ap),void 0),i=[`A`,`E`,`I`,`O`,`U`,`S`],a=[`A`,`E`,`I`,`O`,`U`],s={A:`aa`,E:`ee`,I:`ih`,O:`oh`,U:`ou`},c={A:`A`,E:`E`,I:`I`,O:`O`,U:`U`,S:`I`},l={A:0,E:0,I:0,O:0,U:0},u=.7,d=0;m([r,e],([e,t],[,r])=>{if(r&&r!==t)try{r.disconnect()}catch{}if(!(!e||!t||!n.value))try{t.connect(n.value)}catch{}},{immediate:!0}),o(()=>e.value?.disconnect());function f(e,t=.016){let r=n.value;if(!e?.expressionManager||!r)return;let o=r.volume??0,f=Math.min(o*.9,1)**.7,p={A:0,E:0,I:0,O:0,U:0};for(let e of i){let t=c[e],n=r.weights[e]??0;p[t]=Math.max(p[t],n*f)}let m=`I`,h=`E`,g=-1/0,_=-1/0;for(let e of a){let t=p[e];t>g?(_=g,h=m,g=t,m=e):t>_&&(_=t,h=e)}let v=performance.now(),y=f<.04||g<.05;y||(d=v),v-d>160&&(y=!0);let b={A:0,E:0,I:0,O:0,U:0};y||(b[m]=Math.min(u,g),b[h]=Math.min(u*.5,_*.6));for(let n of a){let r=l[n],i=b[n],a=1-Math.exp(-(i>r?50:30)*t);l[n]=r+(i-r)*a;let o=(l[n]<=.01?0:l[n])*.7;e.expressionManager.setValue(s[n],o)}}return{update:f}}var Mp=e({__name:`VRMModel`,props:{currentAudioSource:{},modelSrc:{},lastModelSrc:{},idleAnimation:{},paused:{type:Boolean,default:!1},envSelect:{},skyBoxIntensity:{},nprIrrSH:{},modelOffset:{},modelRotationY:{},lookAtTarget:{},trackingMode:{},eyeHeight:{},cameraPosition:{},camera:{}},emits:[`loadingProgress`,`loadStart`,`cameraPosition`,`modelOrigin`,`modelSize`,`modelRotationY`,`eyeHeight`,`lookAtTarget`,`error`,`loaded`],setup(e,{expose:t,emit:i}){let a=e,s=i,{currentAudioSource:c,modelSrc:l,lastModelSrc:u,idleAnimation:d,paused:g,envSelect:_,skyBoxIntensity:v,nprIrrSH:y,modelOffset:b,modelRotationY:x,lookAtTarget:S,trackingMode:C,eyeHeight:ee,cameraPosition:te,camera:ne}=r(a),{scene:re}=Et(),E=w(),D=w(),O=T(!1),{x:ie,y:ae}=an(),k=new de,oe=new L,A=w(),se,ce,le=T(),{onBeforeRender:j,stop:fe,start:pe}=pt(),me,he=xp(),ge=Sp(),_e=T(),ve=jp(c),ye=T(0),be=null;function M(){me?.(),D.value&&D.value.removeFromParent(),E.value&&Xu.deepDispose(E.value.scene),be?.dispose(),be=null}function xe(e,t,n){oe.x=e/window.innerWidth*2-1,oe.y=-(t/window.innerHeight)*2+1,k.setFromCamera(oe,n.value);let r=new F;n.value.getWorldDirection(r);let i=new ue;i.setFromNormalAndCoplanarPoint(r,n.value.position.clone().add(r.multiplyScalar(1)));let a=new F;return k.ray.intersectPlane(i,a),{x:a.x,y:a.y,z:a.z}}function Se(e){return{x:0,y:e,z:-100}}async function Ce(){try{if(!re.value){console.warn(`Scene is not ready, cannot load VRM model.`);return}if(D.value&&M(),!l.value){console.warn(`NO model src, cannot load VRM model.`);return}let e=l.value!==u.value;try{s(`loadStart`),O.value=!1;let t=await Cp(l.value,{scene:re.value,lookAt:!0,onProgress:e=>s(`loadingProgress`,Number((100*e.loaded/e.total).toFixed(2)))});if(!t||!t._vrm||!t?._vrmGroup){console.warn(`VRM model loading failure!`);return}let{_vrm:n,_vrmGroup:r,modelCenter:i,modelSize:a,initialCameraOffset:o}=t;E.value=n,D.value=r,e&&(s(`cameraPosition`,{x:i.x+o.x,y:i.y+o.y,z:i.z+o.z}),s(`modelOrigin`,{x:i.x,y:i.y,z:i.z}),s(`modelSize`,{x:a.x,y:a.y,z:a.z})),e&&s(`modelRotationY`,0);let c=await yp(n,await vp(d.value));if(!c){console.warn(`No VRM animation loaded`);return}bp(c,n),le.value=new st(n.scene),le.value.clipAction(c).play(),_e.value=wp(n);function u(e){return!!(e?.isShaderMaterial&&e.userData?.vrmMaterialType===`MToon`)}let f=e=>!!e?.isShaderMaterial;!be&&re.value&&(be=ad(re.value)),n.scene.traverse(e=>{e instanceof it&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{if(e instanceof ft||e instanceof St)e.envMapIntensity=1,e.needsUpdate=!0;else if(u(e))`toneMapped`in e&&(e.toneMapped=!1);else if(f(e)){`toneMapped`in e&&(e.toneMapped=!1),`envMap`in e&&e.envMap&&(e.envMap=null);let t=e.map;if(t&&t.colorSpace!==void 0)try{t.colorSpace=N}catch(e){console.warn(`Failed to set colorSpace on texture:`,e)}rd(e)}})});function p(){let e=E.value?.humanoid?.getNormalizedBoneNode(`head`);if(!e)return null;let t=new F;return e.getWorldPosition(t),t.y}if(e){let e=p();e&&(s(`eyeHeight`,e),s(`lookAtTarget`,Se(e)))}me=j(({delta:e})=>{le.value?.update(e),E.value?.update(e),E.value?.lookAt?.update?.(e),he.update(E.value,e),ge.update(E.value,S,e),_e.value?.update(e),ve.update(E.value,e),E.value?.springBoneManager?.update(e)}).off,s(`loaded`,l.value),O.value=!0}catch(e){console.error(e),s(`error`,e)}}catch(e){console.error(e),s(`error`,e)}}return f(async()=>{await tn(()=>re.value).toBeTruthy(),await Ce(),m(l,(e,t)=>{e!==t&&Ce()}),m(g,e=>{e?fe():pe()},{immediate:!0}),m(b,()=>{D.value&&D.value.position.set(b.value.x,b.value.y,b.value.z)},{immediate:!0,deep:!0}),m(x,e=>{D.value&&(D.value.rotation.y=I.degToRad(e))},{immediate:!0}),m([_,v,y],async()=>{if(!E.value)return;ye.value+=1;let e=td(_.value);id(E.value?.scene,{mode:e,intensity:v.value,sh:y.value??null}),be?.update(e,v.value,y.value??null)},{immediate:!0}),m(C,e=>{ce?.(),ce=void 0,se?.(),se=void 0,e===`camera`?ce=m(te,e=>{s(`lookAtTarget`,e)},{immediate:!0,deep:!0}):e===`mouse`?se=m([ie,ae],([e,t])=>{A.value=xe(e,t,ne),s(`lookAtTarget`,A.value)},{immediate:!0,deep:!0}):s(`lookAtTarget`,Se(ee.value))},{immediate:!0}),m(S,e=>{ge.instantUpdate(E.value,e)},{deep:!0})}),o(()=>M()),t({setExpression(e){_e.value?.setEmotionWithResetAfter(e,1e3)},scene:h(()=>E.value?.scene),lookAtUpdate(e){ge.instantUpdate(E.value,e)}}),(e,t)=>O.value?p(e.$slots,`default`,{key:0}):n(``,!0)}}),Np=[`color`,`ground-color`,`intensity`],Pp=[`color`,`intensity`],Fp=[`color`,`position`,`intensity`],Ip={key:2,size:1},Lp=e({__name:`ThreeScene`,props:{currentAudioSource:{},modelSrc:{},skyBoxSrc:{},showAxes:{type:Boolean,default:!1},idleAnimation:{default:new URL(`/assets/idle_loop-Cs1QaHgK.vrma`,``+import.meta.url).href},paused:{type:Boolean,default:!1}},emits:[`loadModelProgress`,`error`],setup(e,{expose:t,emit:r}){let i=e,a=r,u=T(),{width:p,height:h}=sn(u),{lastModelSrc:b,modelSize:x,modelOrigin:S,modelOffset:C,modelRotationY:E,cameraFOV:D,cameraPosition:O,cameraDistance:ie,directionalLightPosition:ae,directionalLightTarget:k,directionalLightRotation:oe,directionalLightIntensity:A,directionalLightColor:se,ambientLightIntensity:ce,ambientLightColor:le,hemisphereSkyColor:ue,hemisphereGroundColor:j,hemisphereLightIntensity:de,lookAtTarget:fe,trackingMode:pe,eyeHeight:me,envSelect:he,skyBoxSrc:ge,skyBoxIntensity:_e}=Zt(No()),ve=T(),ye=w(new Ie),be=w(),M=w(),xe=T(),N=T();function Ce(e){(Math.abs(O.value.x-e.newCameraPosition.x)>1e-6||Math.abs(O.value.y-e.newCameraPosition.y)>1e-6||Math.abs(O.value.z-e.newCameraPosition.z)>1e-6)&&(O.value=e.newCameraPosition),Math.abs(ie.value-e.newCameraDistance)>1e-6&&(ie.value=e.newCameraDistance)}let we=T(!1);function Te(){we.value=!0}let Ee=T(!1),De=T(!1);function Oe(){Ee.value=!1,De.value=!1}function ke(e){O.value.x=e.x,O.value.y=e.y,O.value.z=e.z}function Ae(e){S.value.x=e.x,S.value.y=e.y,S.value.z=e.z}function je(e){x.value.x=e.x,x.value.y=e.y,x.value.z=e.z}function P(e){E.value=e}function Me(e){me.value=e}function Ne(e){fe.value.x=e.x,fe.value.y=e.y,fe.value.z=e.z}function Pe(e){b.value=e,Ee.value=!0,De.value=!0}let Fe=T(null);function Le(e){Fe.value=e.irrSH||null}function Re(e){M.value=e}f(()=>{he.value===`skyBox`&&xe.value?.reload(ge.value)}),o(()=>{});let ze={saturation:.3,hue:0,blendFunction:K.SRC},Be=T(!1),Ve=T(!1);function He(){Ve.value=!0}m([we,Ve],([e,t])=>{if(e&&t&&ye.value&&be.value&&be.value.controls&&N.value)try{N.value.parent?.add(N.value.target),N.value.target.position.set(k.value.x,k.value.y,k.value.z),N.value.target.updateMatrixWorld()}finally{Be.value=!0}});function Ue(e){let t=N.value;if(!t)return;let{x:n,y:r,z:i}=e,a=new F(ae.value.x,ae.value.y,ae.value.z),o=new F(0,0,0),s=new Se(I.degToRad(n),I.degToRad(r),I.degToRad(i),`XYZ`),c=o.clone().sub(a).normalize().applyEuler(s).normalize(),l=a.distanceTo(o),u=a.clone().addScaledVector(c,l);t.target.position.copy(u),t.target.updateMatrixWorld(),k.value={x:u.x,y:u.y,z:u.z}}return m(oe,e=>{Ue(e)},{deep:!0}),t({setExpression:e=>{ve.value?.setExpression(e)},canvasElement:()=>M.value?.renderer.instance.domElement}),(e,t)=>(s(),ne(`div`,{ref_key:`sceneContainerRef`,ref:u,w:`100%`,h:`100%`},[te(_(v(Lt),{camera:ye.value,antialias:!0,width:v(p),height:v(h),"tone-mapping":v(4),"tone-mapping-exposure":1,"clear-alpha":0,onReady:Re},{default:y(()=>[_(v(es),{ref_key:`controlsRef`,ref:be,"control-enable":De.value,"model-loaded":Ee.value,"model-size":v(x),"camera-position":v(O),"camera-target":v(S),"camera-f-o-v":v(D),"camera-distance":v(ie),onOrbitControlsCameraChanged:Ce,onOrbitControlsReady:Te},null,8,[`control-enable`,`model-loaded`,`model-size`,`camera-position`,`camera-target`,`camera-f-o-v`,`camera-distance`]),v(he)===`skyBox`?(s(),d(v(as),{key:0,ref_key:`skyBoxEnvRef`,ref:xe,"sky-box-src":v(ge),"as-background":!0,onSkyBoxReady:Le},null,8,[`sky-box-src`])):(s(),ne(`TresHemisphereLight`,{key:1,color:v(un)(v(ue)),"ground-color":v(un)(v(j)),position:[0,1,0],intensity:v(de),"cast-shadow":``},null,8,Np)),re(`TresAmbientLight`,{color:v(un)(v(le)),intensity:v(ce),"cast-shadow":``},null,8,Pp),re(`TresDirectionalLight`,{ref_key:`dirLightRef`,ref:N,color:v(un)(v(se)),position:[v(ae).x,v(ae).y,v(ae).z],intensity:v(A),"cast-shadow":``,onReady:He},null,40,Fp),(s(),d(g,null,{default:y(()=>[_(v(wo),null,{default:y(()=>[_(v(jo),l(c(ze)),null,16)]),_:1})]),_:1})),_(v(Mp),{ref_key:`modelRef`,ref:ve,"current-audio-source":i.currentAudioSource,"model-src":i.modelSrc,"last-model-src":v(b),"idle-animation":i.idleAnimation,paused:i.paused,"env-select":v(he),"sky-box-intensity":v(_e),"npr-irr-s-h":Fe.value,"model-offset":v(C),"model-rotation-y":v(E),"look-at-target":v(fe),"tracking-mode":v(pe),"eye-height":v(me),"camera-position":v(O),camera:ye.value,onLoadingProgress:t[0]||=e=>a(`loadModelProgress`,e),onLoadStart:Oe,onCameraPosition:ke,onModelOrigin:Ae,onModelSize:je,onModelRotationY:P,onEyeHeight:Me,onLookAtTarget:Ne,onError:t[1]||=e=>a(`error`,e),onLoaded:Pe},null,8,[`current-audio-source`,`model-src`,`last-model-src`,`idle-animation`,`paused`,`env-select`,`sky-box-intensity`,`npr-irr-s-h`,`model-offset`,`model-rotation-y`,`look-at-target`,`tracking-mode`,`eye-height`,`camera-position`,`camera`]),i.showAxes?(s(),ne(`TresAxesHelper`,Ip)):n(``,!0)]),_:1},8,[`camera`,`width`,`height`,`tone-mapping`]),[[ee,!0]])],512))}});export{Fn as a,Pa as i,No as n,Fa as r,Lp as t}; \ No newline at end of file