@needle-tools/engine 4.7.3 → 4.8.0-alpha
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.
- package/CHANGELOG.md +3 -0
- package/dist/gltf-progressive-VTcU5sMu.min.js +8 -0
- package/dist/gltf-progressive-VXeY4K8o.js +1370 -0
- package/dist/gltf-progressive-_-uQwSK8.umd.cjs +8 -0
- package/dist/loader.worker-D5fjeWJO.js +27 -0
- package/dist/needle-engine.bundle-3y1KBFjI.js +42600 -0
- package/dist/needle-engine.bundle-D5cg00Gf.min.js +1607 -0
- package/dist/needle-engine.bundle-DQ3d-G3Q.umd.cjs +1607 -0
- package/dist/needle-engine.js +591 -592
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-BzY0H7ry.min.js → postprocessing-ChsrvDkI.min.js} +54 -54
- package/dist/{postprocessing-vKBVFpSz.js → postprocessing-DElbMQgB.js} +479 -483
- package/dist/{postprocessing-Dw2OCMp4.umd.cjs → postprocessing-DtxaELce.umd.cjs} +66 -66
- package/dist/{three-examples-DUcCNw9s.umd.cjs → three-examples-BhQvv1B9.umd.cjs} +11 -11
- package/dist/{three-examples-tvuhV8Ne.js → three-examples-CM6Iip03.js} +23 -27
- package/dist/{three-examples-BMOhDaYR.min.js → three-examples-D2zemuAM.min.js} +12 -12
- package/dist/{three-mesh-ui-CxuWt7m-.js → three-mesh-ui-D6Mz5Yl7.js} +799 -810
- package/dist/three-mesh-ui-DWcMuyQ_.min.js +406 -0
- package/dist/three-mesh-ui-tt0buEDC.umd.cjs +406 -0
- package/dist/{vendor-BmYIgaS1.js → vendor-ClB-U1Hn.js} +10 -10
- package/dist/{vendor-Cavtu3CP.umd.cjs → vendor-bOWOWClg.umd.cjs} +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +8 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/package.json +5 -5
- package/plugins/vite/dependencies.js +28 -19
- package/plugins/vite/dependency-watcher.js +6 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +14 -0
- package/dist/gltf-progressive-BMJtMiwp.js +0 -1204
- package/dist/gltf-progressive-DMJSXxbo.umd.cjs +0 -8
- package/dist/gltf-progressive-zQ2CaD2H.min.js +0 -8
- package/dist/needle-engine.bundle-BxHtcHHV.js +0 -43846
- package/dist/needle-engine.bundle-DItBuJY3.min.js +0 -1607
- package/dist/needle-engine.bundle-DM_LxEPT.umd.cjs +0 -1607
- package/dist/three-mesh-ui-B3p3gyUz.min.js +0 -406
- package/dist/three-mesh-ui-CQiIQIlA.umd.cjs +0 -406
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"use strict";const m=require("./three-B_hneGZr.umd.cjs");var k={};k.d=(i,e)=>{for(var t in e)k.o(e,t)&&!k.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:e[t]})};k.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e);k.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var v={};k.d(v,{ti:()=>p,nS:()=>bt,eB:()=>M,Yp:()=>oe,VB:()=>C,BC:()=>L,zN:()=>R,cV:()=>U,hW:()=>O,k2:()=>We,K6:()=>S,M7:()=>ae,ls:()=>z,Hi:()=>it,EY:()=>F,MR:()=>Ye,zf:()=>ze,Ay:()=>jr,yo:()=>xt});var oe={};k.r(oe);k.d(oe,{get:()=>Oe,set:()=>Tt});var ae={};k.r(ae);k.d(ae,{alphaTestTransformer:()=>K,asPreprocessorValueTransformer:()=>Ke,toPreprocessorTriggerTransformer:()=>ve,toUserDataTransformer:()=>$i,uniformOrUserDataTransformer:()=>w});const re={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},Tt=function(i){for(const e in i)re[e]=i[e]},Oe=function(i){return Object.prototype.hasOwnProperty.call(re,i)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${i}'`),re[i]};class p{constructor(e,t=null,s=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=s}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 Oe(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 Mt 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 s=e._parent._value;if(s!==null){const r=s._renderOrder._actualValue,n=1+s._children._uis.indexOf(e);this._actualValue=r+n}}for(const s of e._children._uis)s._renderOrder._value==="auto"&&(s._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,s=!0){super(e,t,s),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 s=t[`_${this._id}`];s!==void 0&&s._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 Ft extends R{constructor(){super("offset","inherit",!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}}class Ot extends R{constructor(){super("fontSmooth","inherit",!0),this._needsUpdate=!1,this.isValid=zt,this.output=this._outputValue}}const Lt=["inherit","none","antialiased"];function zt(i){return Lt.indexOf(i)===-1?(console.warn(`.fontSmoothing value '${i}' is not valid. Aborted`),!1):!0}var Wt=i=>{var e={};return k.d(e,i),e};const u=Wt({BackSide:()=>m.BackSide,BufferAttribute:()=>m.BufferAttribute,BufferGeometry:()=>m.BufferGeometry,Color:()=>m.Color,DoubleSide:()=>m.DoubleSide,EventDispatcher:()=>m.EventDispatcher,FileLoader:()=>m.FileLoader,FrontSide:()=>m.FrontSide,LinearFilter:()=>m.LinearFilter,Mesh:()=>m.Mesh,MeshBasicMaterial:()=>m.MeshBasicMaterial,Object3D:()=>m.Object3D,Plane:()=>m.Plane,PlaneGeometry:()=>m.PlaneGeometry,ShaderMaterial:()=>m.ShaderMaterial,Texture:()=>m.Texture,TextureLoader:()=>m.TextureLoader,Vector2:()=>m.Vector2,Vector3:()=>m.Vector3,Vector4:()=>m.Vector4});class g extends p{constructor(e,t,s=!0){super(e,"unset",s),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 s of e._children._uis){const r=s[`_${this._id}`];(r._input?r._input:r._value)==="inherit"&&(s[`_${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 Y extends g{constructor(e,t){super(e,t,!1),this._input=new u.Vector4(0,0,0,0),this._inline=null,this._value=new u.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 u.Vector4){e.copy(t);return}if((typeof t=="string"||t instanceof String)&&(t=t.split(" ")),Array.isArray(t))switch(t=t.map(s=>parseFloat(s)),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 Et extends Y{constructor(){super("padding",new u.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 Dt extends Y{constructor(){super("margin",new u.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}}const Ce=function(i,e,t){i[e]=t},Ht=function(i,e,t){t!==null&&(i[e]=t)};class W{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,s,r=null){for(const n in this._definition){const o=this._definition[n];if(s[n]!==void 0){const a=o.t?o.t:Ce;a(t,o.m,s[n]),r&&a(r,o.m,s[n])}}}static mediate(e,t,s,r,n=null){if(t)for(const o in r){const a=r[o];if(s[o]!==void 0){const l=a.t?a.t:Ce;l(t,a.m,s[o]),n&&l(n,a.m,s[o])}}}}class Gt 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 ne=function(i,e,t=6){return i.toFixed(t)===e.toFixed(t)};class Re extends p{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(ne(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}}class Be extends R{constructor(e){super(e,"inherit",!0),this.isValid=Nt}}const $t=[u.FrontSide,u.BackSide,u.DoubleSide];function Nt(i){return $t.indexOf(i)===-1?(console.warn(`SideProperty value '${i}' is not valid. Abort`),!1):!0}class Le{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 ze{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 We extends Le{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 Xt={light:"100",normal:"400",bold:"700",bolder:"900"};function ue(i){if(!isNaN(i))return i.toString();const e=Xt[i];return e||i}class jt extends u.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=ue(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 s=this._getFallbackCharacter(e);if(s&&(t=this._chars[s],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 s=this.getTypographicGlyph(t),r=e[t];for(const n in r)s["_"+n]=e[t][n]}}_checkReadiness(){this._readyCondition()&&Kt(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 Yt={type:"ready"};function Kt(i){i._isReady=!0,i.dispatchEvent(Yt)}const L=jt;class qt extends p{constructor(e=null){super("font",e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=Jt}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 L)this._fontVariant=this._value;else{const s=e._fontFamily._value;s&&(this._fontVariant=s.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=Zt(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 Jt(i){return i instanceof L?!0:(console.warn(`.font value '${i}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function Zt(i,e){return function(){e._needsUpdate=!0,i._glyphs._needsProcess=!0,e._fontVariant.removeEventListener("ready",e._handleFontReadyClosure),e._handleFontReadyClosure=null}}class Qt extends g{constructor(e){super("display",e),this._value="flex",this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=ti}computeOutputValue(e){e._visible._value=this._output!=="none"}}const ei=["none","flex"];function ti(i){return ei.indexOf(i)===-1?(console.warn(`(.style) display value '${i}' is not valid. Aborted`),!1):!0}class ii extends g{constructor(e){super("boxSizing",e),this._allowsInherit=!1,this.isValidValue=ri}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}}const si=["border-box","content-box"];function ri(i){return si.indexOf(i)===-1?(console.warn(`(.style) boxSizing value '${i}' is not valid. Aborted`),!1):!0}class A extends g{constructor(e,t){super(e,t,!1),this._value=new u.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 Q extends g{constructor(e,t){super(e,t,!0),this.isValidValue=ni,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 ni(i){return i<0&&i>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${i}' is not valid)`),!1):!0}class oi extends g{constructor(e){super("backgroundImage",e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new u.Vector2(1,1),this.isValidValue=ai}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 u.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 ai(i){return!0}class ui extends g{constructor(e){super("backgroundSize",e,!0),this.isValidValue=li,this.output=this._outputValue}}const hi=["cover","contain","stretch"];function li(i){return hi.indexOf(i)===-1?(console.warn(`(.style) backgroundSize value '${i}' is not valid. Aborted`),!1):!0}class ci extends g{constructor(e){super("overflow",e,!0),this.isValidValue=_i,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 s of e._children._uis)s._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 s=t._overflow;if((s._value==="hidden"||s._clippingPlanes!==null)&&!this._clippingPlanes){this._clippingPlanes=[new u.Plane(new u.Vector3(0,-1,0),1),new u.Plane(new u.Vector3(-1,0,0),1),new u.Plane(new u.Vector3(0,1,0),1),new u.Plane(new u.Vector3(1,0,0),1)];for(let r=0;r<this._clippingPlanes.length;r++)this._clippingPlanes[r].parent=t;s._clippingPlanes!==null&&this._clippingPlanes.push(...s._clippingPlanes),this._renderStrategy=this._hiddenRender,this._needsRender=!0}else(s._value==="visible"||s._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,s=t._bounds._offsetHeight,r=t._bounds._offsetWidth,n=t._padding._value,o=t._borderWidth._value;for(let a=0;a<4&&a<this._clippingPlanes.length;a++){const l=this._clippingPlanes[a];switch(a%4){case 0:l.constant=s/2-(n.x+o.x);break;case 1:l.constant=r/2-(n.y+o.y);break;case 2:l.constant=s/2-(n.z+o.z);break;case 3:l.constant=r/2-(n.w+o.w);break}l.applyMatrix4(t.matrixWorld)}for(let a=0;a<e._children._uis.length;a++){const l=e._children._uis[a];l._overflow._needsRender=!0}}_propagateRender(e){for(let t=0;t<e._children._uis.length;t++){const s=e._children._uis[t];s._overflow._needsRender=!0}}}const di=["visible","hidden"];function _i(i){return di.indexOf(i)===-1?(console.warn(`(.style) overflow value '${i}' is not valid. Aborted`),!1):!0}const B="rem",Ee="em",$="%",fi=[B,Ee,$],De=function(i){return fi.indexOf(i)===-1?B:i};class pi extends Y{constructor(e){super("borderRadius",e),this._valueUV=this._value.clone(),this._input=new u.Vector4(0,0,0,0),this._mediation=!0,this._cornerTL=new u.Vector2(0,1),this._cornerTR=new u.Vector2(1,1),this._cornerBR=new u.Vector2(1,0),this._cornerBL=new u.Vector2(0,0);const t=new E(this._valueUV,["x","y"]),s=new E(this._valueUV,["z","w"]),r=new E(this._valueUV,["x","w"]),n=new E(this._valueUV,["y","z"]);t.complementaryMediation=s,s.complementaryMediation=t,r.complementaryMediation=n,n.complementaryMediation=r,this._sideMediators=[t,s,r,n],this._units=B}set units(e){this._units=De(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,s=e._bounds._offsetHeight;if(this._units===$&&this._valueUV.divideScalar(100),this._units===B&&this._valueUV.divideScalar(Math.min(t,s)),this._mediation)do this._sideMediators.forEach(o=>o.computeValue()),this._sideMediators.sort((o,a)=>o.value<a.value?1:-1),this._sideMediators[0].value>1&&this._sideMediators[0].mediate();while(this._sideMediators[0].value>1);let r=t>s?s/t:1,n=t<s?t/s:1;this._units===$&&(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 E{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 gi extends Y{constructor(e){super("borderWidth",e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=B}set units(e){this._units=De(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,s=e._bounds._offsetHeight;if(this._units===$&&(console.log("Percent"),console.log(this._valueUV)),this._units===B)t!==0&&(this._valueUV.w/=t,this._valueUV.y/=t),s!==0&&(this._valueUV.x/=s,this._valueUV.z/=s);else if(this._units===Ee){if(t!==0){const r=t>s?s/t:1;this._valueUV.y*=r,this._valueUV.w*=r}if(s!==0){const r=t<s?t/s:1;this._valueUV.x*=r,this._valueUV.z*=r}}}}class mi 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 He extends A{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 I extends p{constructor(e="untitled"){super(e,void 0,!1)}update(e,t){}output(e){}}class vi extends p{constructor(){super("inlineJustificator",null,!1),this._value=null}update(e,t){}process(e){const t=e._bounds._innerHeight,s=e._layouter._value,r=Math.abs(s.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,a=e._borderWidth._value;n+=(-o.x+o.z)/2+(-a.x+a.z)/2,s.forEach(l=>{l.y+=n,l.forEach(d=>{d.offsetY+=n})})}}const yi=["start","center","end","stretch"],bi=function(i){return yi.indexOf(i)===-1?(console.warn(`(.style) alignItems value '${i}' is not valid. Aborted`),!1):!0};class he extends g{constructor(){super("alignItems","inherit",!0),this.isValidValue=bi}}class le extends g{constructor(){super("textAlign","inherit",!0),this.isValidValue=wi}}const xi=["left","right","center","justify","justify-left","justify-right","justify-center"],wi=function(i){return xi.indexOf(i)===-1?(console.warn(`(.style) textAlign value '${i}' is not valid. Aborted`),!1):!0};class ce extends g{constructor(){super("flexDirection","inherit",!0),this.isValid=Vi}}const Si=["row","row-reverse","column","column-reverse"];function Vi(i){return Si.indexOf(i)===-1?(console.warn(`(.style) flexDirection value '${i}' is not valid. Aborted`),!1):!0}class de extends g{constructor(){super("justifyContent","inherit",!0),this.isValidValue=Pi}}const ki=["start","center","end","space-between","space-around","space-evenly"];function Pi(i){return ki.indexOf(i)===-1?(console.warn(`(.style) justifyContent value '${i}' is not valid. Aborted`),!1):!0}class Ii 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 Ge extends g{constructor(){super("position","static",!0),this._allowsInherit=!1,this._value="static",this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=Ri}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}}const Ci=["static","absolute"];function Ri(i){return Ci.indexOf(i)===-1?(console.warn(`(.style) position value '${i}' is not valid. Aborted`),!1):!0}class $e 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 s of e._children._uis)s[`_${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 Bi extends $e{constructor(){super("width")}}class Ui extends $e{constructor(){super("height")}computeOutputValue(e){super.computeOutputValue(e)}}class Ne extends I{constructor(){super("textContent"),this._needsUpdate=!1}set value(e){}process(e){let t="";for(let s=0;s<e.children.length;s++){const r=e.children[s];r.isUI&&(t+=r.textContent)}this._value=t}}class Xe extends g{constructor(e){super("fontStyle",e,!0),this.isValidValue=Ti}}const Ai=["normal","italic"];function Ti(i){return Ai.indexOf(i)===-1?(console.warn(`(.style) fontStyle value '${i}' is not valid. Aborted`),!1):!0}class je extends g{constructor(){super("fontWeight","inherit",!0),this.isValid=Fi}}const Mi=["100","200","300","400","500","600","700","800","900","light","normal","bold","bolder"];function Fi(i){return Mi.indexOf(i.toString())===-1?(console.warn(`(.style) fontWeight value '${i}' is not valid. Aborted`),!1):!0}class Ye{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 Oi extends Ye{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 Li extends We{constructor(e){super(e)}get uv(){return this.typographic.uv}}class N extends ze{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 N(this._font,{char:e,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new Li(this)}}class zi extends u.PlaneGeometry{constructor(e,t){let s=1,r=1;const n=e.typographic.font.size,o=t._segments.value;s=Math.ceil(e.typographic.width/n*o),r=Math.ceil(e.typographic.height/n*o),super(e.width,e.height,s,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,s=e.uv.bottom-e.uv.top,r=this.getAttribute("uv").array.slice(),n=[];for(let o=0;o<r.length;o+=2){const a=r[o],l=r[o+1];n.push(e.uv.left+t*a),n.push(e.uv.top+s*l)}this.setAttribute("uvG",new u.BufferAttribute(new Float32Array(n),2))}_nullifyUVs(){const e=[],t=this.getAttribute("uv").array.length;for(let s=0;s<t;s++)e.push(0);this.setAttribute("uvG",new u.BufferAttribute(new Float32Array(e),2))}_transformGeometry(e){this.translate(e.width/2,-e.height/2,0)}}const Wi=`
|
|
3
|
+
attribute vec2 uvG;
|
|
4
|
+
varying vec2 vUvG;
|
|
5
|
+
`,_e=Wi,Ei=`
|
|
6
|
+
vUvG = uvG;
|
|
7
|
+
`,fe=Ei,Di=`
|
|
8
|
+
gl_Position.z -= 0.00001;
|
|
9
|
+
`,pe=Di,Hi=`
|
|
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
|
+
`,ge=Hi,Gi=`
|
|
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
|
+
`,me=Gi,K=function(i,e,t){i.alphaTest=t,ve(i,"USE_ALPHATEST",t>0)},ve=function(i,e,t){i.defines&&(t?i.defines[e]===void 0&&(i.defines[e]="",i.needsUpdate=!0):i.defines[e]!==void 0&&(delete i.defines[e],i.needsUpdate=!0))},Ke=function(i,e,t){i.defines[e]&&i.defines[e]===t||(i.defines[e]=t,i.needsUpdate=!0)},w=function(i,e,t){i.userData[e]?i.userData[e].value=t:i.uniforms[e].value=t},$i=function(i,e,t){i.userData[e].value=t};class S{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 u.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(e){S.injectVertexShaderChunks(e),S.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>",`#include <uv_pars_vertex>
|
|
71
|
+
`+_e),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
|
|
72
|
+
`+fe),e.vertexShader=e.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
73
|
+
`+pe)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>",`#include <uv_pars_fragment>
|
|
74
|
+
`+ge),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",`#include <alphamap_fragment>
|
|
75
|
+
`+me)}static from(e){return class extends e{static get fontMaterialProperties(){return S.mediation}constructor(t={}){S.ensureMaterialOptions(t),super(t),S.ensureDefines(this),S.ensureUserData(this,t),this._userDefinedOnBeforeCompile=s=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(t){this._userDefinedOnBeforeCompile=t}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=t=>{S.bindUniformsWithUserData(t,this),S.injectShaderChunks(t),this._userDefinedOnBeforeCompile(t)}}}static get mediation(){return ji}}const Ni=function(i,e,t){const s=t?t.texture:null,r=t?t.unitRange:new u.Vector2;if(i[e]!==void 0){i.glyphMap=s,i.unitRange=r;return}i.userData&&i.userData.glyphMap&&(i.userData.glyphMap.value=s,i.userData.unitRange.value=r)},Xi=function(i,e,t){t&&t!=="antialiased"?i.defines.NO_RGSS="":delete i.defines.NO_RGSS,i.needsUpdate=!0},ji={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:K},fontSide:{m:"side"},font:{m:"glyphMap",t:Ni},color:{m:"color"},fontOpacity:{m:"opacity"},fontSmooth:{m:"NO_RGSS",t:Xi},invertAlpha:{m:"INVERT_ALPHA",t:ve}},Yi=`
|
|
76
|
+
${_e}
|
|
77
|
+
#include <clipping_planes_pars_vertex>
|
|
78
|
+
void main() {
|
|
79
|
+
${fe}
|
|
80
|
+
#include <begin_vertex>
|
|
81
|
+
#include <project_vertex>
|
|
82
|
+
${pe}
|
|
83
|
+
#include <clipping_planes_vertex>
|
|
84
|
+
}
|
|
85
|
+
`,Ki=`
|
|
86
|
+
uniform vec3 diffuse;
|
|
87
|
+
uniform float opacity;
|
|
88
|
+
${ge}
|
|
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
|
+
${me}
|
|
95
|
+
#include <alphatest_fragment>
|
|
96
|
+
// instead of <output_fragment>
|
|
97
|
+
gl_FragColor = diffuseColor;
|
|
98
|
+
#include <clipping_planes_fragment>
|
|
99
|
+
}
|
|
100
|
+
`,qi=.02;class ye extends u.ShaderMaterial{static get mediation(){return S.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new u.Vector2(0,0)},alphaTest:{value:qi}},transparent:!0,clipping:!0,vertexShader:Yi,fragmentShader:Ki,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===ye}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}}class Ji extends L{constructor(e,t,s,r){if(super(e,t),this._unitRange=new u.Vector2(1,1),s.pages?this._buildData(s):Zi(this,s),r instanceof u.Texture)this._texture=r,this._buildTexture(r);else if(typeof r=="string"||r instanceof String)Qi(this,r);else throw new Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=ye,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 Oi(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 u.Vector2(this._distanceRange,this._distanceRange).divide(new u.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=u.LinearFilter,e.magFilter=u.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return C.missingCharacter(this,e)}getGeometricGlyph(e,t){return new zi(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){const t={};for(let s=0;s<e.kernings.length;s++){const r=e.kernings[s];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 s=0;s<e.chars.length;s++){const r=e.chars[s];t[r.char]=new N(this._font,r)}return t}_buildCharacterWhite(e,t=" ",s=1,r=1){return new N(this._font,{char:t,width:e.info.size/3*s,height:e.info.size*.7*r})}_alterElementProperties(e){}}function Zi(i,e){new u.FileLoader().setResponseType("json").load(e,t=>{i._buildData(t),i._checkReadiness()})}function Qi(i,e){i._texture=new u.TextureLoader().load(e,t=>{i._buildTexture(t),i._checkReadiness()})}class q extends u.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,s,r,n=!1){if(n||!this.getVariant(e,t)){this._isReady=!1;const o=new Ji(e,t,s,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=ue(e),this._variants.find(s=>s.weight===e&&s.style===t)}get name(){return this._name}_checkReadiness=()=>{this._variants.every(e=>e.isReady)&&ts(this)}}const es={type:"ready"};function ts(i){i._isReady=!0,i.dispatchEvent(es)}const G={},is=function(i){const e=[...arguments];e.forEach(s=>{if(!(s instanceof q))throw new Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof s} given.`)});const t=function(){return e.every(s=>s.isReady)};return new Promise((s,r)=>{if(t())s();else for(let n=0;n<e.length;n++){const o=e[n];o.isReady||o.addEventListener("ready",()=>{t()&&s()})}})},ss=function(i){return G[i]&&console.error(`FontLibrary::addFontFamily - Font('${i}') is already registered`),G[i]=new q(i),G[i]},rs=function(i){return G[i]},ns=function(i){qe=i};let qe=function(i,e){return console.error(`The character '${e}' is not included in the font characters set.`)," "};function os(i,e){return qe(i,e)}const as={addFontFamily:ss,getFontFamily:rs,prepare:is,setMissingCharacterHandler:ns,missingCharacter:os},C=as;class Je extends g{constructor(){super("fontFamily","inherit",!0)}computeOutputValue(e){if(this._input instanceof q)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 Ze extends g{constructor(){super("lineHeight","inherit",!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}}class Qe extends g{constructor(){super("whiteSpace","inherit"),this.isValidValue=hs}}const us=["normal","nowrap","pre","pre-line","pre-wrap"];function hs(i){return us.indexOf(i)===-1?(console.warn(`(.style) whiteSpace value '${i}' is not valid. Aborted`),!1):!0}class et extends g{constructor(){super("letterSpacing","inherit",!0)}}class ls extends g{constructor(){super("fontSize","inherit",!0)}}class tt extends p{constructor(){super("segments",1,!1)}}class cs extends R{constructor(){super("invertAlpha","inherit")}}class J extends g{constructor(){super("fontKerning","inherit"),this.isValidValue=_s}}const ds=["normal","none","inherit"];function _s(i){return ds.indexOf(i)===-1?(console.warn(`(.style) fontKerning value '${i}' is not valid. Aborted`),!1):!0}class D extends R{constructor(e){super(e,"inherit",!0)}}class Ue 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:K},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,s=null;for(;t._parent._value;)if(t=t._parent._value,t[`_${this._id}`]._value!=="inherit"){s=t[`_${this._id}`]._value;break}return s!==null?s:this.getDefaultValue()}getDefaultValue(){return this._defaultMaterial}}const fs=function(i,e,t){i.traverse(s=>{s.renderOrder=t})};class z extends u.Object3D{constructor(e,t){super(),Object.defineProperties(this,{isUI:{configurable:!1,enumerable:!0,value:!0}}),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundCustomDepthMaterial=null,this._backgroundMaterialMediation={},this._backgroundMeshMediation={backgroundCastShadow:{m:"castShadow"},backgroundReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder",t:fs}},this._fontMesh=null,this._fontMaterial=new Ue("fontMaterial"),this._fontCustomDepthMaterial=new Ue("fontCustomDepthMaterial"),this._fontMeshMediation={fontMaterial:{m:"material"},fontCustomDepthMaterial:{m:"customDepthMaterial",t:Ht},fontCastShadow:{m:"castShadow"},fontReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder"}},this._children=e.children?new e.children:new I("children"),this._parent=new Gt,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI),this._backgroundSide=new Be("backgroundSide"),this._fontSide=new Be("fontSide"),this._backgroundAlphaTest=new Re("backgroundAlphaTest",.02),this._fontAlphaTest=new Re("fontAlphaTest",.02),this._visible=new mi("visible",!0),this._backgroundCastShadow=new D("backgroundCastShadow"),this._fontCastShadow=new D("fontCastShadow"),this._backgroundReceiveShadow=new D("backgroundReceiveShadow"),this._fontReceiveShadow=new D("fontReceiveShadow"),this._renderOrder=new Mt,this._segments=e.segments?new e.segments:new tt,this._bounds=e.bounds?new e.bounds:new I("bounds"),this._order=new Ii,this._padding=new Et,this._margin=new Dt,this._position=new Ge,this._flexDirection=e.flexDirection?new e.flexDirection:new ce,this._justifyContent=e.justifyContent?new e.justifyContent:new de,this._alignItems=e.alignItems?new e.alignItems:new he,this._display=new Qt("flex"),this._boxSizing=new ii("border-box"),this._width=new Bi,this._height=new Ui,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new He,this._backgroundOpacity=new Q("backgroundOpacity",.5),this._backgroundImage=new oi,this._backgroundSize=new ui("cover"),this._color=e.color?new e.color:new A("color","inherit"),this._fontOpacity=new Q("fontOpacity","inherit"),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Qe,this._fontFamily=e.fontFamily?new e.fontFamily:new Je,this._fontStyle=e.fontStyle?new e.fontStyle:new Xe("normal"),this._fontWeight=e.fontWeight?new e.fontWeight:new je,this._fontSize=e.fontSize?new e.fontSize:new ls,this._lineHeight=e.lineHeight?new e.lineHeight:new Ze,this._fontKerning=e.fontKerning?new e.fontKerning:new J,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new et,this._overflow=new ci("visible"),this._borderRadius=new pi(0),this._borderWidth=new gi(0),this._borderColor=new A("borderColor",16711935),this._borderOpacity=new Q("borderOpacity",1),this._font=new qt,this._lineBreak=e.lineBreak?new e.lineBreak:new I("lineBreak"),this._textContent=e.textContent?new e.textContent:new Ne,this._glyphs=e.glyphs?new e.glyphs:new I("glyphs"),this._inlines=e.inlines?new e.inlines:new I("inlines"),this._layouter=e.layouter?new e.layouter:new I("layouter"),this._inlineJustificator=new vi,this._textAlign=e.textAlign?new e.textAlign:new le,this._autoSize=e.autoSize?new e.autoSize:new I("autoSize"),this._renderer=e.renderer?new e.renderer:new I("renderer"),this._offset=new Ft,this._invertAlpha=new cs,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new Ot,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 s=C.getFontFamily(t);if(!s){const r=e.fontStyle?e.fontStyle:"normal",n=e.fontWeight?e.fontWeight:"400";s=C.addFontFamily(t).addVariant(n,r,e.fontFamily,e.fontTexture)}e.fontFamily=s,delete e.fontTexture}for(let t of Object.keys(e)){const s=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=s;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=s);break;case"paddingTop":this._padding.top=s;break;case"paddingRight":this._padding.right=s;break;case"paddingBottom":this._padding.bottom=s;break;case"paddingLeft":this._padding.left=s;break;case"marginTop":this._margin.top=s;break;case"marginRight":this._margin.right=s;break;case"marginBottom":this._margin.bottom=s;break;case"marginLeft":this._margin.left=s;break;case"borderTopWidth":this._borderWidth.top=s;break;case"borderRightWidth":this._borderWidth.right=s;break;case"borderBottomWidth":this._borderWidth.bottom=s;break;case"borderLeftWidth":this._borderWidth.left=s;break;case"borderTopLeftRadius":this._borderRadius.topLeft=s;break;case"borderTopRightRadius":this._borderRadius.topRight=s;break;case"borderBottomRightRadius":this._borderRadius.bottomRight=s;break;case"borderBottomLeftRadius":this._borderRadius.bottomLeft=s;break;case"side":case"castShadow":case"receiveShadow":const r=t.charAt(0).toUpperCase()+t.substr(1);this[`_background${r}`].value=s,this[`_font${r}`].value=s;break;case"fontSide":case"backgroundSide":case"fontCastShadow":case"backgroundCastShadow":case"fontReceiveShadow":case"backgroundReceiveShadow":case"fontMaterial":case"fontCustomDepthMaterial":this[`_${t}`].value=s;break;default:this[`_${t}`]!==void 0?this[`_${t}`].value=s:this[t]=s}}}get(e){switch(e){case"overflow":case"width":case"height":return this[`_${e}`].inline}}_rebuildChildrenLists(){this._children._needsUpdate=!0}_rebuildParentUI=()=>{this._parent._needsUpdate=!0,this.parent&&!this.parent.isUI?(X.register(this),this.activatePseudoState("root")):(X.remove(this),this.deactivatePseudoState("root"))};add(e){let t=!1;for(let s=0;s<arguments.length;s++)super.add(arguments[s]),arguments[s].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,w(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)}W.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 s of this._components)s.output(e)}W.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)}W.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&&w(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)}W.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 s=this[`_${e}`],r=this._components.indexOf(s);return this._components[r]=this[`_${e}`]=t,t.needsUpdate=!0,s}}class X{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()}}X.elements=[];const ps=`
|
|
103
|
+
|
|
104
|
+
// FrameBorder vertex pars
|
|
105
|
+
attribute vec2 uvB;
|
|
106
|
+
varying vec2 vUvB;
|
|
107
|
+
|
|
108
|
+
`,be=ps,gs=`
|
|
109
|
+
|
|
110
|
+
// FrameBorder vertex shader
|
|
111
|
+
vUvB = uvB;
|
|
112
|
+
|
|
113
|
+
`,xe=gs,ms=`
|
|
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
|
+
`,we=ms,vs=`
|
|
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
|
+
`,Se=vs,ys=`
|
|
268
|
+
|
|
269
|
+
// To be removed - required for both border and background
|
|
270
|
+
uniform vec3 frameSize;
|
|
271
|
+
uniform vec2 textureSize;
|
|
272
|
+
|
|
273
|
+
`,Ve=ys,bs=`
|
|
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
|
+
`,ke=bs,xs=`
|
|
321
|
+
#ifdef USE_MAP
|
|
322
|
+
|
|
323
|
+
vec4 textureSample = sampleTexture();
|
|
324
|
+
diffuseColor *= textureSample;
|
|
325
|
+
|
|
326
|
+
#endif
|
|
327
|
+
`,Pe=xs,it={msdfAlphaglyphParsVertexGlsl:_e,msdfAlphaglyphVertexGlsl:fe,msdfOffsetglyphVertexGlsl:pe,msdfAlphaglyphParsFragmentGlsl:ge,msdfAlphaglyphFragmentGlsl:me,frameBorderParsVertexGlsl:be,frameBorderVertexGlsl:xe,frameCommonParsFragmentGlsl:Ve,frameBorderParsFragmentGlsl:we,frameBorderFragmentGlsl:Se,frameBackgroundParsFragmentGlsl:ke,frameBackgroundFragmentGlsl:Pe},ws=`
|
|
328
|
+
// Would be automatic on three materials and from USE_UV
|
|
329
|
+
#ifdef USE_MAP
|
|
330
|
+
varying vec2 vUv;
|
|
331
|
+
#endif
|
|
332
|
+
|
|
333
|
+
${be}
|
|
334
|
+
|
|
335
|
+
#include <clipping_planes_pars_vertex>
|
|
336
|
+
|
|
337
|
+
void main() {
|
|
338
|
+
|
|
339
|
+
#ifdef USE_MAP
|
|
340
|
+
vUv = uv;
|
|
341
|
+
#endif
|
|
342
|
+
|
|
343
|
+
${xe}
|
|
344
|
+
|
|
345
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
346
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
347
|
+
|
|
348
|
+
#include <clipping_planes_vertex>
|
|
349
|
+
|
|
350
|
+
}
|
|
351
|
+
`,Ss=`
|
|
352
|
+
|
|
353
|
+
// Basic
|
|
354
|
+
uniform vec3 diffuse;
|
|
355
|
+
uniform float opacity;
|
|
356
|
+
|
|
357
|
+
#ifdef USE_ALPHATEST
|
|
358
|
+
uniform float alphaTest;
|
|
359
|
+
#endif
|
|
360
|
+
|
|
361
|
+
${Ve}
|
|
362
|
+
|
|
363
|
+
${we}
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
#ifdef USE_MAP
|
|
367
|
+
varying vec2 vUv;
|
|
368
|
+
uniform sampler2D map;
|
|
369
|
+
#endif
|
|
370
|
+
|
|
371
|
+
${ke}
|
|
372
|
+
|
|
373
|
+
#include <clipping_planes_pars_fragment>
|
|
374
|
+
|
|
375
|
+
void main() {
|
|
376
|
+
|
|
377
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
378
|
+
|
|
379
|
+
// map
|
|
380
|
+
${Pe}
|
|
381
|
+
|
|
382
|
+
${Se}
|
|
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 ks}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 u.Vector4(0,0,0,0)},e.userData.cornerTL={value:new u.Vector2(0,1)},e.userData.cornerTR={value:new u.Vector2(1,1)},e.userData.cornerBR={value:new u.Vector2(1,0)},e.userData.cornerBL={value:new u.Vector2(0,0)},e.userData.borderWidth={value:new u.Vector4(0,0,0,0)},e.userData.borderOpacity={value:null},e.userData.frameSize={value:new u.Vector3(1,1,1)},e.userData.textureSize={value:new u.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
|
+
`+be),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
|
|
398
|
+
`+xe)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
|
|
399
|
+
`+ke),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
|
|
400
|
+
`+we),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>",`#include <map_pars_fragment>
|
|
401
|
+
`+Ve),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",Pe),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",Se+`
|
|
402
|
+
#include <alphamap_fragment>`)}}const Vs=function(i,e,t){t=["stretch","contain","cover"].indexOf(t),Ke(i,"BACKGROUND_MAPPING",t)},ks={clippingPlanes:{m:"clippingPlanes"},backgroundAlphaTest:{m:"alphaTest",t:K},backgroundSide:{m:"side"},backgroundImage:{m:"map"},backgroundColor:{m:"color"},backgroundOpacity:{m:"opacity"},backgroundSize:{m:"computedBackgroundSize",t:Vs},borderWidth:{m:"borderWidth",t:w},borderColor:{m:"borderColor",t:w},cornerTL:{m:"cornerTL",t:w},cornerTR:{m:"cornerTR",t:w},cornerBR:{m:"cornerBR",t:w},cornerBL:{m:"cornerBL",t:w},borderOpacity:{m:"borderOpacity",t:w},size:{m:"frameSize",t:w},tSize:{m:"textureSize",t:w}};class st extends u.ShaderMaterial{static get mediation(){return j.mediation}constructor(){super({uniforms:{alphaTest:{value:.02},map:{value:null},diffuse:{value:new u.Color(16777215)},opacity:{value:1},borderColor:{value:new u.Color(0)},borderOpacity:{value:0},borderRadius:{value:new u.Vector4(0,0,0,0)},cornerTL:{value:new u.Vector2(0,1)},cornerTR:{value:new u.Vector2(1,1)},cornerBR:{value:new u.Vector2(1,0)},cornerBL:{value:new u.Vector2(0,0)},borderWidth:{value:new u.Vector4(0,0,0,0)},frameSize:{value:new u.Vector3(1,1,1)},textureSize:{value:new u.Vector2(1,1)}},side:u.FrontSide,transparent:!0,clipping:!0,vertexShader:ws,fragmentShader:Ss,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 Ps extends p{constructor(){super("children",null,!1),this._uis=[],this._boxes=[]}update(e,t){this._compute(e),e._layouter._needsUpdate=!0,e._renderOrder._needsUpdate=!0}process(e){this._compute(e),e._flexDirection._needsProcess=!0,e._layouter._needsProcess=!0,e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter(t=>t.visible&&t.isUI),this._boxes=this._uis.filter(t=>t.isBox).sort(this._sortOrder)}dispose(){this._uis=null,this._boxes=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class rt extends p{constructor(){super("bounds",null,!1),this._size=new u.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 s=e._width,r=e._padding._value,n=e._borderWidth._value,o=e._margin._value,a=s._auto?1:s._value,l=t*a-(o.y+o.w);ne(l,this._offsetWidth)||(this._offsetWidth=l,this._innerWidth=this._offsetWidth-(r.y+r.w+n.y+n.w),this._centerX=ee(e),this._propagateWidth(e),this._triggerCascadingDependencies(e))}setReferenceHeight(e,t){const s=e._height,r=e._padding._value,n=e._borderWidth._value,o=e._margin._value,a=s._auto?1:s._value,l=t*a-(o.x+o.z);ne(l,this._offsetHeight)||(this._offsetHeight=l,this._innerHeight=this._offsetHeight-(r.x+r.z+n.x+n.z),this._centerY=te(e),this._propagateHeight(e),this._triggerCascadingDependencies(e))}setChildrenWidth(e,t){const s=e._padding._value,r=e._borderWidth._value;this._innerWidth=t,this._offsetWidth=this._innerWidth+(s.y+s.w+r.y+r.w),this._centerX=ee(e),this._propagateWidth(e),this._triggerCascadingDependencies(e)}setChildrenHeight(e,t){const s=e._padding._value,r=e._borderWidth._value;this._innerHeight=t,this._offsetHeight=this._innerHeight+(s.x+s.z+r.x+r.z),this._centerY=te(e),this._propagateHeight(e),this._triggerCascadingDependencies(e)}update(e,t){const s=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+s.y+s.w+r.y+r.w):(this._offsetWidth=n._value,this._innerWidth=this._offsetWidth-(s.y+s.w+r.y+r.w)),this._centerX=ee(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+s.x+s.z+r.x+r.z):(this._offsetHeight=o._value,this._innerHeight=this._offsetHeight-(s.x+s.z+r.x+r.z)),this._centerY=te(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 Is(e)}_computeChildrenSideHeight(e){return Cs(e)}_propagateWidth(e){for(let t=0;t<e._children._boxes.length;t++){const s=e._children._boxes[t];s._width._relative&&s._bounds.setReferenceWidth(s,this._innerWidth)}}_propagateHeight(e){for(let t=0;t<e._children._boxes.length;t++){const s=e._children._boxes[t];s._height._relative&&s._bounds.setReferenceHeight(s,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 ee(i){const e=i._padding._value,t=i._borderWidth._value,s=e.w+t.w,r=e.y+t.y;return(s-r)/2}function te(i){const e=i._padding._value,t=i._borderWidth._value,s=e.x+t.x;return(e.z+t.z-s)/2}function Is(i){return i._children._boxes.reduce((e,t)=>{const s=t._margin._value,r=t._bounds._offsetWidth+s.y+s.w;return e+r},0)}function Cs(i){return i._children._boxes.reduce((e,t)=>{const s=t._margin._value,r=t._bounds._offsetHeight+s.x+s.z;return e+r},0)}class Rs extends he{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=Fs,this._value){case"start":this._childAlign=Us;break;case"end":this._childAlign=Bs;break;default:this._childAlign=Ae}break;case"column":case"column-reverse":switch(this._process=Ms,this._value){case"start":this._childAlign=Ts;break;case"end":this._childAlign=As;break;default:this._childAlign=Ae}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",s="center",r="center";const n=e._padding._value,o=e._borderWidth._value;e._flexDirection._value.indexOf("column")!==-1?this._value==="start"?t=s="left":this._value==="end"?t=s="right":t="centerX":this._value==="start"?t=r="top":this._value==="end"?t=r="bottom":t="centerY";let a=-(n.x-n.z)/2-(o.x-o.z)/2,l=-(n.y-n.w)/2-(o.y-o.w)/2;s==="left"?l=(n.w-n.y)/2+(o.w-o.y)/2:s==="right"&&(l=-(n.y-n.w)/2-(o.y-o.w)/2),r==="top"?a=-(n.x-n.z)/2-(o.x-o.z)/2:r==="bottom"&&(a=(n.z-n.x)/2+(o.z-o.x)/2),e._children._boxes.forEach(d=>{let c=0,h=0;t==="top"?h=-d._margin._value.x:t==="bottom"?h=d._margin._value.z:t==="left"?c=d._margin._value.w:t==="right"?c=-d._margin._value.y:t==="centerX"?c=(d._margin._value.w-d._margin._value.y)/2:t==="centerY"&&(h=(-d._margin._value.x+d._margin._value.z)/2),e._layouter._childrenPos[d.id].x+=l+c,e._layouter._childrenPos[d.id].y+=a+h})}}function Ae(){return 0}function Bs(i,e){return-e+i._bounds._offsetHeight/2}function Us(i,e){return e-i._bounds._offsetHeight/2}function As(i,e){return e-i._bounds._offsetWidth/2}function Ts(i,e){return-e+i._bounds._offsetWidth/2}function Ms(i,e){const t=i._bounds._innerWidth/2;i._children._boxes.forEach(s=>{i._layouter._childrenPos[s.id].x=e(s,t)})}function Fs(i,e){const t=i._bounds._innerHeight/2;i._children._boxes.forEach(s=>{i._layouter._childrenPos[s.id].y=e(s,t)})}class Os extends ce{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=Ls;break;case"row-reverse":this._process=zs;break;case"column":this._process=Ws;break;case"column-reverse":this._process=Es;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 Ls(i){let e=i._flexDirection._offset;const t=i._flexDirection._reverse,s=i._children._boxes;for(let r=0;r<s.length;r++){const n=s[r],o=n.id,a=n._bounds._offsetWidth;e+=n._margin._value.w*t;const l=i._layouter._childrenPos[o];l.x=e+a/2*t,l.y=0,e+=t*(a+n._margin._value.y)}}function zs(i){let e=i._flexDirection._offset;const t=i._flexDirection._reverse,s=i._children._boxes;for(let r=0;r<s.length;r++){const n=s[r],o=n.id,a=n._bounds._offsetWidth;e+=n._margin._value.y*t;const l=i._layouter._childrenPos[o];l.x=e+a/2*t,l.y=0,e+=(a+n._margin._value.w)*t}}function Ws(i){let e=i._flexDirection._offset;const t=i._flexDirection._reverse,s=i._children._boxes;for(let r=0;r<s.length;r++){const n=s[r],o=n.id,a=n._bounds._offsetHeight;e+=n._margin._value.x*t;const l=i._layouter._childrenPos[o];l.x=0,l.y=e+a/2*t,e+=(a+n._margin._value.z)*t}}function Es(i){let e=i._flexDirection._offset;const t=i._flexDirection._reverse,s=i._children._boxes;for(let r=0;r<s.length;r++){const n=s[r],o=n.id,a=n._bounds._offsetHeight;e+=n._margin._value.z*t;const l=i._layouter._childrenPos[o];l.x=0,l.y=e+a/2*t,e+=(a+n._margin._value.x)*t}}class Ds extends de{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=Gs.bind(this);break;case"row-reverse":case"row":this._process=Hs.bind(this);break}switch(this._value){case"end":this._computeOffset=Xs,this._computeMargin=ie;break;case"center":this._computeOffset=js,this._computeMargin=ie;break;case"start":this._computeOffset=H,this._computeMargin=ie;break;case"space-between":this._computeOffset=H,this._computeMargin=Ys;break;case"space-around":this._computeOffset=H,this._computeMargin=qs;break;case"space-evenly":this._computeOffset=H,this._computeMargin=Ks;break}e._flexDirection._needsProcess=!0}process(e){this._process(e),e._alignItems._needsProcess=!0}}function Hs(i){const e=i._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:s}=$s(i),r=e*2-t*Math.sign(e),n=this._computeOffset(r),o=this._computeMargin(i,s,i._flexDirection._reverse);i._children._boxes.forEach((a,l)=>{i._layouter._childrenPos[a.id].x-=n-o[l]})}function Gs(i){const e=i._flexDirection._offset,{usedDirectionSpace:t,remainingSpace:s}=Ns(i),r=e*2-t*Math.sign(e),n=this._computeOffset(r),o=this._computeMargin(i,s,i._flexDirection._reverse);i._children._boxes.forEach((a,l)=>{i._layouter._childrenPos[a.id].y-=n-o[l]})}function $s(i){const e=i._bounds._computeChildrenSideWidth(i);return{usedDirectionSpace:e,remainingSpace:i._bounds._innerWidth-e}}function Ns(i){const e=i._bounds._computeChildrenSideHeight(i);return{usedDirectionSpace:e,remainingSpace:i._bounds._innerHeight-e}}function H(i){return 0}function Xs(i){return i}function js(i){return i/2}function ie(i,e=0,t=1){return Array(i._children._boxes.length).fill(0)}function Ys(i,e=0,t=1){const r=i._children._boxes.length,n=Array(r).fill(0);if(e>0&&r>1){const o=e/(r-1)*t;n[0]=0;for(let a=1;a<r;a++)n[a]=o*a}return n}function Ks(i,e=0,t=1){const r=i._children._boxes.length,n=Array(r).fill(0);if(e>0){const o=e/(r+1)*t;for(let a=0;a<r;a++)n[a]=o*(a+1)}return n}function qs(i,e=0,t=1){const r=i._children._boxes.length,n=Array(r).fill(0);if(e>0){const o=e/r*t,a=o/2;n[0]=a;for(let l=1;l<r;l++)n[l]=a+o*l}return n}let se;class nt extends u.Mesh{constructor(e){const t=e.slice,s={};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 _=new u.PlaneGeometry(t.left*r,t.top*n,1,1);P(_,0,t.left,1-t.top,1),_.translate(t.left*r/2,-t.top*n/2,0),s.topLeft=_}const h=new u.PlaneGeometry(1,t.top*n,1,1);if(P(h,t.left,1-t.right,1-t.top,1),h.translate(0,-t.top*n/2,0),s.top=h,t.right){const _=new u.PlaneGeometry(t.right*r,t.top*n,1,1);P(_,1-t.right,1,1-t.top,1),_.translate(-t.right*r/2,-t.top*n/2,0),s.topRight=_}}if(t.left){const h=new u.PlaneGeometry(t.left*r,1,1,1);P(h,0,t.left,t.bottom,1-t.top),h.translate(t.left*r/2,0,0),s.left=h}const c=new u.PlaneGeometry(1,1,1,1);if(P(c,t.left,1-t.right,t.bottom,1-t.top),s.middle=c,t.right){const h=new u.PlaneGeometry(t.right*r,1,1,1);P(h,1-t.right,1,t.bottom,1-t.top),h.translate(-t.right*r/2,0,0),s.right=h}if(t.bottom){if(t.left){const _=new u.PlaneGeometry(t.left*r,t.bottom*n,1,1);P(_,0,t.left,0,t.bottom),_.translate(t.left*r/2,t.bottom*n/2,0),s.bottomLeft=_}const h=new u.PlaneGeometry(1,t.bottom*n,1,1);if(P(h,t.left,1-t.right,0,t.bottom),h.translate(0,t.bottom*n/2,0),s.bottom=h,t.right){const _=new u.PlaneGeometry(t.right*r,t.bottom*n,1,1);P(_,1-t.right,1,0,t.bottom),_.translate(-t.right*r/2,t.bottom*n/2,0),s.bottomRight=_}}}let o=e.backgroundMaterial;t&&(se||(se=new u.MeshBasicMaterial({alphaTest:1.1})),o=se);const a=new u.PlaneGeometry(1,1,e._segments.value,e._segments.value),l=new u.BufferAttribute(new Float32Array(a.getAttribute("uv").array),2);if(a.setAttribute("uvB",l).name="uvB",super(a,o),this.name="UIBackgroundBox",t){this.slice=t,this.sliceSize=new u.Vector3(1-(t.left+t.right),1-(t.bottom+t.top),1),this.sliceScale=new u.Vector3(r,n,1);for(const d in s){const c=new u.Mesh(s[d],e.backgroundMaterial);this.add(c),s[d]=c}this.updateScale=this.updateScaleSlice,this.slices=s}}updateScale(){}updateScaleSlice(){const e=new u.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 s=this.slices[t];s.scale.set(1/this.scale.x,1/this.scale.y,this.scale.y);const r=Js[t];for(const o in r)s.position[o]=this.scale[o]*r[o]*s.scale[o];const n=Zs[t];if(n){n.x&&(s.position.x=this.sliceScale.x*.5*(this.slice.left-this.slice.right)*(1/this.scale.x)),n.y&&(s.position.y=this.sliceScale.y*.5*(this.slice.bottom-this.slice.top)*(1/this.scale.y));for(const o in n){const a=this.scale[o]-(1-this.sliceSize[o])*this.sliceScale[o];s.scale[o]=Math.max(0,a*(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 Js={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}},Zs={top:{x:1},left:{y:1},right:{y:1},bottom:{x:1},middle:{x:1,y:1}};function P(i,e,t,s,r){const n=t-e,o=r-s,a=i.attributes.uv;for(let d=0;d<a.count;d++){const c=a.getX(d),h=a.getY(d);a.setXY(d,e+c*n,s+h*o)}const l=new u.BufferAttribute(new Float32Array(i.getAttribute("uv").array),2);i.setAttribute("uvB",l).name="uvB"}class ot extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new nt(e)),e.performAfterUpdate()}}class Qs extends Ge{constructor(){super("position")}update(e,t){super.update(e,t),this._needsProcess=!0}}class er extends p{constructor(){super("autosize"),this._needsProcess=!0}process(e){e._width._auto&&tr(e),e._height._auto&&ir(e);const t=e._alignItems._value==="stretch",s=t&&e._flexDirection._value.indexOf("column")!==-1,r=t&&!s;for(const n of e._children._boxes)(n._width._auto&&s||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 tr(i){i._bounds.setChildrenWidth(i,rr(i))}function ir(i){i._bounds.setChildrenHeight(i,sr(i))}function sr(i){switch(i._flexDirection._value){case"row":case"row-reverse":return ur(i);case"column":case"column-reverse":return or(i)}}function rr(i){switch(i._flexDirection._value){case"row":case"row-reverse":return nr(i);case"column":case"column-reverse":return ar(i)}}function nr(i){let e=0;for(const t of i._children._boxes){if(t._position._value!=="static")continue;const s=t._margin._value,r=t._bounds._offsetWidth+s.y+s.w;e+=r}return e}function or(i){let e=0;for(const t of i._children._boxes){if(t._position._value!=="static")continue;const s=t._margin._value,r=t._bounds._offsetHeight+s.x+s.z;e+=r}return e}function ar(i){let e=0;for(const t of i._children._boxes){if(t._position._value!=="static")continue;const s=t._margin._value,r=t._bounds._offsetWidth+s.y+s.w;r>e&&(e=r)}return e}function ur(i){let e=0;for(const t of i._children._boxes){if(t._position._value!=="static")continue;const s=t._margin._value,r=t._bounds._offsetHeight+s.x+s.z;r>e&&(e=r)}return e}class T extends z{constructor(e,t){T.definePropertiesValues(e,t),super(e,t),T.init(this)}bindBackgroundMeshProperties(){this._bounds._size=this._backgroundMesh.scale,this._bounds._needsProcess=!0}unbindBackgroundMeshProperties(){this._bounds._size=new u.Vector3(1,1,1),this._bounds._needsProcess=!0}static definePropertiesValues(e,t){e.children||(e.children=Ps),e.bounds||(e.bounds=rt),e.flexDirection||(e.flexDirection=Os),e.justifyContent||(e.justifyContent=Ds),e.alignItems||(e.alignItems=Rs),e.position||(e.position=Qs),e.autoSize||(e.autoSize=er),e.renderer||(e.renderer=ot),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 st,e._renderer.render(e),e._backgroundMesh.visible=!1}}class Te extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}}class hr extends p{constructor(){super("layouter",null,!1),this._needsUpdate=!0,this._childrenPos={}}update(e,t){this._childrenPos={};for(const s of e._children._boxes)s._position._value==="static"&&(this._childrenPos[s.id]=s.position)}process(e){}}class M extends T{constructor(e={}){const t={};M.definePropertiesValues(t,e),super(t,e),M.init(this)}add(e){const t=[];for(let s=0;s<arguments.length;s++){const r=arguments[s];!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=hr}static init(e){Object.defineProperties(e,{isBlock:{configurable:!1,enumerable:!0,value:!0}})}}class lr extends p{constructor(){super("textContent",null,!1)}update(e,t){e._glyphs._needsUpdate=!0,e._whiteSpace._needsProcess=!0}}class cr 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 dr 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 _r extends A{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 at 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 s=0;s<e._inlines._value.length;s++){const r=e._inlines._value[s],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 ut extends p{constructor(){super("layouter",null,!1),this._value=null}update(e,t){this._value=e._parent.find(s=>s.isUI&&s.isText),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}}class fr extends A{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 ht extends Xe{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class lt extends je{constructor(){super()}computeOutputValue(e){this._value=ue(this.getInheritedInput(e))}}class ct extends Je{constructor(){super("fontFamily","inherit",!0),this._input="inherit",this._needsUpdate=!0,this._allowsInherit=!1}computeOutputValue(e){let t=this._inheritedInput;if(t==="inherit"&&(t=this.getInheritedInput(e)),t instanceof q)this._value=t,e._font._needsUpdate=!0;else if(typeof t=="string"){const s=C.getFontFamily(t);s?(this._value=s,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 Ie extends Qe{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=pr(this._value),this._value){case"nowrap":case"normal":this._stringCollapser=gr;break;case"pre-line":this._stringCollapser=dt;break;default:this._stringCollapser=mr}switch(this._value){case"pre-line":case"nowrap":case"normal":this._inlineCollapser=wr;break;case"pre-wrap":this._inlineCollapser=xr;break;default:this._inlineCollapser=Sr}switch(this._value){case"pre-line":case"pre-wrap":case"normal":this._inlineWrapper=vr;break;case"pre":this._inlineWrapper=yr;break;default:this._inlineWrapper=br}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}}const Me={" ":" ","\n":`
|
|
404
|
+
`,"\r":"\r"," ":" "},pr=function(i){switch(i){case"pre":case"pre-wrap":case"pre-line":return"mandatory"}return null};function gr(i){return dt(i.replace(/\n/g," "))}function dt(i){return i.replace(/[ ]{2,}/g," ")}function mr(i){return i}function vr(i,e,t,s){const r=i[e];if(r.lineBreak==="mandatory"||t+r.xadvance+r.xoffset+r.kerning>s.INNER_WIDTH)return!0;const n=pt(i,e,s);return Vr(i[e-1],t,n,s)}function yr(i,e,t,s){return i[e].lineBreak==="mandatory"}function br(){return!1}function xr(i){if(!i[0])return 0;const e=i[0],t=i[i.length-1];return e.char&&e.char===`
|
|
405
|
+
`&&i.length>1&&ft([e],i[1]),t.char&&t.char===`
|
|
406
|
+
`&&i.length>1&&_t([t],i[i.length-2]),e.offsetX}function wr(i){if(!i[0])return 0;let e=[],t;for(let s=0;s<i.length;s++){const r=i[s];if(r.char&&Me[r.char]&&i.length>s){e.push(r),t=i[s+1];continue}break}ft(e,t),e=[],t=null;for(let s=i.length-1;s>0;s--){const r=i[s];if(r.char&&Me[r.char]&&s>0){e.push(r),t=i[s-1];continue}break}return _t(e,t),i[0].offsetX}function Sr(i){return i[0]?i[0].offsetX:0}function _t(i,e){if(e)for(let t=0;t<i.length;t++){const s=i[t];s.fontFactor=0,s.offsetX=e.offsetX+e.cumulativeWidth,s.cumulativeWidth=0}}function ft(i,e){if(e)for(let t=0;t<i.length;t++){const s=i[t];s.fontFactor=0,s.offsetX=e.offsetX,s.cumulativeWidth=0}}function pt(i,e,t,s){if(s=s||0,!i[e])return s;const r=i[e];return r.lineBreak?s+r.xadvance:pt(i,e+1,t,s+r.xadvance+r.xoffset+r.kerning+t.LETTERSPACING)}function Vr(i,e,t,s){return!i||!i.char||e+t<s.INNER_WIDTH?!1:s.BREAKON.indexOf(i.char)>-1}class gt extends et{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 mt 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,s=e._inlines._value;for(let r=0;r<s.length;r++){const n=s[r];n.resetOffsets(),n.fontSize=this._value,n.fontFactor=t}}get value(){return this._value}}class vt extends tt{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 kr extends vt{constructor(){super(),this._value="inherit"}}class Pr extends J{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value._layouter._needsProcess=!1}process(e){if(this._value!=="none"){const t=e._whiteSpace._whiteSpacedContent,s=e._inlines._value;for(let r=1;r<s.length;r++){const n=t[r-1]+t[r];s[r].kerning=e._font._fontVariant.getKerningAmount(n)}}}}class yt extends p{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function Ir(i,e=!1){const t=i[0].index!==null,s=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),n={},o={},a=i[0].morphTargetsRelative,l=new u.BufferGeometry;let d=0;for(let c=0;c<i.length;++c){const h=i[c];let _=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in h.attributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.attributes[f]),_++}if(_!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(d,f,c),d+=f}}if(t){let c=0;const h=[];for(let _=0;_<i.length;++_){const f=i[_].index;for(let y=0;y<f.count;++y)h.push(f.getX(y)+c);c+=i[_].attributes.position.count}l.setIndex(h)}for(const c in n){const h=Fe(n[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(const c in o){const h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let _=0;_<h;++_){const f=[];for(let V=0;V<o[c].length;++V)f.push(o[c][V][_]);const y=Fe(f);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(y)}}return l}function Fe(i){let e,t,s,r=-1,n=0;for(let d=0;d<i.length;++d){const c=i[d];if(e===void 0&&(e=c.array.constructor),e!==c.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=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=c.normalized),s!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=c.gpuType),r!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=c.count*t}const o=new e(n),a=new u.BufferAttribute(o,t,s);let l=0;for(let d=0;d<i.length;++d){const c=i[d];if(c.isInterleavedBufferAttribute){const h=l/t;for(let _=0,f=c.count;_<f;_++)for(let y=0;y<t;y++){const V=c.getComponent(_,y);a.setComponent(_+h,y,V)}}else o.set(c.array,l);l+=c.count*t}return r!==void 0&&(a.gpuType=r),a}class Cr 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)),s=Ir(t);e.setFontMesh(new u.Mesh(s,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class Rr extends le{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class U extends z{constructor(e={}){const t={};U.definePropertiesValues(t,e),super(t,e),U.init(this)}add(e){const t=[];for(let s=0;s<arguments.length;s++){const r=arguments[s];!r.isUI||r.isInline?(t.push(r),r.position.z=.005):console.warn("Block element can only contain Box elements.",r)}return super.add(...t)}_rebuildParentUI=()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0};set textContent(e){this._textContent.value=e}get textContent(){return this._textContent._value}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}static definePropertiesValues(e,t){e.children||(e.children=yt),e.textContent||(e.textContent=lr),e.glyphs||(e.glyphs=dr),e.inlines||(e.inlines=cr),e.layouter||(e.layouter=ut),e.renderer||(e.renderer=Cr),e.fontFamily||(e.fontFamily=ct),e.fontWeight||(e.fontWeight=lt),e.fontStyle||(e.fontStyle=ht),e.fontSize||(e.fontSize=mt),e.color||(e.color=_r),e.backgroundColor||(e.backgroundColor=fr),e.lineBreak||(e.lineBreak=at),e.letterSpacing||(e.letterSpacing=gt),e.whiteSpace||(e.whiteSpace=Ie),e.segments||(e.segments=kr),e.textAlign||(e.textAlign=Rr),e.fontKerning||(e.fontKerning=Pr)}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class Br extends Ne{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 s=e.children.length-1;s>=0;s--){const r=e.children[s];r.isUI&&(e.remove(r),r.clear())}e._children._uis=[],this._value&&e.add(new U({name:"anonymousInline",textContent:this._value}))}}class Ur extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class Ar 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 s=e._lineHeight._value,r=new Ur(new Te);let n=0;e._children._inlines.forEach(h=>{if(!h._inlines.value)return;this._resetInlines(h);const _=h._fontSize._value,f=h._letterSpacing._value*_,y=h._whiteSpace._value,V=h._lineBreak._value,x={WHITESPACE:y,LETTERSPACING:f,BREAKON:V,INNER_WIDTH:t},Bt=h._whiteSpace._inlineWrapper;n+=h._margin._value.w+h._padding._value.w,h._inlines.value.forEach((b,Ut,At)=>{const Z=r[r.length-1];if(Bt(At,Ut,n,x)){if(r.push(new Te(b)),b.offsetX=b.xoffset,b.width===0){n=0;return}b.cumulativeWidth=b.xadvance+f,n=b.cumulativeWidth;return}r[r.length-1].push(b),b.offsetX=n+b.xoffset+b.kerning,b.cumulativeWidth=b.xadvance+b.kerning+f,n+=b.cumulativeWidth,Z.length-1===1&&Z[Z.length-2].width===0&&(b.offsetX-=b.xoffset,n-=b.xoffset)}),n+=h._margin._value.y+h._padding._value.y});const o=e._whiteSpace._inlineCollapser;let a=0,l=0,d=0;r.forEach((h,_)=>{const f=o(h);let y=0,V=0;if(h.forEach(x=>{y=Math.max(y,x.lineHeight),V=Math.max(V,x.lineBase),x.offsetX-=f}),h.lineHeight=y,h.lineBase=V,_===0?d=-(y*s-y)*.5:d-=r[_-1].lineHeight*s,h.y=d,h.x=0,h.forEach(x=>{x.offsetY=d-x.anchor,x.lineHeight<h.lineHeight&&(x.offsetY-=h.lineBase-x.lineBase)}),l+=h.lineHeight*s,h.width=0,h[0]){const x=h[h.length-1];h.width=x.offsetX+x.cumulativeWidth+x.paddingRight+x.marginRight+h[0].offsetX,a=Math.max(a,h.width)}}),r.height=l,r.width=a,this._value=r,t===1/0&&e._bounds.setChildrenWidth(e,r.width),e._height._auto&&e._bounds.setChildrenHeight(e,r.height);const c=e._parent._value;c&&(c._autoSize._needsProcess=!0,c._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}}class Tr extends le{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){Mr(e),e._renderer._needsRender=!0}}function Mr(i){const e=i._layouter._value,t=i._textAlign._value,s=i._bounds._innerWidth;for(let r=0;r<e.length;r++){const n=e[r],o=Fr(i,n,r===e.length-1),a=i._padding._value,l=i._borderWidth._value,d=(-a.w+a.y)/2+(-l.w+l.y)/2;n.x+=o;for(let c=0;c<n.length;c++)n[c].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=s-n.width;if(o<=0)return;let a=0;for(let h=1;h<n.length-1;h++)a+=n[h].char===" "?1:0;const l=o/a;let d=1;t==="justify-right"&&(n.reverse(),d=-1);let c=0;for(let h=1;h<=n.length-1;h++){const _=n[h];_.offsetX+=c*d,c+=_.char===" "?l:0}t==="justify-right"&&n.reverse()}}function Fr(i,e,t){switch(i._textAlign._value){case"justify-left":case"justify":case"left":return-i._bounds._innerWidth/2;case"justify-right":case"right":return-e.width+i._bounds._innerWidth/2;case"center":return-e.width/2;case"justify-center":return t?-e.width/2:-i._bounds._innerWidth/2;default:console.warn(`textAlign: '${i._textAlign._value}' is not valid`)}}class Or extends ce{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class Lr extends Ze{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class zr extends J{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class Wr extends rt{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class Er extends p{constructor(){super("children",null,!1),this._uis=[],this._inlines=[],this._boxes=[]}update(e,t){this._compute(e),this._needsProcess=!0}process(e){this._compute(e),e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter(t=>t.visible&&t.isUI),this._inlines=this._uis.filter(t=>t.isInline).sort(this._sortOrder)}dispose(){this._inlines=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class Dr extends p{constructor(){super("autosize")}process(e){if(e._layouter._value&&e._layouter._value.length){const t=e._layouter._value,s=e._padding._value,r=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+s.w+s.y+r.w+r.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+s.x+s.z+r.x+r.z)}}}class Hr extends ot{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 F extends T{constructor(e={},t={}){F.definePropertiesValues(t,e),super(t,e),F.init(this)}add(e){const t=[];let s=!1;for(let r=0;r<arguments.length;r++){const n=arguments[r];!n.isUI||n.isInline?(n.isInline&&(s=!0),t.push(n)):console.warn("Block element can only contain Box elements.",n)}return t.length>0&&super.add(...t),s&&(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=Or,e.justifyContent=de,e.alignItems=he,e.bounds=Wr,e.autoSize=Dr,e.renderer=Hr,e.children||(e.children=Er),e.textContent||(e.textContent=Br),e.layouter||(e.layouter=Ar),e.lineHeight||(e.lineHeight=Lr),e.textAlign||(e.textAlign=Tr),e.whiteSpace||(e.whiteSpace=Ie),e.fontKerning||(e.fontKerning=zr),e.segments||(e.segments=vt),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class Gr 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 $r extends p{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new nt(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 Nr extends p{constructor(){super("bounds",null,!1),this._size=new u.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 O extends z{constructor(e={}){const t={};O.definePropertiesValues(t,e),super(t,e),O.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 u.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){const t=[];for(let s=0;s<arguments.length;s++){const r=arguments[s];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=yt),e.bounds||(e.bounds=Nr),e.inlines||(e.inlines=Gr),e.layouter||(e.layouter=ut),e.renderer||(e.renderer=$r),e.fontFamily||(e.fontFamily=ct),e.fontWeight||(e.fontWeight=lt),e.fontStyle||(e.fontStyle=ht),e.fontSize||(e.fontSize=mt),e.backgroundColor||(e.backgroundColor=He),e.lineBreak||(e.lineBreak=at),e.letterSpacing||(e.letterSpacing=gt),e.whiteSpace||(e.whiteSpace=Ie),e.fontKerning||(e.fontKerning=J),t.backgroundSize||(t.backgroundSize="cover"),t.width||(t.width="100%"),t.height||(t.height="100%"),t.boxSizing||(t.boxSizing="border-box")}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0},isInlineBlock:{configurable:!1,enumerable:!0,value:!0}}),e._inlines._value=[new Xr(e)],e.backgroundMaterial=new st,e._renderer.render(e)}}class Xr extends Le{constructor(e){super(),this._uiElement=e}get xadvance(){const e=this._uiElement._padding._value,t=this._uiElement._width;return t._relative?t._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.w+e.y+t.value}get width(){const e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}}class bt{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw new Error(`Behavior::act() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}detach(){console.error(`Behavior::detach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}clear(){}}const xt=()=>X.update(),wt={BaseProperty:p,Block:M,Text:F,Inline:U,InlineBlock:O,MeshUIBaseElement:z,FontLibrary:C,update:xt,MSDFFontMaterialUtils:S,ShaderChunkUI:it,Behavior:bt,FontVariant:L};typeof global<"u"&&(global.ThreeMeshUI=wt);const jr=wt;var Yr=v.ti,St=v.nS,Vt=v.eB,Kr=v.Yp,kt=v.VB,qr=v.BC,Jr=v.zN,Pt=v.cV,Zr=v.hW,Qr=v.k2,en=v.K6,tn=v.M7,sn=v.ls,rn=v.Hi,It=v.EY,nn=v.MR,on=v.zf,Ct=v.Ay,Rt=v.yo;const an=Object.freeze(Object.defineProperty({__proto__:null,BaseProperty:Yr,Behavior:St,Block:Vt,DefaultValues:Kr,FontLibrary:kt,FontVariant:qr,InheritableProperty:Jr,Inline:Pt,InlineBlock:Zr,InlineGlyph:Qr,MSDFFontMaterialUtils:en,MaterialTransformers:tn,MeshUIBaseElement:sn,ShaderChunkUI:rn,Text:It,TypographicFont:nn,TypographicGlyph:on,default:Ct,update:Rt},Symbol.toStringTag,{value:"Module"}));class un extends St{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._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 s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.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 s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);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()}}exports.SimpleStateBehavior=un;exports.ThreeMeshUI=an;exports.__webpack_exports__Block=Vt;exports.__webpack_exports__FontLibrary=kt;exports.__webpack_exports__Inline=Pt;exports.__webpack_exports__Text=It;exports.__webpack_exports__default=Ct;exports.__webpack_exports__update=Rt;
|