babylon.gui.d.ts 146 KB

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