babylon.gui.d.ts 147 KB

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