@needle-tools/engine 4.8.0-next.9de3f45 → 4.8.0-next.d64b390

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/gltf-progressive-43ba_8ZL.min.js +8 -0
  2. package/dist/gltf-progressive-BrzbysCn.umd.cjs +8 -0
  3. package/dist/gltf-progressive-DtAMqRsU.js +1385 -0
  4. package/dist/loader.worker-D5fjeWJO.js +27 -0
  5. package/dist/needle-engine.bundle-B23O7jqK.js +42600 -0
  6. package/dist/needle-engine.bundle-BFJMdMtI.min.js +1607 -0
  7. package/dist/needle-engine.bundle-DiXKsIfg.umd.cjs +1607 -0
  8. package/dist/needle-engine.d.ts +15 -15
  9. package/dist/needle-engine.js +591 -592
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/{postprocessing-BzY0H7ry.min.js → postprocessing-ChsrvDkI.min.js} +54 -54
  13. package/dist/{postprocessing-vKBVFpSz.js → postprocessing-DElbMQgB.js} +479 -483
  14. package/dist/{postprocessing-Dw2OCMp4.umd.cjs → postprocessing-DtxaELce.umd.cjs} +66 -66
  15. package/dist/{three-examples-DUcCNw9s.umd.cjs → three-examples-BhQvv1B9.umd.cjs} +11 -11
  16. package/dist/{three-examples-tvuhV8Ne.js → three-examples-CM6Iip03.js} +23 -27
  17. package/dist/{three-examples-BMOhDaYR.min.js → three-examples-D2zemuAM.min.js} +12 -12
  18. package/dist/{three-mesh-ui-CxuWt7m-.js → three-mesh-ui-D6Mz5Yl7.js} +799 -810
  19. package/dist/three-mesh-ui-DWcMuyQ_.min.js +406 -0
  20. package/dist/three-mesh-ui-tt0buEDC.umd.cjs +406 -0
  21. package/dist/{vendor-BmYIgaS1.js → vendor-ClB-U1Hn.js} +10 -10
  22. package/dist/{vendor-Cavtu3CP.umd.cjs → vendor-bOWOWClg.umd.cjs} +1 -1
  23. package/lib/engine/engine_serialization_builtin_serializer.js +1 -1
  24. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  25. package/lib/engine/extensions/extensions.js +1 -1
  26. package/lib/engine/extensions/extensions.js.map +1 -1
  27. package/package.json +3 -3
  28. package/plugins/vite/dependencies.js +28 -19
  29. package/plugins/vite/dependency-watcher.js +6 -1
  30. package/src/engine/engine_serialization_builtin_serializer.ts +1 -1
  31. package/src/engine/extensions/extensions.ts +1 -1
  32. package/dist/gltf-progressive-Bz6FXMZ1.min.js +0 -8
  33. package/dist/gltf-progressive-DAdiYt1v.js +0 -1392
  34. package/dist/gltf-progressive-D_S7mZaT.umd.cjs +0 -8
  35. package/dist/loader.worker-qHzhYKEC.js +0 -1
  36. package/dist/needle-engine.bundle-C5vAAuK3.js +0 -43849
  37. package/dist/needle-engine.bundle-fg0LG9Pa.umd.cjs +0 -1607
  38. package/dist/needle-engine.bundle-tepIih-J.min.js +0 -1607
  39. package/dist/three-mesh-ui-B3p3gyUz.min.js +0 -406
  40. package/dist/three-mesh-ui-CQiIQIlA.umd.cjs +0 -406
