babylon.gui.d.ts 143 KB

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