- Track Needle/MenuScene/dist and Needle/SampleScene/dist for container deploys - Dockerfile copies pre-built dist (no npm in image); rebuild with npm run build before commit - Fix Needle .gitignore: /assets/ so dist/assets is not ignored - Git LFS: track *.wasm; relax .dockerignore so dist is sent as build context Made-with: Cursor
406 lines
110 KiB
JavaScript
406 lines
110 KiB
JavaScript
import{n as e}from"./rolldown-runtime.CYVBeYYp.js";import{A as t,Ar as n,It as r,Qt as i,S as a,Zt as o,_n as s,_r as c,fn as l,gr as u,it as d,jr as f,kr as ee,nt as te,tr as ne,vn as re,x as ie}from"./three@0.169.19.js";var ae=e({BaseProperty:()=>xi,Behavior:()=>Si,Block:()=>Ci,DefaultValues:()=>wi,FontLibrary:()=>Ti,FontVariant:()=>Ei,InheritableProperty:()=>Di,Inline:()=>Oi,InlineBlock:()=>ki,InlineGlyph:()=>Ai,MSDFFontMaterialUtils:()=>ji,MaterialTransformers:()=>Mi,MeshUIBaseElement:()=>Ni,ShaderChunkUI:()=>Pi,Text:()=>Fi,TypographicFont:()=>Ii,TypographicGlyph:()=>Li,default:()=>Ri,update:()=>zi}),p={};p.d=(e,t)=>{for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,`__esModule`,{value:!0})};var m={};p.d(m,{ti:()=>v,nS:()=>_i,eB:()=>mr,Yp:()=>h,VB:()=>W,BC:()=>E,zN:()=>y,cV:()=>Zr,hW:()=>hi,k2:()=>we,K6:()=>V,M7:()=>g,ls:()=>q,Hi:()=>hn,EY:()=>di,MR:()=>Tt,zf:()=>Ce,Ay:()=>bi,yo:()=>vi});var h={};p.r(h),p.d(h,{get:()=>se,set:()=>oe});var g={};p.r(g),p.d(g,{alphaTestTransformer:()=>R,asPreprocessorValueTransformer:()=>Mt,toPreprocessorTriggerTransformer:()=>z,toUserDataTransformer:()=>Nt,uniformOrUserDataTransformer:()=>B});var _={fontFamily:null,fontSize:.05,fontKerning:`auto`,fontStyle:`normal`,fontWeight:`normal`,offset:.005,lineHeight:1.2,lineBreak:`- ,.:?!
|
|
`,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},oe=function(e){for(let t in e)_[t]=e[t]},se=function(e){return Object.prototype.hasOwnProperty.call(_,e)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${e}'`),_[e]},v=class{constructor(e,t=null,n=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=n}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;let t=e._parent._value;return t&&t[`_${this._id}`]?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return se(this._id)}isValid(e){return!0}emptyStrategyLogic(){throw 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}},ce=class extends v{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{let t=e._parent._value;t!==null&&(this._actualValue=t._renderOrder._actualValue+(1+t._children._uis.indexOf(e)))}for(let t of e._children._uis)t._renderOrder._value===`auto`&&(t._renderOrder._needsUpdate=!0);this._outputValue(t)}_outputValue(e){e[this._id]=this._actualValue}get value(){return this._value}},y=class extends v{constructor(e,t=null,n=!0){super(e,t,n),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(let t of e._children._uis){let e=t[`_${this._id}`];e!==void 0&&e._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}},le=class extends y{constructor(){super(`offset`,`inherit`,!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}},ue=class extends y{constructor(){super(`fontSmooth`,`inherit`,!0),this._needsUpdate=!1,this.isValid=fe,this.output=this._outputValue}},de=[`inherit`,`none`,`antialiased`];function fe(e){return de.indexOf(e)===-1?(console.warn(`.fontSmoothing value '${e}' is not valid. Aborted`),!1):!0}var b=(e=>{var t={};return p.d(t,e),t})({BackSide:()=>1,BufferAttribute:()=>ie,BufferGeometry:()=>a,Color:()=>t,DoubleSide:()=>2,EventDispatcher:()=>te,FileLoader:()=>d,FrontSide:()=>0,LinearFilter:()=>r,Mesh:()=>o,MeshBasicMaterial:()=>i,Object3D:()=>l,Plane:()=>s,PlaneGeometry:()=>re,ShaderMaterial:()=>ne,Texture:()=>u,TextureLoader:()=>c,Vector2:()=>ee,Vector3:()=>n,Vector4:()=>f}),x=class extends v{constructor(e,t,n=!0){super(e,`unset`,n),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(let t of e._children._uis){let e=t[`_${this._id}`];(e._input?e._input:e._value)===`inherit`&&(t[`_${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;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}},S=class extends x{constructor(e,t){super(e,t,!1),this._input=new b.Vector4(0,0,0,0),this._inline=null,this._value=new b.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 b.Vector4){e.copy(t);return}if((typeof t==`string`||t instanceof String)&&(t=t.split(` `)),Array.isArray(t))switch(t=t.map(e=>parseFloat(e)),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)}},pe=class extends S{constructor(){super(`padding`,new b.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)}},me=class extends S{constructor(){super(`margin`,new b.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}},he=function(e,t,n){e[t]=n},ge=function(e,t,n){n!==null&&(e[t]=n)},C=class{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,n,r=null){for(let e in this._definition){let i=this._definition[e];if(n[e]!==void 0){let a=i.t?i.t:he;a(t,i.m,n[e]),r&&a(r,i.m,n[e])}}}static mediate(e,t,n,r,i=null){if(t)for(let e in r){let a=r[e];if(n[e]!==void 0){let r=a.t?a.t:he;r(t,a.m,n[e]),i&&r(i,a.m,n[e])}}}},_e=class extends v{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}},w=function(e,t,n=6){return e.toFixed(n)===t.toFixed(n)},ve=class extends v{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(w(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}},ye=class extends y{constructor(e){super(e,`inherit`,!0),this.isValid=xe}},be=[b.FrontSide,b.BackSide,b.DoubleSide];function xe(e){return be.indexOf(e)===-1?(console.warn(`SideProperty value '${e}' is not valid. Abort`),!1):!0}var Se=class{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}},Ce=class{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 Error(`Abstract... Need to be implemented`)}asInlineGlyph(){throw Error(`Abstract... Need to be implemented`)}},we=class extends Se{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}},Te={light:`100`,normal:`400`,bold:`700`,bolder:`900`};function T(e){return isNaN(e)?Te[e]||e:e.toString()}var Ee=class extends b.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=T(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[` `];let n=this._getFallbackCharacter(e);if(n&&(t=this._chars[n],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 Error(`FontVariant(${typeof this})::_getFallbackCharacter() is abstract and should therefore be overridden.`)}getGeometricGlyph(e,t){throw 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(let t in e){let n=this.getTypographicGlyph(t),r=e[t];for(let i in r)n[`_`+i]=e[t][i]}}_checkReadiness(){this._readyCondition()&&Oe(this)}_alterElementProperties(e){throw Error(`FontVariant(${typeof this})::_alterElementProperties() is abstract and should therefore be overridden.`)}_readyCondition(){throw Error(`FontVariant(${typeof this})::_readyCondition() is abstract and should therefore be overridden.`)}},De={type:`ready`};function Oe(e){e._isReady=!0,e.dispatchEvent(De)}var E=Ee,ke=class extends v{constructor(e=null){super(`font`,e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=Ae}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 E)this._fontVariant=this._value;else{let t=e._fontFamily._value;t&&(this._fontVariant=t.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=je(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),null),this._value=null,this._fontVariant=null}};function Ae(e){return e instanceof E?!0:(console.warn(`.font value '${e}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function je(e,t){return function(){t._needsUpdate=!0,e._glyphs._needsProcess=!0,t._fontVariant.removeEventListener(`ready`,t._handleFontReadyClosure),t._handleFontReadyClosure=null}}var Me=class extends x{constructor(e){super(`display`,e),this._value=`flex`,this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=Pe}computeOutputValue(e){e._visible._value=this._output!==`none`}},Ne=[`none`,`flex`];function Pe(e){return Ne.indexOf(e)===-1?(console.warn(`(.style) display value '${e}' is not valid. Aborted`),!1):!0}var Fe=class extends x{constructor(e){super(`boxSizing`,e),this._allowsInherit=!1,this.isValidValue=Le}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}},Ie=[`border-box`,`content-box`];function Le(e){return Ie.indexOf(e)===-1?(console.warn(`(.style) boxSizing value '${e}' is not valid. Aborted`),!1):!0}var D=class extends x{constructor(e,t){super(e,t,!1),this._value=new b.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}},O=class extends x{constructor(e,t){super(e,t,!0),this.isValidValue=Re,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 Re(e){return e<0&&e>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${e}' is not valid)`),!1):!0}var ze=class extends x{constructor(e){super(`backgroundImage`,e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new b.Vector2(1,1),this.isValidValue=Be}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 b.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 Be(e){return!0}var Ve=class extends x{constructor(e){super(`backgroundSize`,e,!0),this.isValidValue=Ue,this.output=this._outputValue}},He=[`cover`,`contain`,`stretch`];function Ue(e){return He.indexOf(e)===-1?(console.warn(`(.style) backgroundSize value '${e}' is not valid. Aborted`),!1):!0}var We=class extends x{constructor(e){super(`overflow`,e,!0),this.isValidValue=Ke,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(let t of e._children._uis)t._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);let t=e._parent._value;if(t!==null){let e=t._overflow;if((e._value===`hidden`||e._clippingPlanes!==null)&&!this._clippingPlanes){this._clippingPlanes=[new b.Plane(new b.Vector3(0,-1,0),1),new b.Plane(new b.Vector3(-1,0,0),1),new b.Plane(new b.Vector3(0,1,0),1),new b.Plane(new b.Vector3(1,0,0),1)];for(let e=0;e<this._clippingPlanes.length;e++)this._clippingPlanes[e].parent=t;e._clippingPlanes!==null&&this._clippingPlanes.push(...e._clippingPlanes),this._renderStrategy=this._hiddenRender,this._needsRender=!0}else (e._value===`visible`||e._clippingPlanes===null)&&this._clippingPlanes!==null&&(this._clippingPlanes=null,this._renderStrategy=this._emptyRender,this._needsRender=!0)}}render(e){this._renderStrategy(e)}_emptyRender(e){}_hiddenRender(e){let t=e._parent._value,n=t._bounds._offsetHeight,r=t._bounds._offsetWidth,i=t._padding._value,a=t._borderWidth._value;for(let e=0;e<4&&e<this._clippingPlanes.length;e++){let o=this._clippingPlanes[e];switch(e%4){case 0:o.constant=n/2-(i.x+a.x);break;case 1:o.constant=r/2-(i.y+a.y);break;case 2:o.constant=n/2-(i.z+a.z);break;case 3:o.constant=r/2-(i.w+a.w);break}o.applyMatrix4(t.matrixWorld)}for(let t=0;t<e._children._uis.length;t++){let n=e._children._uis[t];n._overflow._needsRender=!0}}_propagateRender(e){for(let t=0;t<e._children._uis.length;t++){let n=e._children._uis[t];n._overflow._needsRender=!0}}},Ge=[`visible`,`hidden`];function Ke(e){return Ge.indexOf(e)===-1?(console.warn(`(.style) overflow value '${e}' is not valid. Aborted`),!1):!0}var k=`rem`,qe=`em`,A=`%`,Je=[k,qe,A],Ye=function(e){return Je.indexOf(e)===-1?k:e},Xe=class extends S{constructor(e){super(`borderRadius`,e),this._valueUV=this._value.clone(),this._input=new b.Vector4(0,0,0,0),this._mediation=!0,this._cornerTL=new b.Vector2(0,1),this._cornerTR=new b.Vector2(1,1),this._cornerBR=new b.Vector2(1,0),this._cornerBL=new b.Vector2(0,0);let t=new j(this._valueUV,[`x`,`y`]),n=new j(this._valueUV,[`z`,`w`]),r=new j(this._valueUV,[`x`,`w`]),i=new j(this._valueUV,[`y`,`z`]);t.complementaryMediation=n,n.complementaryMediation=t,r.complementaryMediation=i,i.complementaryMediation=r,this._sideMediators=[t,n,r,i],this._units=k}set units(e){this._units=Ye(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);let t=e._bounds._offsetWidth,n=e._bounds._offsetHeight;if(this._units===A&&this._valueUV.divideScalar(100),this._units===k&&this._valueUV.divideScalar(Math.min(t,n)),this._mediation)do this._sideMediators.forEach(e=>e.computeValue()),this._sideMediators.sort((e,t)=>e.value<t.value?1:-1),this._sideMediators[0].value>1&&this._sideMediators[0].mediate();while(this._sideMediators[0].value>1);let r=t>n?n/t:1,i=t<n?t/n:1;this._units===A&&(r=i=1),this._cornerTL.x=this._valueUV.x*r,this._cornerTL.y=1-this._valueUV.x*i,this._cornerTR.x=1-this._valueUV.y*r,this._cornerTR.y=1-this._valueUV.y*i,this._cornerBR.x=1-this._valueUV.z*r,this._cornerBR.y=this._valueUV.z*i,this._cornerBL.x=this._valueUV.w*r,this._cornerBL.y=this._valueUV.w*i}dispose(){for(let 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}},j=class{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(let t of this._sideProperties)e+=this._borderRadiuses[t];this._value=e}mediate(e=!0){if(!(this._value<1)){for(let e of this._sideProperties)this._borderRadiuses[e]/=this._value;e&&this._complementaryMediation.mediate(!1)}}dispose(){this._complementaryMediation=null,this._borderRadiuses=null}},Ze=class extends S{constructor(e){super(`borderWidth`,e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=k}set units(e){this._units=Ye(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);let t=e._bounds._offsetWidth,n=e._bounds._offsetHeight;if(this._units===A&&(console.log(`Percent`),console.log(this._valueUV)),this._units===k)t!==0&&(this._valueUV.w/=t,this._valueUV.y/=t),n!==0&&(this._valueUV.x/=n,this._valueUV.z/=n);else if(this._units===qe){if(t!==0){let e=t>n?n/t:1;this._valueUV.y*=e,this._valueUV.w*=e}if(n!==0){let e=t<n?t/n:1;this._valueUV.x*=e,this._valueUV.z*=e}}}},Qe=class extends v{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}},$e=class extends D{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)}},M=class extends v{constructor(e=`untitled`){super(e,void 0,!1)}update(e,t){}output(e){}},et=class extends v{constructor(){super(`inlineJustificator`,null,!1),this._value=null}update(e,t){}process(e){let t=e._bounds._innerHeight,n=e._layouter._value,r=Math.abs(n.height),i=(()=>{switch(e._alignItems._value){case`inherit`:case`start`:return t/2;case`end`:return r-t/2;case`stretch`:case`center`:return r/2}})(),a=e._padding._value,o=e._borderWidth._value;i+=(-a.x+a.z)/2+(-o.x+o.z)/2,n.forEach(e=>{e.y+=i,e.forEach(e=>{e.offsetY+=i})})}},tt=[`start`,`center`,`end`,`stretch`],nt=function(e){return tt.indexOf(e)===-1?(console.warn(`(.style) alignItems value '${e}' is not valid. Aborted`),!1):!0},N=class extends x{constructor(){super(`alignItems`,`inherit`,!0),this.isValidValue=nt}},P=class extends x{constructor(){super(`textAlign`,`inherit`,!0),this.isValidValue=it}},rt=[`left`,`right`,`center`,`justify`,`justify-left`,`justify-right`,`justify-center`],it=function(e){return rt.indexOf(e)===-1?(console.warn(`(.style) textAlign value '${e}' is not valid. Aborted`),!1):!0},at=class extends x{constructor(){super(`flexDirection`,`inherit`,!0),this.isValid=st}},ot=[`row`,`row-reverse`,`column`,`column-reverse`];function st(e){return ot.indexOf(e)===-1?(console.warn(`(.style) flexDirection value '${e}' is not valid. Aborted`),!1):!0}var ct=class extends x{constructor(){super(`justifyContent`,`inherit`,!0),this.isValidValue=ut}},lt=[`start`,`center`,`end`,`space-between`,`space-around`,`space-evenly`];function ut(e){return lt.indexOf(e)===-1?(console.warn(`(.style) justifyContent value '${e}' is not valid. Aborted`),!1):!0}var dt=class extends x{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)}},ft=class extends x{constructor(){super(`position`,`static`,!0),this._allowsInherit=!1,this._value=`static`,this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=mt}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}},pt=[`static`,`absolute`];function mt(e){return pt.indexOf(e)===-1?(console.warn(`(.style) position value '${e}' is not valid. Aborted`),!1):!0}var ht=class extends x{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?e=this._input===`inherit`:(this._computed===this._input&&(e=!1),this._input=this._computed),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;let e=parseFloat(this._input.replace(`%`,``).trim());isNaN(e)||(this._value=e/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(let t of e._children._uis)t[`_${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;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return 0}get value(){return this._value}},gt=class extends ht{constructor(){super(`width`)}},_t=class extends ht{constructor(){super(`height`)}computeOutputValue(e){super.computeOutputValue(e)}},vt=class extends M{constructor(){super(`textContent`),this._needsUpdate=!1}set value(e){}process(e){let t=``;for(let n=0;n<e.children.length;n++){let r=e.children[n];r.isUI&&(t+=r.textContent)}this._value=t}},yt=class extends x{constructor(e){super(`fontStyle`,e,!0),this.isValidValue=xt}},bt=[`normal`,`italic`];function xt(e){return bt.indexOf(e)===-1?(console.warn(`(.style) fontStyle value '${e}' is not valid. Aborted`),!1):!0}var St=class extends x{constructor(){super(`fontWeight`,`inherit`,!0),this.isValid=wt}},Ct=[`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`,`light`,`normal`,`bold`,`bolder`];function wt(e){return Ct.indexOf(e.toString())===-1?(console.warn(`(.style) fontWeight value '${e}' is not valid. Aborted`),!1):!0}var Tt=class{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}},Et=class extends Tt{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(e=>e.char).join(``)}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}},Dt=class extends we{constructor(e){super(e)}get uv(){return this.typographic.uv}},Ot=class e extends Ce{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(t){return new e(this._font,{char:t,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new Dt(this)}},kt=class extends b.PlaneGeometry{constructor(e,t){let n=1,r=1,i=e.typographic.font.size,a=t._segments.value;n=Math.ceil(e.typographic.width/i*a),r=Math.ceil(e.typographic.height/i*a),super(e.width,e.height,n,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){let t=e.uv.right-e.uv.left,n=e.uv.bottom-e.uv.top,r=this.getAttribute(`uv`).array.slice(),i=[];for(let a=0;a<r.length;a+=2){let o=r[a],s=r[a+1];i.push(e.uv.left+t*o),i.push(e.uv.top+n*s)}this.setAttribute(`uvG`,new b.BufferAttribute(new Float32Array(i),2))}_nullifyUVs(){let e=[],t=this.getAttribute(`uv`).array.length;for(let n=0;n<t;n++)e.push(0);this.setAttribute(`uvG`,new b.BufferAttribute(new Float32Array(e),2))}_transformGeometry(e){this.translate(e.width/2,-e.height/2,0)}},At=`
|
|
attribute vec2 uvG;
|
|
varying vec2 vUvG;
|
|
`,jt=`
|
|
vUvG = uvG;
|
|
`,F=`
|
|
gl_Position.z -= 0.00001;
|
|
`,I=`
|
|
varying vec2 vUvG;
|
|
uniform sampler2D glyphMap;
|
|
uniform vec2 unitRange;
|
|
// functions from the original msdf repo:
|
|
// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field
|
|
float median(float r, float g, float b) {
|
|
return max(min(r, g), min(max(r, g), b));
|
|
}
|
|
float screenPxRange() {
|
|
|
|
// precomputed unitRange as recommended by Chlumsky
|
|
// vec2 unitRange = vec2(pxRange)/vec2(textureSize(glyphMap, 0));
|
|
vec2 screenTexSize = vec2(1.0)/fwidth(vUvG);
|
|
return max(0.5*dot(unitRange, screenTexSize), 1.0);
|
|
}
|
|
float tap(vec2 offsetUV) {
|
|
vec3 msd = texture( glyphMap, offsetUV ).rgb;
|
|
float sd = median(msd.r, msd.g, msd.b);
|
|
float screenPxDistance = screenPxRange() * (sd - 0.5);
|
|
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
return alpha;
|
|
}
|
|
`,L=`
|
|
float alpha;
|
|
#ifdef NO_RGSS
|
|
|
|
alpha = tap( vUvG );
|
|
|
|
#else
|
|
|
|
// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec
|
|
// per pixel partial derivatives
|
|
vec2 dx = dFdx(vUvG);
|
|
vec2 dy = dFdy(vUvG);
|
|
// rotated grid uv offsets
|
|
vec2 uvOffsets = vec2(0.125, 0.375);
|
|
vec2 offsetUV = vec2(0.0, 0.0);
|
|
// supersampled using 2x2 rotated grid
|
|
alpha = 0.0;
|
|
offsetUV.xy = vUvG + uvOffsets.x * dx + uvOffsets.y * dy;
|
|
alpha += tap(offsetUV);
|
|
offsetUV.xy = vUvG - uvOffsets.x * dx - uvOffsets.y * dy;
|
|
alpha += tap(offsetUV);
|
|
offsetUV.xy = vUvG + uvOffsets.y * dx - uvOffsets.x * dy;
|
|
alpha += tap(offsetUV);
|
|
offsetUV.xy = vUvG - uvOffsets.y * dx + uvOffsets.x * dy;
|
|
alpha += tap(offsetUV);
|
|
alpha *= 0.25;
|
|
|
|
#endif
|
|
|
|
alpha = clamp( alpha, 0.0, 1.0 );
|
|
|
|
#ifdef INVERT_ALPHA
|
|
|
|
alpha = 1.0 - alpha;
|
|
|
|
#endif
|
|
|
|
diffuseColor.a *= alpha;
|
|
`,R=function(e,t,n){e.alphaTest=n,z(e,`USE_ALPHATEST`,n>0)},z=function(e,t,n){e.defines&&(n?e.defines[t]===void 0&&(e.defines[t]=``,e.needsUpdate=!0):e.defines[t]!==void 0&&(delete e.defines[t],e.needsUpdate=!0))},Mt=function(e,t,n){e.defines[t]&&e.defines[t]===n||(e.defines[t]=n,e.needsUpdate=!0)},B=function(e,t,n){e.userData[t]?e.userData[t].value=n:e.uniforms[t].value=n},Nt=function(e,t,n){e.userData[t].value=n},V=class e{static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||={}}static ensureUserData(e,t){e.userData.glyphMap={value:t.glyphMap},e.userData.unitRange={value:new b.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(t){e.injectVertexShaderChunks(t),e.injectFragmentShaderChunks(t)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace(`#include <uv_pars_vertex>`,`#include <uv_pars_vertex>
|
|
`+At),e.vertexShader=e.vertexShader.replace(`#include <uv_vertex>`,`#include <uv_vertex>
|
|
`+jt),e.vertexShader=e.vertexShader.replace(`#include <project_vertex>`,`#include <project_vertex>
|
|
`+F)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace(`#include <uv_pars_fragment>`,`#include <uv_pars_fragment>
|
|
`+I),e.fragmentShader=e.fragmentShader.replace(`#include <alphamap_fragment>`,`#include <alphamap_fragment>
|
|
`+L)}static from(t){return class extends t{static get fontMaterialProperties(){return e.mediation}constructor(t={}){e.ensureMaterialOptions(t),super(t),e.ensureDefines(this),e.ensureUserData(this,t),this._userDefinedOnBeforeCompile=e=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(e){this._userDefinedOnBeforeCompile=e}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=t=>{e.bindUniformsWithUserData(t,this),e.injectShaderChunks(t),this._userDefinedOnBeforeCompile(t)}}}static get mediation(){return Pt}},Pt={clippingPlanes:{m:`clippingPlanes`},fontAlphaTest:{m:`alphaTest`,t:R},fontSide:{m:`side`},font:{m:`glyphMap`,t:function(e,t,n){let r=n?n.texture:null,i=n?n.unitRange:new b.Vector2;if(e[t]!==void 0){e.glyphMap=r,e.unitRange=i;return}e.userData&&e.userData.glyphMap&&(e.userData.glyphMap.value=r,e.userData.unitRange.value=i)}},color:{m:`color`},fontOpacity:{m:`opacity`},fontSmooth:{m:`NO_RGSS`,t:function(e,t,n){n&&n!==`antialiased`?e.defines.NO_RGSS=``:delete e.defines.NO_RGSS,e.needsUpdate=!0}},invertAlpha:{m:`INVERT_ALPHA`,t:z}},Ft=`
|
|
${At}
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
${jt}
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
${F}
|
|
#include <clipping_planes_vertex>
|
|
}
|
|
`,It=`
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
${I}
|
|
#include <alphatest_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
// instead of <color_fragment> : vec4 diffuseColor
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
${L}
|
|
#include <alphatest_fragment>
|
|
// instead of <output_fragment>
|
|
gl_FragColor = diffuseColor;
|
|
#include <clipping_planes_fragment>
|
|
}
|
|
`,Lt=.02,Rt=class e extends b.ShaderMaterial{static get mediation(){return V.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new b.Vector2(0,0)},alphaTest:{value:Lt}},transparent:!0,clipping:!0,vertexShader:Ft,fragmentShader:It,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===e}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}},zt=class extends E{constructor(e,t,n,r){if(super(e,t),this._unitRange=new b.Vector2(1,1),n.pages?this._buildData(n):Bt(this,n),r instanceof b.Texture)this._texture=r,this._buildTexture(r);else if(typeof r==`string`||r instanceof String)Vt(this,r);else throw Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=Rt,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 Et(e),this._kernings=this._buildKerningPairs(e),this._chars=this._buildCharacters(e),this._chars[` `]=this._buildCharacterWhite(e),this._chars[`
|
|
`]=this._buildCharacterWhite(e,`
|
|
`,.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 b.Vector2(this._distanceRange,this._distanceRange).divide(new b.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=b.LinearFilter,e.magFilter=b.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return W.missingCharacter(this,e)}getGeometricGlyph(e,t){return new kt(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){let t={};for(let n=0;n<e.kernings.length;n++){let r=e.kernings[n];if(r.amount===0)continue;let i=String.fromCharCode(r.first,r.second);t[i]=r.amount}return t}_buildCharacters(e){let t={};for(let n=0;n<e.chars.length;n++){let r=e.chars[n];t[r.char]=new Ot(this._font,r)}return t}_buildCharacterWhite(e,t=` `,n=1,r=1){return new Ot(this._font,{char:t,width:e.info.size/3*n,height:e.info.size*.7*r})}_alterElementProperties(e){}};function Bt(e,t){new b.FileLoader().setResponseType(`json`).load(t,t=>{e._buildData(t),e._checkReadiness()})}function Vt(e,t){e._texture=new b.TextureLoader().load(t,t=>{e._buildTexture(t),e._checkReadiness()})}var H=class extends b.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,n,r,i=!1){if(i||!this.getVariant(e,t)){this._isReady=!1;let i=new zt(e,t,n,r);this._variants.push(i),i.isReady?this._checkReadiness():i.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=T(e),this._variants.find(n=>n.weight===e&&n.style===t)}get name(){return this._name}_checkReadiness=()=>{this._variants.every(e=>e.isReady)&&Ut(this)}},Ht={type:`ready`};function Ut(e){e._isReady=!0,e.dispatchEvent(Ht)}var U={},Wt=function(e){let t=[...arguments];t.forEach(e=>{if(!(e instanceof H))throw Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof e} given.`)});let n=function(){return t.every(e=>e.isReady)};return new Promise((e,r)=>{if(n())e();else for(let r=0;r<t.length;r++){let i=t[r];i.isReady||i.addEventListener(`ready`,()=>{n()&&e()})}})},Gt=function(e){return U[e]&&console.error(`FontLibrary::addFontFamily - Font('${e}') is already registered`),U[e]=new H(e),U[e]},Kt=function(e){return U[e]},qt=function(e){Jt=e},Jt=function(e,t){return console.error(`The character '${t}' is not included in the font characters set.`),` `};function Yt(e,t){return Jt(e,t)}var W={addFontFamily:Gt,getFontFamily:Kt,prepare:Wt,setMissingCharacterHandler:qt,missingCharacter:Yt},Xt=class extends x{constructor(){super(`fontFamily`,`inherit`,!0)}computeOutputValue(e){if(this._input instanceof H)this._value=this._input;else if(this._input!==`inherit`)if(typeof this._input==`string`){let e=W.getFontFamily(this._input);e?this._value=e: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;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}},Zt=class extends x{constructor(){super(`lineHeight`,`inherit`,!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}},Qt=class extends x{constructor(){super(`whiteSpace`,`inherit`),this.isValidValue=en}},$t=[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`];function en(e){return $t.indexOf(e)===-1?(console.warn(`(.style) whiteSpace value '${e}' is not valid. Aborted`),!1):!0}var tn=class extends x{constructor(){super(`letterSpacing`,`inherit`,!0)}},nn=class extends x{constructor(){super(`fontSize`,`inherit`,!0)}},rn=class extends v{constructor(){super(`segments`,1,!1)}},an=class extends y{constructor(){super(`invertAlpha`,`inherit`)}},G=class extends x{constructor(){super(`fontKerning`,`inherit`),this.isValidValue=sn}},on=[`normal`,`none`,`inherit`];function sn(e){return on.indexOf(e)===-1?(console.warn(`(.style) fontKerning value '${e}' is not valid. Aborted`),!1):!0}var K=class extends y{constructor(e){super(e,`inherit`,!0)}},cn=class extends y{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:R},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,n=null;for(;t._parent._value;)if(t=t._parent._value,t[`_${this._id}`]._value!==`inherit`){n=t[`_${this._id}`]._value;break}return n===null?this.getDefaultValue():n}getDefaultValue(){return this._defaultMaterial}},ln=function(e,t,n){e.traverse(e=>{e.renderOrder=n})},q=class extends b.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:ln}},this._fontMesh=null,this._fontMaterial=new cn(`fontMaterial`),this._fontCustomDepthMaterial=new cn(`fontCustomDepthMaterial`),this._fontMeshMediation={fontMaterial:{m:`material`},fontCustomDepthMaterial:{m:`customDepthMaterial`,t:ge},fontCastShadow:{m:`castShadow`},fontReceiveShadow:{m:`receiveShadow`},renderOrder:{m:`renderOrder`}},this._children=e.children?new e.children:new M(`children`),this._parent=new _e,this.addEventListener(`added`,this._rebuildParentUI),this.addEventListener(`removed`,this._rebuildParentUI),this._backgroundSide=new ye(`backgroundSide`),this._fontSide=new ye(`fontSide`),this._backgroundAlphaTest=new ve(`backgroundAlphaTest`,.02),this._fontAlphaTest=new ve(`fontAlphaTest`,.02),this._visible=new Qe(`visible`,!0),this._backgroundCastShadow=new K(`backgroundCastShadow`),this._fontCastShadow=new K(`fontCastShadow`),this._backgroundReceiveShadow=new K(`backgroundReceiveShadow`),this._fontReceiveShadow=new K(`fontReceiveShadow`),this._renderOrder=new ce,this._segments=e.segments?new e.segments:new rn,this._bounds=e.bounds?new e.bounds:new M(`bounds`),this._order=new dt,this._padding=new pe,this._margin=new me,this._position=new ft,this._flexDirection=e.flexDirection?new e.flexDirection:new at,this._justifyContent=e.justifyContent?new e.justifyContent:new ct,this._alignItems=e.alignItems?new e.alignItems:new N,this._display=new Me(`flex`),this._boxSizing=new Fe(`border-box`),this._width=new gt,this._height=new _t,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new $e,this._backgroundOpacity=new O(`backgroundOpacity`,.5),this._backgroundImage=new ze,this._backgroundSize=new Ve(`cover`),this._color=e.color?new e.color:new D(`color`,`inherit`),this._fontOpacity=new O(`fontOpacity`,`inherit`),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Qt,this._fontFamily=e.fontFamily?new e.fontFamily:new Xt,this._fontStyle=e.fontStyle?new e.fontStyle:new yt(`normal`),this._fontWeight=e.fontWeight?new e.fontWeight:new St,this._fontSize=e.fontSize?new e.fontSize:new nn,this._lineHeight=e.lineHeight?new e.lineHeight:new Zt,this._fontKerning=e.fontKerning?new e.fontKerning:new G,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new tn,this._overflow=new We(`visible`),this._borderRadius=new Xe(0),this._borderWidth=new Ze(0),this._borderColor=new D(`borderColor`,16711935),this._borderOpacity=new O(`borderOpacity`,1),this._font=new ke,this._lineBreak=e.lineBreak?new e.lineBreak:new M(`lineBreak`),this._textContent=e.textContent?new e.textContent:new vt,this._glyphs=e.glyphs?new e.glyphs:new M(`glyphs`),this._inlines=e.inlines?new e.inlines:new M(`inlines`),this._layouter=e.layouter?new e.layouter:new M(`layouter`),this._inlineJustificator=new et,this._textAlign=e.textAlign?new e.textAlign:new P,this._autoSize=e.autoSize?new e.autoSize:new M(`autoSize`),this._renderer=e.renderer?new e.renderer:new M(`renderer`),this._offset=new le,this._invertAlpha=new an,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new ue,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||=0,t&&this.set(t)}update(){let e={};for(let t of this._components)t._needsUpdate&&=(t.update(this,e),!1);this._transferToBackgroundMesh(e),this._transferToFontMesh(e),this._transferToBackgroundMaterial(e),this._transferToFontMaterial(e);for(let e of this._children._uis)e.update()}process(){for(let e of this._children._uis)e.process();for(let e of this._components)e._needsProcess&&=(e.process(this),!1)}render(){for(let e=0;e<this._components.length;e++){let t=this._components[e];t._needsRender&&=(t.render(this),!1)}for(let 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)){let t=e.fontFamily.pages?e.fontFamily.info.face:e.fontFamily,n=W.getFontFamily(t);if(!n){let r=e.fontStyle?e.fontStyle:`normal`,i=e.fontWeight?e.fontWeight:`400`;n=W.addFontFamily(t).addVariant(i,r,e.fontFamily,e.fontTexture)}e.fontFamily=n,delete e.fontTexture}for(let t of Object.keys(e)){let n=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=n;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=n);break;case`paddingTop`:this._padding.top=n;break;case`paddingRight`:this._padding.right=n;break;case`paddingBottom`:this._padding.bottom=n;break;case`paddingLeft`:this._padding.left=n;break;case`marginTop`:this._margin.top=n;break;case`marginRight`:this._margin.right=n;break;case`marginBottom`:this._margin.bottom=n;break;case`marginLeft`:this._margin.left=n;break;case`borderTopWidth`:this._borderWidth.top=n;break;case`borderRightWidth`:this._borderWidth.right=n;break;case`borderBottomWidth`:this._borderWidth.bottom=n;break;case`borderLeftWidth`:this._borderWidth.left=n;break;case`borderTopLeftRadius`:this._borderRadius.topLeft=n;break;case`borderTopRightRadius`:this._borderRadius.topRight=n;break;case`borderBottomRightRadius`:this._borderRadius.bottomRight=n;break;case`borderBottomLeftRadius`:this._borderRadius.bottomLeft=n;break;case`side`:case`castShadow`:case`receiveShadow`:let e=t.charAt(0).toUpperCase()+t.substr(1);this[`_background${e}`].value=n,this[`_font${e}`].value=n;break;case`fontSide`:case`backgroundSide`:case`fontCastShadow`:case`backgroundCastShadow`:case`fontReceiveShadow`:case`backgroundReceiveShadow`:case`fontMaterial`:case`fontCustomDepthMaterial`:this[`_${t}`].value=n;break;default:this[`_${t}`]===void 0?this[t]=n:this[`_${t}`].value=n}}}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?(J.register(this),this.activatePseudoState(`root`)):(J.remove(this),this.deactivatePseudoState(`root`))};add(e){let t=!1;for(let e=0;e<arguments.length;e++)super.add(arguments[e]),arguments[e].isUI&&(t=!0);return t&&this._rebuildChildrenLists(),this}remove(e){for(let e of Object.keys(arguments))arguments[e].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,B(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(let t of this._components)t.output(e)}C.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){let t=this._fontMaterial.value;if(t){if(!e){e={};for(let t of this._components)t.output(e)}C.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(let t of this._components)t.output(e)}C.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&&B(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(let t of this._components)t.output(e)}C.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){let 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){let n=this[`_${e}`],r=this._components.indexOf(n);return this._components[r]=this[`_${e}`]=t,t.needsUpdate=!0,n}},J=class{static register(e){this.elements.includes(e)||this.elements.push(e)}static remove(e){let t=this.elements.indexOf(e);t!==-1&&this.elements.splice(t,1)}static update(){for(let e of this.elements)e.update(),e.process(),e.process(),e.render()}};J.elements=[];var Y=`
|
|
|
|
// FrameBorder vertex pars
|
|
attribute vec2 uvB;
|
|
varying vec2 vUvB;
|
|
|
|
`,X=`
|
|
|
|
// FrameBorder vertex shader
|
|
vUvB = uvB;
|
|
|
|
`,un=`
|
|
|
|
// borders sequences are : x:TOP, y:RIGHT, z:BOTTOM, w:LEFT
|
|
uniform vec4 borderWidth;
|
|
uniform vec3 borderColor;
|
|
uniform float borderOpacity;
|
|
uniform vec4 borderRadius;
|
|
|
|
uniform vec2 cornerTL;
|
|
uniform vec2 cornerTR;
|
|
uniform vec2 cornerBR;
|
|
uniform vec2 cornerBL;
|
|
|
|
varying vec2 vUvB;
|
|
|
|
float getEllipticFactor( vec2 uv, vec2 center, float radiusX, float radiusY )
|
|
{
|
|
|
|
float edx = uv.x - center.x;
|
|
float edy = uv.y - center.y;
|
|
|
|
float ddx = (edx * edx) / (radiusX * radiusX);
|
|
float ddy = (edy * edy) / (radiusY * radiusY);
|
|
|
|
return ddx + ddy;
|
|
|
|
}
|
|
|
|
`,dn=`
|
|
|
|
vec4 borderColor = vec4( borderColor, borderOpacity );
|
|
|
|
// This could be tweak to produce more smoothing
|
|
float mult = 1.0;
|
|
|
|
// Step 1 ----------------------------------------------
|
|
// Draw the four borders ( top - right - bottom - left )
|
|
// Without worrying about radiuses ( Straight boorders )
|
|
|
|
// Top
|
|
float topBorderUVy = 1.0 - borderWidth.x;
|
|
if( borderWidth.x > 0.0 && vUvB.y > topBorderUVy )
|
|
{
|
|
|
|
float w = fwidth( 1.0 - vUvB.y ) * mult;
|
|
float step = smoothstep( topBorderUVy , topBorderUVy + w , vUvB.y );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
// Left
|
|
float leftBorderUVx = borderWidth.w;
|
|
if( borderWidth.w > 0.0 && vUvB.x < leftBorderUVx )
|
|
{
|
|
|
|
float w = fwidth( vUvB.x ) * mult ;
|
|
float step = smoothstep( leftBorderUVx , leftBorderUVx - w , vUvB.x );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
// Bottom
|
|
float bottomBorderUVy = borderWidth.z;
|
|
if( borderWidth.z > 0.0 && vUvB.y < bottomBorderUVy )
|
|
{
|
|
float w = fwidth( vUvB.y ) * mult;
|
|
float step = smoothstep( bottomBorderUVy , bottomBorderUVy - w , vUvB.y );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
}
|
|
|
|
// Right
|
|
float rightBorderUVx = 1.0 - borderWidth.y;
|
|
if( borderWidth.y > 0.0 && vUvB.x > rightBorderUVx )
|
|
{
|
|
float w = fwidth( 1.0 - vUvB.x ) * mult;
|
|
float step = smoothstep( rightBorderUVx , rightBorderUVx + w , vUvB.x );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
}
|
|
|
|
|
|
// Step 2 ----------------------------------------------
|
|
// Process each corners ( topLeft, topRight, bottomRight, bottomLeft )
|
|
// To transparentize outside radiuses
|
|
// To draw ellipse border on the corner
|
|
|
|
|
|
// Top Left corner
|
|
if( vUvB.x < cornerTL.x && vUvB.y > cornerTL.y ) {
|
|
|
|
// Only draw border if width is set
|
|
if( borderWidth.w + borderWidth.x > 0.0 ){
|
|
|
|
float borderFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x - borderWidth.w, ( 1.0 - cornerTL.y ) - borderWidth.x );
|
|
float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
// Then then radius
|
|
float radiusFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x, 1.0 - cornerTL.y );
|
|
float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
|
|
diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
|
|
|
|
}
|
|
// Bottom Left
|
|
if( vUvB.x < cornerBL.x && vUvB.y < cornerBL.y ) {
|
|
|
|
if( borderWidth.w + borderWidth.z > 0.0 ){
|
|
|
|
float borderFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x - borderWidth.w, cornerBL.y - borderWidth.z );
|
|
float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
|
|
float radiusFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x, cornerBL.y );
|
|
float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
|
|
diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
|
|
|
|
}
|
|
// Top Right
|
|
if( vUvB.x > cornerTR.x && vUvB.y > cornerTR.y ) {
|
|
|
|
if( borderWidth.y + borderWidth.x > 0.0 ){
|
|
|
|
float borderFactor = getEllipticFactor( vUvB, cornerTR, ( 1.0 - cornerTR.x ) - borderWidth.y, ( 1.0 - cornerTR.y ) - borderWidth.x );
|
|
float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
float radiusFactor = getEllipticFactor( vUvB, cornerTR, 1.0 - cornerTR.x, 1.0 - cornerTR.y );
|
|
float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
|
|
diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
|
|
|
|
}
|
|
// Bottom Right
|
|
if( vUvB.x > cornerBR.x && vUvB.y < cornerBR.y ) {
|
|
|
|
if( borderWidth.y + borderWidth.z > 0.0 ){
|
|
|
|
float borderFactor = getEllipticFactor( vUvB, cornerBR, ( 1.0 - cornerBR.x ) - borderWidth.y, cornerBR.y - borderWidth.z );
|
|
float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );
|
|
diffuseColor = mix( diffuseColor, borderColor, step );
|
|
|
|
}
|
|
|
|
float radiusFactor = getEllipticFactor( vUvB, cornerBR, 1.0 - cornerBR.x, cornerBR.y );
|
|
float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );
|
|
diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );
|
|
|
|
}
|
|
|
|
`,fn=`
|
|
|
|
// To be removed - required for both border and background
|
|
uniform vec3 frameSize;
|
|
uniform vec2 textureSize;
|
|
|
|
`,pn=`
|
|
|
|
#ifdef USE_MAP
|
|
|
|
vec4 sampleTexture() {
|
|
|
|
vec2 uv = vUv;
|
|
|
|
// default stretch
|
|
#if BACKGROUND_MAPPING != 0
|
|
|
|
float textureRatio = textureSize.x / textureSize.y;
|
|
float panelRatio = frameSize.x / frameSize.y;
|
|
float ratio = panelRatio / textureRatio;
|
|
float ratio2 = textureRatio / panelRatio;
|
|
|
|
// contain
|
|
#if BACKGROUND_MAPPING == 1
|
|
if ( textureRatio < panelRatio ) { // repeat on X
|
|
float newX = uv.x * ratio;
|
|
newX += 0.5 - 0.5 * ratio;
|
|
uv.x = newX;
|
|
} else { // repeat on Y
|
|
float newY = uv.y * ratio2;
|
|
newY += 0.5 - 0.5 * ratio2;
|
|
uv.y = newY;
|
|
}
|
|
#else
|
|
// cover
|
|
if ( textureRatio < panelRatio ) { // stretch on Y
|
|
float newY = uv.y * ratio2;
|
|
newY += 0.5 - 0.5 * ratio2;
|
|
uv.y = newY;
|
|
} else { // stretch on X
|
|
float newX = uv.x * ratio;
|
|
newX += 0.5 - 0.5 * ratio;
|
|
uv.x = newX;
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return texture2D( map, uv );
|
|
|
|
}
|
|
#endif
|
|
`,mn=`
|
|
#ifdef USE_MAP
|
|
|
|
vec4 textureSample = sampleTexture();
|
|
diffuseColor *= textureSample;
|
|
|
|
#endif
|
|
`,hn={msdfAlphaglyphParsVertexGlsl:At,msdfAlphaglyphVertexGlsl:jt,msdfOffsetglyphVertexGlsl:F,msdfAlphaglyphParsFragmentGlsl:I,msdfAlphaglyphFragmentGlsl:L,frameBorderParsVertexGlsl:Y,frameBorderVertexGlsl:X,frameCommonParsFragmentGlsl:fn,frameBorderParsFragmentGlsl:un,frameBorderFragmentGlsl:dn,frameBackgroundParsFragmentGlsl:pn,frameBackgroundFragmentGlsl:mn},gn=`
|
|
// Would be automatic on three materials and from USE_UV
|
|
#ifdef USE_MAP
|
|
varying vec2 vUv;
|
|
#endif
|
|
|
|
${Y}
|
|
|
|
#include <clipping_planes_pars_vertex>
|
|
|
|
void main() {
|
|
|
|
#ifdef USE_MAP
|
|
vUv = uv;
|
|
#endif
|
|
|
|
${X}
|
|
|
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
|
|
#include <clipping_planes_vertex>
|
|
|
|
}
|
|
`,_n=`
|
|
|
|
// Basic
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
|
|
#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif
|
|
|
|
${fn}
|
|
|
|
${un}
|
|
|
|
|
|
#ifdef USE_MAP
|
|
varying vec2 vUv;
|
|
uniform sampler2D map;
|
|
#endif
|
|
|
|
${pn}
|
|
|
|
#include <clipping_planes_pars_fragment>
|
|
|
|
void main() {
|
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
|
// map
|
|
${mn}
|
|
|
|
${dn}
|
|
|
|
#ifdef USE_ALPHATEST
|
|
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
|
|
#endif
|
|
|
|
// output
|
|
gl_FragColor = diffuseColor;
|
|
|
|
|
|
#include <clipping_planes_fragment>
|
|
}
|
|
`,vn=class e{static get mediation(){return yn}static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||={}}static ensureUserData(e,t){e.userData.borderColor={value:null},e.userData.borderRadius={value:new b.Vector4(0,0,0,0)},e.userData.cornerTL={value:new b.Vector2(0,1)},e.userData.cornerTR={value:new b.Vector2(1,1)},e.userData.cornerBR={value:new b.Vector2(1,0)},e.userData.cornerBL={value:new b.Vector2(0,0)},e.userData.borderWidth={value:new b.Vector4(0,0,0,0)},e.userData.borderOpacity={value:null},e.userData.frameSize={value:new b.Vector3(1,1,1)},e.userData.textureSize={value:new b.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(t){e.injectVertexShaderChunks(t),e.injectFragmentShaderChunks(t)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace(`#include <uv_pars_vertex>`,`#include <uv_pars_vertex>
|
|
`+Y),e.vertexShader=e.vertexShader.replace(`#include <uv_vertex>`,`#include <uv_vertex>
|
|
`+X)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace(`#include <map_pars_fragment>`,`#include <map_pars_fragment>
|
|
`+pn),e.fragmentShader=e.fragmentShader.replace(`#include <map_pars_fragment>`,`#include <map_pars_fragment>
|
|
`+un),e.fragmentShader=e.fragmentShader.replace(`#include <map_pars_fragment>`,`#include <map_pars_fragment>
|
|
`+fn),e.fragmentShader=e.fragmentShader.replace(`#include <map_fragment>`,mn),e.fragmentShader=e.fragmentShader.replace(`#include <alphamap_fragment>`,dn+`
|
|
#include <alphamap_fragment>`)}},yn={clippingPlanes:{m:`clippingPlanes`},backgroundAlphaTest:{m:`alphaTest`,t:R},backgroundSide:{m:`side`},backgroundImage:{m:`map`},backgroundColor:{m:`color`},backgroundOpacity:{m:`opacity`},backgroundSize:{m:`computedBackgroundSize`,t:function(e,t,n){n=[`stretch`,`contain`,`cover`].indexOf(n),Mt(e,`BACKGROUND_MAPPING`,n)}},borderWidth:{m:`borderWidth`,t:B},borderColor:{m:`borderColor`,t:B},cornerTL:{m:`cornerTL`,t:B},cornerTR:{m:`cornerTR`,t:B},cornerBR:{m:`cornerBR`,t:B},cornerBL:{m:`cornerBL`,t:B},borderOpacity:{m:`borderOpacity`,t:B},size:{m:`frameSize`,t:B},tSize:{m:`textureSize`,t:B}},bn=class extends b.ShaderMaterial{static get mediation(){return vn.mediation}constructor(){super({uniforms:{alphaTest:{value:.02},map:{value:null},diffuse:{value:new b.Color(16777215)},opacity:{value:1},borderColor:{value:new b.Color(0)},borderOpacity:{value:0},borderRadius:{value:new b.Vector4(0,0,0,0)},cornerTL:{value:new b.Vector2(0,1)},cornerTR:{value:new b.Vector2(1,1)},cornerBR:{value:new b.Vector2(1,0)},cornerBL:{value:new b.Vector2(0,0)},borderWidth:{value:new b.Vector4(0,0,0,0)},frameSize:{value:new b.Vector3(1,1,1)},textureSize:{value:new b.Vector2(1,1)}},side:b.FrontSide,transparent:!0,clipping:!0,vertexShader:gn,fragmentShader:_n,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}},xn=class extends v{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(e=>e.visible&&e.isUI),this._boxes=this._uis.filter(e=>e.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},Sn=class extends v{constructor(){super(`bounds`,null,!1),this._size=new b.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){let n=e._width,r=e._padding._value,i=e._borderWidth._value,a=e._margin._value,o=t*(n._auto?1:n._value)-(a.y+a.w);w(o,this._offsetWidth)||(this._offsetWidth=o,this._innerWidth=this._offsetWidth-(r.y+r.w+i.y+i.w),this._centerX=Cn(e),this._propagateWidth(e),this._triggerCascadingDependencies(e))}setReferenceHeight(e,t){let n=e._height,r=e._padding._value,i=e._borderWidth._value,a=e._margin._value,o=t*(n._auto?1:n._value)-(a.x+a.z);w(o,this._offsetHeight)||(this._offsetHeight=o,this._innerHeight=this._offsetHeight-(r.x+r.z+i.x+i.z),this._centerY=Z(e),this._propagateHeight(e),this._triggerCascadingDependencies(e))}setChildrenWidth(e,t){let n=e._padding._value,r=e._borderWidth._value;this._innerWidth=t,this._offsetWidth=this._innerWidth+(n.y+n.w+r.y+r.w),this._centerX=Cn(e),this._propagateWidth(e),this._triggerCascadingDependencies(e)}setChildrenHeight(e,t){let n=e._padding._value,r=e._borderWidth._value;this._innerHeight=t,this._offsetHeight=this._innerHeight+(n.x+n.z+r.x+r.z),this._centerY=Z(e),this._propagateHeight(e),this._triggerCascadingDependencies(e)}update(e,t){let n=e._padding._value,r=e._borderWidth._value,i=e._width;!i._auto&&!i._relative&&(e._boxSizing._value===`content-box`?(this._innerWidth=i._value,this._offsetWidth=this._innerWidth+n.y+n.w+r.y+r.w):(this._offsetWidth=i._value,this._innerWidth=this._offsetWidth-(n.y+n.w+r.y+r.w)),this._centerX=Cn(e),this._needsProcess=!0,this._propagateWidth(e),this._triggerCascadingDependencies(e));let a=e._height;!a._auto&&!a._relative&&(e._boxSizing._value===`content-box`?(this._innerHeight=a._value,this._offsetHeight=this._innerHeight+n.x+n.z+r.x+r.z):(this._offsetHeight=a._value,this._innerHeight=this._offsetHeight-(n.x+n.z+r.x+r.z)),this._centerY=Z(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 wn(e)}_computeChildrenSideHeight(e){return Tn(e)}_propagateWidth(e){for(let t=0;t<e._children._boxes.length;t++){let n=e._children._boxes[t];n._width._relative&&n._bounds.setReferenceWidth(n,this._innerWidth)}}_propagateHeight(e){for(let t=0;t<e._children._boxes.length;t++){let n=e._children._boxes[t];n._height._relative&&n._bounds.setReferenceHeight(n,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 Cn(e){let t=e._padding._value,n=e._borderWidth._value;return(t.w+n.w-(t.y+n.y))/2}function Z(e){let t=e._padding._value,n=e._borderWidth._value,r=t.x+n.x;return(t.z+n.z-r)/2}function wn(e){return e._children._boxes.reduce((e,t)=>{let n=t._margin._value;return e+(t._bounds._offsetWidth+n.y+n.w)},0)}function Tn(e){return e._children._boxes.reduce((e,t)=>{let n=t._margin._value;return e+(t._bounds._offsetHeight+n.x+n.z)},0)}var En=class extends N{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=Nn,this._value){case`start`:this._childAlign=kn;break;case`end`:this._childAlign=On;break;default:this._childAlign=Dn}break;case`column`:case`column-reverse`:switch(this._process=Mn,this._value){case`start`:this._childAlign=jn;break;case`end`:this._childAlign=An;break;default:this._childAlign=Dn}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`,n=`center`,r=`center`,i=e._padding._value,a=e._borderWidth._value;t=e._flexDirection._value.indexOf(`column`)===-1?this._value===`start`?r=`top`:this._value===`end`?r=`bottom`:`centerY`:this._value===`start`?n=`left`:this._value===`end`?n=`right`:`centerX`;let o=-(i.x-i.z)/2-(a.x-a.z)/2,s=-(i.y-i.w)/2-(a.y-a.w)/2;n===`left`?s=(i.w-i.y)/2+(a.w-a.y)/2:n===`right`&&(s=-(i.y-i.w)/2-(a.y-a.w)/2),r===`top`?o=-(i.x-i.z)/2-(a.x-a.z)/2:r===`bottom`&&(o=(i.z-i.x)/2+(a.z-a.x)/2),e._children._boxes.forEach(n=>{let r=0,i=0;t===`top`?i=-n._margin._value.x:t===`bottom`?i=n._margin._value.z:t===`left`?r=n._margin._value.w:t===`right`?r=-n._margin._value.y:t===`centerX`?r=(n._margin._value.w-n._margin._value.y)/2:t===`centerY`&&(i=(-n._margin._value.x+n._margin._value.z)/2),e._layouter._childrenPos[n.id].x+=s+r,e._layouter._childrenPos[n.id].y+=o+i})}};function Dn(){return 0}function On(e,t){return-t+e._bounds._offsetHeight/2}function kn(e,t){return t-e._bounds._offsetHeight/2}function An(e,t){return t-e._bounds._offsetWidth/2}function jn(e,t){return-t+e._bounds._offsetWidth/2}function Mn(e,t){let n=e._bounds._innerWidth/2;e._children._boxes.forEach(r=>{e._layouter._childrenPos[r.id].x=t(r,n)})}function Nn(e,t){let n=e._bounds._innerHeight/2;e._children._boxes.forEach(r=>{e._layouter._childrenPos[r.id].y=t(r,n)})}var Pn=class extends at{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=Fn;break;case`row-reverse`:this._process=In;break;case`column`:this._process=Ln;break;case`column-reverse`:this._process=Rn;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 Fn(e){let t=e._flexDirection._offset,n=e._flexDirection._reverse,r=e._children._boxes;for(let i=0;i<r.length;i++){let a=r[i],o=a.id,s=a._bounds._offsetWidth;t+=a._margin._value.w*n;let c=e._layouter._childrenPos[o];c.x=t+s/2*n,c.y=0,t+=n*(s+a._margin._value.y)}}function In(e){let t=e._flexDirection._offset,n=e._flexDirection._reverse,r=e._children._boxes;for(let i=0;i<r.length;i++){let a=r[i],o=a.id,s=a._bounds._offsetWidth;t+=a._margin._value.y*n;let c=e._layouter._childrenPos[o];c.x=t+s/2*n,c.y=0,t+=(s+a._margin._value.w)*n}}function Ln(e){let t=e._flexDirection._offset,n=e._flexDirection._reverse,r=e._children._boxes;for(let i=0;i<r.length;i++){let a=r[i],o=a.id,s=a._bounds._offsetHeight;t+=a._margin._value.x*n;let c=e._layouter._childrenPos[o];c.x=0,c.y=t+s/2*n,t+=(s+a._margin._value.z)*n}}function Rn(e){let t=e._flexDirection._offset,n=e._flexDirection._reverse,r=e._children._boxes;for(let i=0;i<r.length;i++){let a=r[i],o=a.id,s=a._bounds._offsetHeight;t+=a._margin._value.z*n;let c=e._layouter._childrenPos[o];c.x=0,c.y=t+s/2*n,t+=(s+a._margin._value.x)*n}}var zn=class extends ct{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=Vn.bind(this);break;case`row-reverse`:case`row`:this._process=Bn.bind(this);break}switch(this._value){case`end`:this._computeOffset=Wn,this._computeMargin=Kn;break;case`center`:this._computeOffset=Gn,this._computeMargin=Kn;break;case`start`:this._computeOffset=Q,this._computeMargin=Kn;break;case`space-between`:this._computeOffset=Q,this._computeMargin=qn;break;case`space-around`:this._computeOffset=Q,this._computeMargin=Yn;break;case`space-evenly`:this._computeOffset=Q,this._computeMargin=Jn;break}e._flexDirection._needsProcess=!0}process(e){this._process(e),e._alignItems._needsProcess=!0}};function Bn(e){let t=e._flexDirection._offset,{usedDirectionSpace:n,remainingSpace:r}=Hn(e),i=t*2-n*Math.sign(t),a=this._computeOffset(i),o=this._computeMargin(e,r,e._flexDirection._reverse);e._children._boxes.forEach((t,n)=>{e._layouter._childrenPos[t.id].x-=a-o[n]})}function Vn(e){let t=e._flexDirection._offset,{usedDirectionSpace:n,remainingSpace:r}=Un(e),i=t*2-n*Math.sign(t),a=this._computeOffset(i),o=this._computeMargin(e,r,e._flexDirection._reverse);e._children._boxes.forEach((t,n)=>{e._layouter._childrenPos[t.id].y-=a-o[n]})}function Hn(e){let t=e._bounds._computeChildrenSideWidth(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerWidth-t}}function Un(e){let t=e._bounds._computeChildrenSideHeight(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerHeight-t}}function Q(e){return 0}function Wn(e){return e}function Gn(e){return e/2}function Kn(e,t=0,n=1){return Array(e._children._boxes.length).fill(0)}function qn(e,t=0,n=1){let r=e._children._boxes.length,i=Array(r).fill(0);if(t>0&&r>1){let e=t/(r-1)*n;i[0]=0;for(let t=1;t<r;t++)i[t]=e*t}return i}function Jn(e,t=0,n=1){let r=e._children._boxes.length,i=Array(r).fill(0);if(t>0){let e=t/(r+1)*n;for(let t=0;t<r;t++)i[t]=e*(t+1)}return i}function Yn(e,t=0,n=1){let r=e._children._boxes.length,i=Array(r).fill(0);if(t>0){let e=t/r*n,a=e/2;i[0]=a;for(let t=1;t<r;t++)i[t]=a+e*t}return i}var Xn,Zn=class extends b.Mesh{constructor(e){let t=e.slice,n={},r=1,i=1;if(t){if(r=t.width?t.width:1,i=t.height?t.height:1,t.top){if(t.left){let e=new b.PlaneGeometry(t.left*r,t.top*i,1,1);$(e,0,t.left,1-t.top,1),e.translate(t.left*r/2,-t.top*i/2,0),n.topLeft=e}let e=new b.PlaneGeometry(1,t.top*i,1,1);if($(e,t.left,1-t.right,1-t.top,1),e.translate(0,-t.top*i/2,0),n.top=e,t.right){let e=new b.PlaneGeometry(t.right*r,t.top*i,1,1);$(e,1-t.right,1,1-t.top,1),e.translate(-t.right*r/2,-t.top*i/2,0),n.topRight=e}}if(t.left){let e=new b.PlaneGeometry(t.left*r,1,1,1);$(e,0,t.left,t.bottom,1-t.top),e.translate(t.left*r/2,0,0),n.left=e}let e=new b.PlaneGeometry(1,1,1,1);if($(e,t.left,1-t.right,t.bottom,1-t.top),n.middle=e,t.right){let e=new b.PlaneGeometry(t.right*r,1,1,1);$(e,1-t.right,1,t.bottom,1-t.top),e.translate(-t.right*r/2,0,0),n.right=e}if(t.bottom){if(t.left){let e=new b.PlaneGeometry(t.left*r,t.bottom*i,1,1);$(e,0,t.left,0,t.bottom),e.translate(t.left*r/2,t.bottom*i/2,0),n.bottomLeft=e}let e=new b.PlaneGeometry(1,t.bottom*i,1,1);if($(e,t.left,1-t.right,0,t.bottom),e.translate(0,t.bottom*i/2,0),n.bottom=e,t.right){let e=new b.PlaneGeometry(t.right*r,t.bottom*i,1,1);$(e,1-t.right,1,0,t.bottom),e.translate(-t.right*r/2,t.bottom*i/2,0),n.bottomRight=e}}}let a=e.backgroundMaterial;t&&(Xn||=new b.MeshBasicMaterial({alphaTest:1.1}),a=Xn);let o=new b.PlaneGeometry(1,1,e._segments.value,e._segments.value),s=new b.BufferAttribute(new Float32Array(o.getAttribute(`uv`).array),2);if(o.setAttribute(`uvB`,s).name=`uvB`,super(o,a),this.name=`UIBackgroundBox`,t){this.slice=t,this.sliceSize=new b.Vector3(1-(t.left+t.right),1-(t.bottom+t.top),1),this.sliceScale=new b.Vector3(r,i,1);for(let t in n){let r=new b.Mesh(n[t],e.backgroundMaterial);this.add(r),n[t]=r}this.updateScale=this.updateScaleSlice,this.slices=n}}updateScale(){}updateScaleSlice(){let e=new b.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(let e in this.slices){let t=this.slices[e];t.scale.set(1/this.scale.x,1/this.scale.y,this.scale.y);let n=Qn[e];for(let e in n)t.position[e]=this.scale[e]*n[e]*t.scale[e];let r=$n[e];if(r){r.x&&(t.position.x=this.sliceScale.x*.5*(this.slice.left-this.slice.right)*(1/this.scale.x)),r.y&&(t.position.y=this.sliceScale.y*.5*(this.slice.bottom-this.slice.top)*(1/this.scale.y));for(let e in r){let n=this.scale[e]-(1-this.sliceSize[e])*this.sliceScale[e];t.scale[e]=Math.max(0,n*(1/this.scale[e]))}}}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)}},Qn={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}},$n={top:{x:1},left:{y:1},right:{y:1},bottom:{x:1},middle:{x:1,y:1}};function $(e,t,n,r,i){let a=n-t,o=i-r,s=e.attributes.uv;for(let e=0;e<s.count;e++){let n=s.getX(e),i=s.getY(e);s.setXY(e,t+n*a,r+i*o)}let c=new b.BufferAttribute(new Float32Array(e.getAttribute(`uv`).array),2);e.setAttribute(`uvB`,c).name=`uvB`}var er=class extends v{constructor(){super(`renderer`)}render(e){e._backgroundMesh||e.setBackgroundMesh(new Zn(e)),e.performAfterUpdate()}},tr=class extends ft{constructor(){super(`position`)}update(e,t){super.update(e,t),this._needsProcess=!0}},nr=class extends v{constructor(){super(`autosize`),this._needsProcess=!0}process(e){e._width._auto&&rr(e),e._height._auto&&ir(e);let t=e._alignItems._value===`stretch`,n=t&&e._flexDirection._value.indexOf(`column`)!==-1,r=t&&!n;for(let t of e._children._boxes)(t._width._auto&&n||t._width._relative)&&t._bounds.setReferenceWidth(t,e._bounds._innerWidth),(t._height._auto&&r||t._height._relative)&&t._bounds.setReferenceHeight(t,e._bounds._innerHeight)}};function rr(e){e._bounds.setChildrenWidth(e,or(e))}function ir(e){e._bounds.setChildrenHeight(e,ar(e))}function ar(e){switch(e._flexDirection._value){case`row`:case`row-reverse`:return ur(e);case`column`:case`column-reverse`:return cr(e)}}function or(e){switch(e._flexDirection._value){case`row`:case`row-reverse`:return sr(e);case`column`:case`column-reverse`:return lr(e)}}function sr(e){let t=0;for(let n of e._children._boxes){if(n._position._value!==`static`)continue;let e=n._margin._value,r=n._bounds._offsetWidth+e.y+e.w;t+=r}return t}function cr(e){let t=0;for(let n of e._children._boxes){if(n._position._value!==`static`)continue;let e=n._margin._value,r=n._bounds._offsetHeight+e.x+e.z;t+=r}return t}function lr(e){let t=0;for(let n of e._children._boxes){if(n._position._value!==`static`)continue;let e=n._margin._value,r=n._bounds._offsetWidth+e.y+e.w;r>t&&(t=r)}return t}function ur(e){let t=0;for(let n of e._children._boxes){if(n._position._value!==`static`)continue;let e=n._margin._value,r=n._bounds._offsetHeight+e.x+e.z;r>t&&(t=r)}return t}var dr=class e extends q{constructor(t,n){e.definePropertiesValues(t,n),super(t,n),e.init(this)}bindBackgroundMeshProperties(){this._bounds._size=this._backgroundMesh.scale,this._bounds._needsProcess=!0}unbindBackgroundMeshProperties(){this._bounds._size=new b.Vector3(1,1,1),this._bounds._needsProcess=!0}static definePropertiesValues(e,t){e.children||=xn,e.bounds||=Sn,e.flexDirection||=Pn,e.justifyContent||=zn,e.alignItems||=En,e.position||=tr,e.autoSize||=nr,e.renderer||=er,t.fontSide||=0,t.invertAlpha||=!1,t.fontCastShadow||=!1,t.fontReceiveShadow||=!1,t.backgroundCastShadow||=!1,t.backgroundReceiveShadow||=!1}static init(e){Object.defineProperties(e,{isBox:{configurable:!1,enumerable:!0,value:!0}}),e.backgroundMaterial=new bn,e._renderer.render(e),e._backgroundMesh.visible=!1}},fr=class extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}},pr=class extends v{constructor(){super(`layouter`,null,!1),this._needsUpdate=!0,this._childrenPos={}}update(e,t){this._childrenPos={};for(let t of e._children._boxes)t._position._value===`static`&&(this._childrenPos[t.id]=t.position)}process(e){}},mr=class e extends dr{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}add(e){let t=[];for(let e=0;e<arguments.length;e++){let n=arguments[e];!n.isUI||n.isBox?t.push(n):console.warn(`Block element can only contain Box elements.`,n)}return super.add(...t)}static definePropertiesValues(e,t){e.layouter=pr}static init(e){Object.defineProperties(e,{isBlock:{configurable:!1,enumerable:!0,value:!0}})}},hr=class extends v{constructor(){super(`textContent`,null,!1)}update(e,t){e._glyphs._needsUpdate=!0,e._whiteSpace._needsProcess=!0}},gr=class extends v{constructor(){super(`inlines`,null,!1),this._value=null}process(e){if(this._value=e._glyphs._value.map(e=>e.asInlineGlyph()),this._value.length){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;let 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}},_r=class extends v{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}},vr=class extends D{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)}},yr=class extends v{constructor(e=`- ,.:?!
|
|
`){super(`lineBreak`,e,!0),this._newLineBreakability=null}update(e,t){this._needsProcess=!0}process(e){let t=e._whiteSpace._newLineBreakability;if(e._inlines._value)for(let n=0;n<e._inlines._value.length;n++){let r=e._inlines._value[n],i=r.char,a=null;i!==void 0&&(t!==`nowrap`&&(this._value.includes(i)||i.match(/\s/g))&&(a=`possible`),i.match(/\n/g)&&(a=t)),r.lineBreak=a}}get value(){return this._value}},br=class extends v{constructor(){super(`layouter`,null,!1),this._value=null}update(e,t){this._value=e._parent.find(e=>e.isUI&&e.isText),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}},xr=class extends D{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)}},Sr=class extends yt{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}},Cr=class extends St{constructor(){super()}computeOutputValue(e){this._value=T(this.getInheritedInput(e))}},wr=class extends Xt{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 H)this._value=t,e._font._needsUpdate=!0;else if(typeof t==`string`){let n=W.getFontFamily(t);n?(this._value=n,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}},Tr=class extends Qt{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=Dr(this._value),this._value){case`nowrap`:case`normal`:this._stringCollapser=Or;break;case`pre-line`:this._stringCollapser=kr;break;default:this._stringCollapser=Ar}switch(this._value){case`pre-line`:case`nowrap`:case`normal`:this._inlineCollapser=Fr;break;case`pre-wrap`:this._inlineCollapser=Pr;break;default:this._inlineCollapser=Ir}switch(this._value){case`pre-line`:case`pre-wrap`:case`normal`:this._inlineWrapper=jr;break;case`pre`:this._inlineWrapper=Mr;break;default:this._inlineWrapper=Nr}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}},Er={" ":` `,"\n":`
|
|
`,"\r":`\r`," ":` `},Dr=function(e){switch(e){case`pre`:case`pre-wrap`:case`pre-line`:return`mandatory`}return null};function Or(e){return kr(e.replace(/\n/g,` `))}function kr(e){return e.replace(/[ ]{2,}/g,` `)}function Ar(e){return e}function jr(e,t,n,r){let i=e[t];if(i.lineBreak===`mandatory`||n+i.xadvance+i.xoffset+i.kerning>r.INNER_WIDTH)return!0;let a=zr(e,t,r);return Br(e[t-1],n,a,r)}function Mr(e,t,n,r){return e[t].lineBreak===`mandatory`}function Nr(){return!1}function Pr(e){if(!e[0])return 0;let t=e[0],n=e[e.length-1];return t.char&&t.char===`
|
|
`&&e.length>1&&Rr([t],e[1]),n.char&&n.char===`
|
|
`&&e.length>1&&Lr([n],e[e.length-2]),t.offsetX}function Fr(e){if(!e[0])return 0;let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];if(i.char&&Er[i.char]&&e.length>r){t.push(i),n=e[r+1];continue}break}Rr(t,n),t=[],n=null;for(let r=e.length-1;r>0;r--){let i=e[r];if(i.char&&Er[i.char]&&r>0){t.push(i),n=e[r-1];continue}break}return Lr(t,n),e[0].offsetX}function Ir(e){return e[0]?e[0].offsetX:0}function Lr(e,t){if(t)for(let n=0;n<e.length;n++){let r=e[n];r.fontFactor=0,r.offsetX=t.offsetX+t.cumulativeWidth,r.cumulativeWidth=0}}function Rr(e,t){if(t)for(let n=0;n<e.length;n++){let r=e[n];r.fontFactor=0,r.offsetX=t.offsetX,r.cumulativeWidth=0}}function zr(e,t,n,r){if(r||=0,!e[t])return r;let i=e[t];return i.lineBreak?r+i.xadvance:zr(e,t+1,n,r+i.xadvance+i.xoffset+i.kerning+n.LETTERSPACING)}function Br(e,t,n,r){return!e||!e.char||t+n<r.INNER_WIDTH?!1:r.BREAKON.indexOf(e.char)>-1}var Vr=class extends tn{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}},Hr=class extends x{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;let t=this._value/e._font._fontVariant.typographic.size,n=e._inlines._value;for(let e=0;e<n.length;e++){let r=n[e];r.resetOffsets(),r.fontSize=this._value,r.fontFactor=t}}get value(){return this._value}},Ur=class extends rn{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}},Wr=class extends Ur{constructor(){super(),this._value=`inherit`}},Gr=class extends G{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`){let t=e._whiteSpace._whiteSpacedContent,n=e._inlines._value;for(let r=1;r<n.length;r++){let i=t[r-1]+t[r];n[r].kerning=e._font._fontVariant.getKerningAmount(i)}}}},Kr=class extends v{constructor(){super(`children`,null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}};function qr(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new b.BufferGeometry,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=Jr(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=Jr(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}return c}function Jr(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new b.BufferAttribute(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var Yr=class extends v{constructor(){super(`renderer`)}render(e){if(!e._inlines._value||!e._inlines._value.length)return;let t=qr(e._inlines._value.map(t=>e._font._fontVariant.getGeometricGlyph(t,e).translate(t.offsetX,t.offsetY,0)));e.setFontMesh(new b.Mesh(t,e.fontMaterial)),e._fontMesh.renderOrder=1/0}},Xr=class extends P{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}},Zr=class e extends q{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}add(e){let t=[];for(let e=0;e<arguments.length;e++){let n=arguments[e];!n.isUI||n.isInline?(t.push(n),n.position.z=.005):console.warn(`Block element can only contain Box elements.`,n)}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||=Kr,e.textContent||=hr,e.glyphs||=_r,e.inlines||=gr,e.layouter||=br,e.renderer||=Yr,e.fontFamily||=wr,e.fontWeight||=Cr,e.fontStyle||=Sr,e.fontSize||=Hr,e.color||=vr,e.backgroundColor||=xr,e.lineBreak||=yr,e.letterSpacing||=Vr,e.whiteSpace||=Tr,e.segments||=Wr,e.textAlign||=Xr,e.fontKerning||=Gr}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}},Qr=class extends vt{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 t=e.children.length-1;t>=0;t--){let n=e.children[t];n.isUI&&(e.remove(n),n.clear())}e._children._uis=[],this._value&&e.add(new Zr({name:`anonymousInline`,textContent:this._value}))}},$r=class extends Array{constructor(...e){super(...e),this.width=0,this.height=0}},ei=class extends v{constructor(){super(`layouter`,null,!1),this._value=null}update(e,t){}process(e){let t=e._width._value;t=e._width._auto?1/0:e._bounds._innerWidth;let n=e._lineHeight._value,r=new $r(new fr),i=0;e._children._inlines.forEach(e=>{if(!e._inlines.value)return;this._resetInlines(e);let n=e._fontSize._value,a=e._letterSpacing._value*n,o={WHITESPACE:e._whiteSpace._value,LETTERSPACING:a,BREAKON:e._lineBreak._value,INNER_WIDTH:t},s=e._whiteSpace._inlineWrapper;i+=e._margin._value.w+e._padding._value.w,e._inlines.value.forEach((e,t,n)=>{let c=r[r.length-1];if(s(n,t,i,o)){if(r.push(new fr(e)),e.offsetX=e.xoffset,e.width===0){i=0;return}e.cumulativeWidth=e.xadvance+a,i=e.cumulativeWidth;return}r[r.length-1].push(e),e.offsetX=i+e.xoffset+e.kerning,e.cumulativeWidth=e.xadvance+e.kerning+a,i+=e.cumulativeWidth,c.length-1==1&&c[c.length-2].width===0&&(e.offsetX-=e.xoffset,i-=e.xoffset)}),i+=e._margin._value.y+e._padding._value.y});let a=e._whiteSpace._inlineCollapser,o=0,s=0,c=0;r.forEach((e,t)=>{let i=a(e),l=0,u=0;if(e.forEach(e=>{l=Math.max(l,e.lineHeight),u=Math.max(u,e.lineBase),e.offsetX-=i}),e.lineHeight=l,e.lineBase=u,t===0?c=-(l*n-l)*.5:c-=r[t-1].lineHeight*n,e.y=c,e.x=0,e.forEach(t=>{t.offsetY=c-t.anchor,t.lineHeight<e.lineHeight&&(t.offsetY-=e.lineBase-t.lineBase)}),s+=e.lineHeight*n,e.width=0,e[0]){let t=e[e.length-1];e.width=t.offsetX+t.cumulativeWidth+t.paddingRight+t.marginRight+e[0].offsetX,o=Math.max(o,e.width)}}),r.height=s,r.width=o,this._value=r,t===1/0&&e._bounds.setChildrenWidth(e,r.width),e._height._auto&&e._bounds.setChildrenHeight(e,r.height);let l=e._parent._value;l&&(l._autoSize._needsProcess=!0,l._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}},ti=class extends P{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){ni(e),e._renderer._needsRender=!0}};function ni(e){let t=e._layouter._value,n=e._textAlign._value,r=e._bounds._innerWidth;for(let n=0;n<t.length;n++){let r=t[n],i=ri(e,r,n===t.length-1),a=e._padding._value,o=e._borderWidth._value,s=(-a.w+a.y)/2+(-o.w+o.y)/2;r.x+=i;for(let e=0;e<r.length;e++)r[e].offsetX+=i-s}if(n.indexOf(`justify`)===0)for(let e=0;e<t.length;e++){let i=t[e];if(n.indexOf(`-`)!==-1&&e===t.length-1)return;let a=r-i.width;if(a<=0)return;let o=0;for(let e=1;e<i.length-1;e++)o+=+(i[e].char===` `);let s=a/o,c=1;n===`justify-right`&&(i.reverse(),c=-1);let l=0;for(let e=1;e<=i.length-1;e++){let t=i[e];t.offsetX+=l*c,l+=t.char===` `?s:0}n===`justify-right`&&i.reverse()}}function ri(e,t,n){switch(e._textAlign._value){case`justify-left`:case`justify`:case`left`:return-e._bounds._innerWidth/2;case`justify-right`:case`right`:return-t.width+e._bounds._innerWidth/2;case`center`:return-t.width/2;case`justify-center`:return n?-t.width/2:-e._bounds._innerWidth/2;default:console.warn(`textAlign: '${e._textAlign._value}' is not valid`)}}var ii=class extends at{constructor(){super(),this._value=this._input=`column`,this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}},ai=class extends Zt{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}},oi=class extends G{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}},si=class extends Sn{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}},ci=class extends v{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(e=>e.visible&&e.isUI),this._inlines=this._uis.filter(e=>e.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},li=class extends v{constructor(){super(`autosize`)}process(e){if(e._layouter._value&&e._layouter._value.length){let t=e._layouter._value,n=e._padding._value,r=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+n.w+n.y+r.w+r.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+n.x+n.z+r.x+r.z)}}},ui=class extends er{constructor(){super(`renderer`),this._needsUpdate=!1}render(e){super.render(e);for(let t of e._children._inlines)t._renderer.render(t);e.performAfterUpdate()}},di=class e extends dr{constructor(t={},n={}){e.definePropertiesValues(n,t),super(n,t),e.init(this)}add(e){let t=[],n=!1;for(let e=0;e<arguments.length;e++){let r=arguments[e];!r.isUI||r.isInline?(r.isInline&&(n=!0),t.push(r)):console.warn(`Block element can only contain Box elements.`,r)}return t.length>0&&super.add(...t),n&&(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=ii,e.justifyContent=ct,e.alignItems=N,e.bounds=si,e.autoSize=li,e.renderer=ui,e.children||=ci,e.textContent||=Qr,e.layouter||=ei,e.lineHeight||=ai,e.textAlign||=ti,e.whiteSpace||=Tr,e.fontKerning||=oi,e.segments||=Ur,t.width||=`100%`,t.fontSide||=0}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}},fi=class extends v{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;let t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}},pi=class extends v{constructor(){super(`renderer`)}render(e){e._backgroundMesh||e.setBackgroundMesh(new Zn(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)}},mi=class extends v{constructor(){super(`bounds`,null,!1),this._size=new b.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}},hi=class e extends q{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}clear(){for(let 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 b.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){let t=[];for(let e=0;e<arguments.length;e++){let n=arguments[e];n.isUI?console.warn(`ThreeMeshUI::InlineBlockElement cannot contains UI Elements.`,n):(t.push(n),n.position.z=.005)}return super.add(...t)}static definePropertiesValues(e,t){e.children||=Kr,e.bounds||=mi,e.inlines||=fi,e.layouter||=br,e.renderer||=pi,e.fontFamily||=wr,e.fontWeight||=Cr,e.fontStyle||=Sr,e.fontSize||=Hr,e.backgroundColor||=$e,e.lineBreak||=yr,e.letterSpacing||=Vr,e.whiteSpace||=Tr,e.fontKerning||=G,t.backgroundSize||=`cover`,t.width||=`100%`,t.height||=`100%`,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 gi(e)],e.backgroundMaterial=new bn,e._renderer.render(e)}},gi=class extends Se{constructor(e){super(),this._uiElement=e}get xadvance(){let 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(){let e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){let e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){let e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){let e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}},_i=class{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw 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(){}},vi=()=>J.update(),yi={BaseProperty:v,Block:mr,Text:di,Inline:Zr,InlineBlock:hi,MeshUIBaseElement:q,FontLibrary:W,update:vi,MSDFFontMaterialUtils:V,ShaderChunkUI:hn,Behavior:_i,FontVariant:E};typeof global<`u`&&(global.ThreeMeshUI=yi);var bi=yi,xi=m.ti,Si=m.nS,Ci=m.eB,wi=m.Yp,Ti=m.VB,Ei=m.BC,Di=m.zN,Oi=m.cV,ki=m.hW,Ai=m.k2,ji=m.K6,Mi=m.M7,Ni=m.ls,Pi=m.Hi,Fi=m.EY,Ii=m.MR,Li=m.zf,Ri=m.Ay,zi=m.yo,Bi=class extends Si{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(let n in t)for(let r in t[n])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(n);for(let t of e._components)e._simpleState__statesProperties[t.id]&&(e._simpleState__normalStyles[t.id]=t.inline?t.inline:t._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;let n=[];for(let r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],n.push(r)),this._simpleState__statesProperties[r].push(e);for(let e of this._components)n.indexOf(e.id)>-1&&(this._simpleState__normalStyles[e.id]=e.inline?e.inline:e._value)}renderStates(){let e={...this._simpleState__normalStyles};for(let 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(let t in e)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=e[t]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){let t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){let t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}};export{Fi as a,ae as c,Oi as i,Ci as n,Ri as o,Ti as r,zi as s,Bi as t}; |