babylon.gui.d.ts 180 KB

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