babylon.gui.d.ts 142 KB

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