babylon.gui.d.ts 150 KB

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