@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
@@ -1,406 +0,0 @@
1
- var Tt=Object.defineProperty,Ft=(s,e,t)=>e in s?Tt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,M=(s,e,t)=>Ft(s,typeof e!="symbol"?e+"":e,t);import{Vector4 as Ot,Vector3 as zt,Vector2 as At,TextureLoader as Wt,Texture as Dt,ShaderMaterial as Et,PlaneGeometry as Lt,Plane as Ht,Object3D as Gt,MeshBasicMaterial as $t,Mesh as jt,LinearFilter as Xt,FrontSide as Yt,FileLoader as Nt,EventDispatcher as Kt,DoubleSide as qt,Color as Jt,BufferGeometry as Qt,BufferAttribute as Zt,BackSide as es}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:()=>yt,eB:()=>z,Yp:()=>Z,VB:()=>C,BC:()=>I,zN:()=>R,cV:()=>P,hW:()=>W,k2:()=>Fe,K6:()=>w,M7:()=>ee,ls:()=>F,Hi:()=>Qe,EY:()=>A,MR:()=>Ge,zf:()=>Te,Ay:()=>gn,yo:()=>xt});var Z={};k.r(Z),k.d(Z,{get:()=>Ce,set:()=>ts});var ee={};k.r(ee),k.d(ee,{alphaTestTransformer:()=>G,asPreprocessorValueTransformer:()=>$e,toPreprocessorTriggerTransformer:()=>pe,toUserDataTransformer:()=>di,uniformOrUserDataTransformer:()=>x});const te={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},ts=function(s){for(const e in s)te[e]=s[e]},Ce=function(s){return Object.prototype.hasOwnProperty.call(te,s)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${s}'`),te[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 Ce(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 ss 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 is extends R{constructor(){super("offset","inherit",!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}}class rs extends R{constructor(){super("fontSmooth","inherit",!0),this._needsUpdate=!1,this.isValid=os,this.output=this._outputValue}}const ns=["inherit","none","antialiased"];function os(s){return ns.indexOf(s)===-1?(console.warn(`.fontSmoothing value '${s}' is not valid. Aborted`),!1):!0}var as=s=>{var e={};return k.d(e,s),e};const a=as({BackSide:()=>es,BufferAttribute:()=>Zt,BufferGeometry:()=>Qt,Color:()=>Jt,DoubleSide:()=>qt,EventDispatcher:()=>Kt,FileLoader:()=>Nt,FrontSide:()=>Yt,LinearFilter:()=>Xt,Mesh:()=>jt,MeshBasicMaterial:()=>$t,Object3D:()=>Gt,Plane:()=>Ht,PlaneGeometry:()=>Lt,ShaderMaterial:()=>Et,Texture:()=>Dt,TextureLoader:()=>Wt,Vector2:()=>At,Vector3:()=>zt,Vector4:()=>Ot});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 D 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 ls extends D{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 hs extends D{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 Me=function(s,e,t){s[e]=t},us=function(s,e,t){t!==null&&(s[e]=t)};class E{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:Me;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:Me;c(t,h.m,i[o]),n&&c(n,h.m,i[o])}}}}class cs 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 se=function(s,e,t=6){return s.toFixed(t)===e.toFixed(t)};class Be extends p{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(se(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}}class Pe extends R{constructor(e){super(e,"inherit",!0),this.isValid=_s}}const ds=[a.FrontSide,a.BackSide,a.DoubleSide];function _s(s){return ds.indexOf(s)===-1?(console.warn(`SideProperty value '${s}' is not valid. Abort`),!1):!0}class Ie{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 Te{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 Fe extends Ie{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 ps={light:"100",normal:"400",bold:"700",bolder:"900"};function ie(s){return isNaN(s)?ps[s]||s:s.toString()}class fs extends a.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=ie(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()&&ms(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 gs={type:"ready"};function ms(s){s._isReady=!0,s.dispatchEvent(gs)}const I=fs;class vs extends p{constructor(e=null){super("font",e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=bs}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 I)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=ys(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 bs(s){return s instanceof I?!0:(console.warn(`.font value '${s}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function ys(s,e){return function(){e._needsUpdate=!0,s._glyphs._needsProcess=!0,e._fontVariant.removeEventListener("ready",e._handleFontReadyClosure),e._handleFontReadyClosure=null}}class xs extends g{constructor(e){super("display",e),this._value="flex",this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=Ss}computeOutputValue(e){e._visible._value=this._output!=="none"}}const ws=["none","flex"];function Ss(s){return ws.indexOf(s)===-1?(console.warn(`(.style) display value '${s}' is not valid. Aborted`),!1):!0}class ks extends g{constructor(e){super("boxSizing",e),this._allowsInherit=!1,this.isValidValue=Us}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}}const Vs=["border-box","content-box"];function Us(s){return Vs.indexOf(s)===-1?(console.warn(`(.style) boxSizing value '${s}' is not valid. Aborted`),!1):!0}class T 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 re extends g{constructor(e,t){super(e,t,!0),this.isValidValue=Rs,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 Rs(s){return s<0&&s>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${s}' is not valid)`),!1):!0}class Cs extends g{constructor(e){super("backgroundImage",e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new a.Vector2(1,1),this.isValidValue=Ms}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 Ms(s){return!0}class Bs extends g{constructor(e){super("backgroundSize",e,!0),this.isValidValue=Is,this.output=this._outputValue}}const Ps=["cover","contain","stretch"];function Is(s){return Ps.indexOf(s)===-1?(console.warn(`(.style) backgroundSize value '${s}' is not valid. Aborted`),!1):!0}class Ts extends g{constructor(e){super("overflow",e,!0),this.isValidValue=Os,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 Fs=["visible","hidden"];function Os(s){return Fs.indexOf(s)===-1?(console.warn(`(.style) overflow value '${s}' is not valid. Aborted`),!1):!0}const B="rem",Oe="em",L="%",zs=[B,Oe,L],ze=function(s){return zs.indexOf(s)===-1?B:s};class As extends D{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 H(this._valueUV,["x","y"]),i=new H(this._valueUV,["z","w"]),r=new H(this._valueUV,["x","w"]),n=new H(this._valueUV,["y","z"]);t.complementaryMediation=i,i.complementaryMediation=t,r.complementaryMediation=n,n.complementaryMediation=r,this._sideMediators=[t,i,r,n],this._units=B}set units(e){this._units=ze(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===L&&this._valueUV.divideScalar(100),this._units===B&&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===L&&(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 H{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 Ws extends D{constructor(e){super("borderWidth",e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=B}set units(e){this._units=ze(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===L&&(console.log("Percent"),console.log(this._valueUV)),this._units===B)t!==0&&(this._valueUV.w/=t,this._valueUV.y/=t),i!==0&&(this._valueUV.x/=i,this._valueUV.z/=i);else if(this._units===Oe){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 Ds 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 Ae extends T{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 Es 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 Ls=["start","center","end","stretch"],Hs=function(s){return Ls.indexOf(s)===-1?(console.warn(`(.style) alignItems value '${s}' is not valid. Aborted`),!1):!0};class ne extends g{constructor(){super("alignItems","inherit",!0),this.isValidValue=Hs}}class oe extends g{constructor(){super("textAlign","inherit",!0),this.isValidValue=$s}}const Gs=["left","right","center","justify","justify-left","justify-right","justify-center"],$s=function(s){return Gs.indexOf(s)===-1?(console.warn(`(.style) textAlign value '${s}' is not valid. Aborted`),!1):!0};class ae extends g{constructor(){super("flexDirection","inherit",!0),this.isValid=Xs}}const js=["row","row-reverse","column","column-reverse"];function Xs(s){return js.indexOf(s)===-1?(console.warn(`(.style) flexDirection value '${s}' is not valid. Aborted`),!1):!0}class le extends g{constructor(){super("justifyContent","inherit",!0),this.isValidValue=Ns}}const Ys=["start","center","end","space-between","space-around","space-evenly"];function Ns(s){return Ys.indexOf(s)===-1?(console.warn(`(.style) justifyContent value '${s}' is not valid. Aborted`),!1):!0}class Ks 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 We extends g{constructor(){super("position","static",!0),this._allowsInherit=!1,this._value="static",this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=Js}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}}const qs=["static","absolute"];function Js(s){return qs.indexOf(s)===-1?(console.warn(`(.style) position value '${s}' is not valid. Aborted`),!1):!0}class De 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 Qs extends De{constructor(){super("width")}}class Zs extends De{constructor(){super("height")}computeOutputValue(e){super.computeOutputValue(e)}}class Ee 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 Le extends g{constructor(e){super("fontStyle",e,!0),this.isValidValue=ti}}const ei=["normal","italic"];function ti(s){return ei.indexOf(s)===-1?(console.warn(`(.style) fontStyle value '${s}' is not valid. Aborted`),!1):!0}class He extends g{constructor(){super("fontWeight","inherit",!0),this.isValid=ii}}const si=["100","200","300","400","500","600","700","800","900","light","normal","bold","bolder"];function ii(s){return si.indexOf(s.toString())===-1?(console.warn(`(.style) fontWeight value '${s}' is not valid. Aborted`),!1):!0}class Ge{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 ri extends Ge{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 ni extends Fe{constructor(e){super(e)}get uv(){return this.typographic.uv}}class q extends Te{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 q(this._font,{char:e,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new ni(this)}}class oi 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 ai=`
3
- attribute vec2 uvG;
4
- varying vec2 vUvG;
5
- `,he=ai,li=`
6
- vUvG = uvG;
7
- `,ue=li,hi=`
8
- gl_Position.z -= 0.00001;
9
- `,ce=hi,ui=`
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
- `,de=ui,ci=`
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
- `,_e=ci,G=function(s,e,t){s.alphaTest=t,pe(s,"USE_ALPHATEST",t>0)},pe=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))},$e=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},di=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
- `+he),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
72
- `+ue),e.vertexShader=e.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
73
- `+ce)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>",`#include <uv_pars_fragment>
74
- `+de),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",`#include <alphamap_fragment>
75
- `+_e)}static from(e){return class extends e{constructor(t={}){w.ensureMaterialOptions(t),super(t),M(this,"_cumulativeOnBeforeCompile",i=>{w.bindUniformsWithUserData(i,this),w.injectShaderChunks(i),this._userDefinedOnBeforeCompile(i)}),w.ensureDefines(this),w.ensureUserData(this,t),this._userDefinedOnBeforeCompile=i=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}static get fontMaterialProperties(){return w.mediation}set onBeforeCompile(t){this._userDefinedOnBeforeCompile=t}get onBeforeCompile(){return this._onBeforeCompile}}}static get mediation(){return fi}}const _i=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)},pi=function(s,e,t){t&&t!=="antialiased"?s.defines.NO_RGSS="":delete s.defines.NO_RGSS,s.needsUpdate=!0},fi={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:G},fontSide:{m:"side"},font:{m:"glyphMap",t:_i},color:{m:"color"},fontOpacity:{m:"opacity"},fontSmooth:{m:"NO_RGSS",t:pi},invertAlpha:{m:"INVERT_ALPHA",t:pe}},gi=`
76
- ${he}
77
- #include <clipping_planes_pars_vertex>
78
- void main() {
79
- ${ue}
80
- #include <begin_vertex>
81
- #include <project_vertex>
82
- ${ce}
83
- #include <clipping_planes_vertex>
84
- }
85
- `,mi=`
86
- uniform vec3 diffuse;
87
- uniform float opacity;
88
- ${de}
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
- ${_e}
95
- #include <alphatest_fragment>
96
- // instead of <output_fragment>
97
- gl_FragColor = diffuseColor;
98
- #include <clipping_planes_fragment>
99
- }
100
- `,vi=.02;class Re 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:vi}},transparent:!0,clipping:!0,vertexShader:gi,fragmentShader:mi,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===Re}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}}class bi extends I{constructor(e,t,i,r){if(super(e,t),this._unitRange=new a.Vector2(1,1),i.pages?this._buildData(i):yi(this,i),r instanceof a.Texture)this._texture=r,this._buildTexture(r);else if(typeof r=="string"||r instanceof String)xi(this,r);else throw new Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=Re,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 ri(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 oi(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 q(this._font,r)}return t}_buildCharacterWhite(e,t=" ",i=1,r=1){return new q(this._font,{char:t,width:e.info.size/3*i,height:e.info.size*.7*r})}_alterElementProperties(e){}}function yi(s,e){new a.FileLoader().setResponseType("json").load(e,t=>{s._buildData(t),s._checkReadiness()})}function xi(s,e){s._texture=new a.TextureLoader().load(e,t=>{s._buildTexture(t),s._checkReadiness()})}class $ extends a.EventDispatcher{constructor(e){super(),M(this,"_checkReadiness",()=>{this._variants.every(t=>t.isReady)&&Si(this)}),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 bi(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=ie(e),this._variants.find(i=>i.weight===e&&i.style===t)}get name(){return this._name}}const wi={type:"ready"};function Si(s){s._isReady=!0,s.dispatchEvent(wi)}const j={},ki=function(s){const e=[...arguments];e.forEach(i=>{if(!(i instanceof $))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()})}})},Vi=function(s){return j[s]&&console.error(`FontLibrary::addFontFamily - Font('${s}') is already registered`),j[s]=new $(s),j[s]},Ui=function(s){return j[s]},Ri=function(s){je=s};let je=function(s,e){return console.error(`The character '${e}' is not included in the font characters set.`)," "};function Ci(s,e){return je(s,e)}const Mi={addFontFamily:Vi,getFontFamily:Ui,prepare:ki,setMissingCharacterHandler:Ri,missingCharacter:Ci},C=Mi;class Xe extends g{constructor(){super("fontFamily","inherit",!0)}computeOutputValue(e){if(this._input instanceof $)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 Ye 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=Pi}}const Bi=["normal","nowrap","pre","pre-line","pre-wrap"];function Pi(s){return Bi.indexOf(s)===-1?(console.warn(`(.style) whiteSpace value '${s}' is not valid. Aborted`),!1):!0}class Ke extends g{constructor(){super("letterSpacing","inherit",!0)}}class Ii extends g{constructor(){super("fontSize","inherit",!0)}}class qe extends p{constructor(){super("segments",1,!1)}}class Ti extends R{constructor(){super("invertAlpha","inherit")}}class X extends g{constructor(){super("fontKerning","inherit"),this.isValidValue=Oi}}const Fi=["normal","none","inherit"];function Oi(s){return Fi.indexOf(s)===-1?(console.warn(`(.style) fontKerning value '${s}' is not valid. Aborted`),!1):!0}class Y extends R{constructor(e){super(e,"inherit",!0)}}class Je 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:G},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 zi=function(s,e,t){s.traverse(i=>{i.renderOrder=t})};class F extends a.Object3D{constructor(e,t){super(),M(this,"_rebuildParentUI",()=>{this._parent._needsUpdate=!0,this.parent&&!this.parent.isUI?(N.register(this),this.activatePseudoState("root")):(N.remove(this),this.deactivatePseudoState("root"))}),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:zi}},this._fontMesh=null,this._fontMaterial=new Je("fontMaterial"),this._fontCustomDepthMaterial=new Je("fontCustomDepthMaterial"),this._fontMeshMediation={fontMaterial:{m:"material"},fontCustomDepthMaterial:{m:"customDepthMaterial",t:us},fontCastShadow:{m:"castShadow"},fontReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder"}},this._children=e.children?new e.children:new V("children"),this._parent=new cs,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI),this._backgroundSide=new Pe("backgroundSide"),this._fontSide=new Pe("fontSide"),this._backgroundAlphaTest=new Be("backgroundAlphaTest",.02),this._fontAlphaTest=new Be("fontAlphaTest",.02),this._visible=new Ds("visible",!0),this._backgroundCastShadow=new Y("backgroundCastShadow"),this._fontCastShadow=new Y("fontCastShadow"),this._backgroundReceiveShadow=new Y("backgroundReceiveShadow"),this._fontReceiveShadow=new Y("fontReceiveShadow"),this._renderOrder=new ss,this._segments=e.segments?new e.segments:new qe,this._bounds=e.bounds?new e.bounds:new V("bounds"),this._order=new Ks,this._padding=new ls,this._margin=new hs,this._position=new We,this._flexDirection=e.flexDirection?new e.flexDirection:new ae,this._justifyContent=e.justifyContent?new e.justifyContent:new le,this._alignItems=e.alignItems?new e.alignItems:new ne,this._display=new xs("flex"),this._boxSizing=new ks("border-box"),this._width=new Qs,this._height=new Zs,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new Ae,this._backgroundOpacity=new re("backgroundOpacity",.5),this._backgroundImage=new Cs,this._backgroundSize=new Bs("cover"),this._color=e.color?new e.color:new T("color","inherit"),this._fontOpacity=new re("fontOpacity","inherit"),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Ne,this._fontFamily=e.fontFamily?new e.fontFamily:new Xe,this._fontStyle=e.fontStyle?new e.fontStyle:new Le("normal"),this._fontWeight=e.fontWeight?new e.fontWeight:new He,this._fontSize=e.fontSize?new e.fontSize:new Ii,this._lineHeight=e.lineHeight?new e.lineHeight:new Ye,this._fontKerning=e.fontKerning?new e.fontKerning:new X,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new Ke,this._overflow=new Ts("visible"),this._borderRadius=new As(0),this._borderWidth=new Ws(0),this._borderColor=new T("borderColor",16711935),this._borderOpacity=new re("borderOpacity",1),this._font=new vs,this._lineBreak=e.lineBreak?new e.lineBreak:new V("lineBreak"),this._textContent=e.textContent?new e.textContent:new Ee,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 Es,this._textAlign=e.textAlign?new e.textAlign:new oe,this._autoSize=e.autoSize?new e.autoSize:new V("autoSize"),this._renderer=e.renderer?new e.renderer:new V("renderer"),this._offset=new is,this._invertAlpha=new Ti,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new rs,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}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)}E.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)}E.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)}E.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)}E.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 Ai=`
103
-
104
- // FrameBorder vertex pars
105
- attribute vec2 uvB;
106
- varying vec2 vUvB;
107
-
108
- `,fe=Ai,Wi=`
109
-
110
- // FrameBorder vertex shader
111
- vUvB = uvB;
112
-
113
- `,ge=Wi,Di=`
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
- `,me=Di,Ei=`
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
- `,ve=Ei,Li=`
268
-
269
- // To be removed - required for both border and background
270
- uniform vec3 frameSize;
271
- uniform vec2 textureSize;
272
-
273
- `,be=Li,Hi=`
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
- `,ye=Hi,Gi=`
321
- #ifdef USE_MAP
322
-
323
- vec4 textureSample = sampleTexture();
324
- diffuseColor *= textureSample;
325
-
326
- #endif
327
- `,xe=Gi,Qe={msdfAlphaglyphParsVertexGlsl:he,msdfAlphaglyphVertexGlsl:ue,msdfOffsetglyphVertexGlsl:ce,msdfAlphaglyphParsFragmentGlsl:de,msdfAlphaglyphFragmentGlsl:_e,frameBorderParsVertexGlsl:fe,frameBorderVertexGlsl:ge,frameCommonParsFragmentGlsl:be,frameBorderParsFragmentGlsl:me,frameBorderFragmentGlsl:ve,frameBackgroundParsFragmentGlsl:ye,frameBackgroundFragmentGlsl:xe},$i=`
328
- // Would be automatic on three materials and from USE_UV
329
- #ifdef USE_MAP
330
- varying vec2 vUv;
331
- #endif
332
-
333
- ${fe}
334
-
335
- #include <clipping_planes_pars_vertex>
336
-
337
- void main() {
338
-
339
- #ifdef USE_MAP
340
- vUv = uv;
341
- #endif
342
-
343
- ${ge}
344
-
345
- vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
346
- gl_Position = projectionMatrix * mvPosition;
347
-
348
- #include <clipping_planes_vertex>
349
-
350
- }
351
- `,ji=`
352
-
353
- // Basic
354
- uniform vec3 diffuse;
355
- uniform float opacity;
356
-
357
- #ifdef USE_ALPHATEST
358
- uniform float alphaTest;
359
- #endif
360
-
361
- ${be}
362
-
363
- ${me}
364
-
365
-
366
- #ifdef USE_MAP
367
- varying vec2 vUv;
368
- uniform sampler2D map;
369
- #endif
370
-
371
- ${ye}
372
-
373
- #include <clipping_planes_pars_fragment>
374
-
375
- void main() {
376
-
377
- vec4 diffuseColor = vec4( diffuse, opacity );
378
-
379
- // map
380
- ${xe}
381
-
382
- ${ve}
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 J{static get mediation(){return Yi}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){J.injectVertexShaderChunks(e),J.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>",`#include <uv_pars_vertex>
397
- `+fe),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
398
- `+ge)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
399
- `+ye),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
400
- `+me),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
401
- `+be),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",xe),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",ve+`
402
- #include <alphamap_fragment>`)}}const Xi=function(s,e,t){t=["stretch","contain","cover"].indexOf(t),$e(s,"BACKGROUND_MAPPING",t)},Yi={clippingPlanes:{m:"clippingPlanes"},backgroundAlphaTest:{m:"alphaTest",t:G},backgroundSide:{m:"side"},backgroundImage:{m:"map"},backgroundColor:{m:"color"},backgroundOpacity:{m:"opacity"},backgroundSize:{m:"computedBackgroundSize",t:Xi},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 Ze extends a.ShaderMaterial{static get mediation(){return J.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:$i,fragmentShader:ji,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 Ni extends p{constructor(){super("children",null,!1),M(this,"_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),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}}class et 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);se(c,this._offsetWidth)||(this._offsetWidth=c,this._innerWidth=this._offsetWidth-(r.y+r.w+n.y+n.w),this._centerX=we(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);se(c,this._offsetHeight)||(this._offsetHeight=c,this._innerHeight=this._offsetHeight-(r.x+r.z+n.x+n.z),this._centerY=Se(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=we(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=Se(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=we(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=Se(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 Ki(e)}_computeChildrenSideHeight(e){return qi(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 we(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 Se(s){const e=s._padding._value,t=s._borderWidth._value,i=e.x+t.x;return(e.z+t.z-i)/2}function Ki(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 qi(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 Ji extends ne{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=ir,this._value){case"start":this._childAlign=Zi;break;case"end":this._childAlign=Qi;break;default:this._childAlign=tt}break;case"column":case"column-reverse":switch(this._process=sr,this._value){case"start":this._childAlign=tr;break;case"end":this._childAlign=er;break;default:this._childAlign=tt}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 tt(){return 0}function Qi(s,e){return-e+s._bounds._offsetHeight/2}function Zi(s,e){return e-s._bounds._offsetHeight/2}function er(s,e){return e-s._bounds._offsetWidth/2}function tr(s,e){return-e+s._bounds._offsetWidth/2}function sr(s,e){const t=s._bounds._innerWidth/2;s._children._boxes.forEach(i=>{s._layouter._childrenPos[i.id].x=e(i,t)})}function ir(s,e){const t=s._bounds._innerHeight/2;s._children._boxes.forEach(i=>{s._layouter._childrenPos[i.id].y=e(i,t)})}class rr extends ae{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=nr;break;case"row-reverse":this._process=or;break;case"column":this._process=ar;break;case"column-reverse":this._process=lr;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 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._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 or(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 ar(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 lr(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 hr extends le{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=cr.bind(this);break;case"row-reverse":case"row":this._process=ur.bind(this);break}switch(this._value){case"end":this._computeOffset=pr,this._computeMargin=ke;break;case"center":this._computeOffset=fr,this._computeMargin=ke;break;case"start":this._computeOffset=K,this._computeMargin=ke;break;case"space-between":this._computeOffset=K,this._computeMargin=gr;break;case"space-around":this._computeOffset=K,this._computeMargin=vr;break;case"space-evenly":this._computeOffset=K,this._computeMargin=mr;break}e._flexDirection._needsProcess=!0}process(e){this._process(e),e._alignItems._needsProcess=!0}}function ur(s){const e=s._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:i}=dr(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 cr(s){const e=s._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:i}=_r(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 dr(s){const e=s._bounds._computeChildrenSideWidth(s);return{usedDirectionSpace:e,remainingSpace:s._bounds._innerWidth-e}}function _r(s){const e=s._bounds._computeChildrenSideHeight(s);return{usedDirectionSpace:e,remainingSpace:s._bounds._innerHeight-e}}function K(s){return 0}function pr(s){return s}function fr(s){return s/2}function ke(s,e=0,t=1){return Array(s._children._boxes.length).fill(0)}function gr(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 mr(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 vr(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 Ve;class st 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&&(Ve||(Ve=new a.MeshBasicMaterial({alphaTest:1.1})),o=Ve);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=br[t];for(const o in r)i.position[o]=this.scale[o]*r[o]*i.scale[o];const n=yr[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 br={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}},yr={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 it extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new st(e)),e.performAfterUpdate()}}class xr extends We{constructor(){super("position")}update(e,t){super.update(e,t),this._needsProcess=!0}}class wr extends p{constructor(){super("autosize"),this._needsProcess=!0}process(e){e._width._auto&&Sr(e),e._height._auto&&kr(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 Sr(s){s._bounds.setChildrenWidth(s,Ur(s))}function kr(s){s._bounds.setChildrenHeight(s,Vr(s))}function Vr(s){switch(s._flexDirection._value){case"row":case"row-reverse":return Br(s);case"column":case"column-reverse":return Cr(s)}}function Ur(s){switch(s._flexDirection._value){case"row":case"row-reverse":return Rr(s);case"column":case"column-reverse":return Mr(s)}}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._offsetWidth+i.y+i.w;e+=r}return e}function Cr(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 Mr(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 Br(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 O extends F{constructor(e,t){O.definePropertiesValues(e,t),super(e,t),O.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=Ni),e.bounds||(e.bounds=et),e.flexDirection||(e.flexDirection=rr),e.justifyContent||(e.justifyContent=hr),e.alignItems||(e.alignItems=Ji),e.position||(e.position=xr),e.autoSize||(e.autoSize=wr),e.renderer||(e.renderer=it),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 Ze,e._renderer.render(e),e._backgroundMesh.visible=!1}}class rt extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}}class Pr 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 z extends O{constructor(e={}){const t={};z.definePropertiesValues(t,e),super(t,e),z.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=Pr}static init(e){Object.defineProperties(e,{isBlock:{configurable:!1,enumerable:!0,value:!0}})}}class Ir extends p{constructor(){super("textContent",null,!1)}update(e,t){e._glyphs._needsUpdate=!0,e._whiteSpace._needsProcess=!0}}class Tr 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 Fr 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 Or extends T{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 nt 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 ot 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 zr extends T{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 at extends Le{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class lt extends He{constructor(){super()}computeOutputValue(e){this._value=ie(this.getInheritedInput(e))}}class ht extends Xe{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 $)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 Ue 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=Ar(this._value),this._value){case"nowrap":case"normal":this._stringCollapser=Wr;break;case"pre-line":this._stringCollapser=ct;break;default:this._stringCollapser=Dr}switch(this._value){case"pre-line":case"nowrap":case"normal":this._inlineCollapser=$r;break;case"pre-wrap":this._inlineCollapser=Gr;break;default:this._inlineCollapser=jr}switch(this._value){case"pre-line":case"pre-wrap":case"normal":this._inlineWrapper=Er;break;case"pre":this._inlineWrapper=Lr;break;default:this._inlineWrapper=Hr}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}}const ut={" ":" ","\n":`
404
- `,"\r":"\r"," ":" "},Ar=function(s){switch(s){case"pre":case"pre-wrap":case"pre-line":return"mandatory"}return null};function Wr(s){return ct(s.replace(/\n/g," "))}function ct(s){return s.replace(/[ ]{2,}/g," ")}function Dr(s){return s}function Er(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=pt(s,e,i);return Xr(s[e-1],t,n,i)}function Lr(s,e,t,i){return s[e].lineBreak==="mandatory"}function Hr(){return!1}function Gr(s){if(!s[0])return 0;const e=s[0],t=s[s.length-1];return e.char&&e.char===`
405
- `&&s.length>1&&_t([e],s[1]),t.char&&t.char===`
406
- `&&s.length>1&&dt([t],s[s.length-2]),e.offsetX}function $r(s){if(!s[0])return 0;let e=[],t;for(let i=0;i<s.length;i++){const r=s[i];if(r.char&&ut[r.char]&&s.length>i){e.push(r),t=s[i+1];continue}break}_t(e,t),e=[],t=null;for(let i=s.length-1;i>0;i--){const r=s[i];if(r.char&&ut[r.char]&&i>0){e.push(r),t=s[i-1];continue}break}return dt(e,t),s[0].offsetX}function jr(s){return s[0]?s[0].offsetX: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+e.cumulativeWidth,i.cumulativeWidth=0}}function _t(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 pt(s,e,t,i){if(i=i||0,!s[e])return i;const r=s[e];return r.lineBreak?i+r.xadvance:pt(s,e+1,t,i+r.xadvance+r.xoffset+r.kerning+t.LETTERSPACING)}function Xr(s,e,t,i){return!s||!s.char||e+t<i.INNER_WIDTH?!1:i.BREAKON.indexOf(s.char)>-1}class ft extends Ke{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 gt 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 mt extends qe{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 Yr extends mt{constructor(){super(),this._value="inherit"}}class Nr extends X{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 vt extends p{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function Kr(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=bt(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=bt(_);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 bt(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 qr 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=Kr(t);e.setFontMesh(new a.Mesh(i,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class Jr extends oe{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class P extends F{constructor(e={}){const t={};P.definePropertiesValues(t,e),super(t,e),M(this,"_rebuildParentUI",()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0}),P.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)}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=vt),e.textContent||(e.textContent=Ir),e.glyphs||(e.glyphs=Fr),e.inlines||(e.inlines=Tr),e.layouter||(e.layouter=ot),e.renderer||(e.renderer=qr),e.fontFamily||(e.fontFamily=ht),e.fontWeight||(e.fontWeight=lt),e.fontStyle||(e.fontStyle=at),e.fontSize||(e.fontSize=gt),e.color||(e.color=Or),e.backgroundColor||(e.backgroundColor=zr),e.lineBreak||(e.lineBreak=nt),e.letterSpacing||(e.letterSpacing=ft),e.whiteSpace||(e.whiteSpace=Ue),e.segments||(e.segments=Yr),e.textAlign||(e.textAlign=Jr),e.fontKerning||(e.fontKerning=Nr)}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class Qr extends Ee{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 P({name:"anonymousInline",textContent:this._value}))}}class Zr extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class en 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 Zr(new rt);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},Bt=l._whiteSpace._inlineWrapper;n+=l._margin._value.w+l._padding._value.w,l._inlines.value.forEach((b,Pt,It)=>{const Q=r[r.length-1];if(Bt(It,Pt,n,y)){if(r.push(new rt(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,Q.length-1===1&&Q[Q.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 tn extends oe{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){sn(e),e._renderer._needsRender=!0}}function sn(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=rn(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 rn(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 nn extends ae{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class on extends Ye{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class an extends X{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class ln extends et{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class hn extends p{constructor(){super("children",null,!1),M(this,"_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),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}}class un 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 cn extends it{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 A extends O{constructor(e={},t={}){A.definePropertiesValues(t,e),super(t,e),A.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=nn,e.justifyContent=le,e.alignItems=ne,e.bounds=ln,e.autoSize=un,e.renderer=cn,e.children||(e.children=hn),e.textContent||(e.textContent=Qr),e.layouter||(e.layouter=en),e.lineHeight||(e.lineHeight=on),e.textAlign||(e.textAlign=tn),e.whiteSpace||(e.whiteSpace=Ue),e.fontKerning||(e.fontKerning=an),e.segments||(e.segments=mt),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class dn 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 _n extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new st(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 pn 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 W extends F{constructor(e={}){const t={};W.definePropertiesValues(t,e),super(t,e),W.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=vt),e.bounds||(e.bounds=pn),e.inlines||(e.inlines=dn),e.layouter||(e.layouter=ot),e.renderer||(e.renderer=_n),e.fontFamily||(e.fontFamily=ht),e.fontWeight||(e.fontWeight=lt),e.fontStyle||(e.fontStyle=at),e.fontSize||(e.fontSize=gt),e.backgroundColor||(e.backgroundColor=Ae),e.lineBreak||(e.lineBreak=nt),e.letterSpacing||(e.letterSpacing=ft),e.whiteSpace||(e.whiteSpace=Ue),e.fontKerning||(e.fontKerning=X),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 fn(e)],e.backgroundMaterial=new Ze,e._renderer.render(e)}}class fn extends Ie{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 yt{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 xt=()=>N.update(),wt={BaseProperty:p,Block:z,Text:A,Inline:P,InlineBlock:W,MeshUIBaseElement:F,FontLibrary:C,update:xt,MSDFFontMaterialUtils:w,ShaderChunkUI:Qe,Behavior:yt,FontVariant:I};typeof global<"u"&&(global.ThreeMeshUI=wt);const gn=wt;var mn=m.ti,St=m.nS,kt=m.eB,vn=m.Yp,Vt=m.VB,bn=m.BC,yn=m.zN,Ut=m.cV,xn=m.hW,wn=m.k2,Sn=m.K6,kn=m.M7,Vn=m.ls,Un=m.Hi,Rt=m.EY,Rn=m.MR,Cn=m.zf,Ct=m.Ay,Mt=m.yo;const Mn=Object.freeze(Object.defineProperty({__proto__:null,BaseProperty:mn,Behavior:St,Block:kt,DefaultValues:vn,FontLibrary:Vt,FontVariant:bn,InheritableProperty:yn,Inline:Ut,InlineBlock:xn,InlineGlyph:wn,MSDFFontMaterialUtils:Sn,MaterialTransformers:kn,MeshUIBaseElement:Vn,ShaderChunkUI:Un,Text:Rt,TypographicFont:Rn,TypographicGlyph:Cn,default:Ct,update:Mt},Symbol.toStringTag,{value:"Module"}));class Bn extends St{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{Bn as SimpleStateBehavior,Mn as ThreeMeshUI,kt as __webpack_exports__Block,Vt as __webpack_exports__FontLibrary,Ut as __webpack_exports__Inline,Rt as __webpack_exports__Text,Ct as __webpack_exports__default,Mt as __webpack_exports__update};