babylon.gui.d.ts 139 KB

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