babylon.gui.d.ts 165 KB

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