babylon.gui.d.ts 181 KB

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