babylon.gui.d.ts 168 KB

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