babylon.gui.d.ts 143 KB

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