babylon.gui.d.ts 143 KB

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