babylon.gui.d.ts 143 KB

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