babylon.gui.d.ts 166 KB

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