babylon.gui.d.ts 169 KB

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