babylon.gui.d.ts 143 KB

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