babylon.gui.d.ts 180 KB

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