@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
102 lines (92 loc) • 115 kB
JavaScript
"use strict";const m=require("./three.umd.cjs");var k={};k.d=(i,e)=>{for(var t in e)k.o(e,t)&&!k.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:e[t]})};k.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e);k.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var v={};k.d(v,{ti:()=>p,nS:()=>bt,eB:()=>M,Yp:()=>oe,VB:()=>C,BC:()=>L,zN:()=>R,cV:()=>U,hW:()=>O,k2:()=>We,K6:()=>S,M7:()=>ae,ls:()=>z,Hi:()=>it,EY:()=>F,MR:()=>Ye,zf:()=>ze,Ay:()=>jr,yo:()=>xt});var oe={};k.r(oe);k.d(oe,{get:()=>Oe,set:()=>Tt});var ae={};k.r(ae);k.d(ae,{alphaTestTransformer:()=>K,asPreprocessorValueTransformer:()=>Ke,toPreprocessorTriggerTransformer:()=>ve,toUserDataTransformer:()=>$i,uniformOrUserDataTransformer:()=>w});const re={fontFamily:null,fontSize:.05,fontKerning:"auto",fontStyle:"normal",fontWeight:"normal",offset:.005,lineHeight:1.2,lineBreak:`- ,.:?!
`,whiteSpace:"pre-line",flexDirection:"column",justifyContent:"start",alignItems:"start",backgroundImage:null,textAlign:"left",boxSizing:"content-box",position:"static",color:16777215,fontColor:16777215,fontOpacity:1,opacity:1,fontPXRange:4,fontSupersampling:!0,fontSmooth:"antialiased",borderRadius:0,borderWidth:0,borderColor:"black",borderOpacity:1,backgroundSize:"cover",backgroundColor:0,backgroundOpacity:0,overflow:"visible",letterSpacing:0,invertAlpha:!1,segments:1},Tt=function(i){for(const e in i)re[e]=i[e]},Oe=function(i){return Object.prototype.hasOwnProperty.call(re,i)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${i}'`),re[i]};class p{constructor(e,t=null,s=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=s}get id(){return this._id}get value(){return this._value}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this.output(t)}output(e){}_outputValue(e){e[this._id]=this._value}process(e){}render(e){}getInheritedInput(e){if(this._value!=="inherit")return this._value;const t=e._parent._value;return t&&t[`_${this._id}`]?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return Oe(this._id)}isValid(e){return!0}emptyStrategyLogic(){throw new Error(`ThreeMeshUI::${this.constructor.name} has empty strategy. Update has not been processed.`)}requestUpdate(){this._needsUpdate=!0}requestProcess(){this._needsProcess=!1}requestRender(){this._needsRender=!1}}class Mt extends p{constructor(){super("renderOrder","auto",!0),this.output=this._outputValue,this._actualValue=0}set value(e){this.isValid(e)&&(this._value=e,this._needsUpdate=!0)}update(e,t){if(this._value!=="auto")this._actualValue=this._value;else{const s=e._parent._value;if(s!==null){const r=s._renderOrder._actualValue,n=1+s._children._uis.indexOf(e);this._actualValue=r+n}}for(const s of e._children._uis)s._renderOrder._value==="auto"&&(s._renderOrder._needsUpdate=!0);this._outputValue(t)}_outputValue(e){e[this._id]=this._actualValue}get value(){return this._value}}class R extends p{constructor(e,t=null,s=!0){super(e,t,s),this.output=this._outputValue,this._notInheritedValue=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"&&(this._notInheritedValue=this.getInheritedInput(e)),this.propagate(e),this._outputValue(t)}propagate(e){for(const t of e._children._uis){const s=t[`_${this._id}`];s!==void 0&&s._value==="inherit"&&(t[`_${this._id}`]._needsUpdate=!0)}}_outputValue(e){e[this._id]=this._notInheritedValue}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value==="inherit"?this._notInheritedValue:this._value}}class Ft extends R{constructor(){super("offset","inherit",!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}}class Ot extends R{constructor(){super("fontSmooth","inherit",!0),this._needsUpdate=!1,this.isValid=zt,this.output=this._outputValue}}const Lt=["inherit","none","antialiased"];function zt(i){return Lt.indexOf(i)===-1?(console.warn(`.fontSmoothing value '${i}' is not valid. Aborted`),!1):!0}var Wt=i=>{var e={};return k.d(e,i),e};const u=Wt({BackSide:()=>m.BackSide,BufferAttribute:()=>m.BufferAttribute,BufferGeometry:()=>m.BufferGeometry,Color:()=>m.Color,DoubleSide:()=>m.DoubleSide,EventDispatcher:()=>m.EventDispatcher,FileLoader:()=>m.FileLoader,FrontSide:()=>m.FrontSide,LinearFilter:()=>m.LinearFilter,Mesh:()=>m.Mesh,MeshBasicMaterial:()=>m.MeshBasicMaterial,Object3D:()=>m.Object3D,Plane:()=>m.Plane,PlaneGeometry:()=>m.PlaneGeometry,ShaderMaterial:()=>m.ShaderMaterial,Texture:()=>m.Texture,TextureLoader:()=>m.TextureLoader,Vector2:()=>m.Vector2,Vector3:()=>m.Vector3,Vector4:()=>m.Vector4});class g extends p{constructor(e,t,s=!0){super(e,"unset",s),this._input="inherit",this._allowsInherit=!0,this._inheritedInput=void 0,this._inline=void 0}update(e,t){this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const s of e._children._uis){const r=s[`_${this._id}`];(r._input?r._input:r._value)==="inherit"&&(s[`_${this._id}`]._needsUpdate=!0)}this.output(t)}computeOutputValue(e){this._value=this._input}_computeFromInherited(e){this._value=this._inheritedInput}set value(e){console.warn(".(style) sub-property cannot be directly set. It must comes from inline or computed setter.")}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._input=this._inline=e,this._needsUpdate=!0)}get inline(){return this._inline}isValidValue(e){return!0}getInheritedInput(e){if(this._input!=="inherit")return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class Y extends g{constructor(e,t){super(e,t,!1),this._input=new u.Vector4(0,0,0,0),this._inline=null,this._value=new u.Vector4(0,0,0,0)}get value(){return this._value}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input)}set inline(e){this._vector4ValueSetter(this._input,e),!this._input.equals(this._value)&&(this._needsUpdate=!0)}set top(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get top(){return this._input.x}set right(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get right(){return this._input.y}set bottom(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottom(){return this._input.z}set left(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get left(){return this._input.w}dispose(){this._computed=null,this._inline=null,this._input=null,this._output=null}_vector4ValueSetter(e,t){if(t instanceof u.Vector4){e.copy(t);return}if((typeof t=="string"||t instanceof String)&&(t=t.split(" ")),Array.isArray(t))switch(t=t.map(s=>parseFloat(s)),t.length){case 1:e.setScalar(t[0]);return;case 2:e.x=e.z=t[0],e.y=e.w=t[1];return;case 3:e.x=t[0],e.y=t[1],e.z=t[2];return;case 4:e.x=t[0],e.y=t[1],e.z=t[2],e.w=t[3];return;default:console.error("StyleVector4Property::set() Four Dimension property had more than four values");return}isNaN(t)||e.setScalar(t)}}class Et extends Y{constructor(){super("padding",new u.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._bounds._needsUpdate=!0,e._bounds._needsRender=!0,e._layouter._needsProcess=!0,e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}class Dt extends Y{constructor(){super("margin",new u.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}}const Ce=function(i,e,t){i[e]=t},Ht=function(i,e,t){t!==null&&(i[e]=t)};class W{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,s,r=null){for(const n in this._definition){const o=this._definition[n];if(s[n]!==void 0){const a=o.t?o.t:Ce;a(t,o.m,s[n]),r&&a(r,o.m,s[n])}}}static mediate(e,t,s,r,n=null){if(t)for(const o in r){const a=r[o];if(s[o]!==void 0){const l=a.t?a.t:Ce;l(t,a.m,s[o]),n&&l(n,a.m,s[o])}}}}class Gt extends p{constructor(){super("parent",null,!1)}update(e,t){e.parent&&e.parent.isUI?this._value=e.parent:this._value=null}set value(e){console.warn("ParentProperty is readonly")}get value(){return this._value}find(e){return this._value?e(this._value)?this._value:this._value._parent.find(e):null}dispose(){this._value=null}}const ne=function(i,e,t=6){return i.toFixed(t)===e.toFixed(t)};class Re extends p{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(ne(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}}class Be extends R{constructor(e){super(e,"inherit",!0),this.isValid=Nt}}const $t=[u.FrontSide,u.BackSide,u.DoubleSide];function Nt(i){return $t.indexOf(i)===-1?(console.warn(`SideProperty value '${i}' is not valid. Abort`),!1):!0}class Le{constructor(){this._offsetX=0,this._offsetY=0,this._lineBreak=null,this._kerning=0,this._fontFactor=1,this._fontSize=0,this._cumulativeWidth=0,this._paddingLeft=0,this._paddingRight=0,this._marginLeft=0,this._marginRight=0}resetOffsets(){this._offsetX=this._offsetY=0,this._cumulativeWidth=0}get xadvance(){return 0}get xoffset(){return 0}get yoffset(){return 0}get width(){return 0}get height(){return 0}set lineBreak(e){this._lineBreak=e}get lineBreak(){return this._lineBreak}get anchor(){return 0}get kerning(){return this._kerning*this._fontFactor}set kerning(e){this._kerning=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get lineHeight(){return 0}get offsetX(){return this._offsetX}set offsetX(e){this._offsetX=e}get offsetY(){return this._offsetY}set offsetY(e){this._offsetY=e}get cumulativeWidth(){return this._cumulativeWidth}set cumulativeWidth(e){this._cumulativeWidth=e}get marginLeft(){return this._marginLeft}set marginLeft(e){this._marginLeft=e}get marginRight(){return this._marginRight}set marginRight(e){this._marginRight=e}get paddingLeft(){return this._paddingLeft}set paddingLeft(e){this._paddingLeft=e}get paddingRight(){return this._paddingRight}set paddingRight(e){this._paddingRight=e}get lineBase(){return 0}set fontFactor(e){this._fontFactor=e}get fontFactor(){return this._fontFactor}}class ze{constructor(e){this._char="",this._width=1,this._heigth=1,this._xadvance=1,this._xoffset=0,this._yoffset=0,this._font=e}get font(){return this._font}get char(){return this._char}get width(){return this._width}get height(){return this._heigth}get xadvance(){return this._xadvance}get xoffset(){return this._xoffset}get yoffset(){return this._yoffset}set yoffset(e){this._yoffset=e}clone(e){throw new Error("Abstract... Need to be implemented")}asInlineGlyph(){throw new Error("Abstract... Need to be implemented")}}class We extends Le{constructor(e){super(),this._typographic=e}get typographic(){return this._typographic}get xadvance(){return this._typographic.xadvance*this._fontFactor}get xoffset(){return this._typographic.xoffset*this._fontFactor}get yoffset(){return this._typographic.yoffset*this._fontFactor}get width(){return this._typographic.width*this._fontFactor}get height(){return this._typographic.height*this._fontFactor}get char(){return this._typographic.char}get anchor(){return this.yoffset}get lineHeight(){return this._typographic.font.lineHeight*this._fontFactor}get lineBase(){return this._typographic.font.lineBase*this._fontFactor}}const Xt={light:"100",normal:"400",bold:"700",bolder:"900"};function ue(i){if(!isNaN(i))return i.toString();const e=Xt[i];return e||i}class jt extends u.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=ue(e),this._style=t,this._size=42,this._lineHeight=42,this._lineBase=42,this._font=null}get typographic(){return this._font}get isReady(){return this._isReady}get weight(){return this._weight}get style(){return this._style}get texture(){return this._texture}set fontMaterial(e){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get fontMaterial(){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get id(){return`${this._name}(w:${this.weight},s:${this.style})`}getTypographicGlyph(e){let t=this._chars[e];if(t)return t;if(e.match(/\s/))return this._chars[" "];const s=this._getFallbackCharacter(e);if(s&&(t=this._chars[s],t))return t;throw Error(`FontVariant('${this.id}')::getTypographicGlyph() - character('${e}') and/or fallback character were not found in provided msdf charset.`)}_getFallbackCharacter(e){throw new Error(`FontVariant(${typeof this})::_getFallbackCharacter() is abstract and should therefore be overridden.`)}getGeometricGlyph(e,t){throw new Error(`FontVariant(${typeof this})::getGeometryCharacter() is abstract and should therefore be overridden.`)}getKerningAmount(e){return this._kernings[e]?this._kernings[e]:0}adjustTypographicGlyphs(e){for(const t in e){const s=this.getTypographicGlyph(t),r=e[t];for(const n in r)s["_"+n]=e[t][n]}}_checkReadiness(){this._readyCondition()&&Kt(this)}_alterElementProperties(e){throw new Error(`FontVariant(${typeof this})::_alterElementProperties() is abstract and should therefore be overridden.`)}_readyCondition(){throw new Error(`FontVariant(${typeof this})::_readyCondition() is abstract and should therefore be overridden.`)}}const Yt={type:"ready"};function Kt(i){i._isReady=!0,i.dispatchEvent(Yt)}const L=jt;class qt extends p{constructor(e=null){super("font",e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=Jt}output(e){e[this._id]=this._fontVariant}update(e,t){if(this._fontVariant&&!this._fontVariant.isReady&&this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._value&&this._value instanceof L)this._fontVariant=this._value;else{const s=e._fontFamily._value;s&&(this._fontVariant=s.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=Zt(e,this),this._fontVariant.isReady?this._handleFontReadyClosure():this._fontVariant.addEventListener("ready",this._handleFontReadyClosure),(!e._fontMaterial._defaultMaterial||!(e._fontMaterial._defaultMaterial instanceof this._fontVariant.fontMaterial))&&(e._fontMaterial._defaultMaterial=new this._fontVariant.fontMaterial,e._fontMaterial._needsUpdate=!0))}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}get fontVariant(){return this._fontVariant}dispose(){this._handleFontReadyClosure&&(this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._handleFontReadyClosure=null),this._value=null,this._fontVariant=null}}function Jt(i){return i instanceof L?!0:(console.warn(`.font value '${i}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function Zt(i,e){return function(){e._needsUpdate=!0,i._glyphs._needsProcess=!0,e._fontVariant.removeEventListener("ready",e._handleFontReadyClosure),e._handleFontReadyClosure=null}}class Qt extends g{constructor(e){super("display",e),this._value="flex",this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=ti}computeOutputValue(e){e._visible._value=this._output!=="none"}}const ei=["none","flex"];function ti(i){return ei.indexOf(i)===-1?(console.warn(`(.style) display value '${i}' is not valid. Aborted`),!1):!0}class ii extends g{constructor(e){super("boxSizing",e),this._allowsInherit=!1,this.isValidValue=ri}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}}const si=["border-box","content-box"];function ri(i){return si.indexOf(i)===-1?(console.warn(`(.style) boxSizing value '${i}' is not valid. Aborted`),!1):!0}class A extends g{constructor(e,t){super(e,t,!1),this._value=new u.Color,this.output=this._outputValue}computeOutputValue(e){this._input!=="inherit"&&this._value.set(this._input)}set inline(e){this._input=this._inline=e,this._needsUpdate=!0}}class Q extends g{constructor(e,t){super(e,t,!0),this.isValidValue=ni,this._allowsInherit=!1,this._input=t,this._value=t,this.output=this._outputValue,this.computeOutputValue=this._computeFromInherited}_outputValue(e){e[this._id]=this._inheritedInput}}function ni(i){return i<0&&i>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${i}' is not valid)`),!1):!0}class oi extends g{constructor(e){super("backgroundImage",e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new u.Vector2(1,1),this.isValidValue=ai}get value(){return this._value}output(e){e[this._id]=this._value,e.tSize=this._textureSize}computeOutputValue(e){if(this._value=this._inheritedInput,this._value instanceof u.Texture&&!this._value.image){console.warn("ThreeMeshUI - .backgroundImage :: Please provide preloaded texture in order to have accurate sizing.");return}this._needsProcess=!0}process(e){this._value?this._textureSize.set(this._value.image.width,this._value.image.height):this._textureSize.set(1,1)}}function ai(i){return!0}class ui extends g{constructor(e){super("backgroundSize",e,!0),this.isValidValue=li,this.output=this._outputValue}}const hi=["cover","contain","stretch"];function li(i){return hi.indexOf(i)===-1?(console.warn(`(.style) backgroundSize value '${i}' is not valid. Aborted`),!1):!0}class ci extends g{constructor(e){super("overflow",e,!0),this.isValidValue=_i,this._clippingPlanes=null,this._renderStrategy=this._emptyRender}update(e,t){this._inline!==void 0&&this._inline!=="unset"?this._input=this._inline:this._computed!==void 0&&(this._input=this._computed),this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const s of e._children._uis)s._overflow._needsUpdate=!0;this.output(t)}output(e){e.clippingPlanes=this._clippingPlanes}computeOutputValue(e){super.computeOutputValue(e),this._value==="hidden"?this._renderStrategy=this._propagateRender:(this._renderStrategy=this._emptyRender,this._clippingPlanes=null);const t=e._parent._value;if(t!==null){const s=t._overflow;if((s._value==="hidden"||s._clippingPlanes!==null)&&!this._clippingPlanes){this._clippingPlanes=[new u.Plane(new u.Vector3(0,-1,0),1),new u.Plane(new u.Vector3(-1,0,0),1),new u.Plane(new u.Vector3(0,1,0),1),new u.Plane(new u.Vector3(1,0,0),1)];for(let r=0;r<this._clippingPlanes.length;r++)this._clippingPlanes[r].parent=t;s._clippingPlanes!==null&&this._clippingPlanes.push(...s._clippingPlanes),this._renderStrategy=this._hiddenRender,this._needsRender=!0}else(s._value==="visible"||s._clippingPlanes===null)&&this._clippingPlanes!==null&&(this._clippingPlanes=null,this._renderStrategy=this._emptyRender,this._needsRender=!0)}}render(e){this._renderStrategy(e)}_emptyRender(e){}_hiddenRender(e){const t=e._parent._value,s=t._bounds._offsetHeight,r=t._bounds._offsetWidth,n=t._padding._value,o=t._borderWidth._value;for(let a=0;a<4&&a<this._clippingPlanes.length;a++){const l=this._clippingPlanes[a];switch(a%4){case 0:l.constant=s/2-(n.x+o.x);break;case 1:l.constant=r/2-(n.y+o.y);break;case 2:l.constant=s/2-(n.z+o.z);break;case 3:l.constant=r/2-(n.w+o.w);break}l.applyMatrix4(t.matrixWorld)}for(let a=0;a<e._children._uis.length;a++){const l=e._children._uis[a];l._overflow._needsRender=!0}}_propagateRender(e){for(let t=0;t<e._children._uis.length;t++){const s=e._children._uis[t];s._overflow._needsRender=!0}}}const di=["visible","hidden"];function _i(i){return di.indexOf(i)===-1?(console.warn(`(.style) overflow value '${i}' is not valid. Aborted`),!1):!0}const B="rem",Ee="em",$="%",fi=[B,Ee,$],De=function(i){return fi.indexOf(i)===-1?B:i};class pi extends Y{constructor(e){super("borderRadius",e),this._valueUV=this._value.clone(),this._input=new u.Vector4(0,0,0,0),this._mediation=!0,this._cornerTL=new u.Vector2(0,1),this._cornerTR=new u.Vector2(1,1),this._cornerBR=new u.Vector2(1,0),this._cornerBL=new u.Vector2(0,0);const t=new E(this._valueUV,["x","y"]),s=new E(this._valueUV,["z","w"]),r=new E(this._valueUV,["x","w"]),n=new E(this._valueUV,["y","z"]);t.complementaryMediation=s,s.complementaryMediation=t,r.complementaryMediation=n,n.complementaryMediation=r,this._sideMediators=[t,s,r,n],this._units=B}set units(e){this._units=De(e),this._needsProcess=!0}get units(){return this._units}set mediation(e){e!==this._mediation&&(this._mediation=e,this._needsUpdate=!0)}get mediation(){return this._mediation}output(e){e.cornerTL=this._cornerTL,e.cornerTR=this._cornerTR,e.cornerBR=this._cornerBR,e.cornerBL=this._cornerBL}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0}process(e){this._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,s=e._bounds._offsetHeight;if(this._units===$&&this._valueUV.divideScalar(100),this._units===B&&this._valueUV.divideScalar(Math.min(t,s)),this._mediation)do this._sideMediators.forEach(o=>o.computeValue()),this._sideMediators.sort((o,a)=>o.value<a.value?1:-1),this._sideMediators[0].value>1&&this._sideMediators[0].mediate();while(this._sideMediators[0].value>1);let r=t>s?s/t:1,n=t<s?t/s:1;this._units===$&&(r=n=1),this._cornerTL.x=this._valueUV.x*r,this._cornerTL.y=1-this._valueUV.x*n,this._cornerTR.x=1-this._valueUV.y*r,this._cornerTR.y=1-this._valueUV.y*n,this._cornerBR.x=1-this._valueUV.z*r,this._cornerBR.y=this._valueUV.z*n,this._cornerBL.x=this._valueUV.w*r,this._cornerBL.y=this._valueUV.w*n}dispose(){for(const e of this._sideMediators)e.dispose();this._sideMediators=null,this._cornerTL=null,this._cornerTR=null,this._cornerBR=null,this._cornerBL=null,super.dispose()}set topLeft(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get topLeft(){return this._input.x}set topRight(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get topRight(){return this._input.y}set bottomRight(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottomRight(){return this._input.z}set bottomLeft(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get bottomLeft(){return this._input.w}set top(e){this._input.x===e&&this._input.y===e||(this._input.x=this._input.y=e,this._needsUpdate=!0)}get top(){return(this._input.x+this._input.y)/2}set right(e){this._input.y===e&&this._input.z===e||(this._input.y=this._input.z=e,this._needsUpdate=!0)}get right(){return(this._input.y+this._input.z)/2}set bottom(e){this._input.z===e&&this._input.w===e||(this._input.z=this._input.w=e,this._needsUpdate=!0)}get bottom(){return(this._input.z+this._input.w)/2}set left(e){this._input.w===e&&this._input.x===e||(this._input.w=this._input.x=e,this._needsUpdate=!0)}get left(){return(this._input.w+this._input.x)/2}}class E{constructor(e,t){this._borderRadiuses=e,this._sideProperties=t,this._complementaryMediation=null,this._value=0}get value(){return this._value}set complementaryMediation(e){this._complementaryMediation=e}computeValue(){let e=0;for(const t of this._sideProperties)e+=this._borderRadiuses[t];this._value=e}mediate(e=!0){if(!(this._value<1)){for(const t of this._sideProperties)this._borderRadiuses[t]/=this._value;e&&this._complementaryMediation.mediate(!1)}}dispose(){this._complementaryMediation=null,this._borderRadiuses=null}}class gi extends Y{constructor(e){super("borderWidth",e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=B}set units(e){this._units=De(e),this._needsUpdate=!0}get units(){return this._units}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0,e._bounds._needsUpdate=!0,e._layouter._needsUpdate=!0}_outputValue(e){e[this._id]=this._valueUV}process(e){this._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,s=e._bounds._offsetHeight;if(this._units===$&&(console.log("Percent"),console.log(this._valueUV)),this._units===B)t!==0&&(this._valueUV.w/=t,this._valueUV.y/=t),s!==0&&(this._valueUV.x/=s,this._valueUV.z/=s);else if(this._units===Ee){if(t!==0){const r=t>s?s/t:1;this._valueUV.y*=r,this._valueUV.w*=r}if(s!==0){const r=t<s?t/s:1;this._valueUV.x*=r,this._valueUV.z*=r}}}}class mi extends p{constructor(e,t=!0){super("visible",t,!0),this._needsUpdate=!1}update(e,t){e.visible=this._value,e._parent._value&&(e._parent._value._children._needsUpdate=!0)}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}}class He extends A{constructor(e){super("backgroundColor",e,!1),this._input="transparent",this._allowsInherit=!1}computeOutputValue(e){e._backgroundMesh.visible=!(this._input==="none"||this._input==="transparent"),this._input==="inherit"?this._value.set(this.getInheritedInput(e)):this._input==="transparent"||this._input==="none"||this._value.set(this._input)}}class I extends p{constructor(e="untitled"){super(e,void 0,!1)}update(e,t){}output(e){}}class vi extends p{constructor(){super("inlineJustificator",null,!1),this._value=null}update(e,t){}process(e){const t=e._bounds._innerHeight,s=e._layouter._value,r=Math.abs(s.height);let n=(()=>{switch(e._alignItems._value){case"inherit":case"start":return t/2;case"end":return r-t/2;case"stretch":case"center":return r/2}})();const o=e._padding._value,a=e._borderWidth._value;n+=(-o.x+o.z)/2+(-a.x+a.z)/2,s.forEach(l=>{l.y+=n,l.forEach(d=>{d.offsetY+=n})})}}const yi=["start","center","end","stretch"],bi=function(i){return yi.indexOf(i)===-1?(console.warn(`(.style) alignItems value '${i}' is not valid. Aborted`),!1):!0};class he extends g{constructor(){super("alignItems","inherit",!0),this.isValidValue=bi}}class le extends g{constructor(){super("textAlign","inherit",!0),this.isValidValue=wi}}const xi=["left","right","center","justify","justify-left","justify-right","justify-center"],wi=function(i){return xi.indexOf(i)===-1?(console.warn(`(.style) textAlign value '${i}' is not valid. Aborted`),!1):!0};class ce extends g{constructor(){super("flexDirection","inherit",!0),this.isValid=Vi}}const Si=["row","row-reverse","column","column-reverse"];function Vi(i){return Si.indexOf(i)===-1?(console.warn(`(.style) flexDirection value '${i}' is not valid. Aborted`),!1):!0}class de extends g{constructor(){super("justifyContent","inherit",!0),this.isValidValue=Pi}}const ki=["start","center","end","space-between","space-around","space-evenly"];function Pi(i){return ki.indexOf(i)===-1?(console.warn(`(.style) justifyContent value '${i}' is not valid. Aborted`),!1):!0}class Ii extends g{constructor(){super("order",0,!0),this._value=0,this._input=0,this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._parent._value&&(e._parent._value._children._needsProcess=!0)}}class Ge extends g{constructor(){super("position","static",!0),this._allowsInherit=!1,this._value="static",this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=Ri}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}}const Ci=["static","absolute"];function Ri(i){return Ci.indexOf(i)===-1?(console.warn(`(.style) position value '${i}' is not valid. Aborted`),!1):!0}class $e extends g{constructor(e,t=null){super(e,t,!0),this._input="auto",this._auto=!0,this._relative=!1,this._updateRequired=!0}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._inline=e,this._input!==this._inline&&this._parseInput())}get inline(){return this._inline}_parseInput(){let e=!0;if(this._inline!==void 0&&this._inline!=="unset"?this._input=this._inline:this._computed!==void 0?(this._computed===this._input&&(e=!1),this._input=this._computed):e=this._input==="inherit",e){if(this._auto=!this._input||this._input==="auto",this._auto)this._relative=!1;else if((typeof this._input=="string"||this._input instanceof String)&&this._input.endsWith("%")){this._relative=!0,this._value=0;const t=parseFloat(this._input.replace("%","").trim());isNaN(t)||(this._value=t/100)}else this._relative=!1,this._value=this._input;this._needsUpdate=this._updateRequired=e}}update(e,t){if(this._updateRequired){this._updateRequired=!1,this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const s of e._children._uis)s[`_${this._id}`]._needsUpdate=!0;this.output(t),e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}computeOutputValue(e){e._bounds._needsUpdate=!0,e._renderer._needsRender=!0}getInheritedInput(e){if(this._input!=="inherit"&&!this._auto)return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return 0}get value(){return this._value}}class Bi extends $e{constructor(){super("width")}}class Ui extends $e{constructor(){super("height")}computeOutputValue(e){super.computeOutputValue(e)}}class Ne extends I{constructor(){super("textContent"),this._needsUpdate=!1}set value(e){}process(e){let t="";for(let s=0;s<e.children.length;s++){const r=e.children[s];r.isUI&&(t+=r.textContent)}this._value=t}}class Xe extends g{constructor(e){super("fontStyle",e,!0),this.isValidValue=Ti}}const Ai=["normal","italic"];function Ti(i){return Ai.indexOf(i)===-1?(console.warn(`(.style) fontStyle value '${i}' is not valid. Aborted`),!1):!0}class je extends g{constructor(){super("fontWeight","inherit",!0),this.isValid=Fi}}const Mi=["100","200","300","400","500","600","700","800","900","light","normal","bold","bolder"];function Fi(i){return Mi.indexOf(i.toString())===-1?(console.warn(`(.style) fontWeight value '${i}' is not valid. Aborted`),!1):!0}class Ye{constructor(){this._size=42,this._lineHeight=42,this._lineBase=38,this._name="-",this._charset=""}get size(){return this._size}get lineHeight(){return this._lineHeight}get lineBase(){return this._lineBase}get name(){return this._name}get charset(){return this._charset}}class Oi extends Ye{constructor(e){super(),this._size=e.info.size,this._lineHeight=e.common.lineHeight,this._lineBase=e.common.base,this._name=e.info.face,this._textureWidth=e.common.scaleW,this._textureHeight=e.common.scaleH,this._charset=e.chars.map(t=>t.char).join("")}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}}class Li extends We{constructor(e){super(e)}get uv(){return this.typographic.uv}}class N extends ze{constructor(e,t){super(e),this._char=t.char,this._width=t.width,this._heigth=t.height,this._xadvance=t.xadvance?t.xadvance:this._width,this._xoffset=t.xoffset?t.xoffset:0,this._yoffset=t.yoffset?t.yoffset:0,this._uv=t.uv?t.uv:null,isNaN(t.x)||(this._uv={left:t.x/e.textureWidth,right:(t.x+t.width)/e.textureWidth,top:1-(t.y+t.height)/e.textureHeight,bottom:1-t.y/e.textureHeight})}get uv(){return this._uv}clone(e){return new N(this._font,{char:e,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new Li(this)}}class zi extends u.PlaneGeometry{constructor(e,t){let s=1,r=1;const n=e.typographic.font.size,o=t._segments.value;s=Math.ceil(e.typographic.width/n*o),r=Math.ceil(e.typographic.height/n*o),super(e.width,e.height,s,r),e.uv?(this._mapUVs(e),this._transformGeometry(e)):(this._nullifyUVs(),this.scale(0,0,1),this.translate(0,e.fontSize/2,0)),this.name="GlyphGeometry"}_mapUVs(e){const t=e.uv.right-e.uv.left,s=e.uv.bottom-e.uv.top,r=this.getAttribute("uv").array.slice(),n=[];for(let o=0;o<r.length;o+=2){const a=r[o],l=r[o+1];n.push(e.uv.left+t*a),n.push(e.uv.top+s*l)}this.setAttribute("uvG",new u.BufferAttribute(new Float32Array(n),2))}_nullifyUVs(){const e=[],t=this.getAttribute("uv").array.length;for(let s=0;s<t;s++)e.push(0);this.setAttribute("uvG",new u.BufferAttribute(new Float32Array(e),2))}_transformGeometry(e){this.translate(e.width/2,-e.height/2,0)}}const Wi=`
attribute vec2 uvG;
varying vec2 vUvG;
`,_e=Wi,Ei=`
vUvG = uvG;
`,fe=Ei,Di=`
gl_Position.z -= 0.00001;
`,pe=Di,Hi=`
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;
}
`,ge=Hi,Gi=`
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;
`,me=Gi,K=function(i,e,t){i.alphaTest=t,ve(i,"USE_ALPHATEST",t>0)},ve=function(i,e,t){i.defines&&(t?i.defines[e]===void 0&&(i.defines[e]="",i.needsUpdate=!0):i.defines[e]!==void 0&&(delete i.defines[e],i.needsUpdate=!0))},Ke=function(i,e,t){i.defines[e]&&i.defines[e]===t||(i.defines[e]=t,i.needsUpdate=!0)},w=function(i,e,t){i.userData[e]?i.userData[e].value=t:i.uniforms[e].value=t},$i=function(i,e,t){i.userData[e].value=t};class S{static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||(e.defines={})}static ensureUserData(e,t){e.userData.glyphMap={value:t.glyphMap},e.userData.unitRange={value:new u.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(e){S.injectVertexShaderChunks(e),S.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>",`#include <uv_pars_vertex>
`+_e),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>",`#include <uv_vertex>
`+fe),e.vertexShader=e.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
`+pe)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>",`#include <uv_pars_fragment>
`+ge),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",`#include <alphamap_fragment>
`+me)}static from(e){return class extends e{static get fontMaterialProperties(){return S.mediation}constructor(t={}){S.ensureMaterialOptions(t),super(t),S.ensureDefines(this),S.ensureUserData(this,t),this._userDefinedOnBeforeCompile=s=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(t){this._userDefinedOnBeforeCompile=t}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=t=>{S.bindUniformsWithUserData(t,this),S.injectShaderChunks(t),this._userDefinedOnBeforeCompile(t)}}}static get mediation(){return ji}}const Ni=function(i,e,t){const s=t?t.texture:null,r=t?t.unitRange:new u.Vector2;if(i[e]!==void 0){i.glyphMap=s,i.unitRange=r;return}i.userData&&i.userData.glyphMap&&(i.userData.glyphMap.value=s,i.userData.unitRange.value=r)},Xi=function(i,e,t){t&&t!=="antialiased"?i.defines.NO_RGSS="":delete i.defines.NO_RGSS,i.needsUpdate=!0},ji={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:K},fontSide:{m:"side"},font:{m:"glyphMap",t:Ni},color:{m:"color"},fontOpacity:{m:"opacity"},fontSmooth:{m:"NO_RGSS",t:Xi},invertAlpha:{m:"INVERT_ALPHA",t:ve}},Yi=`
${_e}
#include <clipping_planes_pars_vertex>
void main() {
${fe}
#include <begin_vertex>
#include <project_vertex>
${pe}
#include <clipping_planes_vertex>
}
`,Ki=`
uniform vec3 diffuse;
uniform float opacity;
${ge}
#include <alphatest_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
// instead of <color_fragment> : vec4 diffuseColor
vec4 diffuseColor = vec4( diffuse, opacity );
${me}
#include <alphatest_fragment>
// instead of <output_fragment>
gl_FragColor = diffuseColor;
#include <clipping_planes_fragment>
}
`,qi=.02;class ye extends u.ShaderMaterial{static get mediation(){return S.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new u.Vector2(0,0)},alphaTest:{value:qi}},transparent:!0,clipping:!0,vertexShader:Yi,fragmentShader:Ki,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST="",this.needsUpdate=!0,this.noRGSS=e.noRGSS||!1}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get opacity(){return this.uniforms.opacity.value}get unitRange(){return this.uniforms.unitRange.value}set unitRange(e){this.uniforms.unitRange.value.copy(e)}get glyphMap(){return this.uniforms.glyphMap.value}set glyphMap(e){this.uniforms.glyphMap.value=e}get isDefault(){return this.constructor===ye}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}}class Ji extends L{constructor(e,t,s,r){if(super(e,t),this._unitRange=new u.Vector2(1,1),s.pages?this._buildData(s):Zi(this,s),r instanceof u.Texture)this._texture=r,this._buildTexture(r);else if(typeof r=="string"||r instanceof String)Qi(this,r);else throw new Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=ye,this._checkReadiness()}get texture(){return this._texture}get unitRange(){return this._unitRange}set fontMaterial(e){this._defaultMaterialClass=e}get fontMaterial(){return this._defaultMaterialClass}_buildData(e){this._font=new Oi(e),this._kernings=this._buildKerningPairs(e),this._chars=this._buildCharacters(e),this._chars[" "]=this._buildCharacterWhite(e),this._chars[`
`]=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 u.Vector2(this._distanceRange,this._distanceRange).divide(new u.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=u.LinearFilter,e.magFilter=u.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return C.missingCharacter(this,e)}getGeometricGlyph(e,t){return new zi(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){const t={};for(let s=0;s<e.kernings.length;s++){const r=e.kernings[s];if(r.amount===0)continue;const n=String.fromCharCode(r.first,r.second);t[n]=r.amount}return t}_buildCharacters(e){const t={};for(let s=0;s<e.chars.length;s++){const r=e.chars[s];t[r.char]=new N(this._font,r)}return t}_buildCharacterWhite(e,t=" ",s=1,r=1){return new N(this._font,{char:t,width:e.info.size/3*s,height:e.info.size*.7*r})}_alterElementProperties(e){}}function Zi(i,e){new u.FileLoader().setResponseType("json").load(e,t=>{i._buildData(t),i._checkReadiness()})}function Qi(i,e){i._texture=new u.TextureLoader().load(e,t=>{i._buildTexture(t),i._checkReadiness()})}class q extends u.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,s,r,n=!1){if(n||!this.getVariant(e,t)){this._isReady=!1;const o=new Ji(e,t,s,r);this._variants.push(o),o.isReady?this._checkReadiness():o.addEventListener("ready",this._checkReadiness)}else console.warn(`FontFamily('${this._name}')::addVariant() - Variant(${e}, ${t}) already exists.`);return this}addCustomImplementationVariant(e,t=!1){return t||!this.getVariant(e.weight,e.style)?(this._isReady=!1,this._variants.push(e),e.isReady?this._checkReadiness():e.addEventListener("ready",this._checkReadiness)):console.warn(`FontFamily('${this._name}')::addCustomImplementationVariant() - Variant(${e.weight}, ${e.style}) already exists.`),this}getVariant(e,t){return e=ue(e),this._variants.find(s=>s.weight===e&&s.style===t)}get name(){return this._name}_checkReadiness=()=>{this._variants.every(e=>e.isReady)&&ts(this)}}const es={type:"ready"};function ts(i){i._isReady=!0,i.dispatchEvent(es)}const G={},is=function(i){const e=[...arguments];e.forEach(s=>{if(!(s instanceof q))throw new Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof s} given.`)});const t=function(){return e.every(s=>s.isReady)};return new Promise((s,r)=>{if(t())s();else for(let n=0;n<e.length;n++){const o=e[n];o.isReady||o.addEventListener("ready",()=>{t()&&s()})}})},ss=function(i){return G[i]&&console.error(`FontLibrary::addFontFamily - Font('${i}') is already registered`),G[i]=new q(i),G[i]},rs=function(i){return G[i]},ns=function(i){qe=i};let qe=function(i,e){return console.error(`The character '${e}' is not included in the font characters set.`)," "};function os(i,e){return qe(i,e)}const as={addFontFamily:ss,getFontFamily:rs,prepare:is,setMissingCharacterHandler:ns,missingCharacter:os},C=as;class Je extends g{constructor(){super("fontFamily","inherit",!0)}computeOutputValue(e){if(this._input instanceof q)this._value=this._input;else if(this._input!=="inherit")if(typeof this._input=="string"){const t=C.getFontFamily(this._input);t?this._value=t:console.warn(`(.style) fontFamily, the font '${this._input}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}getInheritedInput(e){if(this._input!=="inherit")return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class Ze extends g{constructor(){super("lineHeight","inherit",!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}}class Qe extends g{constructor(){super("whiteSpace","inherit"),this.isValidValue=hs}}const us=["normal","nowrap","pre","pre-line","pre-wrap"];function hs(i){return us.indexOf(i)===-1?(console.warn(`(.style) whiteSpace value '${i}' is not valid. Aborted`),!1):!0}class et extends g{constructor(){super("letterSpacing","inherit",!0)}}class ls extends g{constructor(){super("fontSize","inherit",!0)}}class tt extends p{constructor(){super("segments",1,!1)}}class cs extends R{constructor(){super("invertAlpha","inherit")}}class J extends g{constructor(){super("fontKerning","inherit"),this.isValidValue=_s}}const ds=["normal","none","inherit"];function _s(i){return ds.indexOf(i)===-1?(console.warn(`(.style) fontKerning value '${i}' is not valid. Aborted`),!1):!0}class D extends R{constructor(e){super(e,"inherit",!0)}}class Ue extends R{constructor(e){super(e,"inherit",!1),this._mediation={},this._defaultMaterial=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"?this._notInheritedValue=this.getInheritedInput(e):this.propagate(e),this._notInheritedValue?this._notInheritedValue.constructor.mediation?this._mediation={...this._notInheritedValue.constructor.mediation}:this._mediation={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:K},fontSide:{m:"side"},color:{m:"color"},fontOpacity:{m:"opacity"}}:this._mediation={},e._transferToFontMaterial(),this._outputValue(t)}getInheritedInput(e){if(this._value!=="inherit")return this._value;let t=e,s=null;for(;t._parent._value;)if(t=t._parent._value,t[`_${this._id}`]._value!=="inherit"){s=t[`_${this._id}`]._value;break}return s!==null?s:this.getDefaultValue()}getDefaultValue(){return this._defaultMaterial}}const fs=function(i,e,t){i.traverse(s=>{s.renderOrder=t})};class z extends u.Object3D{constructor(e,t){super(),Object.defineProperties(this,{isUI:{configurable:!1,enumerable:!0,value:!0}}),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundCustomDepthMaterial=null,this._backgroundMaterialMediation={},this._backgroundMeshMediation={backgroundCastShadow:{m:"castShadow"},backgroundReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder",t:fs}},this._fontMesh=null,this._fontMaterial=new Ue("fontMaterial"),this._fontCustomDepthMaterial=new Ue("fontCustomDepthMaterial"),this._fontMeshMediation={fontMaterial:{m:"material"},fontCustomDepthMaterial:{m:"customDepthMaterial",t:Ht},fontCastShadow:{m:"castShadow"},fontReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder"}},this._children=e.children?new e.children:new I("children"),this._parent=new Gt,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI),this._backgroundSide=new Be("backgroundSide"),this._fontSide=new Be("fontSide"),this._backgroundAlphaTest=new Re("backgroundAlphaTest",.02),this._fontAlphaTest=new Re("fontAlphaTest",.02),this._visible=new mi("visible",!0),this._backgroundCastShadow=new D("backgroundCastShadow"),this._fontCastShadow=new D("fontCastShadow"),this._backgroundReceiveShadow=new D("backgroundReceiveShadow"),this._fontReceiveShadow=new D("fontReceiveShadow"),this._renderOrder=new Mt,this._segments=e.segments?new e.segments:new tt,this._bounds=e.bounds?new e.bounds:new I("bounds"),this._order=new Ii,this._padding=new Et,this._margin=new Dt,this._position=new Ge,this._flexDirection=e.flexDirection?new e.flexDirection:new ce,this._justifyContent=e.justifyContent?new e.justifyContent:new de,this._alignItems=e.alignItems?new e.alignItems:new he,this._display=new Qt("flex"),this._boxSizing=new ii("border-box"),this._width=new Bi,this._height=new Ui,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new He,this._backgroundOpacity=new Q("backgroundOpacity",.5),this._backgroundImage=new oi,this._backgroundSize=new ui("cover"),this._color=e.color?new e.color:new A("color","inherit"),this._fontOpacity=new Q("fontOpacity","inherit"),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Qe,this._fontFamily=e.fontFamily?new e.fontFamily:new Je,this._fontStyle=e.fontStyle?new e.fontStyle:new Xe("normal"),this._fontWeight=e.fontWeight?new e.fontWeight:new je,this._fontSize=e.fontSize?new e.fontSize:new ls,this._lineHeight=e.lineHeight?new e.lineHeight:new Ze,this._fontKerning=e.fontKerning?new e.fontKerning:new J,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new et,this._overflow=new ci("visible"),this._borderRadius=new pi(0),this._borderWidth=new gi(0),this._borderColor=new A("borderColor",16711935),this._borderOpacity=new Q("borderOpacity",1),this._font=new qt,this._lineBreak=e.lineBreak?new e.lineBreak:new I("lineBreak"),this._textContent=e.textContent?new e.textContent:new Ne,this._glyphs=e.glyphs?new e.glyphs:new I("glyphs"),this._inlines=e.inlines?new e.inlines:new I("inlines"),this._layouter=e.layouter?new e.layouter:new I("layouter"),this._inlineJustificator=new vi,this._textAlign=e.textAlign?new e.textAlign:new le,this._autoSize=e.autoSize?new e.autoSize:new I("autoSize"),this._renderer=e.renderer?new e.renderer:new I("renderer"),this._offset=new Ft,this._invertAlpha=new cs,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new Ot,this._components=[this._textContent,this._children,this._parent,this._autoSize,this._fontFamily,this._fontStyle,this._fontWeight,this._font,this._whiteSpace,this._glyphs,this._inlines,this._visible,this._backgroundSide,this._fontSide,this._backgroundAlphaTest,this._fontAlphaTest,this._backgroundCastShadow,this._fontCastShadow,this._backgroundReceiveShadow,this._fontReceiveShadow,this._renderOrder,this._segments,this._padding,this._margin,this._width,this._height,this._borderWidth,this._boxSizing,this._bounds,this._position,this._flexDirection,this._justifyContent,this._alignItems,this._order,this._display,this._backgroundColor,this._backgroundOpacity,this._backgroundImage,this._backgroundSize,this._fontOpacity,this._color,this._fontSize,this._lineHeight,this._fontKerning,this._letterSpacing,this._borderRadius,this._borderColor,this._borderOpacity,this._lineBreak,this._offset,this._layouter,this._inlineJustificator,this._textAlign,this._invertAlpha,this._fontSmooth,this._fontMaterial,this._fontCustomDepthMaterial,this._overflow,this._renderer],this._onAfterUpdates=[],t.backgroundSide||(t.backgroundSide=0),t&&this.set(t)}update(){const e={};for(const t of this._components)t._needsUpdate&&(t.update(this,e),t._needsUpdate=!1);this._transferToBackgroundMesh(e),this._transferToFontMesh(e),this._transferToBackgroundMaterial(e),this._transferToFontMaterial(e);for(const t of this._children._uis)t.update()}process(){for(const e of this._children._uis)e.process();for(const e of this._components)e._needsProcess&&(e.process(this),e._needsProcess=!1)}render(){for(let e=0;e<this._components.length;e++){const t=this._components[e];t._needsRender&&(t.render(this),t._needsRender=!1)}for(const e of this._children._uis)e.render()}set(e){if(e.fontTexture&&(console.warn("ThreeMeshUI::set( {fontTexture} ) is deprecated. Please use fontLibrary to register font families and variants."),e.fontFamily)){const t=e.fontFamily.pages?e.fontFamily.info.face:e.fontFamily;let s=C.getFontFamily(t);if(!s){const r=e.fontStyle?e.fontStyle:"normal",n=e.fontWeight?e.fontWeight:"400";s=C.addFontFamily(t).addVariant(n,r,e.fontFamily,e.fontTexture)}e.fontFamily=s,delete e.fontTexture}for(let t of Object.keys(e)){const s=e[t];switch(t){case"contentDirection":console.warn("ThreeMeshUI v7xx: property `contentDirection` is deprecated and has been renamed as `flexDirection`"),t="flexDirection";break;case"interLine":console.warn("ThreeMeshUI v7xx: property `interLine` is deprecated and ha