babylon.gui.d.ts 147 KB

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