babylon.gui.d.ts 165 KB

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