babylon.gui.d.ts 166 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088
  1. declare module BABYLON.GUI {
  2. /**
  3. * Class used to specific a value and its associated unit
  4. */
  5. export class ValueAndUnit {
  6. /** defines the unit to store */
  7. unit: number;
  8. /** defines a boolean indicating if the value can be negative */
  9. negativeValueAllowed: boolean;
  10. private _value;
  11. private _originalUnit;
  12. /**
  13. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  15. */
  16. ignoreAdaptiveScaling: boolean;
  17. /**
  18. * Creates a new ValueAndUnit
  19. * @param value defines the value to store
  20. * @param unit defines the unit to store
  21. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  22. */
  23. constructor(value: number,
  24. /** defines the unit to store */
  25. unit?: number,
  26. /** defines a boolean indicating if the value can be negative */
  27. negativeValueAllowed?: boolean);
  28. /** Gets a boolean indicating if the value is a percentage */
  29. get isPercentage(): boolean;
  30. /** Gets a boolean indicating if the value is store as pixel */
  31. get isPixel(): boolean;
  32. /** Gets direct internal value */
  33. get internalValue(): number;
  34. /**
  35. * Gets value as pixel
  36. * @param host defines the root host
  37. * @param refValue defines the reference value for percentages
  38. * @returns the value as pixel
  39. */
  40. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  41. /**
  42. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  43. * @param value defines the value to store
  44. * @param unit defines the unit to store
  45. * @returns the current ValueAndUnit
  46. */
  47. updateInPlace(value: number, unit?: number): ValueAndUnit;
  48. /**
  49. * Gets the value accordingly to its unit
  50. * @param host defines the root host
  51. * @returns the value
  52. */
  53. getValue(host: AdvancedDynamicTexture): number;
  54. /**
  55. * Gets a string representation of the value
  56. * @param host defines the root host
  57. * @param decimals defines an optional number of decimals to display
  58. * @returns a string
  59. */
  60. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61. /**
  62. * Store a value parsed from a string
  63. * @param source defines the source string
  64. * @returns true if the value was successfully parsed
  65. */
  66. fromString(source: string | number): boolean;
  67. private static _Regex;
  68. private static _UNITMODE_PERCENTAGE;
  69. private static _UNITMODE_PIXEL;
  70. /** UNITMODE_PERCENTAGE */
  71. static get UNITMODE_PERCENTAGE(): number;
  72. /** UNITMODE_PIXEL */
  73. static get UNITMODE_PIXEL(): number;
  74. }
  75. }
  76. declare module BABYLON.GUI {
  77. /**
  78. * Define a style used by control to automatically setup properties based on a template.
  79. * Only support font related properties so far
  80. */
  81. export class Style implements BABYLON.IDisposable {
  82. private _fontFamily;
  83. private _fontStyle;
  84. private _fontWeight;
  85. /** @hidden */
  86. _host: AdvancedDynamicTexture;
  87. /** @hidden */
  88. _fontSize: ValueAndUnit;
  89. /**
  90. * BABYLON.Observable raised when the style values are changed
  91. */
  92. onChangedObservable: BABYLON.Observable<Style>;
  93. /**
  94. * Creates a new style object
  95. * @param host defines the AdvancedDynamicTexture which hosts this style
  96. */
  97. constructor(host: AdvancedDynamicTexture);
  98. /**
  99. * Gets or sets the font size
  100. */
  101. get fontSize(): string | number;
  102. set fontSize(value: string | number);
  103. /**
  104. * Gets or sets the font family
  105. */
  106. get fontFamily(): string;
  107. set fontFamily(value: string);
  108. /**
  109. * Gets or sets the font style
  110. */
  111. get fontStyle(): string;
  112. set fontStyle(value: string);
  113. /** Gets or sets font weight */
  114. get fontWeight(): string;
  115. set fontWeight(value: string);
  116. /** Dispose all associated resources */
  117. dispose(): void;
  118. }
  119. }
  120. declare module BABYLON.GUI {
  121. /**
  122. * Class used to transport BABYLON.Vector2 information for pointer events
  123. */
  124. export class Vector2WithInfo extends BABYLON.Vector2 {
  125. /** defines the current mouse button index */
  126. buttonIndex: number;
  127. /**
  128. * Creates a new Vector2WithInfo
  129. * @param source defines the vector2 data to transport
  130. * @param buttonIndex defines the current mouse button index
  131. */
  132. constructor(source: BABYLON.Vector2,
  133. /** defines the current mouse button index */
  134. buttonIndex?: number);
  135. }
  136. /** Class used to provide 2D matrix features */
  137. export class Matrix2D {
  138. /** Gets the internal array of 6 floats used to store matrix data */
  139. m: Float32Array;
  140. /**
  141. * Creates a new matrix
  142. * @param m00 defines value for (0, 0)
  143. * @param m01 defines value for (0, 1)
  144. * @param m10 defines value for (1, 0)
  145. * @param m11 defines value for (1, 1)
  146. * @param m20 defines value for (2, 0)
  147. * @param m21 defines value for (2, 1)
  148. */
  149. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  150. /**
  151. * Fills the matrix from direct values
  152. * @param m00 defines value for (0, 0)
  153. * @param m01 defines value for (0, 1)
  154. * @param m10 defines value for (1, 0)
  155. * @param m11 defines value for (1, 1)
  156. * @param m20 defines value for (2, 0)
  157. * @param m21 defines value for (2, 1)
  158. * @returns the current modified matrix
  159. */
  160. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  161. /**
  162. * Gets matrix determinant
  163. * @returns the determinant
  164. */
  165. determinant(): number;
  166. /**
  167. * Inverses the matrix and stores it in a target matrix
  168. * @param result defines the target matrix
  169. * @returns the current matrix
  170. */
  171. invertToRef(result: Matrix2D): Matrix2D;
  172. /**
  173. * Multiplies the current matrix with another one
  174. * @param other defines the second operand
  175. * @param result defines the target matrix
  176. * @returns the current matrix
  177. */
  178. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  179. /**
  180. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  181. * @param x defines the x coordinate to transform
  182. * @param y defines the x coordinate to transform
  183. * @param result defines the target vector2
  184. * @returns the current matrix
  185. */
  186. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  187. /**
  188. * Creates an identity matrix
  189. * @returns a new matrix
  190. */
  191. static Identity(): Matrix2D;
  192. /**
  193. * Creates a translation matrix and stores it in a target matrix
  194. * @param x defines the x coordinate of the translation
  195. * @param y defines the y coordinate of the translation
  196. * @param result defines the target matrix
  197. */
  198. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  199. /**
  200. * Creates a scaling matrix and stores it in a target matrix
  201. * @param x defines the x coordinate of the scaling
  202. * @param y defines the y coordinate of the scaling
  203. * @param result defines the target matrix
  204. */
  205. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  206. /**
  207. * Creates a rotation matrix and stores it in a target matrix
  208. * @param angle defines the rotation angle
  209. * @param result defines the target matrix
  210. */
  211. static RotationToRef(angle: number, result: Matrix2D): void;
  212. private static _TempPreTranslationMatrix;
  213. private static _TempPostTranslationMatrix;
  214. private static _TempRotationMatrix;
  215. private static _TempScalingMatrix;
  216. private static _TempCompose0;
  217. private static _TempCompose1;
  218. private static _TempCompose2;
  219. /**
  220. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  221. * @param tx defines the x coordinate of the translation
  222. * @param ty defines the y coordinate of the translation
  223. * @param angle defines the rotation angle
  224. * @param scaleX defines the x coordinate of the scaling
  225. * @param scaleY defines the y coordinate of the scaling
  226. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  227. * @param result defines the target matrix
  228. */
  229. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  230. }
  231. }
  232. declare module BABYLON.GUI {
  233. /**
  234. * Class used to store 2D control sizes
  235. */
  236. export class Measure {
  237. /** defines left coordinate */
  238. left: number;
  239. /** defines top coordinate */
  240. top: number;
  241. /** defines width dimension */
  242. width: number;
  243. /** defines height dimension */
  244. height: number;
  245. /**
  246. * Creates a new measure
  247. * @param left defines left coordinate
  248. * @param top defines top coordinate
  249. * @param width defines width dimension
  250. * @param height defines height dimension
  251. */
  252. constructor(
  253. /** defines left coordinate */
  254. left: number,
  255. /** defines top coordinate */
  256. top: number,
  257. /** defines width dimension */
  258. width: number,
  259. /** defines height dimension */
  260. height: number);
  261. /**
  262. * Copy from another measure
  263. * @param other defines the other measure to copy from
  264. */
  265. copyFrom(other: Measure): void;
  266. /**
  267. * Copy from a group of 4 floats
  268. * @param left defines left coordinate
  269. * @param top defines top coordinate
  270. * @param width defines width dimension
  271. * @param height defines height dimension
  272. */
  273. copyFromFloats(left: number, top: number, width: number, height: number): void;
  274. /**
  275. * Computes the axis aligned bounding box measure for two given measures
  276. * @param a Input measure
  277. * @param b Input measure
  278. * @param result the resulting bounding measure
  279. */
  280. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  281. /**
  282. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  283. * @param transform the matrix to transform the measure before computing the AABB
  284. * @param result the resulting AABB
  285. */
  286. transformToRef(transform: Matrix2D, result: Measure): void;
  287. /**
  288. * Check equality between this measure and another one
  289. * @param other defines the other measures
  290. * @returns true if both measures are equals
  291. */
  292. isEqualsTo(other: Measure): boolean;
  293. /**
  294. * Creates an empty measure
  295. * @returns a new measure
  296. */
  297. static Empty(): Measure;
  298. }
  299. }
  300. declare module BABYLON.GUI {
  301. /**
  302. * Interface used to define a control that can receive focus
  303. */
  304. export interface IFocusableControl {
  305. /**
  306. * Function called when the control receives the focus
  307. */
  308. onFocus(): void;
  309. /**
  310. * Function called when the control loses the focus
  311. */
  312. onBlur(): void;
  313. /**
  314. * Function called to let the control handle keyboard events
  315. * @param evt defines the current keyboard event
  316. */
  317. processKeyboard(evt: KeyboardEvent): void;
  318. /**
  319. * Function called to get the list of controls that should not steal the focus from this control
  320. * @returns an array of controls
  321. */
  322. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  323. }
  324. /**
  325. * Class used to create texture to support 2D GUI elements
  326. * @see https://doc.babylonjs.com/how_to/gui
  327. */
  328. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  329. private _isDirty;
  330. private _renderObserver;
  331. private _resizeObserver;
  332. private _preKeyboardObserver;
  333. private _pointerMoveObserver;
  334. private _pointerObserver;
  335. private _canvasPointerOutObserver;
  336. private _background;
  337. /** @hidden */
  338. _rootContainer: Container;
  339. /** @hidden */
  340. _lastPickedControl: Control;
  341. /** @hidden */
  342. _lastControlOver: {
  343. [pointerId: number]: Control;
  344. };
  345. /** @hidden */
  346. _lastControlDown: {
  347. [pointerId: number]: Control;
  348. };
  349. /** @hidden */
  350. _capturingControl: {
  351. [pointerId: number]: Control;
  352. };
  353. /** @hidden */
  354. _shouldBlockPointer: boolean;
  355. /** @hidden */
  356. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  357. /** @hidden */
  358. _linkedControls: Control[];
  359. private _isFullscreen;
  360. private _fullscreenViewport;
  361. private _idealWidth;
  362. private _idealHeight;
  363. private _useSmallestIdeal;
  364. private _renderAtIdealSize;
  365. private _focusedControl;
  366. private _blockNextFocusCheck;
  367. private _renderScale;
  368. private _rootElement;
  369. private _cursorChanged;
  370. private _defaultMousePointerId;
  371. /** @hidden */
  372. _numLayoutCalls: number;
  373. /** Gets the number of layout calls made the last time the ADT has been rendered */
  374. get numLayoutCalls(): number;
  375. /** @hidden */
  376. _numRenderCalls: number;
  377. /** Gets the number of render calls made the last time the ADT has been rendered */
  378. get numRenderCalls(): number;
  379. /**
  380. * Define type to string to ensure compatibility across browsers
  381. * Safari doesn't support DataTransfer constructor
  382. */
  383. private _clipboardData;
  384. /**
  385. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  386. */
  387. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  388. /**
  389. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  390. */
  391. onControlPickedObservable: BABYLON.Observable<Control>;
  392. /**
  393. * BABYLON.Observable event triggered before layout is evaluated
  394. */
  395. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  396. /**
  397. * BABYLON.Observable event triggered after the layout was evaluated
  398. */
  399. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  400. /**
  401. * BABYLON.Observable event triggered before the texture is rendered
  402. */
  403. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  404. /**
  405. * BABYLON.Observable event triggered after the texture was rendered
  406. */
  407. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  408. /**
  409. * Gets or sets a boolean defining if alpha is stored as premultiplied
  410. */
  411. premulAlpha: boolean;
  412. /**
  413. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  414. * Useful when you want more antialiasing
  415. */
  416. get renderScale(): number;
  417. set renderScale(value: number);
  418. /** Gets or sets the background color */
  419. get background(): string;
  420. set background(value: string);
  421. /**
  422. * Gets or sets the ideal width used to design controls.
  423. * The GUI will then rescale everything accordingly
  424. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  425. */
  426. get idealWidth(): number;
  427. set idealWidth(value: number);
  428. /**
  429. * Gets or sets the ideal height used to design controls.
  430. * The GUI will then rescale everything accordingly
  431. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  432. */
  433. get idealHeight(): number;
  434. set idealHeight(value: number);
  435. /**
  436. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  437. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  438. */
  439. get useSmallestIdeal(): boolean;
  440. set useSmallestIdeal(value: boolean);
  441. /**
  442. * Gets or sets a boolean indicating if adaptive scaling must be used
  443. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  444. */
  445. get renderAtIdealSize(): boolean;
  446. set renderAtIdealSize(value: boolean);
  447. /**
  448. * Gets the ratio used when in "ideal mode"
  449. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  450. * */
  451. get idealRatio(): number;
  452. /**
  453. * Gets the underlying layer used to render the texture when in fullscreen mode
  454. */
  455. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  456. /**
  457. * Gets the root container control
  458. */
  459. get rootContainer(): Container;
  460. /**
  461. * Returns an array containing the root container.
  462. * This is mostly used to let the Inspector introspects the ADT
  463. * @returns an array containing the rootContainer
  464. */
  465. getChildren(): Array<Container>;
  466. /**
  467. * Will return all controls that are inside this texture
  468. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  469. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  470. * @return all child controls
  471. */
  472. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  473. /**
  474. * Gets or sets the current focused control
  475. */
  476. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  477. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  478. /**
  479. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  480. */
  481. get isForeground(): boolean;
  482. set isForeground(value: boolean);
  483. /**
  484. * Gets or set information about clipboardData
  485. */
  486. get clipboardData(): string;
  487. set clipboardData(value: string);
  488. /**
  489. * Creates a new AdvancedDynamicTexture
  490. * @param name defines the name of the texture
  491. * @param width defines the width of the texture
  492. * @param height defines the height of the texture
  493. * @param scene defines the hosting scene
  494. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  495. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  496. */
  497. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  498. /**
  499. * Get the current class name of the texture useful for serialization or dynamic coding.
  500. * @returns "AdvancedDynamicTexture"
  501. */
  502. getClassName(): string;
  503. /**
  504. * Function used to execute a function on all controls
  505. * @param func defines the function to execute
  506. * @param container defines the container where controls belong. If null the root container will be used
  507. */
  508. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  509. private _useInvalidateRectOptimization;
  510. /**
  511. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  512. */
  513. get useInvalidateRectOptimization(): boolean;
  514. set useInvalidateRectOptimization(value: boolean);
  515. private _invalidatedRectangle;
  516. /**
  517. * Invalidates a rectangle area on the gui texture
  518. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  519. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  520. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  521. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  522. */
  523. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  524. /**
  525. * Marks the texture as dirty forcing a complete update
  526. */
  527. markAsDirty(): void;
  528. /**
  529. * Helper function used to create a new style
  530. * @returns a new style
  531. * @see https://doc.babylonjs.com/how_to/gui#styles
  532. */
  533. createStyle(): Style;
  534. /**
  535. * Adds a new control to the root container
  536. * @param control defines the control to add
  537. * @returns the current texture
  538. */
  539. addControl(control: Control): AdvancedDynamicTexture;
  540. /**
  541. * Removes a control from the root container
  542. * @param control defines the control to remove
  543. * @returns the current texture
  544. */
  545. removeControl(control: Control): AdvancedDynamicTexture;
  546. /**
  547. * Release all resources
  548. */
  549. dispose(): void;
  550. private _onResize;
  551. /** @hidden */
  552. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  553. /**
  554. * Get screen coordinates for a vector3
  555. * @param position defines the position to project
  556. * @param worldMatrix defines the world matrix to use
  557. * @returns the projected position
  558. */
  559. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  560. private _checkUpdate;
  561. private _clearMeasure;
  562. private _render;
  563. /** @hidden */
  564. _changeCursor(cursor: string): void;
  565. /** @hidden */
  566. _registerLastControlDown(control: Control, pointerId: number): void;
  567. private _doPicking;
  568. /** @hidden */
  569. _cleanControlAfterRemovalFromList(list: {
  570. [pointerId: number]: Control;
  571. }, control: Control): void;
  572. /** @hidden */
  573. _cleanControlAfterRemoval(control: Control): void;
  574. /** Attach to all scene events required to support pointer events */
  575. attach(): void;
  576. /** @hidden */
  577. private onClipboardCopy;
  578. /** @hidden */
  579. private onClipboardCut;
  580. /** @hidden */
  581. private onClipboardPaste;
  582. /**
  583. * Register the clipboard Events onto the canvas
  584. */
  585. registerClipboardEvents(): void;
  586. /**
  587. * Unregister the clipboard Events from the canvas
  588. */
  589. unRegisterClipboardEvents(): void;
  590. /**
  591. * Connect the texture to a hosting mesh to enable interactions
  592. * @param mesh defines the mesh to attach to
  593. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  594. */
  595. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  596. /**
  597. * Move the focus to a specific control
  598. * @param control defines the control which will receive the focus
  599. */
  600. moveFocusToControl(control: IFocusableControl): void;
  601. private _manageFocus;
  602. private _attachToOnPointerOut;
  603. /**
  604. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  605. * @param mesh defines the mesh which will receive the texture
  606. * @param width defines the texture width (1024 by default)
  607. * @param height defines the texture height (1024 by default)
  608. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  609. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  610. * @returns a new AdvancedDynamicTexture
  611. */
  612. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  613. /**
  614. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  615. * In this mode the texture will rely on a layer for its rendering.
  616. * This allows it to be treated like any other layer.
  617. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  618. * LayerMask is set through advancedTexture.layer.layerMask
  619. * @param name defines name for the texture
  620. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  621. * @param scene defines the hsoting scene
  622. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  623. * @returns a new AdvancedDynamicTexture
  624. */
  625. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  626. }
  627. }
  628. declare module BABYLON.GUI {
  629. /**
  630. * Root class used for all 2D controls
  631. * @see https://doc.babylonjs.com/how_to/gui#controls
  632. */
  633. export class Control {
  634. /** defines the name of the control */
  635. name?: string | undefined;
  636. /**
  637. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  638. */
  639. static AllowAlphaInheritance: boolean;
  640. private _alpha;
  641. private _alphaSet;
  642. private _zIndex;
  643. /** @hidden */
  644. _host: AdvancedDynamicTexture;
  645. /** Gets or sets the control parent */
  646. parent: BABYLON.Nullable<Container>;
  647. /** @hidden */
  648. _currentMeasure: Measure;
  649. private _fontFamily;
  650. private _fontStyle;
  651. private _fontWeight;
  652. private _fontSize;
  653. private _font;
  654. /** @hidden */
  655. _width: ValueAndUnit;
  656. /** @hidden */
  657. _height: ValueAndUnit;
  658. /** @hidden */
  659. protected _fontOffset: {
  660. ascent: number;
  661. height: number;
  662. descent: number;
  663. };
  664. private _color;
  665. private _style;
  666. private _styleObserver;
  667. /** @hidden */
  668. protected _horizontalAlignment: number;
  669. /** @hidden */
  670. protected _verticalAlignment: number;
  671. /** @hidden */
  672. protected _isDirty: boolean;
  673. /** @hidden */
  674. protected _wasDirty: boolean;
  675. /** @hidden */
  676. _tempParentMeasure: Measure;
  677. /** @hidden */
  678. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  679. /** @hidden */
  680. protected _cachedParentMeasure: Measure;
  681. private _paddingLeft;
  682. private _paddingRight;
  683. private _paddingTop;
  684. private _paddingBottom;
  685. /** @hidden */
  686. _left: ValueAndUnit;
  687. /** @hidden */
  688. _top: ValueAndUnit;
  689. private _scaleX;
  690. private _scaleY;
  691. private _rotation;
  692. private _transformCenterX;
  693. private _transformCenterY;
  694. /** @hidden */
  695. _transformMatrix: Matrix2D;
  696. /** @hidden */
  697. protected _invertTransformMatrix: Matrix2D;
  698. /** @hidden */
  699. protected _transformedPosition: BABYLON.Vector2;
  700. private _isMatrixDirty;
  701. private _cachedOffsetX;
  702. private _cachedOffsetY;
  703. private _isVisible;
  704. private _isHighlighted;
  705. /** @hidden */
  706. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  707. private _fontSet;
  708. private _dummyVector2;
  709. private _downCount;
  710. private _enterCount;
  711. private _doNotRender;
  712. private _downPointerIds;
  713. protected _isEnabled: boolean;
  714. protected _disabledColor: string;
  715. protected _disabledColorItem: string;
  716. /** @hidden */
  717. protected _rebuildLayout: boolean;
  718. /** @hidden */
  719. _customData: any;
  720. /** @hidden */
  721. _isClipped: boolean;
  722. /** @hidden */
  723. _automaticSize: boolean;
  724. /** @hidden */
  725. _tag: any;
  726. /**
  727. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  728. */
  729. uniqueId: number;
  730. /**
  731. * Gets or sets an object used to store user defined information for the node
  732. */
  733. metadata: any;
  734. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  735. isHitTestVisible: boolean;
  736. /** Gets or sets a boolean indicating if the control can block pointer events */
  737. isPointerBlocker: boolean;
  738. /** Gets or sets a boolean indicating if the control can be focusable */
  739. isFocusInvisible: boolean;
  740. /**
  741. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  742. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  743. */
  744. clipChildren: boolean;
  745. /**
  746. * Gets or sets a boolean indicating that control content must be clipped
  747. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  748. */
  749. clipContent: boolean;
  750. /**
  751. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  752. */
  753. useBitmapCache: boolean;
  754. private _cacheData;
  755. private _shadowOffsetX;
  756. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  757. get shadowOffsetX(): number;
  758. set shadowOffsetX(value: number);
  759. private _shadowOffsetY;
  760. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  761. get shadowOffsetY(): number;
  762. set shadowOffsetY(value: number);
  763. private _shadowBlur;
  764. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  765. get shadowBlur(): number;
  766. set shadowBlur(value: number);
  767. private _shadowColor;
  768. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  769. get shadowColor(): string;
  770. set shadowColor(value: string);
  771. /** Gets or sets the cursor to use when the control is hovered */
  772. hoverCursor: string;
  773. /** @hidden */
  774. protected _linkOffsetX: ValueAndUnit;
  775. /** @hidden */
  776. protected _linkOffsetY: ValueAndUnit;
  777. /** Gets the control type name */
  778. get typeName(): string;
  779. /**
  780. * Get the current class name of the control.
  781. * @returns current class name
  782. */
  783. getClassName(): string;
  784. /**
  785. * An event triggered when pointer wheel is scrolled
  786. */
  787. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  788. /**
  789. * An event triggered when the pointer move over the control.
  790. */
  791. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  792. /**
  793. * An event triggered when the pointer move out of the control.
  794. */
  795. onPointerOutObservable: BABYLON.Observable<Control>;
  796. /**
  797. * An event triggered when the pointer taps the control
  798. */
  799. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  800. /**
  801. * An event triggered when pointer up
  802. */
  803. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  804. /**
  805. * An event triggered when a control is clicked on
  806. */
  807. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  808. /**
  809. * An event triggered when pointer enters the control
  810. */
  811. onPointerEnterObservable: BABYLON.Observable<Control>;
  812. /**
  813. * An event triggered when the control is marked as dirty
  814. */
  815. onDirtyObservable: BABYLON.Observable<Control>;
  816. /**
  817. * An event triggered before drawing the control
  818. */
  819. onBeforeDrawObservable: BABYLON.Observable<Control>;
  820. /**
  821. * An event triggered after the control was drawn
  822. */
  823. onAfterDrawObservable: BABYLON.Observable<Control>;
  824. /**
  825. * An event triggered when the control has been disposed
  826. */
  827. onDisposeObservable: BABYLON.Observable<Control>;
  828. /**
  829. * Get the hosting AdvancedDynamicTexture
  830. */
  831. get host(): AdvancedDynamicTexture;
  832. /** Gets or set information about font offsets (used to render and align text) */
  833. get fontOffset(): {
  834. ascent: number;
  835. height: number;
  836. descent: number;
  837. };
  838. set fontOffset(offset: {
  839. ascent: number;
  840. height: number;
  841. descent: number;
  842. });
  843. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  844. get alpha(): number;
  845. set alpha(value: number);
  846. /**
  847. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  848. */
  849. get isHighlighted(): boolean;
  850. set isHighlighted(value: boolean);
  851. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  852. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  853. */
  854. get scaleX(): number;
  855. set scaleX(value: number);
  856. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  857. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  858. */
  859. get scaleY(): number;
  860. set scaleY(value: number);
  861. /** Gets or sets the rotation angle (0 by default)
  862. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  863. */
  864. get rotation(): number;
  865. set rotation(value: number);
  866. /** Gets or sets the transformation center on Y axis (0 by default)
  867. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  868. */
  869. get transformCenterY(): number;
  870. set transformCenterY(value: number);
  871. /** Gets or sets the transformation center on X axis (0 by default)
  872. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  873. */
  874. get transformCenterX(): number;
  875. set transformCenterX(value: number);
  876. /**
  877. * Gets or sets the horizontal alignment
  878. * @see https://doc.babylonjs.com/how_to/gui#alignments
  879. */
  880. get horizontalAlignment(): number;
  881. set horizontalAlignment(value: number);
  882. /**
  883. * Gets or sets the vertical alignment
  884. * @see https://doc.babylonjs.com/how_to/gui#alignments
  885. */
  886. get verticalAlignment(): number;
  887. set verticalAlignment(value: number);
  888. /**
  889. * Gets or sets control width
  890. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  891. */
  892. get width(): string | number;
  893. set width(value: string | number);
  894. /**
  895. * Gets or sets the control width in pixel
  896. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  897. */
  898. get widthInPixels(): number;
  899. set widthInPixels(value: number);
  900. /**
  901. * Gets or sets control height
  902. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  903. */
  904. get height(): string | number;
  905. set height(value: string | number);
  906. /**
  907. * Gets or sets control height in pixel
  908. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  909. */
  910. get heightInPixels(): number;
  911. set heightInPixels(value: number);
  912. /** Gets or set font family */
  913. get fontFamily(): string;
  914. set fontFamily(value: string);
  915. /** Gets or sets font style */
  916. get fontStyle(): string;
  917. set fontStyle(value: string);
  918. /** Gets or sets font weight */
  919. get fontWeight(): string;
  920. set fontWeight(value: string);
  921. /**
  922. * Gets or sets style
  923. * @see https://doc.babylonjs.com/how_to/gui#styles
  924. */
  925. get style(): BABYLON.Nullable<Style>;
  926. set style(value: BABYLON.Nullable<Style>);
  927. /** @hidden */
  928. get _isFontSizeInPercentage(): boolean;
  929. /** Gets or sets font size in pixels */
  930. get fontSizeInPixels(): number;
  931. set fontSizeInPixels(value: number);
  932. /** Gets or sets font size */
  933. get fontSize(): string | number;
  934. set fontSize(value: string | number);
  935. /** Gets or sets foreground color */
  936. get color(): string;
  937. set color(value: string);
  938. /** Gets or sets z index which is used to reorder controls on the z axis */
  939. get zIndex(): number;
  940. set zIndex(value: number);
  941. /** Gets or sets a boolean indicating if the control can be rendered */
  942. get notRenderable(): boolean;
  943. set notRenderable(value: boolean);
  944. /** Gets or sets a boolean indicating if the control is visible */
  945. get isVisible(): boolean;
  946. set isVisible(value: boolean);
  947. /** Gets a boolean indicating that the control needs to update its rendering */
  948. get isDirty(): boolean;
  949. /**
  950. * Gets the current linked mesh (or null if none)
  951. */
  952. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  953. /**
  954. * Gets or sets a value indicating the padding to use on the left of the control
  955. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  956. */
  957. get paddingLeft(): string | number;
  958. set paddingLeft(value: string | number);
  959. /**
  960. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  961. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  962. */
  963. get paddingLeftInPixels(): number;
  964. set paddingLeftInPixels(value: number);
  965. /**
  966. * Gets or sets a value indicating the padding to use on the right of the control
  967. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  968. */
  969. get paddingRight(): string | number;
  970. set paddingRight(value: string | number);
  971. /**
  972. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  974. */
  975. get paddingRightInPixels(): number;
  976. set paddingRightInPixels(value: number);
  977. /**
  978. * Gets or sets a value indicating the padding to use on the top of the control
  979. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  980. */
  981. get paddingTop(): string | number;
  982. set paddingTop(value: string | number);
  983. /**
  984. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  985. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  986. */
  987. get paddingTopInPixels(): number;
  988. set paddingTopInPixels(value: number);
  989. /**
  990. * Gets or sets a value indicating the padding to use on the bottom of the control
  991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  992. */
  993. get paddingBottom(): string | number;
  994. set paddingBottom(value: string | number);
  995. /**
  996. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  997. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  998. */
  999. get paddingBottomInPixels(): number;
  1000. set paddingBottomInPixels(value: number);
  1001. /**
  1002. * Gets or sets a value indicating the left coordinate of the control
  1003. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1004. */
  1005. get left(): string | number;
  1006. set left(value: string | number);
  1007. /**
  1008. * Gets or sets a value indicating the left coordinate in pixels of the control
  1009. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1010. */
  1011. get leftInPixels(): number;
  1012. set leftInPixels(value: number);
  1013. /**
  1014. * Gets or sets a value indicating the top coordinate of the control
  1015. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1016. */
  1017. get top(): string | number;
  1018. set top(value: string | number);
  1019. /**
  1020. * Gets or sets a value indicating the top coordinate in pixels of the control
  1021. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1022. */
  1023. get topInPixels(): number;
  1024. set topInPixels(value: number);
  1025. /**
  1026. * Gets or sets a value indicating the offset on X axis to the linked mesh
  1027. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  1028. */
  1029. get linkOffsetX(): string | number;
  1030. set linkOffsetX(value: string | number);
  1031. /**
  1032. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  1033. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  1034. */
  1035. get linkOffsetXInPixels(): number;
  1036. set linkOffsetXInPixels(value: number);
  1037. /**
  1038. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  1039. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  1040. */
  1041. get linkOffsetY(): string | number;
  1042. set linkOffsetY(value: string | number);
  1043. /**
  1044. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  1045. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  1046. */
  1047. get linkOffsetYInPixels(): number;
  1048. set linkOffsetYInPixels(value: number);
  1049. /** Gets the center coordinate on X axis */
  1050. get centerX(): number;
  1051. /** Gets the center coordinate on Y axis */
  1052. get centerY(): number;
  1053. /** Gets or sets if control is Enabled*/
  1054. get isEnabled(): boolean;
  1055. set isEnabled(value: boolean);
  1056. /** Gets or sets background color of control if it's disabled*/
  1057. get disabledColor(): string;
  1058. set disabledColor(value: string);
  1059. /** Gets or sets front color of control if it's disabled*/
  1060. get disabledColorItem(): string;
  1061. set disabledColorItem(value: string);
  1062. /**
  1063. * Creates a new control
  1064. * @param name defines the name of the control
  1065. */
  1066. constructor(
  1067. /** defines the name of the control */
  1068. name?: string | undefined);
  1069. /** @hidden */
  1070. protected _getTypeName(): string;
  1071. /**
  1072. * Gets the first ascendant in the hierarchy of the given type
  1073. * @param className defines the required type
  1074. * @returns the ascendant or null if not found
  1075. */
  1076. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  1077. /** @hidden */
  1078. _resetFontCache(): void;
  1079. /**
  1080. * Determines if a container is an ascendant of the current control
  1081. * @param container defines the container to look for
  1082. * @returns true if the container is one of the ascendant of the control
  1083. */
  1084. isAscendant(container: Control): boolean;
  1085. /**
  1086. * Gets coordinates in local control space
  1087. * @param globalCoordinates defines the coordinates to transform
  1088. * @returns the new coordinates in local space
  1089. */
  1090. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  1091. /**
  1092. * Gets coordinates in local control space
  1093. * @param globalCoordinates defines the coordinates to transform
  1094. * @param result defines the target vector2 where to store the result
  1095. * @returns the current control
  1096. */
  1097. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  1098. /**
  1099. * Gets coordinates in parent local control space
  1100. * @param globalCoordinates defines the coordinates to transform
  1101. * @returns the new coordinates in parent local space
  1102. */
  1103. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  1104. /**
  1105. * Move the current control to a vector3 position projected onto the screen.
  1106. * @param position defines the target position
  1107. * @param scene defines the hosting scene
  1108. */
  1109. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  1110. /**
  1111. * Will store all controls that have this control as ascendant in a given array
  1112. * @param results defines the array where to store the descendants
  1113. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1114. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1115. */
  1116. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1117. /**
  1118. * Will return all controls that have this control as ascendant
  1119. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1120. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1121. * @return all child controls
  1122. */
  1123. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  1124. /**
  1125. * Link current control with a target mesh
  1126. * @param mesh defines the mesh to link with
  1127. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  1128. */
  1129. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  1130. /** @hidden */
  1131. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  1132. /** @hidden */
  1133. _offsetLeft(offset: number): void;
  1134. /** @hidden */
  1135. _offsetTop(offset: number): void;
  1136. /** @hidden */
  1137. _markMatrixAsDirty(): void;
  1138. /** @hidden */
  1139. _flagDescendantsAsMatrixDirty(): void;
  1140. /** @hidden */
  1141. _intersectsRect(rect: Measure): boolean;
  1142. /** @hidden */
  1143. protected invalidateRect(): void;
  1144. /** @hidden */
  1145. _markAsDirty(force?: boolean): void;
  1146. /** @hidden */
  1147. _markAllAsDirty(): void;
  1148. /** @hidden */
  1149. _link(host: AdvancedDynamicTexture): void;
  1150. /** @hidden */
  1151. protected _transform(context?: CanvasRenderingContext2D): void;
  1152. /** @hidden */
  1153. _renderHighlight(context: CanvasRenderingContext2D): void;
  1154. /** @hidden */
  1155. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  1156. /** @hidden */
  1157. protected _applyStates(context: CanvasRenderingContext2D): void;
  1158. /** @hidden */
  1159. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1160. /** @hidden */
  1161. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1162. protected _evaluateClippingState(parentMeasure: Measure): void;
  1163. /** @hidden */
  1164. _measure(): void;
  1165. /** @hidden */
  1166. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1167. /** @hidden */
  1168. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1169. /** @hidden */
  1170. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1171. /** @hidden */
  1172. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1173. private static _ClipMeasure;
  1174. private _tmpMeasureA;
  1175. private _clip;
  1176. /** @hidden */
  1177. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  1178. /** @hidden */
  1179. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1180. /**
  1181. * Tests if a given coordinates belong to the current control
  1182. * @param x defines x coordinate to test
  1183. * @param y defines y coordinate to test
  1184. * @returns true if the coordinates are inside the control
  1185. */
  1186. contains(x: number, y: number): boolean;
  1187. /** @hidden */
  1188. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  1189. /** @hidden */
  1190. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  1191. /** @hidden */
  1192. _onPointerEnter(target: Control): boolean;
  1193. /** @hidden */
  1194. _onPointerOut(target: Control, force?: boolean): void;
  1195. /** @hidden */
  1196. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1197. /** @hidden */
  1198. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1199. /** @hidden */
  1200. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  1201. /** @hidden */
  1202. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  1203. /** @hidden */
  1204. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  1205. private _prepareFont;
  1206. /** Releases associated resources */
  1207. dispose(): void;
  1208. private static _HORIZONTAL_ALIGNMENT_LEFT;
  1209. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  1210. private static _HORIZONTAL_ALIGNMENT_CENTER;
  1211. private static _VERTICAL_ALIGNMENT_TOP;
  1212. private static _VERTICAL_ALIGNMENT_BOTTOM;
  1213. private static _VERTICAL_ALIGNMENT_CENTER;
  1214. /** HORIZONTAL_ALIGNMENT_LEFT */
  1215. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  1216. /** HORIZONTAL_ALIGNMENT_RIGHT */
  1217. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  1218. /** HORIZONTAL_ALIGNMENT_CENTER */
  1219. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  1220. /** VERTICAL_ALIGNMENT_TOP */
  1221. static get VERTICAL_ALIGNMENT_TOP(): number;
  1222. /** VERTICAL_ALIGNMENT_BOTTOM */
  1223. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  1224. /** VERTICAL_ALIGNMENT_CENTER */
  1225. static get VERTICAL_ALIGNMENT_CENTER(): number;
  1226. private static _FontHeightSizes;
  1227. /** @hidden */
  1228. static _GetFontOffset(font: string): {
  1229. ascent: number;
  1230. height: number;
  1231. descent: number;
  1232. };
  1233. /**
  1234. * Creates a stack panel that can be used to render headers
  1235. * @param control defines the control to associate with the header
  1236. * @param text defines the text of the header
  1237. * @param size defines the size of the header
  1238. * @param options defines options used to configure the header
  1239. * @returns a new StackPanel
  1240. * @ignore
  1241. * @hidden
  1242. */
  1243. static AddHeader: (control: Control, text: string, size: string | number, options: {
  1244. isHorizontal: boolean;
  1245. controlFirst: boolean;
  1246. }) => any;
  1247. /** @hidden */
  1248. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  1249. }
  1250. }
  1251. declare module BABYLON.GUI {
  1252. /**
  1253. * Root class for 2D containers
  1254. * @see https://doc.babylonjs.com/how_to/gui#containers
  1255. */
  1256. export class Container extends Control {
  1257. name?: string | undefined;
  1258. /** @hidden */
  1259. _children: Control[];
  1260. /** @hidden */
  1261. protected _measureForChildren: Measure;
  1262. /** @hidden */
  1263. protected _background: string;
  1264. /** @hidden */
  1265. protected _adaptWidthToChildren: boolean;
  1266. /** @hidden */
  1267. protected _adaptHeightToChildren: boolean;
  1268. /**
  1269. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  1270. */
  1271. logLayoutCycleErrors: boolean;
  1272. /**
  1273. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  1274. */
  1275. maxLayoutCycle: number;
  1276. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  1277. get adaptHeightToChildren(): boolean;
  1278. set adaptHeightToChildren(value: boolean);
  1279. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  1280. get adaptWidthToChildren(): boolean;
  1281. set adaptWidthToChildren(value: boolean);
  1282. /** Gets or sets background color */
  1283. get background(): string;
  1284. set background(value: string);
  1285. /** Gets the list of children */
  1286. get children(): Control[];
  1287. /**
  1288. * Creates a new Container
  1289. * @param name defines the name of the container
  1290. */
  1291. constructor(name?: string | undefined);
  1292. protected _getTypeName(): string;
  1293. _flagDescendantsAsMatrixDirty(): void;
  1294. /**
  1295. * Gets a child using its name
  1296. * @param name defines the child name to look for
  1297. * @returns the child control if found
  1298. */
  1299. getChildByName(name: string): BABYLON.Nullable<Control>;
  1300. /**
  1301. * Gets a child using its type and its name
  1302. * @param name defines the child name to look for
  1303. * @param type defines the child type to look for
  1304. * @returns the child control if found
  1305. */
  1306. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  1307. /**
  1308. * Search for a specific control in children
  1309. * @param control defines the control to look for
  1310. * @returns true if the control is in child list
  1311. */
  1312. containsControl(control: Control): boolean;
  1313. /**
  1314. * Adds a new control to the current container
  1315. * @param control defines the control to add
  1316. * @returns the current container
  1317. */
  1318. addControl(control: BABYLON.Nullable<Control>): Container;
  1319. /**
  1320. * Removes all controls from the current container
  1321. * @returns the current container
  1322. */
  1323. clearControls(): Container;
  1324. /**
  1325. * Removes a control from the current container
  1326. * @param control defines the control to remove
  1327. * @returns the current container
  1328. */
  1329. removeControl(control: Control): Container;
  1330. /** @hidden */
  1331. _reOrderControl(control: Control): void;
  1332. /** @hidden */
  1333. _offsetLeft(offset: number): void;
  1334. /** @hidden */
  1335. _offsetTop(offset: number): void;
  1336. /** @hidden */
  1337. _markAllAsDirty(): void;
  1338. /** @hidden */
  1339. protected _localDraw(context: CanvasRenderingContext2D): void;
  1340. /** @hidden */
  1341. _link(host: AdvancedDynamicTexture): void;
  1342. /** @hidden */
  1343. protected _beforeLayout(): void;
  1344. /** @hidden */
  1345. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1346. /** @hidden */
  1347. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1348. protected _postMeasure(): void;
  1349. /** @hidden */
  1350. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  1351. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1352. /** @hidden */
  1353. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  1354. /** @hidden */
  1355. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1356. /** Releases associated resources */
  1357. dispose(): void;
  1358. }
  1359. }
  1360. declare module BABYLON.GUI {
  1361. /** Class used to create rectangle container */
  1362. export class Rectangle extends Container {
  1363. name?: string | undefined;
  1364. private _thickness;
  1365. private _cornerRadius;
  1366. /** Gets or sets border thickness */
  1367. get thickness(): number;
  1368. set thickness(value: number);
  1369. /** Gets or sets the corner radius angle */
  1370. get cornerRadius(): number;
  1371. set cornerRadius(value: number);
  1372. /**
  1373. * Creates a new Rectangle
  1374. * @param name defines the control name
  1375. */
  1376. constructor(name?: string | undefined);
  1377. protected _getTypeName(): string;
  1378. protected _localDraw(context: CanvasRenderingContext2D): void;
  1379. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1380. private _drawRoundedRect;
  1381. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1382. }
  1383. }
  1384. declare module BABYLON.GUI {
  1385. /**
  1386. * Enum that determines the text-wrapping mode to use.
  1387. */
  1388. export enum TextWrapping {
  1389. /**
  1390. * Clip the text when it's larger than Control.width; this is the default mode.
  1391. */
  1392. Clip = 0,
  1393. /**
  1394. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  1395. */
  1396. WordWrap = 1,
  1397. /**
  1398. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  1399. */
  1400. Ellipsis = 2
  1401. }
  1402. /**
  1403. * Class used to create text block control
  1404. */
  1405. export class TextBlock extends Control {
  1406. /**
  1407. * Defines the name of the control
  1408. */
  1409. name?: string | undefined;
  1410. private _text;
  1411. private _textWrapping;
  1412. private _textHorizontalAlignment;
  1413. private _textVerticalAlignment;
  1414. private _lines;
  1415. private _resizeToFit;
  1416. private _lineSpacing;
  1417. private _outlineWidth;
  1418. private _outlineColor;
  1419. /**
  1420. * An event triggered after the text is changed
  1421. */
  1422. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  1423. /**
  1424. * An event triggered after the text was broken up into lines
  1425. */
  1426. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  1427. /**
  1428. * Function used to split a string into words. By default, a string is split at each space character found
  1429. */
  1430. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  1431. /**
  1432. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1433. */
  1434. get lines(): any[];
  1435. /**
  1436. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1437. */
  1438. get resizeToFit(): boolean;
  1439. /**
  1440. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1441. */
  1442. set resizeToFit(value: boolean);
  1443. /**
  1444. * Gets or sets a boolean indicating if text must be wrapped
  1445. */
  1446. get textWrapping(): TextWrapping | boolean;
  1447. /**
  1448. * Gets or sets a boolean indicating if text must be wrapped
  1449. */
  1450. set textWrapping(value: TextWrapping | boolean);
  1451. /**
  1452. * Gets or sets text to display
  1453. */
  1454. get text(): string;
  1455. /**
  1456. * Gets or sets text to display
  1457. */
  1458. set text(value: string);
  1459. /**
  1460. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1461. */
  1462. get textHorizontalAlignment(): number;
  1463. /**
  1464. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1465. */
  1466. set textHorizontalAlignment(value: number);
  1467. /**
  1468. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1469. */
  1470. get textVerticalAlignment(): number;
  1471. /**
  1472. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1473. */
  1474. set textVerticalAlignment(value: number);
  1475. /**
  1476. * Gets or sets line spacing value
  1477. */
  1478. set lineSpacing(value: string | number);
  1479. /**
  1480. * Gets or sets line spacing value
  1481. */
  1482. get lineSpacing(): string | number;
  1483. /**
  1484. * Gets or sets outlineWidth of the text to display
  1485. */
  1486. get outlineWidth(): number;
  1487. /**
  1488. * Gets or sets outlineWidth of the text to display
  1489. */
  1490. set outlineWidth(value: number);
  1491. /**
  1492. * Gets or sets outlineColor of the text to display
  1493. */
  1494. get outlineColor(): string;
  1495. /**
  1496. * Gets or sets outlineColor of the text to display
  1497. */
  1498. set outlineColor(value: string);
  1499. /**
  1500. * Creates a new TextBlock object
  1501. * @param name defines the name of the control
  1502. * @param text defines the text to display (emptry string by default)
  1503. */
  1504. constructor(
  1505. /**
  1506. * Defines the name of the control
  1507. */
  1508. name?: string | undefined, text?: string);
  1509. protected _getTypeName(): string;
  1510. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1511. private _drawText;
  1512. /** @hidden */
  1513. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1514. protected _applyStates(context: CanvasRenderingContext2D): void;
  1515. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  1516. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1517. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  1518. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  1519. protected _renderLines(context: CanvasRenderingContext2D): void;
  1520. /**
  1521. * Given a width constraint applied on the text block, find the expected height
  1522. * @returns expected height
  1523. */
  1524. computeExpectedHeight(): number;
  1525. dispose(): void;
  1526. }
  1527. }
  1528. declare module BABYLON.GUI {
  1529. /**
  1530. * Class used to create 2D images
  1531. */
  1532. export class Image extends Control {
  1533. name?: string | undefined;
  1534. private _workingCanvas;
  1535. private _domImage;
  1536. private _imageWidth;
  1537. private _imageHeight;
  1538. private _loaded;
  1539. private _stretch;
  1540. private _source;
  1541. private _autoScale;
  1542. private _sourceLeft;
  1543. private _sourceTop;
  1544. private _sourceWidth;
  1545. private _sourceHeight;
  1546. private _svgAttributesComputationCompleted;
  1547. private _isSVG;
  1548. private _cellWidth;
  1549. private _cellHeight;
  1550. private _cellId;
  1551. private _populateNinePatchSlicesFromImage;
  1552. private _sliceLeft;
  1553. private _sliceRight;
  1554. private _sliceTop;
  1555. private _sliceBottom;
  1556. private _detectPointerOnOpaqueOnly;
  1557. /**
  1558. * BABYLON.Observable notified when the content is loaded
  1559. */
  1560. onImageLoadedObservable: BABYLON.Observable<Image>;
  1561. /**
  1562. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  1563. */
  1564. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  1565. /**
  1566. * Gets a boolean indicating that the content is loaded
  1567. */
  1568. get isLoaded(): boolean;
  1569. /**
  1570. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  1571. */
  1572. get populateNinePatchSlicesFromImage(): boolean;
  1573. set populateNinePatchSlicesFromImage(value: boolean);
  1574. /**
  1575. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  1576. * Beware using this as this will comsume more memory as the image has to be stored twice
  1577. */
  1578. get detectPointerOnOpaqueOnly(): boolean;
  1579. set detectPointerOnOpaqueOnly(value: boolean);
  1580. /**
  1581. * Gets or sets the left value for slicing (9-patch)
  1582. */
  1583. get sliceLeft(): number;
  1584. set sliceLeft(value: number);
  1585. /**
  1586. * Gets or sets the right value for slicing (9-patch)
  1587. */
  1588. get sliceRight(): number;
  1589. set sliceRight(value: number);
  1590. /**
  1591. * Gets or sets the top value for slicing (9-patch)
  1592. */
  1593. get sliceTop(): number;
  1594. set sliceTop(value: number);
  1595. /**
  1596. * Gets or sets the bottom value for slicing (9-patch)
  1597. */
  1598. get sliceBottom(): number;
  1599. set sliceBottom(value: number);
  1600. /**
  1601. * Gets or sets the left coordinate in the source image
  1602. */
  1603. get sourceLeft(): number;
  1604. set sourceLeft(value: number);
  1605. /**
  1606. * Gets or sets the top coordinate in the source image
  1607. */
  1608. get sourceTop(): number;
  1609. set sourceTop(value: number);
  1610. /**
  1611. * Gets or sets the width to capture in the source image
  1612. */
  1613. get sourceWidth(): number;
  1614. set sourceWidth(value: number);
  1615. /**
  1616. * Gets or sets the height to capture in the source image
  1617. */
  1618. get sourceHeight(): number;
  1619. set sourceHeight(value: number);
  1620. /** Indicates if the format of the image is SVG */
  1621. get isSVG(): boolean;
  1622. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  1623. get svgAttributesComputationCompleted(): boolean;
  1624. /**
  1625. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1626. * @see https://doc.babylonjs.com/how_to/gui#image
  1627. */
  1628. get autoScale(): boolean;
  1629. set autoScale(value: boolean);
  1630. /** Gets or sets the streching mode used by the image */
  1631. get stretch(): number;
  1632. set stretch(value: number);
  1633. /** @hidden */
  1634. _rotate90(n: number, preserveProperties?: boolean): Image;
  1635. private _handleRotationForSVGImage;
  1636. private _rotate90SourceProperties;
  1637. /**
  1638. * Gets or sets the internal DOM image used to render the control
  1639. */
  1640. set domImage(value: HTMLImageElement);
  1641. get domImage(): HTMLImageElement;
  1642. private _onImageLoaded;
  1643. private _extractNinePatchSliceDataFromImage;
  1644. /**
  1645. * Gets or sets image source url
  1646. */
  1647. set source(value: BABYLON.Nullable<string>);
  1648. /**
  1649. * Checks for svg document with icon id present
  1650. */
  1651. private _svgCheck;
  1652. /**
  1653. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  1654. * given external svg file and icon id
  1655. */
  1656. private _getSVGAttribs;
  1657. /**
  1658. * Gets or sets the cell width to use when animation sheet is enabled
  1659. * @see https://doc.babylonjs.com/how_to/gui#image
  1660. */
  1661. get cellWidth(): number;
  1662. set cellWidth(value: number);
  1663. /**
  1664. * Gets or sets the cell height to use when animation sheet is enabled
  1665. * @see https://doc.babylonjs.com/how_to/gui#image
  1666. */
  1667. get cellHeight(): number;
  1668. set cellHeight(value: number);
  1669. /**
  1670. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1671. * @see https://doc.babylonjs.com/how_to/gui#image
  1672. */
  1673. get cellId(): number;
  1674. set cellId(value: number);
  1675. /**
  1676. * Creates a new Image
  1677. * @param name defines the control name
  1678. * @param url defines the image url
  1679. */
  1680. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  1681. /**
  1682. * Tests if a given coordinates belong to the current control
  1683. * @param x defines x coordinate to test
  1684. * @param y defines y coordinate to test
  1685. * @returns true if the coordinates are inside the control
  1686. */
  1687. contains(x: number, y: number): boolean;
  1688. protected _getTypeName(): string;
  1689. /** Force the control to synchronize with its content */
  1690. synchronizeSizeWithContent(): void;
  1691. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1692. private _prepareWorkingCanvasForOpaqueDetection;
  1693. private _drawImage;
  1694. _draw(context: CanvasRenderingContext2D): void;
  1695. private _renderCornerPatch;
  1696. private _renderNinePatch;
  1697. dispose(): void;
  1698. /** STRETCH_NONE */
  1699. static readonly STRETCH_NONE: number;
  1700. /** STRETCH_FILL */
  1701. static readonly STRETCH_FILL: number;
  1702. /** STRETCH_UNIFORM */
  1703. static readonly STRETCH_UNIFORM: number;
  1704. /** STRETCH_EXTEND */
  1705. static readonly STRETCH_EXTEND: number;
  1706. /** NINE_PATCH */
  1707. static readonly STRETCH_NINE_PATCH: number;
  1708. }
  1709. }
  1710. declare module BABYLON.GUI {
  1711. /**
  1712. * Class used to create 2D buttons
  1713. */
  1714. export class Button extends Rectangle {
  1715. name?: string | undefined;
  1716. /**
  1717. * Function called to generate a pointer enter animation
  1718. */
  1719. pointerEnterAnimation: () => void;
  1720. /**
  1721. * Function called to generate a pointer out animation
  1722. */
  1723. pointerOutAnimation: () => void;
  1724. /**
  1725. * Function called to generate a pointer down animation
  1726. */
  1727. pointerDownAnimation: () => void;
  1728. /**
  1729. * Function called to generate a pointer up animation
  1730. */
  1731. pointerUpAnimation: () => void;
  1732. /**
  1733. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1734. */
  1735. delegatePickingToChildren: boolean;
  1736. private _image;
  1737. /**
  1738. * Returns the image part of the button (if any)
  1739. */
  1740. get image(): BABYLON.Nullable<Image>;
  1741. private _textBlock;
  1742. /**
  1743. * Returns the image part of the button (if any)
  1744. */
  1745. get textBlock(): BABYLON.Nullable<TextBlock>;
  1746. /**
  1747. * Creates a new Button
  1748. * @param name defines the name of the button
  1749. */
  1750. constructor(name?: string | undefined);
  1751. protected _getTypeName(): string;
  1752. /** @hidden */
  1753. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  1754. /** @hidden */
  1755. _onPointerEnter(target: Control): boolean;
  1756. /** @hidden */
  1757. _onPointerOut(target: Control, force?: boolean): void;
  1758. /** @hidden */
  1759. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1760. /** @hidden */
  1761. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1762. /**
  1763. * Creates a new button made with an image and a text
  1764. * @param name defines the name of the button
  1765. * @param text defines the text of the button
  1766. * @param imageUrl defines the url of the image
  1767. * @returns a new Button
  1768. */
  1769. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1770. /**
  1771. * Creates a new button made with an image
  1772. * @param name defines the name of the button
  1773. * @param imageUrl defines the url of the image
  1774. * @returns a new Button
  1775. */
  1776. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1777. /**
  1778. * Creates a new button made with a text
  1779. * @param name defines the name of the button
  1780. * @param text defines the text of the button
  1781. * @returns a new Button
  1782. */
  1783. static CreateSimpleButton(name: string, text: string): Button;
  1784. /**
  1785. * Creates a new button made with an image and a centered text
  1786. * @param name defines the name of the button
  1787. * @param text defines the text of the button
  1788. * @param imageUrl defines the url of the image
  1789. * @returns a new Button
  1790. */
  1791. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1792. }
  1793. }
  1794. declare module BABYLON.GUI {
  1795. /**
  1796. * Class used to create a 2D stack panel container
  1797. */
  1798. export class StackPanel extends Container {
  1799. name?: string | undefined;
  1800. private _isVertical;
  1801. private _manualWidth;
  1802. private _manualHeight;
  1803. private _doNotTrackManualChanges;
  1804. /**
  1805. * Gets or sets a boolean indicating that layou warnings should be ignored
  1806. */
  1807. ignoreLayoutWarnings: boolean;
  1808. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1809. get isVertical(): boolean;
  1810. set isVertical(value: boolean);
  1811. /**
  1812. * Gets or sets panel width.
  1813. * This value should not be set when in horizontal mode as it will be computed automatically
  1814. */
  1815. set width(value: string | number);
  1816. get width(): string | number;
  1817. /**
  1818. * Gets or sets panel height.
  1819. * This value should not be set when in vertical mode as it will be computed automatically
  1820. */
  1821. set height(value: string | number);
  1822. get height(): string | number;
  1823. /**
  1824. * Creates a new StackPanel
  1825. * @param name defines control name
  1826. */
  1827. constructor(name?: string | undefined);
  1828. protected _getTypeName(): string;
  1829. /** @hidden */
  1830. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1831. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1832. protected _postMeasure(): void;
  1833. }
  1834. }
  1835. declare module BABYLON.GUI {
  1836. /**
  1837. * Class used to represent a 2D checkbox
  1838. */
  1839. export class Checkbox extends Control {
  1840. name?: string | undefined;
  1841. private _isChecked;
  1842. private _background;
  1843. private _checkSizeRatio;
  1844. private _thickness;
  1845. /** Gets or sets border thickness */
  1846. get thickness(): number;
  1847. set thickness(value: number);
  1848. /**
  1849. * BABYLON.Observable raised when isChecked property changes
  1850. */
  1851. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  1852. /** Gets or sets a value indicating the ratio between overall size and check size */
  1853. get checkSizeRatio(): number;
  1854. set checkSizeRatio(value: number);
  1855. /** Gets or sets background color */
  1856. get background(): string;
  1857. set background(value: string);
  1858. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1859. get isChecked(): boolean;
  1860. set isChecked(value: boolean);
  1861. /**
  1862. * Creates a new CheckBox
  1863. * @param name defines the control name
  1864. */
  1865. constructor(name?: string | undefined);
  1866. protected _getTypeName(): string;
  1867. /** @hidden */
  1868. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1869. /** @hidden */
  1870. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1871. /**
  1872. * Utility function to easily create a checkbox with a header
  1873. * @param title defines the label to use for the header
  1874. * @param onValueChanged defines the callback to call when value changes
  1875. * @returns a StackPanel containing the checkbox and a textBlock
  1876. */
  1877. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  1878. }
  1879. }
  1880. declare module BABYLON.GUI {
  1881. /**
  1882. * Class used to store key control properties
  1883. */
  1884. export class KeyPropertySet {
  1885. /** Width */
  1886. width?: string;
  1887. /** Height */
  1888. height?: string;
  1889. /** Left padding */
  1890. paddingLeft?: string;
  1891. /** Right padding */
  1892. paddingRight?: string;
  1893. /** Top padding */
  1894. paddingTop?: string;
  1895. /** Bottom padding */
  1896. paddingBottom?: string;
  1897. /** Foreground color */
  1898. color?: string;
  1899. /** Background color */
  1900. background?: string;
  1901. }
  1902. /**
  1903. * Class used to create virtual keyboard
  1904. */
  1905. export class VirtualKeyboard extends StackPanel {
  1906. /** BABYLON.Observable raised when a key is pressed */
  1907. onKeyPressObservable: BABYLON.Observable<string>;
  1908. /** Gets or sets default key button width */
  1909. defaultButtonWidth: string;
  1910. /** Gets or sets default key button height */
  1911. defaultButtonHeight: string;
  1912. /** Gets or sets default key button left padding */
  1913. defaultButtonPaddingLeft: string;
  1914. /** Gets or sets default key button right padding */
  1915. defaultButtonPaddingRight: string;
  1916. /** Gets or sets default key button top padding */
  1917. defaultButtonPaddingTop: string;
  1918. /** Gets or sets default key button bottom padding */
  1919. defaultButtonPaddingBottom: string;
  1920. /** Gets or sets default key button foreground color */
  1921. defaultButtonColor: string;
  1922. /** Gets or sets default key button background color */
  1923. defaultButtonBackground: string;
  1924. /** Gets or sets shift button foreground color */
  1925. shiftButtonColor: string;
  1926. /** Gets or sets shift button thickness*/
  1927. selectedShiftThickness: number;
  1928. /** Gets shift key state */
  1929. shiftState: number;
  1930. protected _getTypeName(): string;
  1931. private _createKey;
  1932. /**
  1933. * Adds a new row of keys
  1934. * @param keys defines the list of keys to add
  1935. * @param propertySets defines the associated property sets
  1936. */
  1937. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1938. /**
  1939. * Set the shift key to a specific state
  1940. * @param shiftState defines the new shift state
  1941. */
  1942. applyShiftState(shiftState: number): void;
  1943. private _currentlyConnectedInputText;
  1944. private _connectedInputTexts;
  1945. private _onKeyPressObserver;
  1946. /** Gets the input text control currently attached to the keyboard */
  1947. get connectedInputText(): BABYLON.Nullable<InputText>;
  1948. /**
  1949. * Connects the keyboard with an input text control
  1950. *
  1951. * @param input defines the target control
  1952. */
  1953. connect(input: InputText): void;
  1954. /**
  1955. * Disconnects the keyboard from connected InputText controls
  1956. *
  1957. * @param input optionally defines a target control, otherwise all are disconnected
  1958. */
  1959. disconnect(input?: InputText): void;
  1960. private _removeConnectedInputObservables;
  1961. /**
  1962. * Release all resources
  1963. */
  1964. dispose(): void;
  1965. /**
  1966. * Creates a new keyboard using a default layout
  1967. *
  1968. * @param name defines control name
  1969. * @returns a new VirtualKeyboard
  1970. */
  1971. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  1972. }
  1973. }
  1974. declare module BABYLON.GUI {
  1975. /**
  1976. * Class used to create input text control
  1977. */
  1978. export class InputText extends Control implements IFocusableControl {
  1979. name?: string | undefined;
  1980. private _text;
  1981. private _placeholderText;
  1982. private _background;
  1983. private _focusedBackground;
  1984. private _focusedColor;
  1985. private _placeholderColor;
  1986. private _thickness;
  1987. private _margin;
  1988. private _autoStretchWidth;
  1989. private _maxWidth;
  1990. private _isFocused;
  1991. private _blinkTimeout;
  1992. private _blinkIsEven;
  1993. private _cursorOffset;
  1994. private _scrollLeft;
  1995. private _textWidth;
  1996. private _clickedCoordinate;
  1997. private _deadKey;
  1998. private _addKey;
  1999. private _currentKey;
  2000. private _isTextHighlightOn;
  2001. private _textHighlightColor;
  2002. private _highligherOpacity;
  2003. private _highlightedText;
  2004. private _startHighlightIndex;
  2005. private _endHighlightIndex;
  2006. private _cursorIndex;
  2007. private _onFocusSelectAll;
  2008. private _isPointerDown;
  2009. private _onClipboardObserver;
  2010. private _onPointerDblTapObserver;
  2011. /** @hidden */
  2012. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  2013. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  2014. promptMessage: string;
  2015. /** Force disable prompt on mobile device */
  2016. disableMobilePrompt: boolean;
  2017. /** BABYLON.Observable raised when the text changes */
  2018. onTextChangedObservable: BABYLON.Observable<InputText>;
  2019. /** BABYLON.Observable raised just before an entered character is to be added */
  2020. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  2021. /** BABYLON.Observable raised when the control gets the focus */
  2022. onFocusObservable: BABYLON.Observable<InputText>;
  2023. /** BABYLON.Observable raised when the control loses the focus */
  2024. onBlurObservable: BABYLON.Observable<InputText>;
  2025. /**Observable raised when the text is highlighted */
  2026. onTextHighlightObservable: BABYLON.Observable<InputText>;
  2027. /**Observable raised when copy event is triggered */
  2028. onTextCopyObservable: BABYLON.Observable<InputText>;
  2029. /** BABYLON.Observable raised when cut event is triggered */
  2030. onTextCutObservable: BABYLON.Observable<InputText>;
  2031. /** BABYLON.Observable raised when paste event is triggered */
  2032. onTextPasteObservable: BABYLON.Observable<InputText>;
  2033. /** BABYLON.Observable raised when a key event was processed */
  2034. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  2035. /** Gets or sets the maximum width allowed by the control */
  2036. get maxWidth(): string | number;
  2037. /** Gets the maximum width allowed by the control in pixels */
  2038. get maxWidthInPixels(): number;
  2039. set maxWidth(value: string | number);
  2040. /** Gets or sets the text highlighter transparency; default: 0.4 */
  2041. get highligherOpacity(): number;
  2042. set highligherOpacity(value: number);
  2043. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  2044. get onFocusSelectAll(): boolean;
  2045. set onFocusSelectAll(value: boolean);
  2046. /** Gets or sets the text hightlight color */
  2047. get textHighlightColor(): string;
  2048. set textHighlightColor(value: string);
  2049. /** Gets or sets control margin */
  2050. get margin(): string;
  2051. /** Gets control margin in pixels */
  2052. get marginInPixels(): number;
  2053. set margin(value: string);
  2054. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  2055. get autoStretchWidth(): boolean;
  2056. set autoStretchWidth(value: boolean);
  2057. /** Gets or sets border thickness */
  2058. get thickness(): number;
  2059. set thickness(value: number);
  2060. /** Gets or sets the background color when focused */
  2061. get focusedBackground(): string;
  2062. set focusedBackground(value: string);
  2063. /** Gets or sets the background color when focused */
  2064. get focusedColor(): string;
  2065. set focusedColor(value: string);
  2066. /** Gets or sets the background color */
  2067. get background(): string;
  2068. set background(value: string);
  2069. /** Gets or sets the placeholder color */
  2070. get placeholderColor(): string;
  2071. set placeholderColor(value: string);
  2072. /** Gets or sets the text displayed when the control is empty */
  2073. get placeholderText(): string;
  2074. set placeholderText(value: string);
  2075. /** Gets or sets the dead key flag */
  2076. get deadKey(): boolean;
  2077. set deadKey(flag: boolean);
  2078. /** Gets or sets the highlight text */
  2079. get highlightedText(): string;
  2080. set highlightedText(text: string);
  2081. /** Gets or sets if the current key should be added */
  2082. get addKey(): boolean;
  2083. set addKey(flag: boolean);
  2084. /** Gets or sets the value of the current key being entered */
  2085. get currentKey(): string;
  2086. set currentKey(key: string);
  2087. /** Gets or sets the text displayed in the control */
  2088. get text(): string;
  2089. set text(value: string);
  2090. /** Gets or sets control width */
  2091. get width(): string | number;
  2092. set width(value: string | number);
  2093. /**
  2094. * Creates a new InputText
  2095. * @param name defines the control name
  2096. * @param text defines the text of the control
  2097. */
  2098. constructor(name?: string | undefined, text?: string);
  2099. /** @hidden */
  2100. onBlur(): void;
  2101. /** @hidden */
  2102. onFocus(): void;
  2103. protected _getTypeName(): string;
  2104. /**
  2105. * Function called to get the list of controls that should not steal the focus from this control
  2106. * @returns an array of controls
  2107. */
  2108. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  2109. /** @hidden */
  2110. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  2111. /** @hidden */
  2112. private _updateValueFromCursorIndex;
  2113. /** @hidden */
  2114. private _processDblClick;
  2115. /** @hidden */
  2116. private _selectAllText;
  2117. /**
  2118. * Handles the keyboard event
  2119. * @param evt Defines the KeyboardEvent
  2120. */
  2121. processKeyboard(evt: KeyboardEvent): void;
  2122. /** @hidden */
  2123. private _onCopyText;
  2124. /** @hidden */
  2125. private _onCutText;
  2126. /** @hidden */
  2127. private _onPasteText;
  2128. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2129. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2130. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2131. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2132. protected _beforeRenderText(text: string): string;
  2133. dispose(): void;
  2134. }
  2135. }
  2136. declare module BABYLON.GUI {
  2137. /**
  2138. * Class used to create a 2D grid container
  2139. */
  2140. export class Grid extends Container {
  2141. name?: string | undefined;
  2142. private _rowDefinitions;
  2143. private _columnDefinitions;
  2144. private _cells;
  2145. private _childControls;
  2146. /**
  2147. * Gets the number of columns
  2148. */
  2149. get columnCount(): number;
  2150. /**
  2151. * Gets the number of rows
  2152. */
  2153. get rowCount(): number;
  2154. /** Gets the list of children */
  2155. get children(): Control[];
  2156. /** Gets the list of cells (e.g. the containers) */
  2157. get cells(): {
  2158. [key: string]: Container;
  2159. };
  2160. /**
  2161. * Gets the definition of a specific row
  2162. * @param index defines the index of the row
  2163. * @returns the row definition
  2164. */
  2165. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  2166. /**
  2167. * Gets the definition of a specific column
  2168. * @param index defines the index of the column
  2169. * @returns the column definition
  2170. */
  2171. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  2172. /**
  2173. * Adds a new row to the grid
  2174. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2175. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  2176. * @returns the current grid
  2177. */
  2178. addRowDefinition(height: number, isPixel?: boolean): Grid;
  2179. /**
  2180. * Adds a new column to the grid
  2181. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2182. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2183. * @returns the current grid
  2184. */
  2185. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  2186. /**
  2187. * Update a row definition
  2188. * @param index defines the index of the row to update
  2189. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2190. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  2191. * @returns the current grid
  2192. */
  2193. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  2194. /**
  2195. * Update a column definition
  2196. * @param index defines the index of the column to update
  2197. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2198. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2199. * @returns the current grid
  2200. */
  2201. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  2202. /**
  2203. * Gets the list of children stored in a specific cell
  2204. * @param row defines the row to check
  2205. * @param column defines the column to check
  2206. * @returns the list of controls
  2207. */
  2208. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  2209. /**
  2210. * Gets a string representing the child cell info (row x column)
  2211. * @param child defines the control to get info from
  2212. * @returns a string containing the child cell info (row x column)
  2213. */
  2214. getChildCellInfo(child: Control): string;
  2215. private _removeCell;
  2216. private _offsetCell;
  2217. /**
  2218. * Remove a column definition at specified index
  2219. * @param index defines the index of the column to remove
  2220. * @returns the current grid
  2221. */
  2222. removeColumnDefinition(index: number): Grid;
  2223. /**
  2224. * Remove a row definition at specified index
  2225. * @param index defines the index of the row to remove
  2226. * @returns the current grid
  2227. */
  2228. removeRowDefinition(index: number): Grid;
  2229. /**
  2230. * Adds a new control to the current grid
  2231. * @param control defines the control to add
  2232. * @param row defines the row where to add the control (0 by default)
  2233. * @param column defines the column where to add the control (0 by default)
  2234. * @returns the current grid
  2235. */
  2236. addControl(control: Control, row?: number, column?: number): Grid;
  2237. /**
  2238. * Removes a control from the current container
  2239. * @param control defines the control to remove
  2240. * @returns the current container
  2241. */
  2242. removeControl(control: Control): Container;
  2243. /**
  2244. * Creates a new Grid
  2245. * @param name defines control name
  2246. */
  2247. constructor(name?: string | undefined);
  2248. protected _getTypeName(): string;
  2249. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  2250. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2251. _flagDescendantsAsMatrixDirty(): void;
  2252. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  2253. /** Releases associated resources */
  2254. dispose(): void;
  2255. }
  2256. }
  2257. declare module BABYLON.GUI {
  2258. /** Class used to create color pickers */
  2259. export class ColorPicker extends Control {
  2260. name?: string | undefined;
  2261. private static _Epsilon;
  2262. private _colorWheelCanvas;
  2263. private _value;
  2264. private _tmpColor;
  2265. private _pointerStartedOnSquare;
  2266. private _pointerStartedOnWheel;
  2267. private _squareLeft;
  2268. private _squareTop;
  2269. private _squareSize;
  2270. private _h;
  2271. private _s;
  2272. private _v;
  2273. private _lastPointerDownID;
  2274. /**
  2275. * BABYLON.Observable raised when the value changes
  2276. */
  2277. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  2278. /** Gets or sets the color of the color picker */
  2279. get value(): BABYLON.Color3;
  2280. set value(value: BABYLON.Color3);
  2281. /**
  2282. * Gets or sets control width
  2283. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2284. */
  2285. get width(): string | number;
  2286. set width(value: string | number);
  2287. /**
  2288. * Gets or sets control height
  2289. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2290. */
  2291. get height(): string | number;
  2292. /** Gets or sets control height */
  2293. set height(value: string | number);
  2294. /** Gets or sets control size */
  2295. get size(): string | number;
  2296. set size(value: string | number);
  2297. /**
  2298. * Creates a new ColorPicker
  2299. * @param name defines the control name
  2300. */
  2301. constructor(name?: string | undefined);
  2302. protected _getTypeName(): string;
  2303. /** @hidden */
  2304. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2305. private _updateSquareProps;
  2306. private _drawGradientSquare;
  2307. private _drawCircle;
  2308. private _createColorWheelCanvas;
  2309. /** @hidden */
  2310. _draw(context: CanvasRenderingContext2D): void;
  2311. private _pointerIsDown;
  2312. private _updateValueFromPointer;
  2313. private _isPointOnSquare;
  2314. private _isPointOnWheel;
  2315. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2316. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2317. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2318. /**
  2319. * This function expands the color picker by creating a color picker dialog with manual
  2320. * color value input and the ability to save colors into an array to be used later in
  2321. * subsequent launches of the dialogue.
  2322. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2323. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2324. * @returns picked color as a hex string and the saved colors array as hex strings.
  2325. */
  2326. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  2327. pickerWidth?: string;
  2328. pickerHeight?: string;
  2329. headerHeight?: string;
  2330. lastColor?: string;
  2331. swatchLimit?: number;
  2332. numSwatchesPerLine?: number;
  2333. savedColors?: Array<string>;
  2334. }): Promise<{
  2335. savedColors?: string[];
  2336. pickedColor: string;
  2337. }>;
  2338. }
  2339. }
  2340. declare module BABYLON.GUI {
  2341. /** Class used to create 2D ellipse containers */
  2342. export class Ellipse extends Container {
  2343. name?: string | undefined;
  2344. private _thickness;
  2345. /** Gets or sets border thickness */
  2346. get thickness(): number;
  2347. set thickness(value: number);
  2348. /**
  2349. * Creates a new Ellipse
  2350. * @param name defines the control name
  2351. */
  2352. constructor(name?: string | undefined);
  2353. protected _getTypeName(): string;
  2354. protected _localDraw(context: CanvasRenderingContext2D): void;
  2355. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2356. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  2357. }
  2358. }
  2359. declare module BABYLON.GUI {
  2360. /**
  2361. * Class used to create a password control
  2362. */
  2363. export class InputPassword extends InputText {
  2364. protected _beforeRenderText(text: string): string;
  2365. }
  2366. }
  2367. declare module BABYLON.GUI {
  2368. /** Class used to render 2D lines */
  2369. export class Line extends Control {
  2370. name?: string | undefined;
  2371. private _lineWidth;
  2372. private _x1;
  2373. private _y1;
  2374. private _x2;
  2375. private _y2;
  2376. private _dash;
  2377. private _connectedControl;
  2378. private _connectedControlDirtyObserver;
  2379. /** Gets or sets the dash pattern */
  2380. get dash(): Array<number>;
  2381. set dash(value: Array<number>);
  2382. /** Gets or sets the control connected with the line end */
  2383. get connectedControl(): Control;
  2384. set connectedControl(value: Control);
  2385. /** Gets or sets start coordinates on X axis */
  2386. get x1(): string | number;
  2387. set x1(value: string | number);
  2388. /** Gets or sets start coordinates on Y axis */
  2389. get y1(): string | number;
  2390. set y1(value: string | number);
  2391. /** Gets or sets end coordinates on X axis */
  2392. get x2(): string | number;
  2393. set x2(value: string | number);
  2394. /** Gets or sets end coordinates on Y axis */
  2395. get y2(): string | number;
  2396. set y2(value: string | number);
  2397. /** Gets or sets line width */
  2398. get lineWidth(): number;
  2399. set lineWidth(value: number);
  2400. /** Gets or sets horizontal alignment */
  2401. set horizontalAlignment(value: number);
  2402. /** Gets or sets vertical alignment */
  2403. set verticalAlignment(value: number);
  2404. private get _effectiveX2();
  2405. private get _effectiveY2();
  2406. /**
  2407. * Creates a new Line
  2408. * @param name defines the control name
  2409. */
  2410. constructor(name?: string | undefined);
  2411. protected _getTypeName(): string;
  2412. _draw(context: CanvasRenderingContext2D): void;
  2413. _measure(): void;
  2414. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2415. /**
  2416. * Move one end of the line given 3D cartesian coordinates.
  2417. * @param position Targeted world position
  2418. * @param scene BABYLON.Scene
  2419. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2420. */
  2421. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  2422. /**
  2423. * Move one end of the line to a position in screen absolute space.
  2424. * @param projectedPosition Position in screen absolute space (X, Y)
  2425. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2426. */
  2427. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  2428. }
  2429. }
  2430. declare module BABYLON.GUI {
  2431. /**
  2432. * Class used to store a point for a MultiLine object.
  2433. * The point can be pure 2D coordinates, a mesh or a control
  2434. */
  2435. export class MultiLinePoint {
  2436. private _multiLine;
  2437. private _x;
  2438. private _y;
  2439. private _control;
  2440. private _mesh;
  2441. private _controlObserver;
  2442. private _meshObserver;
  2443. /** @hidden */
  2444. _point: BABYLON.Vector2;
  2445. /**
  2446. * Creates a new MultiLinePoint
  2447. * @param multiLine defines the source MultiLine object
  2448. */
  2449. constructor(multiLine: MultiLine);
  2450. /** Gets or sets x coordinate */
  2451. get x(): string | number;
  2452. set x(value: string | number);
  2453. /** Gets or sets y coordinate */
  2454. get y(): string | number;
  2455. set y(value: string | number);
  2456. /** Gets or sets the control associated with this point */
  2457. get control(): BABYLON.Nullable<Control>;
  2458. set control(value: BABYLON.Nullable<Control>);
  2459. /** Gets or sets the mesh associated with this point */
  2460. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  2461. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  2462. /** Resets links */
  2463. resetLinks(): void;
  2464. /**
  2465. * Gets a translation vector
  2466. * @returns the translation vector
  2467. */
  2468. translate(): BABYLON.Vector2;
  2469. private _translatePoint;
  2470. /** Release associated resources */
  2471. dispose(): void;
  2472. }
  2473. }
  2474. declare module BABYLON.GUI {
  2475. /**
  2476. * Class used to create multi line control
  2477. */
  2478. export class MultiLine extends Control {
  2479. name?: string | undefined;
  2480. private _lineWidth;
  2481. private _dash;
  2482. private _points;
  2483. private _minX;
  2484. private _minY;
  2485. private _maxX;
  2486. private _maxY;
  2487. /**
  2488. * Creates a new MultiLine
  2489. * @param name defines the control name
  2490. */
  2491. constructor(name?: string | undefined);
  2492. /** Gets or sets dash pattern */
  2493. get dash(): Array<number>;
  2494. set dash(value: Array<number>);
  2495. /**
  2496. * Gets point stored at specified index
  2497. * @param index defines the index to look for
  2498. * @returns the requested point if found
  2499. */
  2500. getAt(index: number): MultiLinePoint;
  2501. /** Function called when a point is updated */
  2502. onPointUpdate: () => void;
  2503. /**
  2504. * Adds new points to the point collection
  2505. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  2506. * @returns the list of created MultiLinePoint
  2507. */
  2508. add(...items: (AbstractMesh | Control | {
  2509. x: string | number;
  2510. y: string | number;
  2511. })[]): MultiLinePoint[];
  2512. /**
  2513. * Adds a new point to the point collection
  2514. * @param item defines the item (mesh, control or 2d coordiantes) to add
  2515. * @returns the created MultiLinePoint
  2516. */
  2517. push(item?: (AbstractMesh | Control | {
  2518. x: string | number;
  2519. y: string | number;
  2520. })): MultiLinePoint;
  2521. /**
  2522. * Remove a specific value or point from the active point collection
  2523. * @param value defines the value or point to remove
  2524. */
  2525. remove(value: number | MultiLinePoint): void;
  2526. /**
  2527. * Resets this object to initial state (no point)
  2528. */
  2529. reset(): void;
  2530. /**
  2531. * Resets all links
  2532. */
  2533. resetLinks(): void;
  2534. /** Gets or sets line width */
  2535. get lineWidth(): number;
  2536. set lineWidth(value: number);
  2537. set horizontalAlignment(value: number);
  2538. set verticalAlignment(value: number);
  2539. protected _getTypeName(): string;
  2540. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2541. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2542. _measure(): void;
  2543. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2544. dispose(): void;
  2545. }
  2546. }
  2547. declare module BABYLON.GUI {
  2548. /**
  2549. * Class used to create radio button controls
  2550. */
  2551. export class RadioButton extends Control {
  2552. name?: string | undefined;
  2553. private _isChecked;
  2554. private _background;
  2555. private _checkSizeRatio;
  2556. private _thickness;
  2557. /** Gets or sets border thickness */
  2558. get thickness(): number;
  2559. set thickness(value: number);
  2560. /** Gets or sets group name */
  2561. group: string;
  2562. /** BABYLON.Observable raised when isChecked is changed */
  2563. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  2564. /** Gets or sets a value indicating the ratio between overall size and check size */
  2565. get checkSizeRatio(): number;
  2566. set checkSizeRatio(value: number);
  2567. /** Gets or sets background color */
  2568. get background(): string;
  2569. set background(value: string);
  2570. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  2571. get isChecked(): boolean;
  2572. set isChecked(value: boolean);
  2573. /**
  2574. * Creates a new RadioButton
  2575. * @param name defines the control name
  2576. */
  2577. constructor(name?: string | undefined);
  2578. protected _getTypeName(): string;
  2579. _draw(context: CanvasRenderingContext2D): void;
  2580. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2581. /**
  2582. * Utility function to easily create a radio button with a header
  2583. * @param title defines the label to use for the header
  2584. * @param group defines the group to use for the radio button
  2585. * @param isChecked defines the initial state of the radio button
  2586. * @param onValueChanged defines the callback to call when value changes
  2587. * @returns a StackPanel containing the radio button and a textBlock
  2588. */
  2589. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  2590. }
  2591. }
  2592. declare module BABYLON.GUI {
  2593. /**
  2594. * Class used to create slider controls
  2595. */
  2596. export class BaseSlider extends Control {
  2597. name?: string | undefined;
  2598. protected _thumbWidth: ValueAndUnit;
  2599. private _minimum;
  2600. private _maximum;
  2601. private _value;
  2602. private _isVertical;
  2603. protected _barOffset: ValueAndUnit;
  2604. private _isThumbClamped;
  2605. protected _displayThumb: boolean;
  2606. private _step;
  2607. private _lastPointerDownID;
  2608. protected _effectiveBarOffset: number;
  2609. protected _renderLeft: number;
  2610. protected _renderTop: number;
  2611. protected _renderWidth: number;
  2612. protected _renderHeight: number;
  2613. protected _backgroundBoxLength: number;
  2614. protected _backgroundBoxThickness: number;
  2615. protected _effectiveThumbThickness: number;
  2616. /** BABYLON.Observable raised when the sldier value changes */
  2617. onValueChangedObservable: BABYLON.Observable<number>;
  2618. /** Gets or sets a boolean indicating if the thumb must be rendered */
  2619. get displayThumb(): boolean;
  2620. set displayThumb(value: boolean);
  2621. /** Gets or sets a step to apply to values (0 by default) */
  2622. get step(): number;
  2623. set step(value: number);
  2624. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  2625. get barOffset(): string | number;
  2626. /** Gets main bar offset in pixels*/
  2627. get barOffsetInPixels(): number;
  2628. set barOffset(value: string | number);
  2629. /** Gets or sets thumb width */
  2630. get thumbWidth(): string | number;
  2631. /** Gets thumb width in pixels */
  2632. get thumbWidthInPixels(): number;
  2633. set thumbWidth(value: string | number);
  2634. /** Gets or sets minimum value */
  2635. get minimum(): number;
  2636. set minimum(value: number);
  2637. /** Gets or sets maximum value */
  2638. get maximum(): number;
  2639. set maximum(value: number);
  2640. /** Gets or sets current value */
  2641. get value(): number;
  2642. set value(value: number);
  2643. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  2644. get isVertical(): boolean;
  2645. set isVertical(value: boolean);
  2646. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  2647. get isThumbClamped(): boolean;
  2648. set isThumbClamped(value: boolean);
  2649. /**
  2650. * Creates a new BaseSlider
  2651. * @param name defines the control name
  2652. */
  2653. constructor(name?: string | undefined);
  2654. protected _getTypeName(): string;
  2655. protected _getThumbPosition(): number;
  2656. protected _getThumbThickness(type: string): number;
  2657. protected _prepareRenderingData(type: string): void;
  2658. private _pointerIsDown;
  2659. /** @hidden */
  2660. protected _updateValueFromPointer(x: number, y: number): void;
  2661. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2662. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2663. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2664. }
  2665. }
  2666. declare module BABYLON.GUI {
  2667. /**
  2668. * Class used to create slider controls
  2669. */
  2670. export class Slider extends BaseSlider {
  2671. name?: string | undefined;
  2672. private _background;
  2673. private _borderColor;
  2674. private _isThumbCircle;
  2675. protected _displayValueBar: boolean;
  2676. /** Gets or sets a boolean indicating if the value bar must be rendered */
  2677. get displayValueBar(): boolean;
  2678. set displayValueBar(value: boolean);
  2679. /** Gets or sets border color */
  2680. get borderColor(): string;
  2681. set borderColor(value: string);
  2682. /** Gets or sets background color */
  2683. get background(): string;
  2684. set background(value: string);
  2685. /** Gets or sets a boolean indicating if the thumb should be round or square */
  2686. get isThumbCircle(): boolean;
  2687. set isThumbCircle(value: boolean);
  2688. /**
  2689. * Creates a new Slider
  2690. * @param name defines the control name
  2691. */
  2692. constructor(name?: string | undefined);
  2693. protected _getTypeName(): string;
  2694. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2695. }
  2696. }
  2697. declare module BABYLON.GUI {
  2698. /** Class used to create a RadioGroup
  2699. * which contains groups of radio buttons
  2700. */
  2701. export class SelectorGroup {
  2702. /** name of SelectorGroup */
  2703. name: string;
  2704. private _groupPanel;
  2705. private _selectors;
  2706. private _groupHeader;
  2707. /**
  2708. * Creates a new SelectorGroup
  2709. * @param name of group, used as a group heading
  2710. */
  2711. constructor(
  2712. /** name of SelectorGroup */
  2713. name: string);
  2714. /** Gets the groupPanel of the SelectorGroup */
  2715. get groupPanel(): StackPanel;
  2716. /** Gets the selectors array */
  2717. get selectors(): StackPanel[];
  2718. /** Gets and sets the group header */
  2719. get header(): string;
  2720. set header(label: string);
  2721. /** @hidden */
  2722. private _addGroupHeader;
  2723. /** @hidden*/
  2724. _getSelector(selectorNb: number): StackPanel | undefined;
  2725. /** Removes the selector at the given position
  2726. * @param selectorNb the position of the selector within the group
  2727. */
  2728. removeSelector(selectorNb: number): void;
  2729. }
  2730. /** Class used to create a CheckboxGroup
  2731. * which contains groups of checkbox buttons
  2732. */
  2733. export class CheckboxGroup extends SelectorGroup {
  2734. /** Adds a checkbox as a control
  2735. * @param text is the label for the selector
  2736. * @param func is the function called when the Selector is checked
  2737. * @param checked is true when Selector is checked
  2738. */
  2739. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  2740. /** @hidden */
  2741. _setSelectorLabel(selectorNb: number, label: string): void;
  2742. /** @hidden */
  2743. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2744. /** @hidden */
  2745. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2746. /** @hidden */
  2747. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2748. }
  2749. /** Class used to create a RadioGroup
  2750. * which contains groups of radio buttons
  2751. */
  2752. export class RadioGroup extends SelectorGroup {
  2753. private _selectNb;
  2754. /** Adds a radio button as a control
  2755. * @param label is the label for the selector
  2756. * @param func is the function called when the Selector is checked
  2757. * @param checked is true when Selector is checked
  2758. */
  2759. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  2760. /** @hidden */
  2761. _setSelectorLabel(selectorNb: number, label: string): void;
  2762. /** @hidden */
  2763. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2764. /** @hidden */
  2765. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2766. /** @hidden */
  2767. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2768. }
  2769. /** Class used to create a SliderGroup
  2770. * which contains groups of slider buttons
  2771. */
  2772. export class SliderGroup extends SelectorGroup {
  2773. /**
  2774. * Adds a slider to the SelectorGroup
  2775. * @param label is the label for the SliderBar
  2776. * @param func is the function called when the Slider moves
  2777. * @param unit is a string describing the units used, eg degrees or metres
  2778. * @param min is the minimum value for the Slider
  2779. * @param max is the maximum value for the Slider
  2780. * @param value is the start value for the Slider between min and max
  2781. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  2782. */
  2783. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  2784. /** @hidden */
  2785. _setSelectorLabel(selectorNb: number, label: string): void;
  2786. /** @hidden */
  2787. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2788. /** @hidden */
  2789. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2790. /** @hidden */
  2791. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2792. }
  2793. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  2794. * @see https://doc.babylonjs.com/how_to/selector
  2795. */
  2796. export class SelectionPanel extends Rectangle {
  2797. /** name of SelectionPanel */
  2798. name: string;
  2799. /** an array of SelectionGroups */
  2800. groups: SelectorGroup[];
  2801. private _panel;
  2802. private _buttonColor;
  2803. private _buttonBackground;
  2804. private _headerColor;
  2805. private _barColor;
  2806. private _barHeight;
  2807. private _spacerHeight;
  2808. private _labelColor;
  2809. private _groups;
  2810. private _bars;
  2811. /**
  2812. * Creates a new SelectionPanel
  2813. * @param name of SelectionPanel
  2814. * @param groups is an array of SelectionGroups
  2815. */
  2816. constructor(
  2817. /** name of SelectionPanel */
  2818. name: string,
  2819. /** an array of SelectionGroups */
  2820. groups?: SelectorGroup[]);
  2821. protected _getTypeName(): string;
  2822. /** Gets or sets the headerColor */
  2823. get headerColor(): string;
  2824. set headerColor(color: string);
  2825. private _setHeaderColor;
  2826. /** Gets or sets the button color */
  2827. get buttonColor(): string;
  2828. set buttonColor(color: string);
  2829. private _setbuttonColor;
  2830. /** Gets or sets the label color */
  2831. get labelColor(): string;
  2832. set labelColor(color: string);
  2833. private _setLabelColor;
  2834. /** Gets or sets the button background */
  2835. get buttonBackground(): string;
  2836. set buttonBackground(color: string);
  2837. private _setButtonBackground;
  2838. /** Gets or sets the color of separator bar */
  2839. get barColor(): string;
  2840. set barColor(color: string);
  2841. private _setBarColor;
  2842. /** Gets or sets the height of separator bar */
  2843. get barHeight(): string;
  2844. set barHeight(value: string);
  2845. private _setBarHeight;
  2846. /** Gets or sets the height of spacers*/
  2847. get spacerHeight(): string;
  2848. set spacerHeight(value: string);
  2849. private _setSpacerHeight;
  2850. /** Adds a bar between groups */
  2851. private _addSpacer;
  2852. /** Add a group to the selection panel
  2853. * @param group is the selector group to add
  2854. */
  2855. addGroup(group: SelectorGroup): void;
  2856. /** Remove the group from the given position
  2857. * @param groupNb is the position of the group in the list
  2858. */
  2859. removeGroup(groupNb: number): void;
  2860. /** Change a group header label
  2861. * @param label is the new group header label
  2862. * @param groupNb is the number of the group to relabel
  2863. * */
  2864. setHeaderName(label: string, groupNb: number): void;
  2865. /** Change selector label to the one given
  2866. * @param label is the new selector label
  2867. * @param groupNb is the number of the groupcontaining the selector
  2868. * @param selectorNb is the number of the selector within a group to relabel
  2869. * */
  2870. relabel(label: string, groupNb: number, selectorNb: number): void;
  2871. /** For a given group position remove the selector at the given position
  2872. * @param groupNb is the number of the group to remove the selector from
  2873. * @param selectorNb is the number of the selector within the group
  2874. */
  2875. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  2876. /** For a given group position of correct type add a checkbox button
  2877. * @param groupNb is the number of the group to remove the selector from
  2878. * @param label is the label for the selector
  2879. * @param func is the function called when the Selector is checked
  2880. * @param checked is true when Selector is checked
  2881. */
  2882. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2883. /** For a given group position of correct type add a radio button
  2884. * @param groupNb is the number of the group to remove the selector from
  2885. * @param label is the label for the selector
  2886. * @param func is the function called when the Selector is checked
  2887. * @param checked is true when Selector is checked
  2888. */
  2889. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2890. /**
  2891. * For a given slider group add a slider
  2892. * @param groupNb is the number of the group to add the slider to
  2893. * @param label is the label for the Slider
  2894. * @param func is the function called when the Slider moves
  2895. * @param unit is a string describing the units used, eg degrees or metres
  2896. * @param min is the minimum value for the Slider
  2897. * @param max is the maximum value for the Slider
  2898. * @param value is the start value for the Slider between min and max
  2899. * @param onVal is the function used to format the value displayed, eg radians to degrees
  2900. */
  2901. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  2902. }
  2903. }
  2904. declare module BABYLON.GUI {
  2905. /**
  2906. * Class used to hold a the container for ScrollViewer
  2907. * @hidden
  2908. */
  2909. export class _ScrollViewerWindow extends Container {
  2910. parentClientWidth: number;
  2911. parentClientHeight: number;
  2912. private _freezeControls;
  2913. private _parentMeasure;
  2914. private _oldLeft;
  2915. private _oldTop;
  2916. get freezeControls(): boolean;
  2917. set freezeControls(value: boolean);
  2918. private _bucketWidth;
  2919. private _bucketHeight;
  2920. private _buckets;
  2921. private _bucketLen;
  2922. get bucketWidth(): number;
  2923. get bucketHeight(): number;
  2924. setBucketSizes(width: number, height: number): void;
  2925. private _useBuckets;
  2926. private _makeBuckets;
  2927. private _dispatchInBuckets;
  2928. private _updateMeasures;
  2929. private _updateChildrenMeasures;
  2930. private _restoreMeasures;
  2931. /**
  2932. * Creates a new ScrollViewerWindow
  2933. * @param name of ScrollViewerWindow
  2934. */
  2935. constructor(name?: string);
  2936. protected _getTypeName(): string;
  2937. /** @hidden */
  2938. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2939. /** @hidden */
  2940. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  2941. private _scrollChildren;
  2942. private _scrollChildrenWithBuckets;
  2943. /** @hidden */
  2944. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  2945. protected _postMeasure(): void;
  2946. }
  2947. }
  2948. declare module BABYLON.GUI {
  2949. /**
  2950. * Class used to create slider controls
  2951. */
  2952. export class ScrollBar extends BaseSlider {
  2953. name?: string | undefined;
  2954. private _background;
  2955. private _borderColor;
  2956. private _tempMeasure;
  2957. /** Gets or sets border color */
  2958. get borderColor(): string;
  2959. set borderColor(value: string);
  2960. /** Gets or sets background color */
  2961. get background(): string;
  2962. set background(value: string);
  2963. /**
  2964. * Creates a new Slider
  2965. * @param name defines the control name
  2966. */
  2967. constructor(name?: string | undefined);
  2968. protected _getTypeName(): string;
  2969. protected _getThumbThickness(): number;
  2970. _draw(context: CanvasRenderingContext2D): void;
  2971. private _first;
  2972. private _originX;
  2973. private _originY;
  2974. /** @hidden */
  2975. protected _updateValueFromPointer(x: number, y: number): void;
  2976. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2977. }
  2978. }
  2979. declare module BABYLON.GUI {
  2980. /**
  2981. * Class used to create slider controls
  2982. */
  2983. export class ImageScrollBar extends BaseSlider {
  2984. name?: string | undefined;
  2985. private _backgroundBaseImage;
  2986. private _backgroundImage;
  2987. private _thumbImage;
  2988. private _thumbBaseImage;
  2989. private _thumbLength;
  2990. private _thumbHeight;
  2991. private _barImageHeight;
  2992. private _tempMeasure;
  2993. /** Number of 90° rotation to apply on the images when in vertical mode */
  2994. num90RotationInVerticalMode: number;
  2995. /**
  2996. * Gets or sets the image used to render the background for horizontal bar
  2997. */
  2998. get backgroundImage(): Image;
  2999. set backgroundImage(value: Image);
  3000. /**
  3001. * Gets or sets the image used to render the thumb
  3002. */
  3003. get thumbImage(): Image;
  3004. set thumbImage(value: Image);
  3005. /**
  3006. * Gets or sets the length of the thumb
  3007. */
  3008. get thumbLength(): number;
  3009. set thumbLength(value: number);
  3010. /**
  3011. * Gets or sets the height of the thumb
  3012. */
  3013. get thumbHeight(): number;
  3014. set thumbHeight(value: number);
  3015. /**
  3016. * Gets or sets the height of the bar image
  3017. */
  3018. get barImageHeight(): number;
  3019. set barImageHeight(value: number);
  3020. /**
  3021. * Creates a new ImageScrollBar
  3022. * @param name defines the control name
  3023. */
  3024. constructor(name?: string | undefined);
  3025. protected _getTypeName(): string;
  3026. protected _getThumbThickness(): number;
  3027. _draw(context: CanvasRenderingContext2D): void;
  3028. private _first;
  3029. private _originX;
  3030. private _originY;
  3031. /** @hidden */
  3032. protected _updateValueFromPointer(x: number, y: number): void;
  3033. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  3034. }
  3035. }
  3036. declare module BABYLON.GUI {
  3037. /**
  3038. * Class used to hold a viewer window and sliders in a grid
  3039. */
  3040. export class ScrollViewer extends Rectangle {
  3041. private _grid;
  3042. private _horizontalBarSpace;
  3043. private _verticalBarSpace;
  3044. private _dragSpace;
  3045. private _horizontalBar;
  3046. private _verticalBar;
  3047. private _barColor;
  3048. private _barBackground;
  3049. private _barImage;
  3050. private _horizontalBarImage;
  3051. private _verticalBarImage;
  3052. private _barBackgroundImage;
  3053. private _horizontalBarBackgroundImage;
  3054. private _verticalBarBackgroundImage;
  3055. private _barSize;
  3056. private _window;
  3057. private _pointerIsOver;
  3058. private _wheelPrecision;
  3059. private _onWheelObserver;
  3060. private _clientWidth;
  3061. private _clientHeight;
  3062. private _useImageBar;
  3063. private _thumbLength;
  3064. private _thumbHeight;
  3065. private _barImageHeight;
  3066. private _horizontalBarImageHeight;
  3067. private _verticalBarImageHeight;
  3068. private _oldWindowContentsWidth;
  3069. private _oldWindowContentsHeight;
  3070. /**
  3071. * Gets the horizontal scrollbar
  3072. */
  3073. get horizontalBar(): ScrollBar | ImageScrollBar;
  3074. /**
  3075. * Gets the vertical scrollbar
  3076. */
  3077. get verticalBar(): ScrollBar | ImageScrollBar;
  3078. /**
  3079. * Adds a new control to the current container
  3080. * @param control defines the control to add
  3081. * @returns the current container
  3082. */
  3083. addControl(control: BABYLON.Nullable<Control>): Container;
  3084. /**
  3085. * Removes a control from the current container
  3086. * @param control defines the control to remove
  3087. * @returns the current container
  3088. */
  3089. removeControl(control: Control): Container;
  3090. /** Gets the list of children */
  3091. get children(): Control[];
  3092. _flagDescendantsAsMatrixDirty(): void;
  3093. /**
  3094. * Freezes or unfreezes the controls in the window.
  3095. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  3096. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  3097. */
  3098. get freezeControls(): boolean;
  3099. set freezeControls(value: boolean);
  3100. /** Gets the bucket width */
  3101. get bucketWidth(): number;
  3102. /** Gets the bucket height */
  3103. get bucketHeight(): number;
  3104. /**
  3105. * Sets the bucket sizes.
  3106. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  3107. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  3108. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  3109. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  3110. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  3111. * used), that's why it is not enabled by default.
  3112. * @param width width of the bucket
  3113. * @param height height of the bucket
  3114. */
  3115. setBucketSizes(width: number, height: number): void;
  3116. private _forceHorizontalBar;
  3117. private _forceVerticalBar;
  3118. /**
  3119. * Forces the horizontal scroll bar to be displayed
  3120. */
  3121. get forceHorizontalBar(): boolean;
  3122. set forceHorizontalBar(value: boolean);
  3123. /**
  3124. * Forces the vertical scroll bar to be displayed
  3125. */
  3126. get forceVerticalBar(): boolean;
  3127. set forceVerticalBar(value: boolean);
  3128. /**
  3129. * Creates a new ScrollViewer
  3130. * @param name of ScrollViewer
  3131. */
  3132. constructor(name?: string, isImageBased?: boolean);
  3133. /** Reset the scroll viewer window to initial size */
  3134. resetWindow(): void;
  3135. protected _getTypeName(): string;
  3136. private _buildClientSizes;
  3137. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3138. protected _postMeasure(): void;
  3139. /**
  3140. * Gets or sets the mouse wheel precision
  3141. * from 0 to 1 with a default value of 0.05
  3142. * */
  3143. get wheelPrecision(): number;
  3144. set wheelPrecision(value: number);
  3145. /** Gets or sets the scroll bar container background color */
  3146. get scrollBackground(): string;
  3147. set scrollBackground(color: string);
  3148. /** Gets or sets the bar color */
  3149. get barColor(): string;
  3150. set barColor(color: string);
  3151. /** Gets or sets the bar image */
  3152. get thumbImage(): Image;
  3153. set thumbImage(value: Image);
  3154. /** Gets or sets the horizontal bar image */
  3155. get horizontalThumbImage(): Image;
  3156. set horizontalThumbImage(value: Image);
  3157. /** Gets or sets the vertical bar image */
  3158. get verticalThumbImage(): Image;
  3159. set verticalThumbImage(value: Image);
  3160. /** Gets or sets the size of the bar */
  3161. get barSize(): number;
  3162. set barSize(value: number);
  3163. /** Gets or sets the length of the thumb */
  3164. get thumbLength(): number;
  3165. set thumbLength(value: number);
  3166. /** Gets or sets the height of the thumb */
  3167. get thumbHeight(): number;
  3168. set thumbHeight(value: number);
  3169. /** Gets or sets the height of the bar image */
  3170. get barImageHeight(): number;
  3171. set barImageHeight(value: number);
  3172. /** Gets or sets the height of the horizontal bar image */
  3173. get horizontalBarImageHeight(): number;
  3174. set horizontalBarImageHeight(value: number);
  3175. /** Gets or sets the height of the vertical bar image */
  3176. get verticalBarImageHeight(): number;
  3177. set verticalBarImageHeight(value: number);
  3178. /** Gets or sets the bar background */
  3179. get barBackground(): string;
  3180. set barBackground(color: string);
  3181. /** Gets or sets the bar background image */
  3182. get barImage(): Image;
  3183. set barImage(value: Image);
  3184. /** Gets or sets the horizontal bar background image */
  3185. get horizontalBarImage(): Image;
  3186. set horizontalBarImage(value: Image);
  3187. /** Gets or sets the vertical bar background image */
  3188. get verticalBarImage(): Image;
  3189. set verticalBarImage(value: Image);
  3190. private _setWindowPosition;
  3191. /** @hidden */
  3192. private _updateScroller;
  3193. _link(host: AdvancedDynamicTexture): void;
  3194. /** @hidden */
  3195. private _addBar;
  3196. /** @hidden */
  3197. private _attachWheel;
  3198. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  3199. /** Releases associated resources */
  3200. dispose(): void;
  3201. }
  3202. }
  3203. declare module BABYLON.GUI {
  3204. /** Class used to render a grid */
  3205. export class DisplayGrid extends Control {
  3206. name?: string | undefined;
  3207. private _cellWidth;
  3208. private _cellHeight;
  3209. private _minorLineTickness;
  3210. private _minorLineColor;
  3211. private _majorLineTickness;
  3212. private _majorLineColor;
  3213. private _majorLineFrequency;
  3214. private _background;
  3215. private _displayMajorLines;
  3216. private _displayMinorLines;
  3217. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  3218. get displayMinorLines(): boolean;
  3219. set displayMinorLines(value: boolean);
  3220. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  3221. get displayMajorLines(): boolean;
  3222. set displayMajorLines(value: boolean);
  3223. /** Gets or sets background color (Black by default) */
  3224. get background(): string;
  3225. set background(value: string);
  3226. /** Gets or sets the width of each cell (20 by default) */
  3227. get cellWidth(): number;
  3228. set cellWidth(value: number);
  3229. /** Gets or sets the height of each cell (20 by default) */
  3230. get cellHeight(): number;
  3231. set cellHeight(value: number);
  3232. /** Gets or sets the tickness of minor lines (1 by default) */
  3233. get minorLineTickness(): number;
  3234. set minorLineTickness(value: number);
  3235. /** Gets or sets the color of minor lines (DarkGray by default) */
  3236. get minorLineColor(): string;
  3237. set minorLineColor(value: string);
  3238. /** Gets or sets the tickness of major lines (2 by default) */
  3239. get majorLineTickness(): number;
  3240. set majorLineTickness(value: number);
  3241. /** Gets or sets the color of major lines (White by default) */
  3242. get majorLineColor(): string;
  3243. set majorLineColor(value: string);
  3244. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  3245. get majorLineFrequency(): number;
  3246. set majorLineFrequency(value: number);
  3247. /**
  3248. * Creates a new GridDisplayRectangle
  3249. * @param name defines the control name
  3250. */
  3251. constructor(name?: string | undefined);
  3252. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  3253. protected _getTypeName(): string;
  3254. }
  3255. }
  3256. declare module BABYLON.GUI {
  3257. /**
  3258. * Class used to create slider controls based on images
  3259. */
  3260. export class ImageBasedSlider extends BaseSlider {
  3261. name?: string | undefined;
  3262. private _backgroundImage;
  3263. private _thumbImage;
  3264. private _valueBarImage;
  3265. private _tempMeasure;
  3266. get displayThumb(): boolean;
  3267. set displayThumb(value: boolean);
  3268. /**
  3269. * Gets or sets the image used to render the background
  3270. */
  3271. get backgroundImage(): Image;
  3272. set backgroundImage(value: Image);
  3273. /**
  3274. * Gets or sets the image used to render the value bar
  3275. */
  3276. get valueBarImage(): Image;
  3277. set valueBarImage(value: Image);
  3278. /**
  3279. * Gets or sets the image used to render the thumb
  3280. */
  3281. get thumbImage(): Image;
  3282. set thumbImage(value: Image);
  3283. /**
  3284. * Creates a new ImageBasedSlider
  3285. * @param name defines the control name
  3286. */
  3287. constructor(name?: string | undefined);
  3288. protected _getTypeName(): string;
  3289. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  3290. }
  3291. }
  3292. declare module BABYLON.GUI {
  3293. /**
  3294. * Forcing an export so that this code will execute
  3295. * @hidden
  3296. */
  3297. const name = "Statics";
  3298. }
  3299. declare module BABYLON.GUI {
  3300. /**
  3301. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  3302. */
  3303. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  3304. /**
  3305. * Define the instrumented AdvancedDynamicTexture.
  3306. */
  3307. texture: AdvancedDynamicTexture;
  3308. private _captureRenderTime;
  3309. private _renderTime;
  3310. private _captureLayoutTime;
  3311. private _layoutTime;
  3312. private _onBeginRenderObserver;
  3313. private _onEndRenderObserver;
  3314. private _onBeginLayoutObserver;
  3315. private _onEndLayoutObserver;
  3316. /**
  3317. * Gets the perf counter used to capture render time
  3318. */
  3319. get renderTimeCounter(): BABYLON.PerfCounter;
  3320. /**
  3321. * Gets the perf counter used to capture layout time
  3322. */
  3323. get layoutTimeCounter(): BABYLON.PerfCounter;
  3324. /**
  3325. * Enable or disable the render time capture
  3326. */
  3327. get captureRenderTime(): boolean;
  3328. set captureRenderTime(value: boolean);
  3329. /**
  3330. * Enable or disable the layout time capture
  3331. */
  3332. get captureLayoutTime(): boolean;
  3333. set captureLayoutTime(value: boolean);
  3334. /**
  3335. * Instantiates a new advanced dynamic texture instrumentation.
  3336. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  3337. * @param texture Defines the AdvancedDynamicTexture to instrument
  3338. */
  3339. constructor(
  3340. /**
  3341. * Define the instrumented AdvancedDynamicTexture.
  3342. */
  3343. texture: AdvancedDynamicTexture);
  3344. /**
  3345. * Dispose and release associated resources.
  3346. */
  3347. dispose(): void;
  3348. }
  3349. }
  3350. declare module BABYLON.GUI {
  3351. /**
  3352. * Class used to load GUI via XML.
  3353. */
  3354. export class XmlLoader {
  3355. private _nodes;
  3356. private _nodeTypes;
  3357. private _isLoaded;
  3358. private _objectAttributes;
  3359. private _parentClass;
  3360. /**
  3361. * Create a new xml loader
  3362. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  3363. */
  3364. constructor(parentClass?: null);
  3365. private _getChainElement;
  3366. private _getClassAttribute;
  3367. private _createGuiElement;
  3368. private _parseGrid;
  3369. private _parseElement;
  3370. private _prepareSourceElement;
  3371. private _parseElementsFromSource;
  3372. private _parseXml;
  3373. /**
  3374. * Gets if the loading has finished.
  3375. * @returns whether the loading has finished or not
  3376. */
  3377. isLoaded(): boolean;
  3378. /**
  3379. * Gets a loaded node / control by id.
  3380. * @param id the Controls id set in the xml
  3381. * @returns element of type Control
  3382. */
  3383. getNodeById(id: string): any;
  3384. /**
  3385. * Gets all loaded nodes / controls
  3386. * @returns Array of controls
  3387. */
  3388. getNodes(): any;
  3389. /**
  3390. * Initiates the xml layout loading
  3391. * @param xmlFile defines the xml layout to load
  3392. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  3393. * @param callback defines the callback called on layout load.
  3394. */
  3395. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  3396. }
  3397. }
  3398. declare module BABYLON.GUI {
  3399. /**
  3400. * Class used to create containers for controls
  3401. */
  3402. export class Container3D extends Control3D {
  3403. private _blockLayout;
  3404. /**
  3405. * Gets the list of child controls
  3406. */
  3407. protected _children: Control3D[];
  3408. /**
  3409. * Gets the list of child controls
  3410. */
  3411. get children(): Array<Control3D>;
  3412. /**
  3413. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  3414. * This is helpful to optimize layout operation when adding multiple children in a row
  3415. */
  3416. get blockLayout(): boolean;
  3417. set blockLayout(value: boolean);
  3418. /**
  3419. * Creates a new container
  3420. * @param name defines the container name
  3421. */
  3422. constructor(name?: string);
  3423. /**
  3424. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  3425. * @returns the current container
  3426. */
  3427. updateLayout(): Container3D;
  3428. /**
  3429. * Gets a boolean indicating if the given control is in the children of this control
  3430. * @param control defines the control to check
  3431. * @returns true if the control is in the child list
  3432. */
  3433. containsControl(control: Control3D): boolean;
  3434. /**
  3435. * Adds a control to the children of this control
  3436. * @param control defines the control to add
  3437. * @returns the current container
  3438. */
  3439. addControl(control: Control3D): Container3D;
  3440. /**
  3441. * This function will be called everytime a new control is added
  3442. */
  3443. protected _arrangeChildren(): void;
  3444. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  3445. /**
  3446. * Removes a control from the children of this control
  3447. * @param control defines the control to remove
  3448. * @returns the current container
  3449. */
  3450. removeControl(control: Control3D): Container3D;
  3451. protected _getTypeName(): string;
  3452. /**
  3453. * Releases all associated resources
  3454. */
  3455. dispose(): void;
  3456. /** Control rotation will remain unchanged */
  3457. static readonly UNSET_ORIENTATION: number;
  3458. /** Control will rotate to make it look at sphere central axis */
  3459. static readonly FACEORIGIN_ORIENTATION: number;
  3460. /** Control will rotate to make it look back at sphere central axis */
  3461. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  3462. /** Control will rotate to look at z axis (0, 0, 1) */
  3463. static readonly FACEFORWARD_ORIENTATION: number;
  3464. /** Control will rotate to look at negative z axis (0, 0, -1) */
  3465. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  3466. }
  3467. }
  3468. declare module BABYLON.GUI {
  3469. /**
  3470. * Class used to manage 3D user interface
  3471. * @see https://doc.babylonjs.com/how_to/gui3d
  3472. */
  3473. export class GUI3DManager implements BABYLON.IDisposable {
  3474. private _scene;
  3475. private _sceneDisposeObserver;
  3476. private _utilityLayer;
  3477. private _rootContainer;
  3478. private _pointerObserver;
  3479. private _pointerOutObserver;
  3480. /** @hidden */
  3481. _lastPickedControl: Control3D;
  3482. /** @hidden */
  3483. _lastControlOver: {
  3484. [pointerId: number]: Control3D;
  3485. };
  3486. /** @hidden */
  3487. _lastControlDown: {
  3488. [pointerId: number]: Control3D;
  3489. };
  3490. /**
  3491. * BABYLON.Observable raised when the point picked by the pointer events changed
  3492. */
  3493. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  3494. /** @hidden */
  3495. _sharedMaterials: {
  3496. [key: string]: BABYLON.Material;
  3497. };
  3498. /** Gets the hosting scene */
  3499. get scene(): BABYLON.Scene;
  3500. /** Gets associated utility layer */
  3501. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  3502. /**
  3503. * Creates a new GUI3DManager
  3504. * @param scene
  3505. */
  3506. constructor(scene?: BABYLON.Scene);
  3507. private _handlePointerOut;
  3508. private _doPicking;
  3509. /**
  3510. * Gets the root container
  3511. */
  3512. get rootContainer(): Container3D;
  3513. /**
  3514. * Gets a boolean indicating if the given control is in the root child list
  3515. * @param control defines the control to check
  3516. * @returns true if the control is in the root child list
  3517. */
  3518. containsControl(control: Control3D): boolean;
  3519. /**
  3520. * Adds a control to the root child list
  3521. * @param control defines the control to add
  3522. * @returns the current manager
  3523. */
  3524. addControl(control: Control3D): GUI3DManager;
  3525. /**
  3526. * Removes a control from the root child list
  3527. * @param control defines the control to remove
  3528. * @returns the current container
  3529. */
  3530. removeControl(control: Control3D): GUI3DManager;
  3531. /**
  3532. * Releases all associated resources
  3533. */
  3534. dispose(): void;
  3535. }
  3536. }
  3537. declare module BABYLON.GUI {
  3538. /**
  3539. * Class used to transport BABYLON.Vector3 information for pointer events
  3540. */
  3541. export class Vector3WithInfo extends BABYLON.Vector3 {
  3542. /** defines the current mouse button index */
  3543. buttonIndex: number;
  3544. /**
  3545. * Creates a new Vector3WithInfo
  3546. * @param source defines the vector3 data to transport
  3547. * @param buttonIndex defines the current mouse button index
  3548. */
  3549. constructor(source: BABYLON.Vector3,
  3550. /** defines the current mouse button index */
  3551. buttonIndex?: number);
  3552. }
  3553. }
  3554. declare module BABYLON.GUI {
  3555. /**
  3556. * Class used as base class for controls
  3557. */
  3558. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  3559. /** Defines the control name */
  3560. name?: string | undefined;
  3561. /** @hidden */
  3562. _host: GUI3DManager;
  3563. private _node;
  3564. private _downCount;
  3565. private _enterCount;
  3566. private _downPointerIds;
  3567. private _isVisible;
  3568. /** Gets or sets the control position in world space */
  3569. get position(): BABYLON.Vector3;
  3570. set position(value: BABYLON.Vector3);
  3571. /** Gets or sets the control scaling in world space */
  3572. get scaling(): BABYLON.Vector3;
  3573. set scaling(value: BABYLON.Vector3);
  3574. /** Callback used to start pointer enter animation */
  3575. pointerEnterAnimation: () => void;
  3576. /** Callback used to start pointer out animation */
  3577. pointerOutAnimation: () => void;
  3578. /** Callback used to start pointer down animation */
  3579. pointerDownAnimation: () => void;
  3580. /** Callback used to start pointer up animation */
  3581. pointerUpAnimation: () => void;
  3582. /**
  3583. * An event triggered when the pointer move over the control
  3584. */
  3585. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  3586. /**
  3587. * An event triggered when the pointer move out of the control
  3588. */
  3589. onPointerOutObservable: BABYLON.Observable<Control3D>;
  3590. /**
  3591. * An event triggered when the pointer taps the control
  3592. */
  3593. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  3594. /**
  3595. * An event triggered when pointer is up
  3596. */
  3597. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  3598. /**
  3599. * An event triggered when a control is clicked on (with a mouse)
  3600. */
  3601. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  3602. /**
  3603. * An event triggered when pointer enters the control
  3604. */
  3605. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  3606. /**
  3607. * Gets or sets the parent container
  3608. */
  3609. parent: BABYLON.Nullable<Container3D>;
  3610. private _behaviors;
  3611. /**
  3612. * Gets the list of attached behaviors
  3613. * @see https://doc.babylonjs.com/features/behaviour
  3614. */
  3615. get behaviors(): BABYLON.Behavior<Control3D>[];
  3616. /**
  3617. * Attach a behavior to the control
  3618. * @see https://doc.babylonjs.com/features/behaviour
  3619. * @param behavior defines the behavior to attach
  3620. * @returns the current control
  3621. */
  3622. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  3623. /**
  3624. * Remove an attached behavior
  3625. * @see https://doc.babylonjs.com/features/behaviour
  3626. * @param behavior defines the behavior to attach
  3627. * @returns the current control
  3628. */
  3629. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  3630. /**
  3631. * Gets an attached behavior by name
  3632. * @param name defines the name of the behavior to look for
  3633. * @see https://doc.babylonjs.com/features/behaviour
  3634. * @returns null if behavior was not found else the requested behavior
  3635. */
  3636. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  3637. /** Gets or sets a boolean indicating if the control is visible */
  3638. get isVisible(): boolean;
  3639. set isVisible(value: boolean);
  3640. /**
  3641. * Creates a new control
  3642. * @param name defines the control name
  3643. */
  3644. constructor(
  3645. /** Defines the control name */
  3646. name?: string | undefined);
  3647. /**
  3648. * Gets a string representing the class name
  3649. */
  3650. get typeName(): string;
  3651. /**
  3652. * Get the current class name of the control.
  3653. * @returns current class name
  3654. */
  3655. getClassName(): string;
  3656. protected _getTypeName(): string;
  3657. /**
  3658. * Gets the transform node used by this control
  3659. */
  3660. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  3661. /**
  3662. * Gets the mesh used to render this control
  3663. */
  3664. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  3665. /**
  3666. * Link the control as child of the given node
  3667. * @param node defines the node to link to. Use null to unlink the control
  3668. * @returns the current control
  3669. */
  3670. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  3671. /** @hidden **/
  3672. _prepareNode(scene: BABYLON.Scene): void;
  3673. /**
  3674. * Node creation.
  3675. * Can be overriden by children
  3676. * @param scene defines the scene where the node must be attached
  3677. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  3678. */
  3679. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  3680. /**
  3681. * Affect a material to the given mesh
  3682. * @param mesh defines the mesh which will represent the control
  3683. */
  3684. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  3685. /** @hidden */
  3686. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  3687. /** @hidden */
  3688. _onPointerEnter(target: Control3D): boolean;
  3689. /** @hidden */
  3690. _onPointerOut(target: Control3D): void;
  3691. /** @hidden */
  3692. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  3693. /** @hidden */
  3694. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3695. /** @hidden */
  3696. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  3697. /** @hidden */
  3698. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  3699. /** @hidden */
  3700. _disposeNode(): void;
  3701. /**
  3702. * Releases all associated resources
  3703. */
  3704. dispose(): void;
  3705. }
  3706. }
  3707. declare module BABYLON.GUI {
  3708. /**
  3709. * Class used as a root to all buttons
  3710. */
  3711. export class AbstractButton3D extends Control3D {
  3712. /**
  3713. * Creates a new button
  3714. * @param name defines the control name
  3715. */
  3716. constructor(name?: string);
  3717. protected _getTypeName(): string;
  3718. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3719. }
  3720. }
  3721. declare module BABYLON.GUI {
  3722. /**
  3723. * Class used to create a button in 3D
  3724. */
  3725. export class Button3D extends AbstractButton3D {
  3726. /** @hidden */
  3727. protected _currentMaterial: BABYLON.Material;
  3728. private _facadeTexture;
  3729. private _content;
  3730. private _contentResolution;
  3731. private _contentScaleRatio;
  3732. /**
  3733. * Gets or sets the texture resolution used to render content (512 by default)
  3734. */
  3735. get contentResolution(): BABYLON.int;
  3736. set contentResolution(value: BABYLON.int);
  3737. /**
  3738. * Gets or sets the texture scale ratio used to render content (2 by default)
  3739. */
  3740. get contentScaleRatio(): number;
  3741. set contentScaleRatio(value: number);
  3742. protected _disposeFacadeTexture(): void;
  3743. protected _resetContent(): void;
  3744. /**
  3745. * Creates a new button
  3746. * @param name defines the control name
  3747. */
  3748. constructor(name?: string);
  3749. /**
  3750. * Gets or sets the GUI 2D content used to display the button's facade
  3751. */
  3752. get content(): Control;
  3753. set content(value: Control);
  3754. /**
  3755. * Apply the facade texture (created from the content property).
  3756. * This function can be overloaded by child classes
  3757. * @param facadeTexture defines the AdvancedDynamicTexture to use
  3758. */
  3759. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3760. protected _getTypeName(): string;
  3761. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3762. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  3763. /**
  3764. * Releases all associated resources
  3765. */
  3766. dispose(): void;
  3767. }
  3768. }
  3769. declare module BABYLON.GUI {
  3770. /**
  3771. * Abstract class used to create a container panel deployed on the surface of a volume
  3772. */
  3773. export abstract class VolumeBasedPanel extends Container3D {
  3774. private _columns;
  3775. private _rows;
  3776. private _rowThenColum;
  3777. private _orientation;
  3778. protected _cellWidth: number;
  3779. protected _cellHeight: number;
  3780. /**
  3781. * Gets or sets the distance between elements
  3782. */
  3783. margin: number;
  3784. /**
  3785. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  3786. * | Value | Type | Description |
  3787. * | ----- | ----------------------------------- | ----------- |
  3788. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  3789. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  3790. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  3791. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  3792. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  3793. */
  3794. get orientation(): number;
  3795. set orientation(value: number);
  3796. /**
  3797. * Gets or sets the number of columns requested (10 by default).
  3798. * The panel will automatically compute the number of rows based on number of child controls.
  3799. */
  3800. get columns(): BABYLON.int;
  3801. set columns(value: BABYLON.int);
  3802. /**
  3803. * Gets or sets a the number of rows requested.
  3804. * The panel will automatically compute the number of columns based on number of child controls.
  3805. */
  3806. get rows(): BABYLON.int;
  3807. set rows(value: BABYLON.int);
  3808. /**
  3809. * Creates new VolumeBasedPanel
  3810. */
  3811. constructor();
  3812. protected _arrangeChildren(): void;
  3813. /** Child classes must implement this function to provide correct control positioning */
  3814. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3815. /** Child classes can implement this function to provide additional processing */
  3816. protected _finalProcessing(): void;
  3817. }
  3818. }
  3819. declare module BABYLON.GUI {
  3820. /**
  3821. * Class used to create a container panel deployed on the surface of a cylinder
  3822. */
  3823. export class CylinderPanel extends VolumeBasedPanel {
  3824. private _radius;
  3825. /**
  3826. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  3827. */
  3828. get radius(): BABYLON.float;
  3829. set radius(value: BABYLON.float);
  3830. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3831. private _cylindricalMapping;
  3832. }
  3833. }
  3834. declare module BABYLON.GUI {
  3835. /** @hidden */
  3836. export var fluentVertexShader: {
  3837. name: string;
  3838. shader: string;
  3839. };
  3840. }
  3841. declare module BABYLON.GUI {
  3842. /** @hidden */
  3843. export var fluentPixelShader: {
  3844. name: string;
  3845. shader: string;
  3846. };
  3847. }
  3848. declare module BABYLON.GUI {
  3849. /** @hidden */
  3850. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  3851. INNERGLOW: boolean;
  3852. BORDER: boolean;
  3853. HOVERLIGHT: boolean;
  3854. TEXTURE: boolean;
  3855. constructor();
  3856. }
  3857. /**
  3858. * Class used to render controls with fluent desgin
  3859. */
  3860. export class FluentMaterial extends BABYLON.PushMaterial {
  3861. /**
  3862. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  3863. */
  3864. innerGlowColorIntensity: number;
  3865. /**
  3866. * Gets or sets the inner glow color (white by default)
  3867. */
  3868. innerGlowColor: BABYLON.Color3;
  3869. /**
  3870. * Gets or sets alpha value (default is 1.0)
  3871. */
  3872. alpha: number;
  3873. /**
  3874. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  3875. */
  3876. albedoColor: BABYLON.Color3;
  3877. /**
  3878. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  3879. */
  3880. renderBorders: boolean;
  3881. /**
  3882. * Gets or sets border width (default is 0.5)
  3883. */
  3884. borderWidth: number;
  3885. /**
  3886. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  3887. */
  3888. edgeSmoothingValue: number;
  3889. /**
  3890. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  3891. */
  3892. borderMinValue: number;
  3893. /**
  3894. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  3895. */
  3896. renderHoverLight: boolean;
  3897. /**
  3898. * Gets or sets the radius used to render the hover light (default is 1.0)
  3899. */
  3900. hoverRadius: number;
  3901. /**
  3902. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  3903. */
  3904. hoverColor: BABYLON.Color4;
  3905. /**
  3906. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  3907. */
  3908. hoverPosition: BABYLON.Vector3;
  3909. private _albedoTexture;
  3910. /** Gets or sets the texture to use for albedo color */
  3911. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  3912. /**
  3913. * Creates a new Fluent material
  3914. * @param name defines the name of the material
  3915. * @param scene defines the hosting scene
  3916. */
  3917. constructor(name: string, scene: BABYLON.Scene);
  3918. needAlphaBlending(): boolean;
  3919. needAlphaTesting(): boolean;
  3920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  3921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  3922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  3923. getActiveTextures(): BABYLON.BaseTexture[];
  3924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  3925. dispose(forceDisposeEffect?: boolean): void;
  3926. clone(name: string): FluentMaterial;
  3927. serialize(): any;
  3928. getClassName(): string;
  3929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  3930. }
  3931. }
  3932. declare module BABYLON.GUI {
  3933. /**
  3934. * Class used to create a holographic button in 3D
  3935. */
  3936. export class HolographicButton extends Button3D {
  3937. private _backPlate;
  3938. private _textPlate;
  3939. private _frontPlate;
  3940. private _text;
  3941. private _imageUrl;
  3942. private _shareMaterials;
  3943. private _frontMaterial;
  3944. private _backMaterial;
  3945. private _plateMaterial;
  3946. private _pickedPointObserver;
  3947. private _tooltipFade;
  3948. private _tooltipTextBlock;
  3949. private _tooltipTexture;
  3950. private _tooltipMesh;
  3951. private _tooltipHoverObserver;
  3952. private _tooltipOutObserver;
  3953. private _disposeTooltip;
  3954. /**
  3955. * Rendering ground id of all the mesh in the button
  3956. */
  3957. set renderingGroupId(id: number);
  3958. get renderingGroupId(): number;
  3959. /**
  3960. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  3961. */
  3962. set tooltipText(text: BABYLON.Nullable<string>);
  3963. get tooltipText(): BABYLON.Nullable<string>;
  3964. /**
  3965. * Gets or sets text for the button
  3966. */
  3967. get text(): string;
  3968. set text(value: string);
  3969. /**
  3970. * Gets or sets the image url for the button
  3971. */
  3972. get imageUrl(): string;
  3973. set imageUrl(value: string);
  3974. /**
  3975. * Gets the back material used by this button
  3976. */
  3977. get backMaterial(): FluentMaterial;
  3978. /**
  3979. * Gets the front material used by this button
  3980. */
  3981. get frontMaterial(): FluentMaterial;
  3982. /**
  3983. * Gets the plate material used by this button
  3984. */
  3985. get plateMaterial(): BABYLON.StandardMaterial;
  3986. /**
  3987. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  3988. */
  3989. get shareMaterials(): boolean;
  3990. /**
  3991. * Creates a new button
  3992. * @param name defines the control name
  3993. */
  3994. constructor(name?: string, shareMaterials?: boolean);
  3995. protected _getTypeName(): string;
  3996. private _rebuildContent;
  3997. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3998. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3999. private _createBackMaterial;
  4000. private _createFrontMaterial;
  4001. private _createPlateMaterial;
  4002. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  4003. /**
  4004. * Releases all associated resources
  4005. */
  4006. dispose(): void;
  4007. }
  4008. }
  4009. declare module BABYLON.GUI {
  4010. /**
  4011. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  4012. */
  4013. export class MeshButton3D extends Button3D {
  4014. /** @hidden */
  4015. protected _currentMesh: BABYLON.Mesh;
  4016. /**
  4017. * Creates a new 3D button based on a mesh
  4018. * @param mesh mesh to become a 3D button
  4019. * @param name defines the control name
  4020. */
  4021. constructor(mesh: BABYLON.Mesh, name?: string);
  4022. protected _getTypeName(): string;
  4023. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  4024. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  4025. }
  4026. }
  4027. declare module BABYLON.GUI {
  4028. /**
  4029. * Class used to create a container panel deployed on the surface of a plane
  4030. */
  4031. export class PlanePanel extends VolumeBasedPanel {
  4032. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  4033. }
  4034. }
  4035. declare module BABYLON.GUI {
  4036. /**
  4037. * Class used to create a container panel where items get randomized planar mapping
  4038. */
  4039. export class ScatterPanel extends VolumeBasedPanel {
  4040. private _iteration;
  4041. /**
  4042. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  4043. */
  4044. get iteration(): BABYLON.float;
  4045. set iteration(value: BABYLON.float);
  4046. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  4047. private _scatterMapping;
  4048. protected _finalProcessing(): void;
  4049. }
  4050. }
  4051. declare module BABYLON.GUI {
  4052. /**
  4053. * Class used to create a container panel deployed on the surface of a sphere
  4054. */
  4055. export class SpherePanel extends VolumeBasedPanel {
  4056. private _radius;
  4057. /**
  4058. * Gets or sets the radius of the sphere where to project controls (5 by default)
  4059. */
  4060. get radius(): BABYLON.float;
  4061. set radius(value: BABYLON.float);
  4062. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  4063. private _sphericalMapping;
  4064. }
  4065. }
  4066. declare module BABYLON.GUI {
  4067. /**
  4068. * Class used to create a stack panel in 3D on XY plane
  4069. */
  4070. export class StackPanel3D extends Container3D {
  4071. private _isVertical;
  4072. /**
  4073. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  4074. */
  4075. get isVertical(): boolean;
  4076. set isVertical(value: boolean);
  4077. /**
  4078. * Gets or sets the distance between elements
  4079. */
  4080. margin: number;
  4081. /**
  4082. * Creates new StackPanel
  4083. * @param isVertical
  4084. */
  4085. constructor(isVertical?: boolean);
  4086. protected _arrangeChildren(): void;
  4087. }
  4088. }