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