@@ -0,0 +1,406 @@
1
+ import{Vector4 as It,Vector3 as Tt,Vector2 as Ft,TextureLoader as Ot,Texture as zt,ShaderMaterial as At,PlaneGeometry as Wt,Plane as Dt,Object3D as Et,MeshBasicMaterial as Lt,Mesh as Ht,LinearFilter as Gt,FrontSide as $t,FileLoader as jt,EventDispatcher as Xt,DoubleSide as Nt,Color as Yt,BufferGeometry as Kt,BufferAttribute as qt,BackSide as Jt}from"./three-DuDKwKB8.min.js";var k={};k.d=(s,e)=>{for(var t in e)k.o(e,t)&&!k.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:e[t]})},k.o=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),k.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})};var m={};k.d(m,{ti:()=>p,nS:()=>bt,eB:()=>O,Yp:()=>Q,VB:()=>C,BC:()=>P,zN:()=>R,cV:()=>B,hW:()=>A,k2:()=>Te,K6:()=>w,M7:()=>Z,ls:()=>T,Hi:()=>Je,EY:()=>z,MR:()=>He,zf:()=>Ie,Ay:()=>_n,yo:()=>yt});var Q={};k.r(Q),k.d(Q,{get:()=>Re,set:()=>Qt});var Z={};k.r(Z),k.d(Z,{alphaTestTransformer:()=>H,asPreprocessorValueTransformer:()=>Ge,toPreprocessorTriggerTransformer:()=>_e,toUserDataTransformer:()=>hi,uniformOrUserDataTransformer:()=>x});const ee={fontFamily:null,fontSize:.05,fontKerning:"auto",fontStyle:"normal",fontWeight:"normal",offset:.005,lineHeight:1.2,lineBreak:`- ,.:?!
2
+ `,whiteSpace:"pre-line",flexDirection:"column",justifyContent:"start",alignItems:"start",backgroundImage:null,textAlign:"left",boxSizing:"content-box",position:"static",color:16777215,fontColor:16777215,fontOpacity:1,opacity:1,fontPXRange:4,fontSupersampling:!0,fontSmooth:"antialiased",borderRadius:0,borderWidth:0,borderColor:"black",borderOpacity:1,backgroundSize:"cover",backgroundColor:0,backgroundOpacity:0,overflow:"visible",letterSpacing:0,invertAlpha:!1,segments:1},Qt=function(s){for(const e in s)ee[e]=s[e]},Re=function(s){return Object.prototype.hasOwnProperty.call(ee,s)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${s}'`),ee[s]};class p{constructor(e,t=null,i=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=i}get id(){return this._id}get value(){return this._value}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this.output(t)}output(e){}_outputValue(e){e[this._id]=this._value}process(e){}render(e){}getInheritedInput(e){if(this._value!=="inherit")return this._value;const t=e._parent._value;return t&&t[`_${this._id}`]?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return Re(this._id)}isValid(e){return!0}emptyStrategyLogic(){throw new Error(`ThreeMeshUI::${this.constructor.name} has empty strategy. Update has not been processed.`)}requestUpdate(){this._needsUpdate=!0}requestProcess(){this._needsProcess=!1}requestRender(){this._needsRender=!1}}class Zt extends p{constructor(){super("renderOrder","auto",!0),this.output=this._outputValue,this._actualValue=0}set value(e){this.isValid(e)&&(this._value=e,this._needsUpdate=!0)}update(e,t){if(this._value!=="auto")this._actualValue=this._value;else{const i=e._parent._value;if(i!==null){const r=i._renderOrder._actualValue,n=1+i._children._uis.indexOf(e);this._actualValue=r+n}}for(const i of e._children._uis)i._renderOrder._value==="auto"&&(i._renderOrder._needsUpdate=!0);this._outputValue(t)}_outputValue(e){e[this._id]=this._actualValue}get value(){return this._value}}class R extends p{constructor(e,t=null,i=!0){super(e,t,i),this.output=this._outputValue,this._notInheritedValue=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"&&(this._notInheritedValue=this.getInheritedInput(e)),this.propagate(e),this._outputValue(t)}propagate(e){for(const t of e._children._uis){const i=t[`_${this._id}`];i!==void 0&&i._value==="inherit"&&(t[`_${this._id}`]._needsUpdate=!0)}}_outputValue(e){e[this._id]=this._notInheritedValue}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value==="inherit"?this._notInheritedValue:this._value}}class es extends R{constructor(){super("offset","inherit",!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}}class ts extends R{constructor(){super("fontSmooth","inherit",!0),this._needsUpdate=!1,this.isValid=is,this.output=this._outputValue}}const ss=["inherit","none","antialiased"];function is(s){return ss.indexOf(s)===-1?(console.warn(`.fontSmoothing value '${s}' is not valid. Aborted`),!1):!0}var rs=s=>{var e={};return k.d(e,s),e};const a=rs({BackSide:()=>Jt,BufferAttribute:()=>qt,BufferGeometry:()=>Kt,Color:()=>Yt,DoubleSide:()=>Nt,EventDispatcher:()=>Xt,FileLoader:()=>jt,FrontSide:()=>$t,LinearFilter:()=>Gt,Mesh:()=>Ht,MeshBasicMaterial:()=>Lt,Object3D:()=>Et,Plane:()=>Dt,PlaneGeometry:()=>Wt,ShaderMaterial:()=>At,Texture:()=>zt,TextureLoader:()=>Ot,Vector2:()=>Ft,Vector3:()=>Tt,Vector4:()=>It});class g extends p{constructor(e,t,i=!0){super(e,"unset",i),this._input="inherit",this._allowsInherit=!0,this._inheritedInput=void 0,this._inline=void 0}update(e,t){this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const i of e._children._uis){const r=i[`_${this._id}`];(r._input?r._input:r._value)==="inherit"&&(i[`_${this._id}`]._needsUpdate=!0)}this.output(t)}computeOutputValue(e){this._value=this._input}_computeFromInherited(e){this._value=this._inheritedInput}set value(e){console.warn(".(style) sub-property cannot be directly set. It must comes from inline or computed setter.")}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._input=this._inline=e,this._needsUpdate=!0)}get inline(){return this._inline}isValidValue(e){return!0}getInheritedInput(e){if(this._input!=="inherit")return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class W extends g{constructor(e,t){super(e,t,!1),this._input=new a.Vector4(0,0,0,0),this._inline=null,this._value=new a.Vector4(0,0,0,0)}get value(){return this._value}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input)}set inline(e){this._vector4ValueSetter(this._input,e),!this._input.equals(this._value)&&(this._needsUpdate=!0)}set top(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get top(){return this._input.x}set right(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get right(){return this._input.y}set bottom(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottom(){return this._input.z}set left(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get left(){return this._input.w}dispose(){this._computed=null,this._inline=null,this._input=null,this._output=null}_vector4ValueSetter(e,t){if(t instanceof a.Vector4){e.copy(t);return}if((typeof t=="string"||t instanceof String)&&(t=t.split(" ")),Array.isArray(t))switch(t=t.map(i=>parseFloat(i)),t.length){case 1:e.setScalar(t[0]);return;case 2:e.x=e.z=t[0],e.y=e.w=t[1];return;case 3:e.x=t[0],e.y=t[1],e.z=t[2];return;case 4:e.x=t[0],e.y=t[1],e.z=t[2],e.w=t[3];return;default:console.error("StyleVector4Property::set() Four Dimension property had more than four values");return}isNaN(t)||e.setScalar(t)}}class ns extends W{constructor(){super("padding",new a.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._bounds._needsUpdate=!0,e._bounds._needsRender=!0,e._layouter._needsProcess=!0,e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}class os extends W{constructor(){super("margin",new a.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}}const Ce=function(s,e,t){s[e]=t},as=function(s,e,t){t!==null&&(s[e]=t)};class D{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,i,r=null){for(const n in this._definition){const o=this._definition[n];if(i[n]!==void 0){const h=o.t?o.t:Ce;h(t,o.m,i[n]),r&&h(r,o.m,i[n])}}}static mediate(e,t,i,r,n=null){if(t)for(const o in r){const h=r[o];if(i[o]!==void 0){const c=h.t?h.t:Ce;c(t,h.m,i[o]),n&&c(n,h.m,i[o])}}}}class ls extends p{constructor(){super("parent",null,!1)}update(e,t){e.parent&&e.parent.isUI?this._value=e.parent:this._value=null}set value(e){console.warn("ParentProperty is readonly")}get value(){return this._value}find(e){return this._value?e(this._value)?this._value:this._value._parent.find(e):null}dispose(){this._value=null}}const te=function(s,e,t=6){return s.toFixed(t)===e.toFixed(t)};class Me extends p{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(te(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}}class Be extends R{constructor(e){super(e,"inherit",!0),this.isValid=us}}const hs=[a.FrontSide,a.BackSide,a.DoubleSide];function us(s){return hs.indexOf(s)===-1?(console.warn(`SideProperty value '${s}' is not valid. Abort`),!1):!0}class Pe{constructor(){this._offsetX=0,this._offsetY=0,this._lineBreak=null,this._kerning=0,this._fontFactor=1,this._fontSize=0,this._cumulativeWidth=0,this._paddingLeft=0,this._paddingRight=0,this._marginLeft=0,this._marginRight=0}resetOffsets(){this._offsetX=this._offsetY=0,this._cumulativeWidth=0}get xadvance(){return 0}get xoffset(){return 0}get yoffset(){return 0}get width(){return 0}get height(){return 0}set lineBreak(e){this._lineBreak=e}get lineBreak(){return this._lineBreak}get anchor(){return 0}get kerning(){return this._kerning*this._fontFactor}set kerning(e){this._kerning=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get lineHeight(){return 0}get offsetX(){return this._offsetX}set offsetX(e){this._offsetX=e}get offsetY(){return this._offsetY}set offsetY(e){this._offsetY=e}get cumulativeWidth(){return this._cumulativeWidth}set cumulativeWidth(e){this._cumulativeWidth=e}get marginLeft(){return this._marginLeft}set marginLeft(e){this._marginLeft=e}get marginRight(){return this._marginRight}set marginRight(e){this._marginRight=e}get paddingLeft(){return this._paddingLeft}set paddingLeft(e){this._paddingLeft=e}get paddingRight(){return this._paddingRight}set paddingRight(e){this._paddingRight=e}get lineBase(){return 0}set fontFactor(e){this._fontFactor=e}get fontFactor(){return this._fontFactor}}class Ie{constructor(e){this._char="",this._width=1,this._heigth=1,this._xadvance=1,this._xoffset=0,this._yoffset=0,this._font=e}get font(){return this._font}get char(){return this._char}get width(){return this._width}get height(){return this._heigth}get xadvance(){return this._xadvance}get xoffset(){return this._xoffset}get yoffset(){return this._yoffset}set yoffset(e){this._yoffset=e}clone(e){throw new Error("Abstract... Need to be implemented")}asInlineGlyph(){throw new Error("Abstract... Need to be implemented")}}class Te extends Pe{constructor(e){super(),this._typographic=e}get typographic(){return this._typographic}get xadvance(){return this._typographic.xadvance*this._fontFactor}get xoffset(){return this._typographic.xoffset*this._fontFactor}get yoffset(){return this._typographic.yoffset*this._fontFactor}get width(){return this._typographic.width*this._fontFactor}get height(){return this._typographic.height*this._fontFactor}get char(){return this._typographic.char}get anchor(){return this.yoffset}get lineHeight(){return this._typographic.font.lineHeight*this._fontFactor}get lineBase(){return this._typographic.font.lineBase*this._fontFactor}}const cs={light:"100",normal:"400",bold:"700",bolder:"900"};function se(s){return isNaN(s)?cs[s]||s:s.toString()}class ds extends a.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=se(e),this._style=t,this._size=42,this._lineHeight=42,this._lineBase=42,this._font=null}get typographic(){return this._font}get isReady(){return this._isReady}get weight(){return this._weight}get style(){return this._style}get texture(){return this._texture}set fontMaterial(e){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get fontMaterial(){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get id(){return`${this._name}(w:${this.weight},s:${this.style})`}getTypographicGlyph(e){let t=this._chars[e];if(t)return t;if(e.match(/\s/))return this._chars[" "];const i=this._getFallbackCharacter(e);if(i&&(t=this._chars[i],t))return t;throw Error(`FontVariant('${this.id}')::getTypographicGlyph() - character('${e}') and/or fallback character were not found in provided msdf charset.`)}_getFallbackCharacter(e){throw new Error(`FontVariant(${typeof this})::_getFallbackCharacter() is abstract and should therefore be overridden.`)}getGeometricGlyph(e,t){throw new Error(`FontVariant(${typeof this})::getGeometryCharacter() is abstract and should therefore be overridden.`)}getKerningAmount(e){return this._kernings[e]?this._kernings[e]:0}adjustTypographicGlyphs(e){for(const t in e){const i=this.getTypographicGlyph(t),r=e[t];for(const n in r)i["_"+n]=e[t][n]}}_checkReadiness(){this._readyCondition()&&ps(this)}_alterElementProperties(e){throw new Error(`FontVariant(${typeof this})::_alterElementProperties() is abstract and should therefore be overridden.`)}_readyCondition(){throw new Error(`FontVariant(${typeof this})::_readyCondition() is abstract and should therefore be overridden.`)}}const _s={type:"ready"};function ps(s){s._isReady=!0,s.dispatchEvent(_s)}const P=ds;class fs extends p{constructor(e=null){super("font",e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=gs}output(e){e[this._id]=this._fontVariant}update(e,t){if(this._fontVariant&&!this._fontVariant.isReady&&this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._value&&this._value instanceof P)this._fontVariant=this._value;else{const i=e._fontFamily._value;i&&(this._fontVariant=i.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=ms(e,this),this._fontVariant.isReady?this._handleFontReadyClosure():this._fontVariant.addEventListener("ready",this._handleFontReadyClosure),(!e._fontMaterial._defaultMaterial||!(e._fontMaterial._defaultMaterial instanceof this._fontVariant.fontMaterial))&&(e._fontMaterial._defaultMaterial=new this._fontVariant.fontMaterial,e._fontMaterial._needsUpdate=!0))}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}get fontVariant(){return this._fontVariant}dispose(){this._handleFontReadyClosure&&(this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._handleFontReadyClosure=null),this._value=null,this._fontVariant=null}}function gs(s){return s instanceof P?!0:(console.warn(`.font value '${s}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function ms(s,e){return function(){e._needsUpdate=!0,s._glyphs._needsProcess=!0,e._fontVariant.removeEventListener("ready",e._handleFontReadyClosure),e._handleFontReadyClosure=null}}class vs extends g{constructor(e){super("display",e),this._value="flex",this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=ys}computeOutputValue(e){e._visible._value=this._output!=="none"}}const bs=["none","flex"];function ys(s){return bs.indexOf(s)===-1?(console.warn(`(.style) display value '${s}' is not valid. Aborted`),!1):!0}class xs extends g{constructor(e){super("boxSizing",e),this._allowsInherit=!1,this.isValidValue=Ss}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}}const ws=["border-box","content-box"];function Ss(s){return ws.indexOf(s)===-1?(console.warn(`(.style) boxSizing value '${s}' is not valid. Aborted`),!1):!0}class I extends g{constructor(e,t){super(e,t,!1),this._value=new a.Color,this.output=this._outputValue}computeOutputValue(e){this._input!=="inherit"&&this._value.set(this._input)}set inline(e){this._input=this._inline=e,this._needsUpdate=!0}}class ie extends g{constructor(e,t){super(e,t,!0),this.isValidValue=ks,this._allowsInherit=!1,this._input=t,this._value=t,this.output=this._outputValue,this.computeOutputValue=this._computeFromInherited}_outputValue(e){e[this._id]=this._inheritedInput}}function ks(s){return s<0&&s>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${s}' is not valid)`),!1):!0}class Vs extends g{constructor(e){super("backgroundImage",e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new a.Vector2(1,1),this.isValidValue=Us}get value(){return this._value}output(e){e[this._id]=this._value,e.tSize=this._textureSize}computeOutputValue(e){if(this._value=this._inheritedInput,this._value instanceof a.Texture&&!this._value.image){console.warn("ThreeMeshUI - .backgroundImage :: Please provide preloaded texture in order to have accurate sizing.");return}this._needsProcess=!0}process(e){this._value?this._textureSize.set(this._value.image.width,this._value.image.height):this._textureSize.set(1,1)}}function Us(s){return!0}class Rs extends g{constructor(e){super("backgroundSize",e,!0),this.isValidValue=Ms,this.output=this._outputValue}}const Cs=["cover","contain","stretch"];function Ms(s){return Cs.indexOf(s)===-1?(console.warn(`(.style) backgroundSize value '${s}' is not valid. Aborted`),!1):!0}class Bs extends g{constructor(e){super("overflow",e,!0),this.isValidValue=Is,this._clippingPlanes=null,this._renderStrategy=this._emptyRender}update(e,t){this._inline!==void 0&&this._inline!=="unset"?this._input=this._inline:this._computed!==void 0&&(this._input=this._computed),this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const i of e._children._uis)i._overflow._needsUpdate=!0;this.output(t)}output(e){e.clippingPlanes=this._clippingPlanes}computeOutputValue(e){super.computeOutputValue(e),this._value==="hidden"?this._renderStrategy=this._propagateRender:(this._renderStrategy=this._emptyRender,this._clippingPlanes=null);const t=e._parent._value;if(t!==null){const i=t._overflow;if((i._value==="hidden"||i._clippingPlanes!==null)&&!this._clippingPlanes){this._clippingPlanes=[new a.Plane(new a.Vector3(0,-1,0),1),new a.Plane(new a.Vector3(-1,0,0),1),new a.Plane(new a.Vector3(0,1,0),1),new a.Plane(new a.Vector3(1,0,0),1)];for(let r=0;r<this._clippingPlanes.length;r++)this._clippingPlanes[r].parent=t;i._clippingPlanes!==null&&this._clippingPlanes.push(...i._clippingPlanes),this._renderStrategy=this._hiddenRender,this._needsRender=!0}else(i._value==="visible"||i._clippingPlanes===null)&&this._clippingPlanes!==null&&(this._clippingPlanes=null,this._renderStrategy=this._emptyRender,this._needsRender=!0)}}render(e){this._renderStrategy(e)}_emptyRender(e){}_hiddenRender(e){const t=e._parent._value,i=t._bounds._offsetHeight,r=t._bounds._offsetWidth,n=t._padding._value,o=t._borderWidth._value;for(let h=0;h<4&&h<this._clippingPlanes.length;h++){const c=this._clippingPlanes[h];switch(h%4){case 0:c.constant=i/2-(n.x+o.x);break;case 1:c.constant=r/2-(n.y+o.y);break;case 2:c.constant=i/2-(n.z+o.z);break;case 3:c.constant=r/2-(n.w+o.w);break}c.applyMatrix4(t.matrixWorld)}for(let h=0;h<e._children._uis.length;h++){const c=e._children._uis[h];c._overflow._needsRender=!0}}_propagateRender(e){for(let t=0;t<e._children._uis.length;t++){const i=e._children._uis[t];i._overflow._needsRender=!0}}}const Ps=["visible","hidden"];function Is(s){return Ps.indexOf(s)===-1?(console.warn(`(.style) overflow value '${s}' is not valid. Aborted`),!1):!0}const M="rem",Fe="em",E="%",Ts=[M,Fe,E],Oe=function(s){return Ts.indexOf(s)===-1?M:s};class Fs extends W{constructor(e){super("borderRadius",e),this._valueUV=this._value.clone(),this._input=new a.Vector4(0,0,0,0),this._mediation=!0,this._cornerTL=new a.Vector2(0,1),this._cornerTR=new a.Vector2(1,1),this._cornerBR=new a.Vector2(1,0),this._cornerBL=new a.Vector2(0,0);const t=new L(this._valueUV,["x","y"]),i=new L(this._valueUV,["z","w"]),r=new L(this._valueUV,["x","w"]),n=new L(this._valueUV,["y","z"]);t.complementaryMediation=i,i.complementaryMediation=t,r.complementaryMediation=n,n.complementaryMediation=r,this._sideMediators=[t,i,r,n],this._units=M}set units(e){this._units=Oe(e),this._needsProcess=!0}get units(){return this._units}set mediation(e){e!==this._mediation&&(this._mediation=e,this._needsUpdate=!0)}get mediation(){return this._mediation}output(e){e.cornerTL=this._cornerTL,e.cornerTR=this._cornerTR,e.cornerBR=this._cornerBR,e.cornerBL=this._cornerBL}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0}process(e){this._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,i=e._bounds._offsetHeight;if(this._units===E&&this._valueUV.divideScalar(100),this._units===M&&this._valueUV.divideScalar(Math.min(t,i)),this._mediation)do this._sideMediators.forEach(o=>o.computeValue()),this._sideMediators.sort((o,h)=>o.value<h.value?1:-1),this._sideMediators[0].value>1&&this._sideMediators[0].mediate();while(this._sideMediators[0].value>1);let r=t>i?i/t:1,n=t<i?t/i:1;this._units===E&&(r=n=1),this._cornerTL.x=this._valueUV.x*r,this._cornerTL.y=1-this._valueUV.x*n,this._cornerTR.x=1-this._valueUV.y*r,this._cornerTR.y=1-this._valueUV.y*n,this._cornerBR.x=1-this._valueUV.z*r,this._cornerBR.y=this._valueUV.z*n,this._cornerBL.x=this._valueUV.w*r,this._cornerBL.y=this._valueUV.w*n}dispose(){for(const e of this._sideMediators)e.dispose();this._sideMediators=null,this._cornerTL=null,this._cornerTR=null,this._cornerBR=null,this._cornerBL=null,super.dispose()}set topLeft(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get topLeft(){return this._input.x}set topRight(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get topRight(){return this._input.y}set bottomRight(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottomRight(){return this._input.z}set bottomLeft(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get bottomLeft(){return this._input.w}set top(e){this._input.x===e&&this._input.y===e||(this._input.x=this._input.y=e,this._needsUpdate=!0)}get top(){return(this._input.x+this._input.y)/2}set right(e){this._input.y===e&&this._input.z===e||(this._input.y=this._input.z=e,this._needsUpdate=!0)}get right(){return(this._input.y+this._input.z)/2}set bottom(e){this._input.z===e&&this._input.w===e||(this._input.z=this._input.w=e,this._needsUpdate=!0)}get bottom(){return(this._input.z+this._input.w)/2}set left(e){this._input.w===e&&this._input.x===e||(this._input.w=this._input.x=e,this._needsUpdate=!0)}get left(){return(this._input.w+this._input.x)/2}}class L{constructor(e,t){this._borderRadiuses=e,this._sideProperties=t,this._complementaryMediation=null,this._value=0}get value(){return this._value}set complementaryMediation(e){this._complementaryMediation=e}computeValue(){let e=0;for(const t of this._sideProperties)e+=this._borderRadiuses[t];this._value=e}mediate(e=!0){if(!(this._value<1)){for(const t of this._sideProperties)this._borderRadiuses[t]/=this._value;e&&this._complementaryMediation.mediate(!1)}}dispose(){this._complementaryMediation=null,this._borderRadiuses=null}}class Os extends W{constructor(e){super("borderWidth",e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=M}set units(e){this._units=Oe(e),this._needsUpdate=!0}get units(){return this._units}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0,e._bounds._needsUpdate=!0,e._layouter._needsUpdate=!0}_outputValue(e){e[this._id]=this._valueUV}process(e){this._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,i=e._bounds._offsetHeight;if(this._units===E&&(console.log("Percent"),console.log(this._valueUV)),this._units===M)t!==0&&(this._valueUV.w/=t,this._valueUV.y/=t),i!==0&&(this._valueUV.x/=i,this._valueUV.z/=i);else if(this._units===Fe){if(t!==0){const r=t>i?i/t:1;this._valueUV.y*=r,this._valueUV.w*=r}if(i!==0){const r=t<i?t/i:1;this._valueUV.x*=r,this._valueUV.z*=r}}}}class zs extends p{constructor(e,t=!0){super("visible",t,!0),this._needsUpdate=!1}update(e,t){e.visible=this._value,e._parent._value&&(e._parent._value._children._needsUpdate=!0)}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}}class ze extends I{constructor(e){super("backgroundColor",e,!1),this._input="transparent",this._allowsInherit=!1}computeOutputValue(e){e._backgroundMesh.visible=!(this._input==="none"||this._input==="transparent"),this._input==="inherit"?this._value.set(this.getInheritedInput(e)):this._input==="transparent"||this._input==="none"||this._value.set(this._input)}}class V extends p{constructor(e="untitled"){super(e,void 0,!1)}update(e,t){}output(e){}}class As extends p{constructor(){super("inlineJustificator",null,!1),this._value=null}update(e,t){}process(e){const t=e._bounds._innerHeight,i=e._layouter._value,r=Math.abs(i.height);let n=(()=>{switch(e._alignItems._value){case"inherit":case"start":return t/2;case"end":return r-t/2;case"stretch":case"center":return r/2}})();const o=e._padding._value,h=e._borderWidth._value;n+=(-o.x+o.z)/2+(-h.x+h.z)/2,i.forEach(c=>{c.y+=n,c.forEach(d=>{d.offsetY+=n})})}}const Ws=["start","center","end","stretch"],Ds=function(s){return Ws.indexOf(s)===-1?(console.warn(`(.style) alignItems value '${s}' is not valid. Aborted`),!1):!0};class re extends g{constructor(){super("alignItems","inherit",!0),this.isValidValue=Ds}}class ne extends g{constructor(){super("textAlign","inherit",!0),this.isValidValue=Ls}}const Es=["left","right","center","justify","justify-left","justify-right","justify-center"],Ls=function(s){return Es.indexOf(s)===-1?(console.warn(`(.style) textAlign value '${s}' is not valid. Aborted`),!1):!0};class oe extends g{constructor(){super("flexDirection","inherit",!0),this.isValid=Gs}}const Hs=["row","row-reverse","column","column-reverse"];function Gs(s){return Hs.indexOf(s)===-1?(console.warn(`(.style) flexDirection value '${s}' is not valid. Aborted`),!1):!0}class ae extends g{constructor(){super("justifyContent","inherit",!0),this.isValidValue=js}}const $s=["start","center","end","space-between","space-around","space-evenly"];function js(s){return $s.indexOf(s)===-1?(console.warn(`(.style) justifyContent value '${s}' is not valid. Aborted`),!1):!0}class Xs extends g{constructor(){super("order",0,!0),this._value=0,this._input=0,this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._parent._value&&(e._parent._value._children._needsProcess=!0)}}class Ae extends g{constructor(){super("position","static",!0),this._allowsInherit=!1,this._value="static",this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=Ys}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}}const Ns=["static","absolute"];function Ys(s){return Ns.indexOf(s)===-1?(console.warn(`(.style) position value '${s}' is not valid. Aborted`),!1):!0}class We extends g{constructor(e,t=null){super(e,t,!0),this._input="auto",this._auto=!0,this._relative=!1,this._updateRequired=!0}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._inline=e,this._input!==this._inline&&this._parseInput())}get inline(){return this._inline}_parseInput(){let e=!0;if(this._inline!==void 0&&this._inline!=="unset"?this._input=this._inline:this._computed!==void 0?(this._computed===this._input&&(e=!1),this._input=this._computed):e=this._input==="inherit",e){if(this._auto=!this._input||this._input==="auto",this._auto)this._relative=!1;else if((typeof this._input=="string"||this._input instanceof String)&&this._input.endsWith("%")){this._relative=!0,this._value=0;const t=parseFloat(this._input.replace("%","").trim());isNaN(t)||(this._value=t/100)}else this._relative=!1,this._value=this._input;this._needsUpdate=this._updateRequired=e}}update(e,t){if(this._updateRequired){this._updateRequired=!1,this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const i of e._children._uis)i[`_${this._id}`]._needsUpdate=!0;this.output(t),e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}computeOutputValue(e){e._bounds._needsUpdate=!0,e._renderer._needsRender=!0}getInheritedInput(e){if(this._input!=="inherit"&&!this._auto)return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return 0}get value(){return this._value}}class Ks extends We{constructor(){super("width")}}class qs extends We{constructor(){super("height")}computeOutputValue(e){super.computeOutputValue(e)}}class De extends V{constructor(){super("textContent"),this._needsUpdate=!1}set value(e){}process(e){let t="";for(let i=0;i<e.children.length;i++){const r=e.children[i];r.isUI&&(t+=r.textContent)}this._value=t}}class Ee extends g{constructor(e){super("fontStyle",e,!0),this.isValidValue=Qs}}const Js=["normal","italic"];function Qs(s){return Js.indexOf(s)===-1?(console.warn(`(.style) fontStyle value '${s}' is not valid. Aborted`),!1):!0}class Le extends g{constructor(){super("fontWeight","inherit",!0),this.isValid=ei}}const Zs=["100","200","300","400","500","600","700","800","900","light","normal","bold","bolder"];function ei(s){return Zs.indexOf(s.toString())===-1?(console.warn(`(.style) fontWeight value '${s}' is not valid. Aborted`),!1):!0}class He{constructor(){this._size=42,this._lineHeight=42,this._lineBase=38,this._name="-",this._charset=""}get size(){return this._size}get lineHeight(){return this._lineHeight}get lineBase(){return this._lineBase}get name(){return this._name}get charset(){return this._charset}}class ti extends He{constructor(e){super(),this._size=e.info.size,this._lineHeight=e.common.lineHeight,this._lineBase=e.common.base,this._name=e.info.face,this._textureWidth=e.common.scaleW,this._textureHeight=e.common.scaleH,this._charset=e.chars.map(t=>t.char).join("")}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}}class si extends Te{constructor(e){super(e)}get uv(){return this.typographic.uv}}class K extends Ie{constructor(e,t){super(e),this._char=t.char,this._width=t.width,this._heigth=t.height,this._xadvance=t.xadvance?t.xadvance:this._width,this._xoffset=t.xoffset?t.xoffset:0,this._yoffset=t.yoffset?t.yoffset:0,this._uv=t.uv?t.uv:null,isNaN(t.x)||(this._uv={left:t.x/e.textureWidth,right:(t.x+t.width)/e.textureWidth,top:1-(t.y+t.height)/e.textureHeight,bottom:1-t.y/e.textureHeight})}get uv(){return this._uv}clone(e){return new K(this._font,{char:e,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new si(this)}}class ii extends a.PlaneGeometry{constructor(e,t){let i=1,r=1;const n=e.typographic.font.size,o=t._segments.value;i=Math.ceil(e.typographic.width/n*o),r=Math.ceil(e.typographic.height/n*o),super(e.width,e.height,i,r),e.uv?(this._mapUVs(e),this._transformGeometry(e)):(this._nullifyUVs(),this.scale(0,0,1),this.translate(0,e.fontSize/2,0)),this.name="GlyphGeometry"}_mapUVs(e){const t=e.uv.right-e.uv.left,i=e.uv.bottom-e.uv.top,r=this.getAttribute("uv").array.slice(),n=[];for(let o=0;o<r.length;o+=2){const h=r[o],c=r[o+1];n.push(e.uv.left+t*h),n.push(e.uv.top+i*c)}this.setAttribute("uvG",new a.BufferAttribute(new Float32Array(n),2))}_nullifyUVs(){const e=[],t=this.getAttribute("uv").array.length;for(let i=0;i<t;i++)e.push(0);this.setAttribute("uvG",new a.BufferAttribute(new Float32Array(e),2))}_transformGeometry(e){this.translate(e.width/2,-e.height/2,0)}}const ri=`
3
+ attribute vec2 uvG;
4
+ varying vec2 vUvG;
5
+ `,le=ri,ni=`
6
+ vUvG = uvG;
7
+ `,he=ni,oi=`
8
+ gl_Position.z -= 0.00001;
9
+ `,ue=oi,ai=`
10
+ varying vec2 vUvG;
11
+ uniform sampler2D glyphMap;
12
+ uniform vec2 unitRange;
13
+ // functions from the original msdf repo:
14
+ // https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field
15
+ float median(float r, float g, float b) {
16
+ return max(min(r, g), min(max(r, g), b));
17
+ }
18
+ float screenPxRange() {
19
+
20
+ // precomputed unitRange as recommended by Chlumsky
21
+ // vec2 unitRange = vec2(pxRange)/vec2(textureSize(glyphMap, 0));
22
+ vec2 screenTexSize = vec2(1.0)/fwidth(vUvG);
23
+ return max(0.5*dot(unitRange, screenTexSize), 1.0);
24
+ }
25
+ float tap(vec2 offsetUV) {
26
+ vec3 msd = texture( glyphMap, offsetUV ).rgb;
27
+ float sd = median(msd.r, msd.g, msd.b);
28
+ float screenPxDistance = screenPxRange() * (sd - 0.5);
29
+ float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
30
+ return alpha;
31
+ }
32
+ `,ce=ai,li=`
33
+ float alpha;
34
+ #ifdef NO_RGSS
35
+
36
+ alpha = tap( vUvG );
37
+
38
+ #else
39
+
40
+ // shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec
41
+ // per pixel partial derivatives
42
+ vec2 dx = dFdx(vUvG);
43
+ vec2 dy = dFdy(vUvG);
44
+ // rotated grid uv offsets
45
+ vec2 uvOffsets = vec2(0.125, 0.375);
46
+ vec2 offsetUV = vec2(0.0, 0.0);
47
+ // supersampled using 2x2 rotated grid
48
+ alpha = 0.0;
49
+ offsetUV.xy = vUvG + uvOffsets.x * dx + uvOffsets.y * dy;
50
+ alpha += tap(offsetUV);
51
+ offsetUV.xy = vUvG - uvOffsets.x * dx - uvOffsets.y * dy;
52
+ alpha += tap(offsetUV);
53
+ offsetUV.xy = vUvG + uvOffsets.y * dx - uvOffsets.x * dy;
54
+ alpha += tap(offsetUV);
55
+ offsetUV.xy = vUvG - uvOffsets.y * dx + uvOffsets.x * dy;
56
+ alpha += tap(offsetUV);
57
+ alpha *= 0.25;
58
+
59
+ #endif
60
+
61
+ alpha = clamp( alpha, 0.0, 1.0 );
62
+
63
+ #ifdef INVERT_ALPHA
64
+
65
+ alpha = 1.0 - alpha;
66
+
67
+ #endif
68
+
69
+ diffuseColor.a *= alpha;
70
+ `,de=li,H=function(s,e,t){s.alphaTest=t,_e(s,"USE_ALPHATEST",t>0)},_e=function(s,e,t){s.defines&&(t?s.defines[e]===void 0&&(s.defines[e]="",s.needsUpdate=!0):s.defines[e]!==void 0&&(delete s.defines[e],s.needsUpdate=!0))},Ge=function(s,e,t){s.defines[e]&&s.defines[e]===t||(s.defines[e]=t,s.needsUpdate=!0)},x=function(s,e,t){s.userData[e]?s.userData[e].value=t:s.uniforms[e].value=t},hi=function(s,e,t){s.userData[e].value=t};class w{static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||(e.defines={})}static ensureUserData(e,t){e.userData.glyphMap={value:t.glyphMap},e.userData.unitRange={value:new a.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(e){w.injectVertexShaderChunks(e),w.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>",`#include <uv_pars_vertex>
71
+ `+le),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
72
+ `+he),e.vertexShader=e.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
73
+ `+ue)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>",`#include <uv_pars_fragment>
74
+ `+ce),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",`#include <alphamap_fragment>
75
+ `+de)}static from(e){return class extends e{static get fontMaterialProperties(){return w.mediation}constructor(t={}){w.ensureMaterialOptions(t),super(t),w.ensureDefines(this),w.ensureUserData(this,t),this._userDefinedOnBeforeCompile=i=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(t){this._userDefinedOnBeforeCompile=t}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=t=>{w.bindUniformsWithUserData(t,this),w.injectShaderChunks(t),this._userDefinedOnBeforeCompile(t)}}}static get mediation(){return di}}const ui=function(s,e,t){const i=t?t.texture:null,r=t?t.unitRange:new a.Vector2;if(s[e]!==void 0){s.glyphMap=i,s.unitRange=r;return}s.userData&&s.userData.glyphMap&&(s.userData.glyphMap.value=i,s.userData.unitRange.value=r)},ci=function(s,e,t){t&&t!=="antialiased"?s.defines.NO_RGSS="":delete s.defines.NO_RGSS,s.needsUpdate=!0},di={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:H},fontSide:{m:"side"},font:{m:"glyphMap",t:ui},color:{m:"color"},fontOpacity:{m:"opacity"},fontSmooth:{m:"NO_RGSS",t:ci},invertAlpha:{m:"INVERT_ALPHA",t:_e}},_i=`
76
+ ${le}
77
+ #include <clipping_planes_pars_vertex>
78
+ void main() {
79
+ ${he}
80
+ #include <begin_vertex>
81
+ #include <project_vertex>
82
+ ${ue}
83
+ #include <clipping_planes_vertex>
84
+ }
85
+ `,pi=`
86
+ uniform vec3 diffuse;
87
+ uniform float opacity;
88
+ ${ce}
89
+ #include <alphatest_pars_fragment>
90
+ #include <clipping_planes_pars_fragment>
91
+ void main() {
92
+ // instead of <color_fragment> : vec4 diffuseColor
93
+ vec4 diffuseColor = vec4( diffuse, opacity );
94
+ ${de}
95
+ #include <alphatest_fragment>
96
+ // instead of <output_fragment>
97
+ gl_FragColor = diffuseColor;
98
+ #include <clipping_planes_fragment>
99
+ }
100
+ `,fi=.02;class Ue extends a.ShaderMaterial{static get mediation(){return w.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new a.Vector2(0,0)},alphaTest:{value:fi}},transparent:!0,clipping:!0,vertexShader:_i,fragmentShader:pi,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST="",this.needsUpdate=!0,this.noRGSS=e.noRGSS||!1}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get opacity(){return this.uniforms.opacity.value}get unitRange(){return this.uniforms.unitRange.value}set unitRange(e){this.uniforms.unitRange.value.copy(e)}get glyphMap(){return this.uniforms.glyphMap.value}set glyphMap(e){this.uniforms.glyphMap.value=e}get isDefault(){return this.constructor===Ue}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}}class gi extends P{constructor(e,t,i,r){if(super(e,t),this._unitRange=new a.Vector2(1,1),i.pages?this._buildData(i):mi(this,i),r instanceof a.Texture)this._texture=r,this._buildTexture(r);else if(typeof r=="string"||r instanceof String)vi(this,r);else throw new Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=Ue,this._checkReadiness()}get texture(){return this._texture}get unitRange(){return this._unitRange}set fontMaterial(e){this._defaultMaterialClass=e}get fontMaterial(){return this._defaultMaterialClass}_buildData(e){this._font=new ti(e),this._kernings=this._buildKerningPairs(e),this._chars=this._buildCharacters(e),this._chars[" "]=this._buildCharacterWhite(e),this._chars[`
101
+ `]=this._buildCharacterWhite(e,`
102
+ `,.001,1),this._chars[" "]=this._buildCharacterWhite(e," ",4,1),this._size=e.info.size,this._lineHeight=e.common.lineHeight,this._lineBase=e.common.base,this._distanceRange=e.distanceField.distanceRange,this._unitRange=new a.Vector2(this._distanceRange,this._distanceRange).divide(new a.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=a.LinearFilter,e.magFilter=a.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return C.missingCharacter(this,e)}getGeometricGlyph(e,t){return new ii(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){const t={};for(let i=0;i<e.kernings.length;i++){const r=e.kernings[i];if(r.amount===0)continue;const n=String.fromCharCode(r.first,r.second);t[n]=r.amount}return t}_buildCharacters(e){const t={};for(let i=0;i<e.chars.length;i++){const r=e.chars[i];t[r.char]=new K(this._font,r)}return t}_buildCharacterWhite(e,t=" ",i=1,r=1){return new K(this._font,{char:t,width:e.info.size/3*i,height:e.info.size*.7*r})}_alterElementProperties(e){}}function mi(s,e){new a.FileLoader().setResponseType("json").load(e,t=>{s._buildData(t),s._checkReadiness()})}function vi(s,e){s._texture=new a.TextureLoader().load(e,t=>{s._buildTexture(t),s._checkReadiness()})}class G extends a.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,i,r,n=!1){if(n||!this.getVariant(e,t)){this._isReady=!1;const o=new gi(e,t,i,r);this._variants.push(o),o.isReady?this._checkReadiness():o.addEventListener("ready",this._checkReadiness)}else console.warn(`FontFamily('${this._name}')::addVariant() - Variant(${e}, ${t}) already exists.`);return this}addCustomImplementationVariant(e,t=!1){return t||!this.getVariant(e.weight,e.style)?(this._isReady=!1,this._variants.push(e),e.isReady?this._checkReadiness():e.addEventListener("ready",this._checkReadiness)):console.warn(`FontFamily('${this._name}')::addCustomImplementationVariant() - Variant(${e.weight}, ${e.style}) already exists.`),this}getVariant(e,t){return e=se(e),this._variants.find(i=>i.weight===e&&i.style===t)}get name(){return this._name}_checkReadiness=()=>{this._variants.every(e=>e.isReady)&&yi(this)}}const bi={type:"ready"};function yi(s){s._isReady=!0,s.dispatchEvent(bi)}const $={},xi=function(s){const e=[...arguments];e.forEach(i=>{if(!(i instanceof G))throw new Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof i} given.`)});const t=function(){return e.every(i=>i.isReady)};return new Promise((i,r)=>{if(t())i();else for(let n=0;n<e.length;n++){const o=e[n];o.isReady||o.addEventListener("ready",()=>{t()&&i()})}})},wi=function(s){return $[s]&&console.error(`FontLibrary::addFontFamily - Font('${s}') is already registered`),$[s]=new G(s),$[s]},Si=function(s){return $[s]},ki=function(s){$e=s};let $e=function(s,e){return console.error(`The character '${e}' is not included in the font characters set.`)," "};function Vi(s,e){return $e(s,e)}const Ui={addFontFamily:wi,getFontFamily:Si,prepare:xi,setMissingCharacterHandler:ki,missingCharacter:Vi},C=Ui;class je extends g{constructor(){super("fontFamily","inherit",!0)}computeOutputValue(e){if(this._input instanceof G)this._value=this._input;else if(this._input!=="inherit")if(typeof this._input=="string"){const t=C.getFontFamily(this._input);t?this._value=t:console.warn(`(.style) fontFamily, the font '${this._input}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}getInheritedInput(e){if(this._input!=="inherit")return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class Xe extends g{constructor(){super("lineHeight","inherit",!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}}class Ne extends g{constructor(){super("whiteSpace","inherit"),this.isValidValue=Ci}}const Ri=["normal","nowrap","pre","pre-line","pre-wrap"];function Ci(s){return Ri.indexOf(s)===-1?(console.warn(`(.style) whiteSpace value '${s}' is not valid. Aborted`),!1):!0}class Ye extends g{constructor(){super("letterSpacing","inherit",!0)}}class Mi extends g{constructor(){super("fontSize","inherit",!0)}}class Ke extends p{constructor(){super("segments",1,!1)}}class Bi extends R{constructor(){super("invertAlpha","inherit")}}class j extends g{constructor(){super("fontKerning","inherit"),this.isValidValue=Ii}}const Pi=["normal","none","inherit"];function Ii(s){return Pi.indexOf(s)===-1?(console.warn(`(.style) fontKerning value '${s}' is not valid. Aborted`),!1):!0}class X extends R{constructor(e){super(e,"inherit",!0)}}class qe extends R{constructor(e){super(e,"inherit",!1),this._mediation={},this._defaultMaterial=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"?this._notInheritedValue=this.getInheritedInput(e):this.propagate(e),this._notInheritedValue?this._notInheritedValue.constructor.mediation?this._mediation={...this._notInheritedValue.constructor.mediation}:this._mediation={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:H},fontSide:{m:"side"},color:{m:"color"},fontOpacity:{m:"opacity"}}:this._mediation={},e._transferToFontMaterial(),this._outputValue(t)}getInheritedInput(e){if(this._value!=="inherit")return this._value;let t=e,i=null;for(;t._parent._value;)if(t=t._parent._value,t[`_${this._id}`]._value!=="inherit"){i=t[`_${this._id}`]._value;break}return i!==null?i:this.getDefaultValue()}getDefaultValue(){return this._defaultMaterial}}const Ti=function(s,e,t){s.traverse(i=>{i.renderOrder=t})};class T extends a.Object3D{constructor(e,t){super(),Object.defineProperties(this,{isUI:{configurable:!1,enumerable:!0,value:!0}}),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundCustomDepthMaterial=null,this._backgroundMaterialMediation={},this._backgroundMeshMediation={backgroundCastShadow:{m:"castShadow"},backgroundReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder",t:Ti}},this._fontMesh=null,this._fontMaterial=new qe("fontMaterial"),this._fontCustomDepthMaterial=new qe("fontCustomDepthMaterial"),this._fontMeshMediation={fontMaterial:{m:"material"},fontCustomDepthMaterial:{m:"customDepthMaterial",t:as},fontCastShadow:{m:"castShadow"},fontReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder"}},this._children=e.children?new e.children:new V("children"),this._parent=new ls,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI),this._backgroundSide=new Be("backgroundSide"),this._fontSide=new Be("fontSide"),this._backgroundAlphaTest=new Me("backgroundAlphaTest",.02),this._fontAlphaTest=new Me("fontAlphaTest",.02),this._visible=new zs("visible",!0),this._backgroundCastShadow=new X("backgroundCastShadow"),this._fontCastShadow=new X("fontCastShadow"),this._backgroundReceiveShadow=new X("backgroundReceiveShadow"),this._fontReceiveShadow=new X("fontReceiveShadow"),this._renderOrder=new Zt,this._segments=e.segments?new e.segments:new Ke,this._bounds=e.bounds?new e.bounds:new V("bounds"),this._order=new Xs,this._padding=new ns,this._margin=new os,this._position=new Ae,this._flexDirection=e.flexDirection?new e.flexDirection:new oe,this._justifyContent=e.justifyContent?new e.justifyContent:new ae,this._alignItems=e.alignItems?new e.alignItems:new re,this._display=new vs("flex"),this._boxSizing=new xs("border-box"),this._width=new Ks,this._height=new qs,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new ze,this._backgroundOpacity=new ie("backgroundOpacity",.5),this._backgroundImage=new Vs,this._backgroundSize=new Rs("cover"),this._color=e.color?new e.color:new I("color","inherit"),this._fontOpacity=new ie("fontOpacity","inherit"),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Ne,this._fontFamily=e.fontFamily?new e.fontFamily:new je,this._fontStyle=e.fontStyle?new e.fontStyle:new Ee("normal"),this._fontWeight=e.fontWeight?new e.fontWeight:new Le,this._fontSize=e.fontSize?new e.fontSize:new Mi,this._lineHeight=e.lineHeight?new e.lineHeight:new Xe,this._fontKerning=e.fontKerning?new e.fontKerning:new j,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new Ye,this._overflow=new Bs("visible"),this._borderRadius=new Fs(0),this._borderWidth=new Os(0),this._borderColor=new I("borderColor",16711935),this._borderOpacity=new ie("borderOpacity",1),this._font=new fs,this._lineBreak=e.lineBreak?new e.lineBreak:new V("lineBreak"),this._textContent=e.textContent?new e.textContent:new De,this._glyphs=e.glyphs?new e.glyphs:new V("glyphs"),this._inlines=e.inlines?new e.inlines:new V("inlines"),this._layouter=e.layouter?new e.layouter:new V("layouter"),this._inlineJustificator=new As,this._textAlign=e.textAlign?new e.textAlign:new ne,this._autoSize=e.autoSize?new e.autoSize:new V("autoSize"),this._renderer=e.renderer?new e.renderer:new V("renderer"),this._offset=new es,this._invertAlpha=new Bi,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new ts,this._components=[this._textContent,this._children,this._parent,this._autoSize,this._fontFamily,this._fontStyle,this._fontWeight,this._font,this._whiteSpace,this._glyphs,this._inlines,this._visible,this._backgroundSide,this._fontSide,this._backgroundAlphaTest,this._fontAlphaTest,this._backgroundCastShadow,this._fontCastShadow,this._backgroundReceiveShadow,this._fontReceiveShadow,this._renderOrder,this._segments,this._padding,this._margin,this._width,this._height,this._borderWidth,this._boxSizing,this._bounds,this._position,this._flexDirection,this._justifyContent,this._alignItems,this._order,this._display,this._backgroundColor,this._backgroundOpacity,this._backgroundImage,this._backgroundSize,this._fontOpacity,this._color,this._fontSize,this._lineHeight,this._fontKerning,this._letterSpacing,this._borderRadius,this._borderColor,this._borderOpacity,this._lineBreak,this._offset,this._layouter,this._inlineJustificator,this._textAlign,this._invertAlpha,this._fontSmooth,this._fontMaterial,this._fontCustomDepthMaterial,this._overflow,this._renderer],this._onAfterUpdates=[],t.backgroundSide||(t.backgroundSide=0),t&&this.set(t)}update(){const e={};for(const t of this._components)t._needsUpdate&&(t.update(this,e),t._needsUpdate=!1);this._transferToBackgroundMesh(e),this._transferToFontMesh(e),this._transferToBackgroundMaterial(e),this._transferToFontMaterial(e);for(const t of this._children._uis)t.update()}process(){for(const e of this._children._uis)e.process();for(const e of this._components)e._needsProcess&&(e.process(this),e._needsProcess=!1)}render(){for(let e=0;e<this._components.length;e++){const t=this._components[e];t._needsRender&&(t.render(this),t._needsRender=!1)}for(const e of this._children._uis)e.render()}set(e){if(e.fontTexture&&(console.warn("ThreeMeshUI::set( {fontTexture} ) is deprecated. Please use fontLibrary to register font families and variants."),e.fontFamily)){const t=e.fontFamily.pages?e.fontFamily.info.face:e.fontFamily;let i=C.getFontFamily(t);if(!i){const r=e.fontStyle?e.fontStyle:"normal",n=e.fontWeight?e.fontWeight:"400";i=C.addFontFamily(t).addVariant(n,r,e.fontFamily,e.fontTexture)}e.fontFamily=i,delete e.fontTexture}for(let t of Object.keys(e)){const i=e[t];switch(t){case"contentDirection":console.warn("ThreeMeshUI v7xx: property `contentDirection` is deprecated and has been renamed as `flexDirection`"),t="flexDirection";break;case"interLine":console.warn("ThreeMeshUI v7xx: property `interLine` is deprecated and has been renamed as `lineHeight`"),t="lineHeight";break;case"content":console.warn("ThreeMeshUI v7xx: property `content` is deprecated and has been renamed as `textContent`"),t="textContent";break;case"fontColor":console.warn("ThreeMeshUI v7xx: property `fontColor` is deprecated and has been renamed as `color`"),t="color";break;case"hiddenOverflow":console.warn("ThreeMeshUI v7xx: property `hiddenOverflow` is deprecated and has been renamed as `overflow`"),t="overflow";break;case"backgroundTexture":console.warn("ThreeMeshUI v7xx: property `backgroundTexture` is deprecated and has been renamed as `backgroundImage`"),t="backgroundImage";break;case"alignContent":console.warn("ThreeMeshUI v7xx: property `alignContent` is deprecated and has been renamed as `alignItems`"),t="alignItems";break;case"borderTopColor":case"borderBottomColor":case"borderLeftColor":case"borderRightColor":t="borderColor";break}switch(t){case"fontSmooth":case"renderOrder":case"segments":case"visible":case"offset":this[`_${t}`].value=i;break;case"flexDirection":case"justifyContent":case"alignItems":case"color":case"fontFamily":case"fontOpacity":case"fontKerning":case"fontSize":case"fontStyle":case"fontWeight":case"textAlign":case"letterSpacing":case"lineHeight":case"whiteSpace":case"breakOn":case"width":case"height":case"padding":case"margin":case"backgroundColor":case"backgroundOpacity":case"backgroundImage":case"backgroundSize":case"borderColor":case"borderOpacity":case"borderRadius":case"borderWidth":case"overflow":case"order":case"boxSizing":this[`_${t}`]&&(this[`_${t}`].inline=i);break;case"paddingTop":this._padding.top=i;break;case"paddingRight":this._padding.right=i;break;case"paddingBottom":this._padding.bottom=i;break;case"paddingLeft":this._padding.left=i;break;case"marginTop":this._margin.top=i;break;case"marginRight":this._margin.right=i;break;case"marginBottom":this._margin.bottom=i;break;case"marginLeft":this._margin.left=i;break;case"borderTopWidth":this._borderWidth.top=i;break;case"borderRightWidth":this._borderWidth.right=i;break;case"borderBottomWidth":this._borderWidth.bottom=i;break;case"borderLeftWidth":this._borderWidth.left=i;break;case"borderTopLeftRadius":this._borderRadius.topLeft=i;break;case"borderTopRightRadius":this._borderRadius.topRight=i;break;case"borderBottomRightRadius":this._borderRadius.bottomRight=i;break;case"borderBottomLeftRadius":this._borderRadius.bottomLeft=i;break;case"side":case"castShadow":case"receiveShadow":const r=t.charAt(0).toUpperCase()+t.substr(1);this[`_background${r}`].value=i,this[`_font${r}`].value=i;break;case"fontSide":case"backgroundSide":case"fontCastShadow":case"backgroundCastShadow":case"fontReceiveShadow":case"backgroundReceiveShadow":case"fontMaterial":case"fontCustomDepthMaterial":this[`_${t}`].value=i;break;default:this[`_${t}`]!==void 0?this[`_${t}`].value=i:this[t]=i}}}get(e){switch(e){case"overflow":case"width":case"height":return this[`_${e}`].inline}}_rebuildChildrenLists(){this._children._needsUpdate=!0}_rebuildParentUI=()=>{this._parent._needsUpdate=!0,this.parent&&!this.parent.isUI?(N.register(this),this.activatePseudoState("root")):(N.remove(this),this.deactivatePseudoState("root"))};add(e){let t=!1;for(let i=0;i<arguments.length;i++)super.add(arguments[i]),arguments[i].isUI&&(t=!0);return t&&this._rebuildChildrenLists(),this}remove(e){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);return super.remove(...arguments),this._rebuildChildrenLists(),this}clear(){return this.removeFromParent(),this.traverse(e=>{e.material&&e.material.dispose(),e.geometry&&e.geometry.dispose()}),super.clear(),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundMaterialMediation=null,this._backgroundMeshMediation=null,this._children.dispose(),this._children=null,this._parent.dispose(),this._parent=null,this._backgroundSide=null,this._backgroundAlphaTest=null,this._visible=null,this._backgroundCastShadow=null,this._backgroundReceiveShadow=null,this._renderOrder=null,this._segments=null,this._bounds=null,this._boxSizing=null,this._padding=null,this._margin=null,this._position=null,this._flexDirection=null,this._justifyContent=null,this._alignItems=null,this._display=null,this._backgroundColor=null,this._backgroundOpacity=null,this._backgroundSize=null,this._fontOpacity=null,this._color=null,this._whiteSpace=null,this._fontFamily=null,this._fontStyle=null,this._fontWeight=null,this._lineHeight=null,this._fontKerning=null,this._letterSpacing=null,this._overflow=null,this._textAlign=null,this._font=null,this._lineBreak=null,this._layouter=null,this}get textContent(){return this._textContent.process(this),this._textContent._value}get backgroundMaterial(){return this._backgroundMaterial}set backgroundMaterial(e){this._backgroundMaterial=e,this._backgroundMaterialMediation={...e.constructor.mediation},this._transferToBackgroundMaterial(),this._backgroundMesh&&(this._backgroundMesh.material=this._backgroundMaterial,x(e,"frameSize",this._backgroundMesh.scale))}set backgroundCustomDepthMaterial(e){this._backgroundCustomDepthMaterial=e,this._transferToBackgroundMaterial(),this._backgroundMesh&&(this._backgroundMesh.customDepthMaterial=this._backgroundCustomDepthMaterial)}get backgroundCustomDepthMaterial(){return this._backgroundCustomDepthMaterial}_transferToBackgroundMaterial(e=null){if(!e){e={};for(const t of this._components)t.output(e)}D.mediate(this,this._backgroundMaterial,e,this._backgroundMaterialMediation,this._backgroundCustomDepthMaterial)}set backgroundSide(e){this._backgroundSide.value=e,this._backgroundMaterial&&(this._backgroundMaterial.side=e)}get backgroundSide(){return this._backgroundSide.value}set backgroundAlphaTest(e){this._backgroundAlphaTest.value=e,this._backgroundMaterial&&(this._backgroundMaterial.alphaTest=e)}get backgroundAlphaTest(){return this._backgroundAlphaTest.value}get fontMaterial(){return this._fontMaterial.value}set fontMaterial(e){this._fontMaterial.value=e}set fontCustomDepthMaterial(e){this._fontCustomDepthMaterial.value=e}get fontCustomDepthMaterial(){return this._fontCustomDepthMaterial.value}_transferToFontMaterial(e=null){const t=this._fontMaterial.value;if(t){if(!e){e={};for(const i of this._components)i.output(e)}D.mediate(this,t,e,this._fontMaterial._mediation,this._fontCustomDepthMaterial.value)}}set fontSide(e){this._fontSide.value=e}get fontSide(){return this._fontSide.value}set fontAlphaTest(e){this._fontAlphaTest.value=e}get fontAlphaTest(){return this._fontAlphaTest.value}_transferToBackgroundMesh(e=null){if(!e){e={};for(const t of this._components)t.output(e)}D.mediate(this,this._backgroundMesh,e,this._backgroundMeshMediation)}setBackgroundMesh(e){this._backgroundMesh&&(this.remove(this._backgroundMesh),this.unbindBackgroundMeshProperties()),this._backgroundMesh=e,this._backgroundMesh&&(this.bindBackgroundMeshProperties(),this._backgroundCustomDepthMaterial&&(this._backgroundMesh.customDepthMaterial=this._backgroundCustomDepthMaterial),this._backgroundMaterial&&x(this._backgroundMaterial,"frameSize",this._backgroundMesh.scale),this._transferToBackgroundMesh(),this.add(this._backgroundMesh))}bindBackgroundMeshProperties(){}unbindBackgroundMeshProperties(){}activatePseudoState(e){}deactivatePseudoState(e){}togglePseudoState(e){}hasPseudoState(e){return!1}set borderRadiusMediation(e){this._borderRadius.mediation=e}set backgroundCastShadow(e){this._backgroundCastShadow&&(this._backgroundCastShadow.value=e)}get backgroundCastShadow(){return this._backgroundCastShadow}set backgroundReceiveShadow(e){this._backgroundReceiveShadow&&(this._backgroundReceiveShadow.value=e)}get backgroundReceiveShadow(){return this._backgroundReceiveShadow}set renderOrder(e){this._renderOrder&&(this._renderOrder.value=e)}get renderOrder(){return this._renderOrder.value}_transferToFontMesh(e=null){if(this._fontMesh){if(!e){e={};for(const t of this._components)t.output(e)}D.mediate(this,this._fontMesh,e,this._fontMeshMediation)}}setFontMesh(e){this._fontMesh&&(this.remove(this._fontMesh),this._fontMesh.material&&this._fontMesh.material.dispose(),this._fontMesh.geometry&&this._fontMesh.geometry.dispose(),this._fontMesh=null,this.unbindFontMeshProperties()),this._fontMesh=e,this._fontMesh&&(this._fontMesh.raycast=()=>{},this.bindFontMeshProperties(),this._transferToFontMaterial(),this._transferToFontMesh(),this.add(this._fontMesh))}bindFontMeshProperties(){}unbindFontMeshProperties(){}set fontCastShadow(e){this._fontCastShadow&&(this._fontCastShadow.value=e)}get fontCastShadow(){return this._fontCastShadow}set fontReceiveShadow(e){this._fontReceiveShadow&&(this._fontReceiveShadow.value=e)}get fontReceiveShadow(){return this._fontReceiveShadow}set segments(e){this._segments.value=e}get segments(){return this._segments.value}set onAfterUpdate(e){console.warn("ThreeMeshUI v7xx : `onAfterUpdate()` property has been deprecated, please rely on `addAfterUpdate` instead."),this.addAfterUpdate(e)}addAfterUpdate(e){this._onAfterUpdates.push(e)}removeAfterUpdate(e){const t=this._onAfterUpdates.indexOf(e);t!==-1&&this._onAfterUpdates.splice(t,1)}performAfterUpdate(){for(let e=0;e<this._onAfterUpdates.length;e++)this._onAfterUpdates[e]()}getProperty(e){return this[`_${e}`]?this[`_${e}`]:null}appendProperty(e,t){this[`_${e}`]=t,this._components.push(t)}replaceProperty(e,t){const i=this[`_${e}`],r=this._components.indexOf(i);return this._components[r]=this[`_${e}`]=t,t.needsUpdate=!0,i}}class N{static register(e){this.elements.includes(e)||this.elements.push(e)}static remove(e){const t=this.elements.indexOf(e);t!==-1&&this.elements.splice(t,1)}static update(){for(const e of this.elements)e.update(),e.process(),e.process(),e.render()}}N.elements=[];const Fi=`
103
+
104
+ // FrameBorder vertex pars
105
+ attribute vec2 uvB;
106
+ varying vec2 vUvB;
107
+
108
+ `,pe=Fi,Oi=`
109
+
110
+ // FrameBorder vertex shader
111
+ vUvB = uvB;
112
+
113
+ `,fe=Oi,zi=`
114
+
115
+ // borders sequences are : x:TOP, y:RIGHT, z:BOTTOM, w:LEFT
116
+ uniform vec4 borderWidth;
117
+ uniform vec3 borderColor;
118
+ uniform float borderOpacity;
119
+ uniform vec4 borderRadius;
120
+
121
+ uniform vec2 cornerTL;
122
+ uniform vec2 cornerTR;
123
+ uniform vec2 cornerBR;
124
+ uniform vec2 cornerBL;
125
+
126
+ varying vec2 vUvB;
127
+
128
+ float getEllipticFactor( vec2 uv, vec2 center, float radiusX, float radiusY )
129
+ {
130
+
131
+ float edx = uv.x - center.x;
132
+ float edy = uv.y - center.y;
133
+
134
+ float ddx = (edx * edx) / (radiusX * radiusX);
135
+ float ddy = (edy * edy) / (radiusY * radiusY);
136
+
137
+ return ddx + ddy;
138
+
139
+ }
140
+
141
+ `,ge=zi,Ai=`
142
+
143
+ vec4 borderColor = vec4( borderColor, borderOpacity );
144
+
145
+ // This could be tweak to produce more smoothing
146
+ float mult = 1.0;
147
+
148
+ // Step 1 ----------------------------------------------
149
+ // Draw the four borders ( top - right - bottom - left )
150
+ // Without worrying about radiuses ( Straight boorders )
151
+
152
+ // Top
153
+ float topBorderUVy = 1.0 - borderWidth.x;
154
+ if( borderWidth.x > 0.0 && vUvB.y > topBorderUVy )
155
+ {
156
+
157
+ float w = fwidth( 1.0 - vUvB.y ) * mult;
158
+ float step = smoothstep( topBorderUVy , topBorderUVy + w , vUvB.y );
159
+ diffuseColor = mix( diffuseColor, borderColor, step );
160
+
161
+ }
162
+
163
+ // Left
164
+ float leftBorderUVx = borderWidth.w;
165
+ if( borderWidth.w > 0.0 && vUvB.x < leftBorderUVx )
166
+ {
167
+
168
+ float w = fwidth( vUvB.x ) * mult ;
169
+ float step = smoothstep( leftBorderUVx , leftBorderUVx - w , vUvB.x );
170
+ diffuseColor = mix( diffuseColor, borderColor, step );
171
+
172
+ }
173
+
174
+ // Bottom
175
+ float bottomBorderUVy = borderWidth.z;
176
+ if( borderWidth.z > 0.0 && vUvB.y < bottomBorderUVy )
177
+ {
178
+ float w = fwidth( vUvB.y ) * mult;
179
+ float step = smoothstep( bottomBorderUVy , bottomBorderUVy - w , vUvB.y );
180
+ diffuseColor = mix( diffuseColor, borderColor, step );
181
+ }
182
+
183
+ // Right
184
+ float rightBorderUVx = 1.0 - borderWidth.y;
185
+ if( borderWidth.y > 0.0 && vUvB.x > rightBorderUVx )
186
+ {
187
+ float w = fwidth( 1.0 - vUvB.x ) * mult;
188
+ float step = smoothstep( rightBorderUVx , rightBorderUVx + w , vUvB.x );
189
+ diffuseColor = mix( diffuseColor, borderColor, step );
190
+ }
191
+
192
+
193
+ // Step 2 ----------------------------------------------
194
+ // Process each corners ( topLeft, topRight, bottomRight, bottomLeft )
195
+ // To transparentize outside radiuses
196
+ // To draw ellipse border on the corner
197
+
198
+
199
+ // Top Left corner
200
+ if( vUvB.x < cornerTL.x && vUvB.y > cornerTL.y ) {
201
+
202
+ // Only draw border if width is set
203
+ if( borderWidth.w + borderWidth.x > 0.0 ){
204
+
205
+ float borderFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x - borderWidth.w, ( 1.0 - cornerTL.y ) - borderWidth.x );
206
+ float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
207
+ diffuseColor = mix( diffuseColor, borderColor, step );
208
+
209
+ }
210
+
211
+ // Then then radius
212
+ float radiusFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x, 1.0 - cornerTL.y );
213
+ float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
214
+ diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
215
+
216
+ }
217
+ // Bottom Left
218
+ if( vUvB.x < cornerBL.x && vUvB.y < cornerBL.y ) {
219
+
220
+ if( borderWidth.w + borderWidth.z > 0.0 ){
221
+
222
+ float borderFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x - borderWidth.w, cornerBL.y - borderWidth.z );
223
+ float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
224
+ diffuseColor = mix( diffuseColor, borderColor, step );
225
+
226
+ }
227
+
228
+
229
+ float radiusFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x, cornerBL.y );
230
+ float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
231
+ diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
232
+
233
+ }
234
+ // Top Right
235
+ if( vUvB.x > cornerTR.x && vUvB.y > cornerTR.y ) {
236
+
237
+ if( borderWidth.y + borderWidth.x > 0.0 ){
238
+
239
+ float borderFactor = getEllipticFactor( vUvB, cornerTR, ( 1.0 - cornerTR.x ) - borderWidth.y, ( 1.0 - cornerTR.y ) - borderWidth.x );
240
+ float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
241
+ diffuseColor = mix( diffuseColor, borderColor, step );
242
+
243
+ }
244
+
245
+ float radiusFactor = getEllipticFactor( vUvB, cornerTR, 1.0 - cornerTR.x, 1.0 - cornerTR.y );
246
+ float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
247
+ diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
248
+
249
+ }
250
+ // Bottom Right
251
+ if( vUvB.x > cornerBR.x && vUvB.y < cornerBR.y ) {
252
+
253
+ if( borderWidth.y + borderWidth.z > 0.0 ){
254
+
255
+ float borderFactor = getEllipticFactor( vUvB, cornerBR, ( 1.0 - cornerBR.x ) - borderWidth.y, cornerBR.y - borderWidth.z );
256
+ float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
257
+ diffuseColor = mix( diffuseColor, borderColor, step );
258
+
259
+ }
260
+
261
+ float radiusFactor = getEllipticFactor( vUvB, cornerBR, 1.0 - cornerBR.x, cornerBR.y );
262
+ float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
263
+ diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
264
+
265
+ }
266
+
267
+ `,me=Ai,Wi=`
268
+
269
+ // To be removed - required for both border and background
270
+ uniform vec3 frameSize;
271
+ uniform vec2 textureSize;
272
+
273
+ `,ve=Wi,Di=`
274
+
275
+ #ifdef USE_MAP
276
+
277
+ vec4 sampleTexture() {
278
+
279
+ vec2 uv = vUv;
280
+
281
+ // default stretch
282
+ #if BACKGROUND_MAPPING != 0
283
+
284
+ float textureRatio = textureSize.x / textureSize.y;
285
+ float panelRatio = frameSize.x / frameSize.y;
286
+ float ratio = panelRatio / textureRatio;
287
+ float ratio2 = textureRatio / panelRatio;
288
+
289
+ // contain
290
+ #if BACKGROUND_MAPPING == 1
291
+ if ( textureRatio < panelRatio ) { // repeat on X
292
+ float newX = uv.x * ratio;
293
+ newX += 0.5 - 0.5 * ratio;
294
+ uv.x = newX;
295
+ } else { // repeat on Y
296
+ float newY = uv.y * ratio2;
297
+ newY += 0.5 - 0.5 * ratio2;
298
+ uv.y = newY;
299
+ }
300
+ #else
301
+ // cover
302
+ if ( textureRatio < panelRatio ) { // stretch on Y
303
+ float newY = uv.y * ratio2;
304
+ newY += 0.5 - 0.5 * ratio2;
305
+ uv.y = newY;
306
+ } else { // stretch on X
307
+ float newX = uv.x * ratio;
308
+ newX += 0.5 - 0.5 * ratio;
309
+ uv.x = newX;
310
+ }
311
+
312
+ #endif
313
+
314
+ #endif
315
+
316
+ return texture2D( map, uv );
317
+
318
+ }
319
+ #endif
320
+ `,be=Di,Ei=`
321
+ #ifdef USE_MAP
322
+
323
+ vec4 textureSample = sampleTexture();
324
+ diffuseColor *= textureSample;
325
+
326
+ #endif
327
+ `,ye=Ei,Je={msdfAlphaglyphParsVertexGlsl:le,msdfAlphaglyphVertexGlsl:he,msdfOffsetglyphVertexGlsl:ue,msdfAlphaglyphParsFragmentGlsl:ce,msdfAlphaglyphFragmentGlsl:de,frameBorderParsVertexGlsl:pe,frameBorderVertexGlsl:fe,frameCommonParsFragmentGlsl:ve,frameBorderParsFragmentGlsl:ge,frameBorderFragmentGlsl:me,frameBackgroundParsFragmentGlsl:be,frameBackgroundFragmentGlsl:ye},Li=`
328
+ // Would be automatic on three materials and from USE_UV
329
+ #ifdef USE_MAP
330
+ varying vec2 vUv;
331
+ #endif
332
+
333
+ ${pe}
334
+
335
+ #include <clipping_planes_pars_vertex>
336
+
337
+ void main() {
338
+
339
+ #ifdef USE_MAP
340
+ vUv = uv;
341
+ #endif
342
+
343
+ ${fe}
344
+
345
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
346
+ gl_Position = projectionMatrix * mvPosition;
347
+
348
+ #include <clipping_planes_vertex>
349
+
350
+ }
351
+ `,Hi=`
352
+
353
+ // Basic
354
+ uniform vec3 diffuse;
355
+ uniform float opacity;
356
+
357
+ #ifdef USE_ALPHATEST
358
+ uniform float alphaTest;
359
+ #endif
360
+
361
+ ${ve}
362
+
363
+ ${ge}
364
+
365
+
366
+ #ifdef USE_MAP
367
+ varying vec2 vUv;
368
+ uniform sampler2D map;
369
+ #endif
370
+
371
+ ${be}
372
+
373
+ #include <clipping_planes_pars_fragment>
374
+
375
+ void main() {
376
+
377
+ vec4 diffuseColor = vec4( diffuse, opacity );
378
+
379
+ // map
380
+ ${ye}
381
+
382
+ ${me}
383
+
384
+ #ifdef USE_ALPHATEST
385
+
386
+ if ( diffuseColor.a < alphaTest ) discard;
387
+
388
+ #endif
389
+
390
+ // output
391
+ gl_FragColor = diffuseColor;
392
+
393
+
394
+ #include <clipping_planes_fragment>
395
+ }
396
+ `;class q{static get mediation(){return $i}static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||(e.defines={})}static ensureUserData(e,t){e.userData.borderColor={value:null},e.userData.borderRadius={value:new a.Vector4(0,0,0,0)},e.userData.cornerTL={value:new a.Vector2(0,1)},e.userData.cornerTR={value:new a.Vector2(1,1)},e.userData.cornerBR={value:new a.Vector2(1,0)},e.userData.cornerBL={value:new a.Vector2(0,0)},e.userData.borderWidth={value:new a.Vector4(0,0,0,0)},e.userData.borderOpacity={value:null},e.userData.frameSize={value:new a.Vector3(1,1,1)},e.userData.textureSize={value:new a.Vector2(1,1)}}static bindUniformsWithUserData(e,t){e.uniforms.borderColor=t.userData.borderColor,e.uniforms.borderRadius=t.userData.borderRadius,e.uniforms.cornerTL=t.userData.cornerTL,e.uniforms.cornerTR=t.userData.cornerTR,e.uniforms.cornerBR=t.userData.cornerBR,e.uniforms.cornerBL=t.userData.cornerBL,e.uniforms.borderWidth=t.userData.borderWidth,e.uniforms.borderOpacity=t.userData.borderOpacity,e.uniforms.frameSize=t.userData.frameSize,e.uniforms.textureSize=t.userData.textureSize}static injectShaderChunks(e){q.injectVertexShaderChunks(e),q.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>",`#include <uv_pars_vertex>
397
+ `+pe),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
398
+ `+fe)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
399
+ `+be),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
400
+ `+ge),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
401
+ `+ve),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",ye),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",me+`
402
+ #include <alphamap_fragment>`)}}const Gi=function(s,e,t){t=["stretch","contain","cover"].indexOf(t),Ge(s,"BACKGROUND_MAPPING",t)},$i={clippingPlanes:{m:"clippingPlanes"},backgroundAlphaTest:{m:"alphaTest",t:H},backgroundSide:{m:"side"},backgroundImage:{m:"map"},backgroundColor:{m:"color"},backgroundOpacity:{m:"opacity"},backgroundSize:{m:"computedBackgroundSize",t:Gi},borderWidth:{m:"borderWidth",t:x},borderColor:{m:"borderColor",t:x},cornerTL:{m:"cornerTL",t:x},cornerTR:{m:"cornerTR",t:x},cornerBR:{m:"cornerBR",t:x},cornerBL:{m:"cornerBL",t:x},borderOpacity:{m:"borderOpacity",t:x},size:{m:"frameSize",t:x},tSize:{m:"textureSize",t:x}};class Qe extends a.ShaderMaterial{static get mediation(){return q.mediation}constructor(){super({uniforms:{alphaTest:{value:.02},map:{value:null},diffuse:{value:new a.Color(16777215)},opacity:{value:1},borderColor:{value:new a.Color(0)},borderOpacity:{value:0},borderRadius:{value:new a.Vector4(0,0,0,0)},cornerTL:{value:new a.Vector2(0,1)},cornerTR:{value:new a.Vector2(1,1)},cornerBR:{value:new a.Vector2(1,0)},cornerBL:{value:new a.Vector2(0,0)},borderWidth:{value:new a.Vector4(0,0,0,0)},frameSize:{value:new a.Vector3(1,1,1)},textureSize:{value:new a.Vector2(1,1)}},side:a.FrontSide,transparent:!0,clipping:!0,vertexShader:Li,fragmentShader:Hi,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST="",this.needsUpdate=!0}set map(e){this.uniforms.map.value=e,e?this.defines.USE_UV===void 0&&(this.defines.USE_UV="",this.needsUpdate=!0):this.defines.USE_UV!==void 0&&(delete this.defines.USE_UV,this.needsUpdate=!0),this.needsUpdate=!0}get map(){return this.uniforms.map.value}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get opacity(){return this.uniforms.opacity.value}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}}class ji extends p{constructor(){super("children",null,!1),this._uis=[],this._boxes=[]}update(e,t){this._compute(e),e._layouter._needsUpdate=!0,e._renderOrder._needsUpdate=!0}process(e){this._compute(e),e._flexDirection._needsProcess=!0,e._layouter._needsProcess=!0,e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter(t=>t.visible&&t.isUI),this._boxes=this._uis.filter(t=>t.isBox).sort(this._sortOrder)}dispose(){this._uis=null,this._boxes=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class Ze extends p{constructor(){super("bounds",null,!1),this._size=new a.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0,this._centerX=.5,this._centerY=.5,this._needsProcess=!0}setReferenceWidth(e,t){const i=e._width,r=e._padding._value,n=e._borderWidth._value,o=e._margin._value,h=i._auto?1:i._value,c=t*h-(o.y+o.w);te(c,this._offsetWidth)||(this._offsetWidth=c,this._innerWidth=this._offsetWidth-(r.y+r.w+n.y+n.w),this._centerX=xe(e),this._propagateWidth(e),this._triggerCascadingDependencies(e))}setReferenceHeight(e,t){const i=e._height,r=e._padding._value,n=e._borderWidth._value,o=e._margin._value,h=i._auto?1:i._value,c=t*h-(o.x+o.z);te(c,this._offsetHeight)||(this._offsetHeight=c,this._innerHeight=this._offsetHeight-(r.x+r.z+n.x+n.z),this._centerY=we(e),this._propagateHeight(e),this._triggerCascadingDependencies(e))}setChildrenWidth(e,t){const i=e._padding._value,r=e._borderWidth._value;this._innerWidth=t,this._offsetWidth=this._innerWidth+(i.y+i.w+r.y+r.w),this._centerX=xe(e),this._propagateWidth(e),this._triggerCascadingDependencies(e)}setChildrenHeight(e,t){const i=e._padding._value,r=e._borderWidth._value;this._innerHeight=t,this._offsetHeight=this._innerHeight+(i.x+i.z+r.x+r.z),this._centerY=we(e),this._propagateHeight(e),this._triggerCascadingDependencies(e)}update(e,t){const i=e._padding._value,r=e._borderWidth._value,n=e._width;!n._auto&&!n._relative&&(e._boxSizing._value==="content-box"?(this._innerWidth=n._value,this._offsetWidth=this._innerWidth+i.y+i.w+r.y+r.w):(this._offsetWidth=n._value,this._innerWidth=this._offsetWidth-(i.y+i.w+r.y+r.w)),this._centerX=xe(e),this._needsProcess=!0,this._propagateWidth(e),this._triggerCascadingDependencies(e));const o=e._height;!o._auto&&!o._relative&&(e._boxSizing._value==="content-box"?(this._innerHeight=o._value,this._offsetHeight=this._innerHeight+i.x+i.z+r.x+r.z):(this._offsetHeight=o._value,this._innerHeight=this._offsetHeight-(i.x+i.z+r.x+r.z)),this._centerY=we(e),this._needsProcess=!0,this._propagateHeight(e),this._triggerCascadingDependencies(e))}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight,e._backgroundMesh&&e._backgroundMesh.updateScale(),e._renderer._needsRender=!0}output(e){e.size=this._size}process(e){e._overflow._needsRender=!0}_computeChildrenSideWidth(e){return Xi(e)}_computeChildrenSideHeight(e){return Ni(e)}_propagateWidth(e){for(let t=0;t<e._children._boxes.length;t++){const i=e._children._boxes[t];i._width._relative&&i._bounds.setReferenceWidth(i,this._innerWidth)}}_propagateHeight(e){for(let t=0;t<e._children._boxes.length;t++){const i=e._children._boxes[t];i._height._relative&&i._bounds.setReferenceHeight(i,this._innerHeight)}}_triggerCascadingDependencies(e){e._parent._value&&(e._parent._value._autoSize._needsProcess=!0),e._flexDirection._needsProcess=!0,e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0,e._overflow._needsRender=!0}}function xe(s){const e=s._padding._value,t=s._borderWidth._value,i=e.w+t.w,r=e.y+t.y;return(i-r)/2}function we(s){const e=s._padding._value,t=s._borderWidth._value,i=e.x+t.x;return(e.z+t.z-i)/2}function Xi(s){return s._children._boxes.reduce((e,t)=>{const i=t._margin._value,r=t._bounds._offsetWidth+i.y+i.w;return e+r},0)}function Ni(s){return s._children._boxes.reduce((e,t)=>{const i=t._margin._value,r=t._bounds._offsetHeight+i.x+i.z;return e+r},0)}class Yi extends re{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0,this._process=this.emptyStrategyLogic,this._childAlign=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,e._flexDirection._value){case"row":case"row-reverse":switch(this._process=er,this._value){case"start":this._childAlign=qi;break;case"end":this._childAlign=Ki;break;default:this._childAlign=et}break;case"column":case"column-reverse":switch(this._process=Zi,this._value){case"start":this._childAlign=Qi;break;case"end":this._childAlign=Ji;break;default:this._childAlign=et}break}this._needsProcess=!0,e._autoSize._needsProcess=!0,e._flexDirection._needsProcess=!0,e._justifyContent._needsProcess=!0,this._needsProcess=!0,e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}process(e){this._process(e,this._childAlign);let t="center",i="center",r="center";const n=e._padding._value,o=e._borderWidth._value;e._flexDirection._value.indexOf("column")!==-1?this._value==="start"?t=i="left":this._value==="end"?t=i="right":t="centerX":this._value==="start"?t=r="top":this._value==="end"?t=r="bottom":t="centerY";let h=-(n.x-n.z)/2-(o.x-o.z)/2,c=-(n.y-n.w)/2-(o.y-o.w)/2;i==="left"?c=(n.w-n.y)/2+(o.w-o.y)/2:i==="right"&&(c=-(n.y-n.w)/2-(o.y-o.w)/2),r==="top"?h=-(n.x-n.z)/2-(o.x-o.z)/2:r==="bottom"&&(h=(n.z-n.x)/2+(o.z-o.x)/2),e._children._boxes.forEach(d=>{let u=0,l=0;t==="top"?l=-d._margin._value.x:t==="bottom"?l=d._margin._value.z:t==="left"?u=d._margin._value.w:t==="right"?u=-d._margin._value.y:t==="centerX"?u=(d._margin._value.w-d._margin._value.y)/2:t==="centerY"&&(l=(-d._margin._value.x+d._margin._value.z)/2),e._layouter._childrenPos[d.id].x+=c+u,e._layouter._childrenPos[d.id].y+=h+l})}}function et(){return 0}function Ki(s,e){return-e+s._bounds._offsetHeight/2}function qi(s,e){return e-s._bounds._offsetHeight/2}function Ji(s,e){return e-s._bounds._offsetWidth/2}function Qi(s,e){return-e+s._bounds._offsetWidth/2}function Zi(s,e){const t=s._bounds._innerWidth/2;s._children._boxes.forEach(i=>{s._layouter._childrenPos[i.id].x=e(i,t)})}function er(s,e){const t=s._bounds._innerHeight/2;s._children._boxes.forEach(i=>{s._layouter._childrenPos[i.id].y=e(i,t)})}class tr extends oe{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0,this._offset=0,this._reverse=1,this._process=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,this._value){case"row":this._process=sr;break;case"row-reverse":this._process=ir;break;case"column":this._process=rr;break;case"column-reverse":this._process=nr;break}e._justifyContent._needsUpdate||e._justifyContent.computeOutputValue(e),e._alignItems._needsUpdate||e._alignItems.computeOutputValue(e),this._needsProcess=!0}process(e){switch(this._value){case"row":this._offset=-e._bounds._innerWidth/2;break;case"row-reverse":this._offset=e._bounds._innerWidth/2;break;case"column":this._offset=e._bounds._innerHeight/2;break;case"column-reverse":this._offset=-e._bounds._innerHeight/2;break}this._reverse=-Math.sign(this._offset),this._reverse===0&&(this._reverse=1),this._process(e),e._justifyContent._needsProcess=!0,e._layouter._needsProcess=!0}}function sr(s){let e=s._flexDirection._offset;const t=s._flexDirection._reverse,i=s._children._boxes;for(let r=0;r<i.length;r++){const n=i[r],o=n.id,h=n._bounds._offsetWidth;e+=n._margin._value.w*t;const c=s._layouter._childrenPos[o];c.x=e+h/2*t,c.y=0,e+=t*(h+n._margin._value.y)}}function ir(s){let e=s._flexDirection._offset;const t=s._flexDirection._reverse,i=s._children._boxes;for(let r=0;r<i.length;r++){const n=i[r],o=n.id,h=n._bounds._offsetWidth;e+=n._margin._value.y*t;const c=s._layouter._childrenPos[o];c.x=e+h/2*t,c.y=0,e+=(h+n._margin._value.w)*t}}function rr(s){let e=s._flexDirection._offset;const t=s._flexDirection._reverse,i=s._children._boxes;for(let r=0;r<i.length;r++){const n=i[r],o=n.id,h=n._bounds._offsetHeight;e+=n._margin._value.x*t;const c=s._layouter._childrenPos[o];c.x=0,c.y=e+h/2*t,e+=(h+n._margin._value.z)*t}}function nr(s){let e=s._flexDirection._offset;const t=s._flexDirection._reverse,i=s._children._boxes;for(let r=0;r<i.length;r++){const n=i[r],o=n.id,h=n._bounds._offsetHeight;e+=n._margin._value.z*t;const c=s._layouter._childrenPos[o];c.x=0,c.y=e+h/2*t,e+=(h+n._margin._value.x)*t}}class or extends ae{constructor(e){super("justifyContent",e,!0),this._allowsInherit=!1,this._needsUpdate=!0,this._computeOffset=this.emptyStrategyLogic,this._computeMargin=this.emptyStrategyLogic,this._process=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,e._flexDirection._value){case"column-reverse":case"column":this._process=lr.bind(this);break;case"row-reverse":case"row":this._process=ar.bind(this);break}switch(this._value){case"end":this._computeOffset=cr,this._computeMargin=Se;break;case"center":this._computeOffset=dr,this._computeMargin=Se;break;case"start":this._computeOffset=Y,this._computeMargin=Se;break;case"space-between":this._computeOffset=Y,this._computeMargin=_r;break;case"space-around":this._computeOffset=Y,this._computeMargin=fr;break;case"space-evenly":this._computeOffset=Y,this._computeMargin=pr;break}e._flexDirection._needsProcess=!0}process(e){this._process(e),e._alignItems._needsProcess=!0}}function ar(s){const e=s._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:i}=hr(s),r=e*2-t*Math.sign(e),n=this._computeOffset(r),o=this._computeMargin(s,i,s._flexDirection._reverse);s._children._boxes.forEach((h,c)=>{s._layouter._childrenPos[h.id].x-=n-o[c]})}function lr(s){const e=s._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:i}=ur(s),r=e*2-t*Math.sign(e),n=this._computeOffset(r),o=this._computeMargin(s,i,s._flexDirection._reverse);s._children._boxes.forEach((h,c)=>{s._layouter._childrenPos[h.id].y-=n-o[c]})}function hr(s){const e=s._bounds._computeChildrenSideWidth(s);return{usedDirectionSpace:e,remainingSpace:s._bounds._innerWidth-e}}function ur(s){const e=s._bounds._computeChildrenSideHeight(s);return{usedDirectionSpace:e,remainingSpace:s._bounds._innerHeight-e}}function Y(s){return 0}function cr(s){return s}function dr(s){return s/2}function Se(s,e=0,t=1){return Array(s._children._boxes.length).fill(0)}function _r(s,e=0,t=1){const i=s._children._boxes.length,r=Array(i).fill(0);if(e>0&&i>1){const n=e/(i-1)*t;r[0]=0;for(let o=1;o<i;o++)r[o]=n*o}return r}function pr(s,e=0,t=1){const i=s._children._boxes.length,r=Array(i).fill(0);if(e>0){const n=e/(i+1)*t;for(let o=0;o<i;o++)r[o]=n*(o+1)}return r}function fr(s,e=0,t=1){const i=s._children._boxes.length,r=Array(i).fill(0);if(e>0){const n=e/i*t,o=n/2;r[0]=o;for(let h=1;h<i;h++)r[h]=o+n*h}return r}let ke;class tt extends a.Mesh{constructor(e){const t=e.slice,i={};let r=1,n=1;if(t){if(r=t.width?t.width:1,n=t.height?t.height:1,t.top){if(t.left){const l=new a.PlaneGeometry(t.left*r,t.top*n,1,1);U(l,0,t.left,1-t.top,1),l.translate(t.left*r/2,-t.top*n/2,0),i.topLeft=l}const u=new a.PlaneGeometry(1,t.top*n,1,1);if(U(u,t.left,1-t.right,1-t.top,1),u.translate(0,-t.top*n/2,0),i.top=u,t.right){const l=new a.PlaneGeometry(t.right*r,t.top*n,1,1);U(l,1-t.right,1,1-t.top,1),l.translate(-t.right*r/2,-t.top*n/2,0),i.topRight=l}}if(t.left){const u=new a.PlaneGeometry(t.left*r,1,1,1);U(u,0,t.left,t.bottom,1-t.top),u.translate(t.left*r/2,0,0),i.left=u}const d=new a.PlaneGeometry(1,1,1,1);if(U(d,t.left,1-t.right,t.bottom,1-t.top),i.middle=d,t.right){const u=new a.PlaneGeometry(t.right*r,1,1,1);U(u,1-t.right,1,t.bottom,1-t.top),u.translate(-t.right*r/2,0,0),i.right=u}if(t.bottom){if(t.left){const l=new a.PlaneGeometry(t.left*r,t.bottom*n,1,1);U(l,0,t.left,0,t.bottom),l.translate(t.left*r/2,t.bottom*n/2,0),i.bottomLeft=l}const u=new a.PlaneGeometry(1,t.bottom*n,1,1);if(U(u,t.left,1-t.right,0,t.bottom),u.translate(0,t.bottom*n/2,0),i.bottom=u,t.right){const l=new a.PlaneGeometry(t.right*r,t.bottom*n,1,1);U(l,1-t.right,1,0,t.bottom),l.translate(-t.right*r/2,t.bottom*n/2,0),i.bottomRight=l}}}let o=e.backgroundMaterial;t&&(ke||(ke=new a.MeshBasicMaterial({alphaTest:1.1})),o=ke);const h=new a.PlaneGeometry(1,1,e._segments.value,e._segments.value),c=new a.BufferAttribute(new Float32Array(h.getAttribute("uv").array),2);if(h.setAttribute("uvB",c).name="uvB",super(h,o),this.name="UIBackgroundBox",t){this.slice=t,this.sliceSize=new a.Vector3(1-(t.left+t.right),1-(t.bottom+t.top),1),this.sliceScale=new a.Vector3(r,n,1);for(const d in i){const u=new a.Mesh(i[d],e.backgroundMaterial);this.add(u),i[d]=u}this.updateScale=this.updateScaleSlice,this.slices=i}}updateScale(){}updateScaleSlice(){const e=new a.Vector3(1,1,1);this.scale.x<(this.slice.left+this.slice.right)*this.sliceScale.x&&(e.x=this.scale.x/((this.slice.left+this.slice.right)*this.sliceScale.x)),this.scale.y<(this.slice.bottom+this.slice.top)*this.sliceScale.y&&(e.y=this.scale.y/((this.slice.bottom+this.slice.top)*this.sliceScale.y));for(const t in this.slices){const i=this.slices[t];i.scale.set(1/this.scale.x,1/this.scale.y,this.scale.y);const r=gr[t];for(const o in r)i.position[o]=this.scale[o]*r[o]*i.scale[o];const n=mr[t];if(n){n.x&&(i.position.x=this.sliceScale.x*.5*(this.slice.left-this.slice.right)*(1/this.scale.x)),n.y&&(i.position.y=this.sliceScale.y*.5*(this.slice.bottom-this.slice.top)*(1/this.scale.y));for(const o in n){const h=this.scale[o]-(1-this.sliceSize[o])*this.sliceScale[o];i.scale[o]=Math.max(0,h*(1/this.scale[o]))}}}e.x!==1&&(this.slices.left.scale.x*=e.x,this.slices.topLeft.scale.x*=e.x,this.slices.bottomLeft.scale.x*=e.x,this.slices.right.scale.x*=e.x,this.slices.topRight.scale.x*=e.x,this.slices.bottomRight.scale.x*=e.x),e.y!==1&&(this.slices.top.scale.y*=e.y,this.slices.topLeft.scale.y*=e.y,this.slices.topRight.scale.y*=e.y,this.slices.bottom.scale.y*=e.y,this.slices.bottomLeft.scale.y*=e.y,this.slices.bottomRight.scale.y*=e.y)}}const gr={topLeft:{x:-.5,y:.5},top:{y:.5},topRight:{x:.5,y:.5},left:{x:-.5},right:{x:.5},bottomLeft:{x:-.5,y:-.5},bottom:{y:-.5},bottomRight:{x:.5,y:-.5}},mr={top:{x:1},left:{y:1},right:{y:1},bottom:{x:1},middle:{x:1,y:1}};function U(s,e,t,i,r){const n=t-e,o=r-i,h=s.attributes.uv;for(let d=0;d<h.count;d++){const u=h.getX(d),l=h.getY(d);h.setXY(d,e+u*n,i+l*o)}const c=new a.BufferAttribute(new Float32Array(s.getAttribute("uv").array),2);s.setAttribute("uvB",c).name="uvB"}class st extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new tt(e)),e.performAfterUpdate()}}class vr extends Ae{constructor(){super("position")}update(e,t){super.update(e,t),this._needsProcess=!0}}class br extends p{constructor(){super("autosize"),this._needsProcess=!0}process(e){e._width._auto&&yr(e),e._height._auto&&xr(e);const t=e._alignItems._value==="stretch",i=t&&e._flexDirection._value.indexOf("column")!==-1,r=t&&!i;for(const n of e._children._boxes)(n._width._auto&&i||n._width._relative)&&n._bounds.setReferenceWidth(n,e._bounds._innerWidth),(n._height._auto&&r||n._height._relative)&&n._bounds.setReferenceHeight(n,e._bounds._innerHeight)}}function yr(s){s._bounds.setChildrenWidth(s,Sr(s))}function xr(s){s._bounds.setChildrenHeight(s,wr(s))}function wr(s){switch(s._flexDirection._value){case"row":case"row-reverse":return Rr(s);case"column":case"column-reverse":return Vr(s)}}function Sr(s){switch(s._flexDirection._value){case"row":case"row-reverse":return kr(s);case"column":case"column-reverse":return Ur(s)}}function kr(s){let e=0;for(const t of s._children._boxes){if(t._position._value!=="static")continue;const i=t._margin._value,r=t._bounds._offsetWidth+i.y+i.w;e+=r}return e}function Vr(s){let e=0;for(const t of s._children._boxes){if(t._position._value!=="static")continue;const i=t._margin._value,r=t._bounds._offsetHeight+i.x+i.z;e+=r}return e}function Ur(s){let e=0;for(const t of s._children._boxes){if(t._position._value!=="static")continue;const i=t._margin._value,r=t._bounds._offsetWidth+i.y+i.w;r>e&&(e=r)}return e}function Rr(s){let e=0;for(const t of s._children._boxes){if(t._position._value!=="static")continue;const i=t._margin._value,r=t._bounds._offsetHeight+i.x+i.z;r>e&&(e=r)}return e}class F extends T{constructor(e,t){F.definePropertiesValues(e,t),super(e,t),F.init(this)}bindBackgroundMeshProperties(){this._bounds._size=this._backgroundMesh.scale,this._bounds._needsProcess=!0}unbindBackgroundMeshProperties(){this._bounds._size=new a.Vector3(1,1,1),this._bounds._needsProcess=!0}static definePropertiesValues(e,t){e.children||(e.children=ji),e.bounds||(e.bounds=Ze),e.flexDirection||(e.flexDirection=tr),e.justifyContent||(e.justifyContent=or),e.alignItems||(e.alignItems=Yi),e.position||(e.position=vr),e.autoSize||(e.autoSize=br),e.renderer||(e.renderer=st),t.fontSide||(t.fontSide=0),t.invertAlpha||(t.invertAlpha=!1),t.fontCastShadow||(t.fontCastShadow=!1),t.fontReceiveShadow||(t.fontReceiveShadow=!1),t.backgroundCastShadow||(t.backgroundCastShadow=!1),t.backgroundReceiveShadow||(t.backgroundReceiveShadow=!1)}static init(e){Object.defineProperties(e,{isBox:{configurable:!1,enumerable:!0,value:!0}}),e.backgroundMaterial=new Qe,e._renderer.render(e),e._backgroundMesh.visible=!1}}class it extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}}class Cr extends p{constructor(){super("layouter",null,!1),this._needsUpdate=!0,this._childrenPos={}}update(e,t){this._childrenPos={};for(const i of e._children._boxes)i._position._value==="static"&&(this._childrenPos[i.id]=i.position)}process(e){}}class O extends F{constructor(e={}){const t={};O.definePropertiesValues(t,e),super(t,e),O.init(this)}add(e){const t=[];for(let i=0;i<arguments.length;i++){const r=arguments[i];!r.isUI||r.isBox?t.push(r):console.warn("Block element can only contain Box elements.",r)}return super.add(...t)}static definePropertiesValues(e,t){e.layouter=Cr}static init(e){Object.defineProperties(e,{isBlock:{configurable:!1,enumerable:!0,value:!0}})}}class Mr extends p{constructor(){super("textContent",null,!1)}update(e,t){e._glyphs._needsUpdate=!0,e._whiteSpace._needsProcess=!0}}class Br extends p{constructor(){super("inlines",null,!1),this._value=null}process(e){if(this._value=e._glyphs._value.map(t=>t.asInlineGlyph()),this._value.length){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}e._fontSize._needsProcess=!0,e._lineBreak._needsProcess=!0,e._fontKerning._needsProcess=!0,e._layouter._needsProcess=!0}get value(){return this._value}}class Pr extends p{constructor(){super("glyphs",null,!1),this._needsUpdate=!1,this._value=null}process(e){e._font._fontVariant&&e._font._fontVariant.isReady&&(this._value=e._whiteSpace._whiteSpacedContent.split("").map(t=>e._font._fontVariant.getTypographicGlyph(t)),this._value&&(e._inlines._needsProcess=!0))}get value(){return this._value}}class Ir extends I{constructor(){super("color","inherit",!1),this.output=this._outputValue}computeOutputValue(e){this._input==="inherit"?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}}class rt extends p{constructor(e=`- ,.:?!
403
+ `){super("lineBreak",e,!0),this._newLineBreakability=null}update(e,t){this._needsProcess=!0}process(e){const t=e._whiteSpace._newLineBreakability;if(e._inlines._value)for(let i=0;i<e._inlines._value.length;i++){const r=e._inlines._value[i],n=r.char;let o=null;n!==void 0&&(t!=="nowrap"&&(this._value.includes(n)||n.match(/\s/g))&&(o="possible"),n.match(/\n/g)&&(o=t)),r.lineBreak=o}}get value(){return this._value}}class nt extends p{constructor(){super("layouter",null,!1),this._value=null}update(e,t){this._value=e._parent.find(i=>i.isUI&&i.isText),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}}class Tr extends I{constructor(e){super("backgroundColor",e,!1),this._allowsInherit=!1,this._input=0}computeOutputValue(e){this._input==="inherit"?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}}class ot extends Ee{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class at extends Le{constructor(){super()}computeOutputValue(e){this._value=se(this.getInheritedInput(e))}}class lt extends je{constructor(){super("fontFamily","inherit",!0),this._input="inherit",this._needsUpdate=!0,this._allowsInherit=!1}computeOutputValue(e){let t=this._inheritedInput;if(t==="inherit"&&(t=this.getInheritedInput(e)),t instanceof G)this._value=t,e._font._needsUpdate=!0;else if(typeof t=="string"){const i=C.getFontFamily(t);i?(this._value=i,e._font._needsUpdate=!0):console.warn(`(.style) fontFamily, the font '${t}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}}class Ve extends Ne{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited,this._whiteSpacedContent="",this._stringCollapser=this.emptyStrategyLogic,this._inlineCollapser=this.emptyStrategyLogic,this._inlineWrapper=this.emptyStrategyLogic}_computeFromInherited(e){switch(super._computeFromInherited(e),this._newLineBreakability=Fr(this._value),this._value){case"nowrap":case"normal":this._stringCollapser=Or;break;case"pre-line":this._stringCollapser=ut;break;default:this._stringCollapser=zr}switch(this._value){case"pre-line":case"nowrap":case"normal":this._inlineCollapser=Lr;break;case"pre-wrap":this._inlineCollapser=Er;break;default:this._inlineCollapser=Hr}switch(this._value){case"pre-line":case"pre-wrap":case"normal":this._inlineWrapper=Ar;break;case"pre":this._inlineWrapper=Wr;break;default:this._inlineWrapper=Dr}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}}const ht={" ":" ","\n":`
404
+ `,"\r":"\r"," ":" "},Fr=function(s){switch(s){case"pre":case"pre-wrap":case"pre-line":return"mandatory"}return null};function Or(s){return ut(s.replace(/\n/g," "))}function ut(s){return s.replace(/[ ]{2,}/g," ")}function zr(s){return s}function Ar(s,e,t,i){const r=s[e];if(r.lineBreak==="mandatory"||t+r.xadvance+r.xoffset+r.kerning>i.INNER_WIDTH)return!0;const n=_t(s,e,i);return Gr(s[e-1],t,n,i)}function Wr(s,e,t,i){return s[e].lineBreak==="mandatory"}function Dr(){return!1}function Er(s){if(!s[0])return 0;const e=s[0],t=s[s.length-1];return e.char&&e.char===`
405
+ `&&s.length>1&&dt([e],s[1]),t.char&&t.char===`
406
+ `&&s.length>1&&ct([t],s[s.length-2]),e.offsetX}function Lr(s){if(!s[0])return 0;let e=[],t;for(let i=0;i<s.length;i++){const r=s[i];if(r.char&&ht[r.char]&&s.length>i){e.push(r),t=s[i+1];continue}break}dt(e,t),e=[],t=null;for(let i=s.length-1;i>0;i--){const r=s[i];if(r.char&&ht[r.char]&&i>0){e.push(r),t=s[i-1];continue}break}return ct(e,t),s[0].offsetX}function Hr(s){return s[0]?s[0].offsetX:0}function ct(s,e){if(e)for(let t=0;t<s.length;t++){const i=s[t];i.fontFactor=0,i.offsetX=e.offsetX+e.cumulativeWidth,i.cumulativeWidth=0}}function dt(s,e){if(e)for(let t=0;t<s.length;t++){const i=s[t];i.fontFactor=0,i.offsetX=e.offsetX,i.cumulativeWidth=0}}function _t(s,e,t,i){if(i=i||0,!s[e])return i;const r=s[e];return r.lineBreak?i+r.xadvance:_t(s,e+1,t,i+r.xadvance+r.xoffset+r.kerning+t.LETTERSPACING)}function Gr(s,e,t,i){return!s||!s.char||e+t<i.INNER_WIDTH?!1:i.BREAKON.indexOf(s.char)>-1}class pt extends Ye{constructor(){super(),this._input="inherit",this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}}class ft extends g{constructor(){super("fontSize","inherit",!0),this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._font._fontVariant&&(e._bounds._needsProcess=!0,e._layouter._needsProcess=!0)}process(e){if(!e._font._fontVariant||!e._font._fontVariant.isReady)return;const t=this._value/e._font._fontVariant.typographic.size,i=e._inlines._value;for(let r=0;r<i.length;r++){const n=i[r];n.resetOffsets(),n.fontSize=this._value,n.fontFactor=t}}get value(){return this._value}}class gt extends Ke{constructor(){super("segments",1,!1),this._notInheritedValue=void 0}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"&&(this._notInheritedValue=this.getInheritedInput(e)),e._layouter._needsUpdate=!0}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value==="inherit"?this._notInheritedValue:this._value}}class $r extends gt{constructor(){super(),this._value="inherit"}}class jr extends j{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value._layouter._needsProcess=!1}process(e){if(this._value!=="none"){const t=e._whiteSpace._whiteSpacedContent,i=e._inlines._value;for(let r=1;r<i.length;r++){const n=t[r-1]+t[r];i[r].kerning=e._font._fontVariant.getKerningAmount(n)}}}}class mt extends p{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function Xr(s,e=!1){const t=s[0].index!==null,i=new Set(Object.keys(s[0].attributes)),r=new Set(Object.keys(s[0].morphAttributes)),n={},o={},h=s[0].morphTargetsRelative,c=new a.BufferGeometry;let d=0;for(let u=0;u<s.length;++u){const l=s[u];let f=0;if(t!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const _ in l.attributes){if(!i.has(_))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+_+'" attribute exists among all geometries, or in none of them.'),null;n[_]===void 0&&(n[_]=[]),n[_].push(l.attributes[_]),f++}if(f!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(h!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const _ in l.morphAttributes){if(!r.has(_))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[_]===void 0&&(o[_]=[]),o[_].push(l.morphAttributes[_])}if(e){let _;if(t)_=l.index.count;else if(l.attributes.position!==void 0)_=l.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(d,_,u),d+=_}}if(t){let u=0;const l=[];for(let f=0;f<s.length;++f){const _=s[f].index;for(let v=0;v<_.count;++v)l.push(_.getX(v)+u);u+=s[f].attributes.position.count}c.setIndex(l)}for(const u in n){const l=vt(n[u]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,l)}for(const u in o){const l=o[u][0].length;if(l===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<l;++f){const _=[];for(let S=0;S<o[u].length;++S)_.push(o[u][S][f]);const v=vt(_);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(v)}}return c}function vt(s){let e,t,i,r=-1,n=0;for(let d=0;d<s.length;++d){const u=s[d];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=u.itemSize),t!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=u.normalized),i!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=u.gpuType),r!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=u.count*t}const o=new e(n),h=new a.BufferAttribute(o,t,i);let c=0;for(let d=0;d<s.length;++d){const u=s[d];if(u.isInterleavedBufferAttribute){const l=c/t;for(let f=0,_=u.count;f<_;f++)for(let v=0;v<t;v++){const S=u.getComponent(f,v);h.setComponent(f+l,v,S)}}else o.set(u.array,c);c+=u.count*t}return r!==void 0&&(h.gpuType=r),h}class Nr extends p{constructor(){super("renderer")}render(e){if(!e._inlines._value||!e._inlines._value.length)return;const t=e._inlines._value.map(r=>e._font._fontVariant.getGeometricGlyph(r,e).translate(r.offsetX,r.offsetY,0)),i=Xr(t);e.setFontMesh(new a.Mesh(i,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class Yr extends ne{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class B extends T{constructor(e={}){const t={};B.definePropertiesValues(t,e),super(t,e),B.init(this)}add(e){const t=[];for(let i=0;i<arguments.length;i++){const r=arguments[i];!r.isUI||r.isInline?(t.push(r),r.position.z=.005):console.warn("Block element can only contain Box elements.",r)}return super.add(...t)}_rebuildParentUI=()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0};set textContent(e){this._textContent.value=e}get textContent(){return this._textContent._value}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}static definePropertiesValues(e,t){e.children||(e.children=mt),e.textContent||(e.textContent=Mr),e.glyphs||(e.glyphs=Pr),e.inlines||(e.inlines=Br),e.layouter||(e.layouter=nt),e.renderer||(e.renderer=Nr),e.fontFamily||(e.fontFamily=lt),e.fontWeight||(e.fontWeight=at),e.fontStyle||(e.fontStyle=ot),e.fontSize||(e.fontSize=ft),e.color||(e.color=Ir),e.backgroundColor||(e.backgroundColor=Tr),e.lineBreak||(e.lineBreak=rt),e.letterSpacing||(e.letterSpacing=pt),e.whiteSpace||(e.whiteSpace=Ve),e.segments||(e.segments=$r),e.textAlign||(e.textAlign=Yr),e.fontKerning||(e.fontKerning=jr)}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class Kr extends De{constructor(){super("textContent",null,!1),this._needsUpdate=!1}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this._needsUpdate=!1;for(let i=e.children.length-1;i>=0;i--){const r=e.children[i];r.isUI&&(e.remove(r),r.clear())}e._children._uis=[],this._value&&e.add(new B({name:"anonymousInline",textContent:this._value}))}}class qr extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class Jr extends p{constructor(){super("layouter",null,!1),this._value=null}update(e,t){}process(e){let t=e._width._value;e._width._auto?t=1/0:t=e._bounds._innerWidth;const i=e._lineHeight._value,r=new qr(new it);let n=0;e._children._inlines.forEach(l=>{if(!l._inlines.value)return;this._resetInlines(l);const f=l._fontSize._value,_=l._letterSpacing._value*f,v=l._whiteSpace._value,S=l._lineBreak._value,y={WHITESPACE:v,LETTERSPACING:_,BREAKON:S,INNER_WIDTH:t},Mt=l._whiteSpace._inlineWrapper;n+=l._margin._value.w+l._padding._value.w,l._inlines.value.forEach((b,Bt,Pt)=>{const J=r[r.length-1];if(Mt(Pt,Bt,n,y)){if(r.push(new it(b)),b.offsetX=b.xoffset,b.width===0){n=0;return}b.cumulativeWidth=b.xadvance+_,n=b.cumulativeWidth;return}r[r.length-1].push(b),b.offsetX=n+b.xoffset+b.kerning,b.cumulativeWidth=b.xadvance+b.kerning+_,n+=b.cumulativeWidth,J.length-1===1&&J[J.length-2].width===0&&(b.offsetX-=b.xoffset,n-=b.xoffset)}),n+=l._margin._value.y+l._padding._value.y});const o=e._whiteSpace._inlineCollapser;let h=0,c=0,d=0;r.forEach((l,f)=>{const _=o(l);let v=0,S=0;if(l.forEach(y=>{v=Math.max(v,y.lineHeight),S=Math.max(S,y.lineBase),y.offsetX-=_}),l.lineHeight=v,l.lineBase=S,f===0?d=-(v*i-v)*.5:d-=r[f-1].lineHeight*i,l.y=d,l.x=0,l.forEach(y=>{y.offsetY=d-y.anchor,y.lineHeight<l.lineHeight&&(y.offsetY-=l.lineBase-y.lineBase)}),c+=l.lineHeight*i,l.width=0,l[0]){const y=l[l.length-1];l.width=y.offsetX+y.cumulativeWidth+y.paddingRight+y.marginRight+l[0].offsetX,h=Math.max(h,l.width)}}),r.height=c,r.width=h,this._value=r,t===1/0&&e._bounds.setChildrenWidth(e,r.width),e._height._auto&&e._bounds.setChildrenHeight(e,r.height);const u=e._parent._value;u&&(u._autoSize._needsProcess=!0,u._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}}class Qr extends ne{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){Zr(e),e._renderer._needsRender=!0}}function Zr(s){const e=s._layouter._value,t=s._textAlign._value,i=s._bounds._innerWidth;for(let r=0;r<e.length;r++){const n=e[r],o=en(s,n,r===e.length-1),h=s._padding._value,c=s._borderWidth._value,d=(-h.w+h.y)/2+(-c.w+c.y)/2;n.x+=o;for(let u=0;u<n.length;u++)n[u].offsetX+=o-d}if(t.indexOf("justify")===0)for(let r=0;r<e.length;r++){const n=e[r];if(t.indexOf("-")!==-1&&r===e.length-1)return;const o=i-n.width;if(o<=0)return;let h=0;for(let l=1;l<n.length-1;l++)h+=n[l].char===" "?1:0;const c=o/h;let d=1;t==="justify-right"&&(n.reverse(),d=-1);let u=0;for(let l=1;l<=n.length-1;l++){const f=n[l];f.offsetX+=u*d,u+=f.char===" "?c:0}t==="justify-right"&&n.reverse()}}function en(s,e,t){switch(s._textAlign._value){case"justify-left":case"justify":case"left":return-s._bounds._innerWidth/2;case"justify-right":case"right":return-e.width+s._bounds._innerWidth/2;case"center":return-e.width/2;case"justify-center":return t?-e.width/2:-s._bounds._innerWidth/2;default:console.warn(`textAlign: '${s._textAlign._value}' is not valid`)}}class tn extends oe{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class sn extends Xe{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class rn extends j{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class nn extends Ze{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class on extends p{constructor(){super("children",null,!1),this._uis=[],this._inlines=[],this._boxes=[]}update(e,t){this._compute(e),this._needsProcess=!0}process(e){this._compute(e),e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter(t=>t.visible&&t.isUI),this._inlines=this._uis.filter(t=>t.isInline).sort(this._sortOrder)}dispose(){this._inlines=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class an extends p{constructor(){super("autosize")}process(e){if(e._layouter._value&&e._layouter._value.length){const t=e._layouter._value,i=e._padding._value,r=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+i.w+i.y+r.w+r.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+i.x+i.z+r.x+r.z)}}}class ln extends st{constructor(){super("renderer"),this._needsUpdate=!1}render(e){super.render(e);for(const t of e._children._inlines)t._renderer.render(t);e.performAfterUpdate()}}class z extends F{constructor(e={},t={}){z.definePropertiesValues(t,e),super(t,e),z.init(this)}add(e){const t=[];let i=!1;for(let r=0;r<arguments.length;r++){const n=arguments[r];!n.isUI||n.isInline?(n.isInline&&(i=!0),t.push(n)):console.warn("Block element can only contain Box elements.",n)}return t.length>0&&super.add(...t),i&&(this._children._needsUpdate=!0,this._layouter._needsProcess=!0),this}set textContent(e){this._textContent.value=e}get textContent(){return super.textContent}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}get lines(){return this._layouter._value}static definePropertiesValues(e,t){e.flexDirection=tn,e.justifyContent=ae,e.alignItems=re,e.bounds=nn,e.autoSize=an,e.renderer=ln,e.children||(e.children=on),e.textContent||(e.textContent=Kr),e.layouter||(e.layouter=Jr),e.lineHeight||(e.lineHeight=sn),e.textAlign||(e.textAlign=Qr),e.whiteSpace||(e.whiteSpace=Ve),e.fontKerning||(e.fontKerning=rn),e.segments||(e.segments=gt),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class hn extends p{constructor(){super("inlines",null,!1),this._value=[]}process(e){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}}class un extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new tt(e)),e._backgroundMesh.position.x=e._inlines._value[0].offsetX+e._inlines._value[0].width/2,e._backgroundMesh.position.y=e._inlines._value[0].offsetY+e._inlines._value[0].lineBase/2,e._bounds.render(e)}}class cn extends p{constructor(){super("bounds",null,!1),this._size=new a.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0}update(e,t){this.output(t),this._needsProcess=!0}process(e){this._offsetWidth=this._innerWidth=e._inlines._value[0].width,this._offsetHeight=this._innerHeight=e._inlines._value[0].height,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight}output(e){e.size=this._size}}class A extends T{constructor(e={}){const t={};A.definePropertiesValues(t,e),super(t,e),A.init(this)}clear(){for(const e of this._inlines._value)e.clear();return super.clear()}bindBackgroundMeshProperties(){this._backgroundMesh.raycast=()=>{},this._bounds._size=this._backgroundMesh.scale,this._bounds._needsUpdate=!0}unbindBackgroundMeshProperties(){this._bounds._size=new a.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){const t=[];for(let i=0;i<arguments.length;i++){const r=arguments[i];r.isUI?console.warn("ThreeMeshUI::InlineBlockElement cannot contains UI Elements.",r):(t.push(r),r.position.z=.005)}return super.add(...t)}static definePropertiesValues(e,t){e.children||(e.children=mt),e.bounds||(e.bounds=cn),e.inlines||(e.inlines=hn),e.layouter||(e.layouter=nt),e.renderer||(e.renderer=un),e.fontFamily||(e.fontFamily=lt),e.fontWeight||(e.fontWeight=at),e.fontStyle||(e.fontStyle=ot),e.fontSize||(e.fontSize=ft),e.backgroundColor||(e.backgroundColor=ze),e.lineBreak||(e.lineBreak=rt),e.letterSpacing||(e.letterSpacing=pt),e.whiteSpace||(e.whiteSpace=Ve),e.fontKerning||(e.fontKerning=j),t.backgroundSize||(t.backgroundSize="cover"),t.width||(t.width="100%"),t.height||(t.height="100%"),t.boxSizing||(t.boxSizing="border-box")}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0},isInlineBlock:{configurable:!1,enumerable:!0,value:!0}}),e._inlines._value=[new dn(e)],e.backgroundMaterial=new Qe,e._renderer.render(e)}}class dn extends Pe{constructor(e){super(),this._uiElement=e}get xadvance(){const e=this._uiElement._padding._value,t=this._uiElement._width;return t._relative?t._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.w+e.y+t.value}get width(){const e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}}class bt{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw new Error(`Behavior::act() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}detach(){console.error(`Behavior::detach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}clear(){}}const yt=()=>N.update(),xt={BaseProperty:p,Block:O,Text:z,Inline:B,InlineBlock:A,MeshUIBaseElement:T,FontLibrary:C,update:yt,MSDFFontMaterialUtils:w,ShaderChunkUI:Je,Behavior:bt,FontVariant:P};typeof global<"u"&&(global.ThreeMeshUI=xt);const _n=xt;var pn=m.ti,wt=m.nS,St=m.eB,fn=m.Yp,kt=m.VB,gn=m.BC,mn=m.zN,Vt=m.cV,vn=m.hW,bn=m.k2,yn=m.K6,xn=m.M7,wn=m.ls,Sn=m.Hi,Ut=m.EY,kn=m.MR,Vn=m.zf,Rt=m.Ay,Ct=m.yo;const Un=Object.freeze(Object.defineProperty({__proto__:null,BaseProperty:pn,Behavior:wt,Block:St,DefaultValues:fn,FontLibrary:kt,FontVariant:gn,InheritableProperty:mn,Inline:Vt,InlineBlock:vn,InlineGlyph:bn,MSDFFontMaterialUtils:yn,MaterialTransformers:xn,MeshUIBaseElement:wn,ShaderChunkUI:Sn,Text:Ut,TypographicFont:kn,TypographicGlyph:Vn,default:Rt,update:Ct},Symbol.toStringTag,{value:"Module"}));class Rn extends wt{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const r in t[i])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],i.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)i.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}export{Rn as SimpleStateBehavior,Un as ThreeMeshUI,St as __webpack_exports__Block,kt as __webpack_exports__FontLibrary,Vt as __webpack_exports__Inline,Ut as __webpack_exports__Text,Rt as __webpack_exports__default,Ct as __webpack_exports__update};