babylon.gui.module.d.ts 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361
  1. declare module 'babylonjs-gui' {
  2. export = BABYLON.GUI;
  3. }
  4. declare module BABYLON.GUI {
  5. /**
  6. * Define a style used by control to automatically setup properties based on a template.
  7. * Only support font related properties so far
  8. */
  9. class Style implements BABYLON.IDisposable {
  10. private _fontFamily;
  11. private _fontStyle;
  12. private _fontWeight;
  13. /** @hidden */
  14. _host: AdvancedDynamicTexture;
  15. /** @hidden */
  16. _fontSize: ValueAndUnit;
  17. /**
  18. * Observable raised when the style values are changed
  19. */
  20. onChangedObservable: Observable<Style>;
  21. /**
  22. * Creates a new style object
  23. * @param host defines the AdvancedDynamicTexture which hosts this style
  24. */
  25. constructor(host: AdvancedDynamicTexture);
  26. /**
  27. * Gets or sets the font size
  28. */
  29. fontSize: string | number;
  30. /**
  31. * Gets or sets the font family
  32. */
  33. fontFamily: string;
  34. /**
  35. * Gets or sets the font style
  36. */
  37. fontStyle: string;
  38. /** Gets or sets font weight */
  39. fontWeight: string;
  40. /** Dispose all associated resources */
  41. dispose(): void;
  42. }
  43. }
  44. declare module BABYLON.GUI {
  45. /**
  46. * Class used to specific a value and its associated unit
  47. */
  48. class ValueAndUnit {
  49. /** defines the unit to store */
  50. unit: number;
  51. /** defines a boolean indicating if the value can be negative */
  52. negativeValueAllowed: boolean;
  53. private _value;
  54. /**
  55. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  57. */
  58. ignoreAdaptiveScaling: boolean;
  59. /**
  60. * Creates a new ValueAndUnit
  61. * @param value defines the value to store
  62. * @param unit defines the unit to store
  63. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64. */
  65. constructor(value: number,
  66. /** defines the unit to store */
  67. unit?: number,
  68. /** defines a boolean indicating if the value can be negative */
  69. negativeValueAllowed?: boolean);
  70. /** Gets a boolean indicating if the value is a percentage */
  71. readonly isPercentage: boolean;
  72. /** Gets a boolean indicating if the value is store as pixel */
  73. readonly isPixel: boolean;
  74. /** Gets direct internal value */
  75. readonly internalValue: number;
  76. /**
  77. * Gets value as pixel
  78. * @param host defines the root host
  79. * @param refValue defines the reference value for percentages
  80. * @returns the value as pixel
  81. */
  82. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  83. /**
  84. * Gets the value accordingly to its unit
  85. * @param host defines the root host
  86. * @returns the value
  87. */
  88. getValue(host: AdvancedDynamicTexture): number;
  89. /**
  90. * Gets a string representation of the value
  91. * @param host defines the root host
  92. * @returns a string
  93. */
  94. toString(host: AdvancedDynamicTexture): string;
  95. /**
  96. * Store a value parsed from a string
  97. * @param source defines the source string
  98. * @returns true if the value was successfully parsed
  99. */
  100. fromString(source: string | number): boolean;
  101. private static _Regex;
  102. private static _UNITMODE_PERCENTAGE;
  103. private static _UNITMODE_PIXEL;
  104. /** UNITMODE_PERCENTAGE */
  105. static readonly UNITMODE_PERCENTAGE: number;
  106. /** UNITMODE_PIXEL */
  107. static readonly UNITMODE_PIXEL: number;
  108. }
  109. }
  110. /**
  111. * This module hosts all controls for 2D and 3D GUIs
  112. * @see http://doc.babylonjs.com/how_to/gui
  113. */
  114. declare module BABYLON.GUI {
  115. /**
  116. * Interface used to define a control that can receive focus
  117. */
  118. interface IFocusableControl {
  119. /**
  120. * Function called when the control receives the focus
  121. */
  122. onFocus(): void;
  123. /**
  124. * Function called when the control loses the focus
  125. */
  126. onBlur(): void;
  127. /**
  128. * Function called to let the control handle keyboard events
  129. * @param evt defines the current keyboard event
  130. */
  131. processKeyboard(evt: KeyboardEvent): void;
  132. }
  133. /**
  134. * Class used to create texture to support 2D GUI elements
  135. * @see http://doc.babylonjs.com/how_to/gui
  136. */
  137. class AdvancedDynamicTexture extends DynamicTexture {
  138. private _isDirty;
  139. private _renderObserver;
  140. private _resizeObserver;
  141. private _preKeyboardObserver;
  142. private _pointerMoveObserver;
  143. private _pointerObserver;
  144. private _canvasPointerOutObserver;
  145. private _background;
  146. /** @hidden */
  147. _rootContainer: Container;
  148. /** @hidden */
  149. _lastPickedControl: Control;
  150. /** @hidden */
  151. _lastControlOver: {
  152. [pointerId: number]: Control;
  153. };
  154. /** @hidden */
  155. _lastControlDown: {
  156. [pointerId: number]: Control;
  157. };
  158. /** @hidden */
  159. _capturingControl: {
  160. [pointerId: number]: Control;
  161. };
  162. /** @hidden */
  163. _shouldBlockPointer: boolean;
  164. /** @hidden */
  165. _layerToDispose: Nullable<Layer>;
  166. /** @hidden */
  167. _linkedControls: Control[];
  168. private _isFullscreen;
  169. private _fullscreenViewport;
  170. private _idealWidth;
  171. private _idealHeight;
  172. private _useSmallestIdeal;
  173. private _renderAtIdealSize;
  174. private _focusedControl;
  175. private _blockNextFocusCheck;
  176. private _renderScale;
  177. /**
  178. * Gets or sets a boolean defining if alpha is stored as premultiplied
  179. */
  180. premulAlpha: boolean;
  181. /**
  182. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  183. * Useful when you want more antialiasing
  184. */
  185. renderScale: number;
  186. /** Gets or sets the background color */
  187. background: string;
  188. /**
  189. * Gets or sets the ideal width used to design controls.
  190. * The GUI will then rescale everything accordingly
  191. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  192. */
  193. idealWidth: number;
  194. /**
  195. * Gets or sets the ideal height used to design controls.
  196. * The GUI will then rescale everything accordingly
  197. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  198. */
  199. idealHeight: number;
  200. /**
  201. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  202. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  203. */
  204. useSmallestIdeal: boolean;
  205. /**
  206. * Gets or sets a boolean indicating if adaptive scaling must be used
  207. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  208. */
  209. renderAtIdealSize: boolean;
  210. /**
  211. * Gets the underlying layer used to render the texture when in fullscreen mode
  212. */
  213. readonly layer: Nullable<Layer>;
  214. /**
  215. * Gets the root container control
  216. */
  217. readonly rootContainer: Container;
  218. /**
  219. * Gets or sets the current focused control
  220. */
  221. focusedControl: Nullable<IFocusableControl>;
  222. /**
  223. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  224. */
  225. isForeground: boolean;
  226. /**
  227. * Creates a new AdvancedDynamicTexture
  228. * @param name defines the name of the texture
  229. * @param width defines the width of the texture
  230. * @param height defines the height of the texture
  231. * @param scene defines the hosting scene
  232. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  233. * @param samplingMode defines the texture sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  234. */
  235. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  236. /**
  237. * Function used to execute a function on all controls
  238. * @param func defines the function to execute
  239. * @param container defines the container where controls belong. If null the root container will be used
  240. */
  241. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  242. /**
  243. * Marks the texture as dirty forcing a complete update
  244. */
  245. markAsDirty(): void;
  246. /**
  247. * Helper function used to create a new style
  248. * @returns a new style
  249. * @see http://doc.babylonjs.com/how_to/gui#styles
  250. */
  251. createStyle(): Style;
  252. /**
  253. * Adds a new control to the root container
  254. * @param control defines the control to add
  255. * @returns the current texture
  256. */
  257. addControl(control: Control): AdvancedDynamicTexture;
  258. /**
  259. * Removes a control from the root container
  260. * @param control defines the control to remove
  261. * @returns the current texture
  262. */
  263. removeControl(control: Control): AdvancedDynamicTexture;
  264. /**
  265. * Release all resources
  266. */
  267. dispose(): void;
  268. private _onResize();
  269. /** @hidden */
  270. _getGlobalViewport(scene: Scene): Viewport;
  271. /**
  272. * Get screen coordinates for a vector3
  273. * @param position defines the position to project
  274. * @param worldMatrix defines the world matrix to use
  275. * @returns the projected position
  276. */
  277. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  278. private _checkUpdate(camera);
  279. private _render();
  280. private _doPicking(x, y, type, pointerId, buttonIndex);
  281. /** @hidden */
  282. _cleanControlAfterRemovalFromList(list: {
  283. [pointerId: number]: Control;
  284. }, control: Control): void;
  285. /** @hidden */
  286. _cleanControlAfterRemoval(control: Control): void;
  287. /** Attach to all scene events required to support pointer events */
  288. attach(): void;
  289. /**
  290. * Connect the texture to a hosting mesh to enable interactions
  291. * @param mesh defines the mesh to attach to
  292. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  293. */
  294. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  295. /**
  296. * Move the focus to a specific control
  297. * @param control defines the control which will receive the focus
  298. */
  299. moveFocusToControl(control: IFocusableControl): void;
  300. private _manageFocus();
  301. private _attachToOnPointerOut(scene);
  302. /**
  303. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  304. * @param mesh defines the mesh which will receive the texture
  305. * @param width defines the texture width (1024 by default)
  306. * @param height defines the texture height (1024 by default)
  307. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  308. * @returns a new AdvancedDynamicTexture
  309. */
  310. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  311. /**
  312. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  313. * In this mode the texture will rely on a layer for its rendering.
  314. * This allows it to be treated like any other layer.
  315. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  316. * LayerMask is set through advancedTexture.layer.layerMask
  317. * @param name defines name for the texture
  318. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  319. * @param scene defines the hsoting scene
  320. * @param sampling defines the texture sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  321. * @returns a new AdvancedDynamicTexture
  322. */
  323. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  324. }
  325. }
  326. declare module BABYLON.GUI {
  327. /**
  328. * Class used to store 2D control sizes
  329. */
  330. class Measure {
  331. /** defines left coordinate */
  332. left: number;
  333. /** defines top coordinate */
  334. top: number;
  335. /** defines width dimension */
  336. width: number;
  337. /** defines height dimension */
  338. height: number;
  339. /**
  340. * Creates a new measure
  341. * @param left defines left coordinate
  342. * @param top defines top coordinate
  343. * @param width defines width dimension
  344. * @param height defines height dimension
  345. */
  346. constructor(
  347. /** defines left coordinate */
  348. left: number,
  349. /** defines top coordinate */
  350. top: number,
  351. /** defines width dimension */
  352. width: number,
  353. /** defines height dimension */
  354. height: number);
  355. /**
  356. * Copy from another measure
  357. * @param other defines the other measure to copy from
  358. */
  359. copyFrom(other: Measure): void;
  360. /**
  361. * Check equality between this measure and another one
  362. * @param other defines the other measures
  363. * @returns true if both measures are equals
  364. */
  365. isEqualsTo(other: Measure): boolean;
  366. /**
  367. * Creates an empty measure
  368. * @returns a new measure
  369. */
  370. static Empty(): Measure;
  371. }
  372. }
  373. declare module BABYLON.GUI {
  374. /**
  375. * Class used to transport Vector2 information for pointer events
  376. */
  377. class Vector2WithInfo extends Vector2 {
  378. /** defines the current mouse button index */
  379. buttonIndex: number;
  380. /**
  381. * Creates a new Vector2WithInfo
  382. * @param source defines the vector2 data to transport
  383. * @param buttonIndex defines the current mouse button index
  384. */
  385. constructor(source: Vector2,
  386. /** defines the current mouse button index */
  387. buttonIndex?: number);
  388. }
  389. /** Class used to provide 2D matrix features */
  390. class Matrix2D {
  391. /** Gets the internal array of 6 floats used to store matrix data */
  392. m: Float32Array;
  393. /**
  394. * Creates a new matrix
  395. * @param m00 defines value for (0, 0)
  396. * @param m01 defines value for (0, 1)
  397. * @param m10 defines value for (1, 0)
  398. * @param m11 defines value for (1, 1)
  399. * @param m20 defines value for (2, 0)
  400. * @param m21 defines value for (2, 1)
  401. */
  402. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  403. /**
  404. * Fills the matrix from direct values
  405. * @param m00 defines value for (0, 0)
  406. * @param m01 defines value for (0, 1)
  407. * @param m10 defines value for (1, 0)
  408. * @param m11 defines value for (1, 1)
  409. * @param m20 defines value for (2, 0)
  410. * @param m21 defines value for (2, 1)
  411. * @returns the current modified matrix
  412. */
  413. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  414. /**
  415. * Gets matrix determinant
  416. * @returns the determinant
  417. */
  418. determinant(): number;
  419. /**
  420. * Inverses the matrix and stores it in a target matrix
  421. * @param result defines the target matrix
  422. * @returns the current matrix
  423. */
  424. invertToRef(result: Matrix2D): Matrix2D;
  425. /**
  426. * Multiplies the current matrix with another one
  427. * @param other defines the second operand
  428. * @param result defines the target matrix
  429. * @returns the current matrix
  430. */
  431. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  432. /**
  433. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  434. * @param x defines the x coordinate to transform
  435. * @param y defines the x coordinate to transform
  436. * @param result defines the target vector2
  437. * @returns the current matrix
  438. */
  439. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  440. /**
  441. * Creates an identity matrix
  442. * @returns a new matrix
  443. */
  444. static Identity(): Matrix2D;
  445. /**
  446. * Creates a translation matrix and stores it in a target matrix
  447. * @param x defines the x coordinate of the translation
  448. * @param y defines the y coordinate of the translation
  449. * @param result defines the target matrix
  450. */
  451. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  452. /**
  453. * Creates a scaling matrix and stores it in a target matrix
  454. * @param x defines the x coordinate of the scaling
  455. * @param y defines the y coordinate of the scaling
  456. * @param result defines the target matrix
  457. */
  458. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  459. /**
  460. * Creates a rotation matrix and stores it in a target matrix
  461. * @param angle defines the rotation angle
  462. * @param result defines the target matrix
  463. */
  464. static RotationToRef(angle: number, result: Matrix2D): void;
  465. private static _TempPreTranslationMatrix;
  466. private static _TempPostTranslationMatrix;
  467. private static _TempRotationMatrix;
  468. private static _TempScalingMatrix;
  469. private static _TempCompose0;
  470. private static _TempCompose1;
  471. private static _TempCompose2;
  472. /**
  473. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  474. * @param tx defines the x coordinate of the translation
  475. * @param ty defines the y coordinate of the translation
  476. * @param angle defines the rotation angle
  477. * @param scaleX defines the x coordinate of the scaling
  478. * @param scaleY defines the y coordinate of the scaling
  479. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  480. * @param result defines the target matrix
  481. */
  482. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  483. }
  484. }
  485. declare module BABYLON.GUI {
  486. /**
  487. * Class used to store a point for a MultiLine object.
  488. * The point can be pure 2D coordinates, a mesh or a control
  489. */
  490. class MultiLinePoint {
  491. private _multiLine;
  492. private _x;
  493. private _y;
  494. private _control;
  495. private _mesh;
  496. private _controlObserver;
  497. private _meshObserver;
  498. /** @hidden */
  499. _point: Vector2;
  500. /**
  501. * Creates a new MultiLinePoint
  502. * @param multiLine defines the source MultiLine object
  503. */
  504. constructor(multiLine: MultiLine);
  505. /** Gets or sets x coordinate */
  506. x: string | number;
  507. /** Gets or sets y coordinate */
  508. y: string | number;
  509. /** Gets or sets the control associated with this point */
  510. control: Nullable<Control>;
  511. /** Gets or sets the mesh associated with this point */
  512. mesh: Nullable<AbstractMesh>;
  513. /**
  514. * Gets a translation vector
  515. * @returns the translation vector
  516. */
  517. translate(): Vector2;
  518. private _translatePoint();
  519. /** Release associated resources */
  520. dispose(): void;
  521. }
  522. }
  523. declare module BABYLON.GUI {
  524. /**
  525. * Root class used for all 2D controls
  526. * @see http://doc.babylonjs.com/how_to/gui#controls
  527. */
  528. class Control {
  529. /** defines the name of the control */
  530. name: string | undefined;
  531. private _alpha;
  532. private _alphaSet;
  533. private _zIndex;
  534. /** @hidden */
  535. _root: Nullable<Container>;
  536. /** @hidden */
  537. _host: AdvancedDynamicTexture;
  538. /** Gets or sets the control parent */
  539. parent: Nullable<Container>;
  540. /** @hidden */
  541. _currentMeasure: Measure;
  542. private _fontFamily;
  543. private _fontStyle;
  544. private _fontWeight;
  545. private _fontSize;
  546. private _font;
  547. /** @hidden */
  548. _width: ValueAndUnit;
  549. /** @hidden */
  550. _height: ValueAndUnit;
  551. /** @hidden */
  552. protected _fontOffset: {
  553. ascent: number;
  554. height: number;
  555. descent: number;
  556. };
  557. private _color;
  558. private _style;
  559. private _styleObserver;
  560. /** @hidden */
  561. protected _horizontalAlignment: number;
  562. /** @hidden */
  563. protected _verticalAlignment: number;
  564. private _isDirty;
  565. /** @hidden */
  566. _tempParentMeasure: Measure;
  567. /** @hidden */
  568. protected _cachedParentMeasure: Measure;
  569. private _paddingLeft;
  570. private _paddingRight;
  571. private _paddingTop;
  572. private _paddingBottom;
  573. /** @hidden */
  574. _left: ValueAndUnit;
  575. /** @hidden */
  576. _top: ValueAndUnit;
  577. private _scaleX;
  578. private _scaleY;
  579. private _rotation;
  580. private _transformCenterX;
  581. private _transformCenterY;
  582. private _transformMatrix;
  583. /** @hidden */
  584. protected _invertTransformMatrix: Matrix2D;
  585. /** @hidden */
  586. protected _transformedPosition: Vector2;
  587. private _onlyMeasureMode;
  588. private _isMatrixDirty;
  589. private _cachedOffsetX;
  590. private _cachedOffsetY;
  591. private _isVisible;
  592. /** @hidden */
  593. _linkedMesh: Nullable<AbstractMesh>;
  594. private _fontSet;
  595. private _dummyVector2;
  596. private _downCount;
  597. private _enterCount;
  598. private _doNotRender;
  599. private _downPointerIds;
  600. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  601. isHitTestVisible: boolean;
  602. /** Gets or sets a boolean indicating if the control can block pointer events */
  603. isPointerBlocker: boolean;
  604. /** Gets or sets a boolean indicating if the control can be focusable */
  605. isFocusInvisible: boolean;
  606. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  607. shadowOffsetX: number;
  608. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  609. shadowOffsetY: number;
  610. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  611. shadowBlur: number;
  612. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  613. shadowColor: string;
  614. /** @hidden */
  615. protected _linkOffsetX: ValueAndUnit;
  616. /** @hidden */
  617. protected _linkOffsetY: ValueAndUnit;
  618. /** Gets the control type name */
  619. readonly typeName: string;
  620. /**
  621. * An event triggered when the pointer move over the control.
  622. */
  623. onPointerMoveObservable: Observable<Vector2>;
  624. /**
  625. * An event triggered when the pointer move out of the control.
  626. */
  627. onPointerOutObservable: Observable<Control>;
  628. /**
  629. * An event triggered when the pointer taps the control
  630. */
  631. onPointerDownObservable: Observable<Vector2WithInfo>;
  632. /**
  633. * An event triggered when pointer up
  634. */
  635. onPointerUpObservable: Observable<Vector2WithInfo>;
  636. /**
  637. * An event triggered when a control is clicked on
  638. */
  639. onPointerClickObservable: Observable<Vector2WithInfo>;
  640. /**
  641. * An event triggered when pointer enters the control
  642. */
  643. onPointerEnterObservable: Observable<Control>;
  644. /**
  645. * An event triggered when the control is marked as dirty
  646. */
  647. onDirtyObservable: Observable<Control>;
  648. /**
  649. * An event triggered after the control is drawn
  650. */
  651. onAfterDrawObservable: Observable<Control>;
  652. /** Gets or set information about font offsets (used to render and align text) */
  653. fontOffset: {
  654. ascent: number;
  655. height: number;
  656. descent: number;
  657. };
  658. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  659. alpha: number;
  660. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  661. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  662. */
  663. scaleX: number;
  664. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  665. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  666. */
  667. scaleY: number;
  668. /** Gets or sets the rotation angle (0 by default)
  669. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  670. */
  671. rotation: number;
  672. /** Gets or sets the transformation center on Y axis (0 by default)
  673. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  674. */
  675. transformCenterY: number;
  676. /** Gets or sets the transformation center on X axis (0 by default)
  677. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  678. */
  679. transformCenterX: number;
  680. /**
  681. * Gets or sets the horizontal alignment
  682. * @see http://doc.babylonjs.com/how_to/gui#alignments
  683. */
  684. horizontalAlignment: number;
  685. /**
  686. * Gets or sets the vertical alignment
  687. * @see http://doc.babylonjs.com/how_to/gui#alignments
  688. */
  689. verticalAlignment: number;
  690. /**
  691. * Gets or sets control width
  692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  693. */
  694. width: string | number;
  695. /**
  696. * Gets control width in pixel
  697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  698. */
  699. readonly widthInPixels: number;
  700. /**
  701. * Gets or sets control height
  702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  703. */
  704. height: string | number;
  705. /**
  706. * Gets control height in pixel
  707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  708. */
  709. readonly heightInPixels: number;
  710. /** Gets or set font family */
  711. fontFamily: string;
  712. /** Gets or sets font style */
  713. fontStyle: string;
  714. /** Gets or sets font weight */
  715. fontWeight: string;
  716. /**
  717. * Gets or sets style
  718. * @see http://doc.babylonjs.com/how_to/gui#styles
  719. */
  720. style: BABYLON.Nullable<Style>;
  721. /** @hidden */
  722. readonly _isFontSizeInPercentage: boolean;
  723. /** Gets font size in pixels */
  724. readonly fontSizeInPixels: number;
  725. /** Gets or sets font size */
  726. fontSize: string | number;
  727. /** Gets or sets foreground color */
  728. color: string;
  729. /** Gets or sets z index which is used to reorder controls on the z axis */
  730. zIndex: number;
  731. /** Gets or sets a boolean indicating if the control can be rendered */
  732. notRenderable: boolean;
  733. /** Gets or sets a boolean indicating if the control is visible */
  734. isVisible: boolean;
  735. /** Gets a boolean indicating that the control needs to update its rendering */
  736. readonly isDirty: boolean;
  737. /**
  738. * Gets or sets a value indicating the padding to use on the left of the control
  739. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  740. */
  741. paddingLeft: string | number;
  742. /**
  743. * Gets a value indicating the padding in pixels to use on the left of the control
  744. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  745. */
  746. readonly paddingLeftInPixels: number;
  747. /**
  748. * Gets or sets a value indicating the padding to use on the right of the control
  749. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  750. */
  751. paddingRight: string | number;
  752. /**
  753. * Gets a value indicating the padding in pixels to use on the right of the control
  754. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  755. */
  756. readonly paddingRightInPixels: number;
  757. /**
  758. * Gets or sets a value indicating the padding to use on the top of the control
  759. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  760. */
  761. paddingTop: string | number;
  762. /**
  763. * Gets a value indicating the padding in pixels to use on the top of the control
  764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  765. */
  766. readonly paddingTopInPixels: number;
  767. /**
  768. * Gets or sets a value indicating the padding to use on the bottom of the control
  769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  770. */
  771. paddingBottom: string | number;
  772. /**
  773. * Gets a value indicating the padding in pixels to use on the bottom of the control
  774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  775. */
  776. readonly paddingBottomInPixels: number;
  777. /**
  778. * Gets or sets a value indicating the left coordinate of the control
  779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  780. */
  781. left: string | number;
  782. /**
  783. * Gets a value indicating the left coordinate in pixels of the control
  784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  785. */
  786. readonly leftInPixels: number;
  787. /**
  788. * Gets or sets a value indicating the top coordinate of the control
  789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  790. */
  791. top: string | number;
  792. /**
  793. * Gets a value indicating the top coordinate in pixels of the control
  794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  795. */
  796. readonly topInPixels: number;
  797. /**
  798. * Gets or sets a value indicating the offset on X axis to the linked mesh
  799. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  800. */
  801. linkOffsetX: string | number;
  802. /**
  803. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  804. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  805. */
  806. readonly linkOffsetXInPixels: number;
  807. /**
  808. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  809. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  810. */
  811. linkOffsetY: string | number;
  812. /**
  813. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  814. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  815. */
  816. readonly linkOffsetYInPixels: number;
  817. /** Gets the center coordinate on X axis */
  818. readonly centerX: number;
  819. /** Gets the center coordinate on Y axis */
  820. readonly centerY: number;
  821. /**
  822. * Creates a new control
  823. * @param name defines the name of the control
  824. */
  825. constructor(
  826. /** defines the name of the control */
  827. name?: string | undefined);
  828. /** @hidden */
  829. protected _getTypeName(): string;
  830. /** @hidden */
  831. _resetFontCache(): void;
  832. /**
  833. * Gets coordinates in local control space
  834. * @param globalCoordinates defines the coordinates to transform
  835. * @returns the new coordinates in local space
  836. */
  837. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  838. /**
  839. * Gets coordinates in local control space
  840. * @param globalCoordinates defines the coordinates to transform
  841. * @param result defines the target vector2 where to store the result
  842. * @returns the current control
  843. */
  844. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  845. /**
  846. * Gets coordinates in parent local control space
  847. * @param globalCoordinates defines the coordinates to transform
  848. * @returns the new coordinates in parent local space
  849. */
  850. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  851. /**
  852. * Move the current control to a vector3 position projected onto the screen.
  853. * @param position defines the target position
  854. * @param scene defines the hosting scene
  855. */
  856. moveToVector3(position: Vector3, scene: Scene): void;
  857. /**
  858. * Link current control with a target mesh
  859. * @param mesh defines the mesh to link with
  860. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  861. */
  862. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  863. /** @hidden */
  864. _moveToProjectedPosition(projectedPosition: Vector3): void;
  865. /** @hidden */
  866. _markMatrixAsDirty(): void;
  867. /** @hidden */
  868. _markAsDirty(): void;
  869. /** @hidden */
  870. _markAllAsDirty(): void;
  871. /** @hidden */
  872. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  873. /** @hidden */
  874. protected _transform(context: CanvasRenderingContext2D): void;
  875. /** @hidden */
  876. protected _applyStates(context: CanvasRenderingContext2D): void;
  877. /** @hidden */
  878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  879. /** @hidden */
  880. protected _clip(context: CanvasRenderingContext2D): void;
  881. /** @hidden */
  882. _measure(): void;
  883. /** @hidden */
  884. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  885. /** @hidden */
  886. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  887. /** @hidden */
  888. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  889. /** @hidden */
  890. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  891. /**
  892. * Tests if a given coordinates belong to the current control
  893. * @param x defines x coordinate to test
  894. * @param y defines y coordinate to test
  895. * @returns true if the coordinates are inside the control
  896. */
  897. contains(x: number, y: number): boolean;
  898. /** @hidden */
  899. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  900. /** @hidden */
  901. _onPointerMove(target: Control, coordinates: Vector2): void;
  902. /** @hidden */
  903. _onPointerEnter(target: Control): boolean;
  904. /** @hidden */
  905. _onPointerOut(target: Control): void;
  906. /** @hidden */
  907. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  908. /** @hidden */
  909. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  910. /** @hidden */
  911. _forcePointerUp(pointerId?: Nullable<number>): void;
  912. /** @hidden */
  913. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  914. private _prepareFont();
  915. /** Releases associated resources */
  916. dispose(): void;
  917. private static _HORIZONTAL_ALIGNMENT_LEFT;
  918. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  919. private static _HORIZONTAL_ALIGNMENT_CENTER;
  920. private static _VERTICAL_ALIGNMENT_TOP;
  921. private static _VERTICAL_ALIGNMENT_BOTTOM;
  922. private static _VERTICAL_ALIGNMENT_CENTER;
  923. /** HORIZONTAL_ALIGNMENT_LEFT */
  924. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  925. /** HORIZONTAL_ALIGNMENT_RIGHT */
  926. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  927. /** HORIZONTAL_ALIGNMENT_CENTER */
  928. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  929. /** VERTICAL_ALIGNMENT_TOP */
  930. static readonly VERTICAL_ALIGNMENT_TOP: number;
  931. /** VERTICAL_ALIGNMENT_BOTTOM */
  932. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  933. /** VERTICAL_ALIGNMENT_CENTER */
  934. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  935. private static _FontHeightSizes;
  936. /** @hidden */
  937. static _GetFontOffset(font: string): {
  938. ascent: number;
  939. height: number;
  940. descent: number;
  941. };
  942. /**
  943. * Creates a stack panel that can be used to render headers
  944. * @param control defines the control to associate with the header
  945. * @param text defines the text of the header
  946. * @param size defines the size of the header
  947. * @param options defines options used to configure the header
  948. * @returns a new StackPanel
  949. */
  950. static AddHeader(control: Control, text: string, size: string | number, options: {
  951. isHorizontal: boolean;
  952. controlFirst: boolean;
  953. }): StackPanel;
  954. /** @hidden */
  955. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  956. }
  957. }
  958. declare module BABYLON.GUI {
  959. /**
  960. * Root class for 2D containers
  961. * @see http://doc.babylonjs.com/how_to/gui#containers
  962. */
  963. class Container extends Control {
  964. name: string | undefined;
  965. /** @hidden */
  966. protected _children: Control[];
  967. /** @hidden */
  968. protected _measureForChildren: Measure;
  969. /** @hidden */
  970. protected _background: string;
  971. /** @hidden */
  972. protected _adaptWidthToChildren: boolean;
  973. /** @hidden */
  974. protected _adaptHeightToChildren: boolean;
  975. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  976. adaptHeightToChildren: boolean;
  977. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  978. adaptWidthToChildren: boolean;
  979. /** Gets or sets background color */
  980. background: string;
  981. /** Gets the list of children */
  982. readonly children: Control[];
  983. /**
  984. * Creates a new Container
  985. * @param name defines the name of the container
  986. */
  987. constructor(name?: string | undefined);
  988. protected _getTypeName(): string;
  989. /**
  990. * Gets a child using its name
  991. * @param name defines the child name to look for
  992. * @returns the child control if found
  993. */
  994. getChildByName(name: string): Nullable<Control>;
  995. /**
  996. * Gets a child using its type and its name
  997. * @param name defines the child name to look for
  998. * @param type defines the child type to look for
  999. * @returns the child control if found
  1000. */
  1001. getChildByType(name: string, type: string): Nullable<Control>;
  1002. /**
  1003. * Search for a specific control in children
  1004. * @param control defines the control to look for
  1005. * @returns true if the control is in child list
  1006. */
  1007. containsControl(control: Control): boolean;
  1008. /**
  1009. * Adds a new control to the current container
  1010. * @param control defines the control to add
  1011. * @returns the current container
  1012. */
  1013. addControl(control: Control): Container;
  1014. /**
  1015. * Removes a control from the current container
  1016. * @param control defines the control to remove
  1017. * @returns the current container
  1018. */
  1019. removeControl(control: Control): Container;
  1020. /** @hidden */
  1021. _reOrderControl(control: Control): void;
  1022. /** @hidden */
  1023. _markMatrixAsDirty(): void;
  1024. /** @hidden */
  1025. _markAllAsDirty(): void;
  1026. /** @hidden */
  1027. protected _localDraw(context: CanvasRenderingContext2D): void;
  1028. /** @hidden */
  1029. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  1030. /** @hidden */
  1031. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1032. /** @hidden */
  1033. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1034. /** @hidden */
  1035. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1036. /** @hidden */
  1037. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1038. /** Releases associated resources */
  1039. dispose(): void;
  1040. }
  1041. }
  1042. declare module BABYLON.GUI {
  1043. /**
  1044. * Class used to create a 2D stack panel container
  1045. */
  1046. class StackPanel extends Container {
  1047. name: string | undefined;
  1048. private _isVertical;
  1049. private _manualWidth;
  1050. private _manualHeight;
  1051. private _doNotTrackManualChanges;
  1052. private _tempMeasureStore;
  1053. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1054. isVertical: boolean;
  1055. /** Gets or sets panel width */
  1056. width: string | number;
  1057. /** Gets or sets panel height */
  1058. height: string | number;
  1059. /**
  1060. * Creates a new StackPanel
  1061. * @param name defines control name
  1062. */
  1063. constructor(name?: string | undefined);
  1064. protected _getTypeName(): string;
  1065. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1066. }
  1067. }
  1068. declare module BABYLON.GUI {
  1069. /** Class used to create rectangle container */
  1070. class Rectangle extends Container {
  1071. name: string | undefined;
  1072. private _thickness;
  1073. private _cornerRadius;
  1074. /** Gets or sets border thickness */
  1075. thickness: number;
  1076. /** Gets or sets the corner radius angle */
  1077. cornerRadius: number;
  1078. /**
  1079. * Creates a new Rectangle
  1080. * @param name defines the control name
  1081. */
  1082. constructor(name?: string | undefined);
  1083. protected _getTypeName(): string;
  1084. protected _localDraw(context: CanvasRenderingContext2D): void;
  1085. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1086. private _drawRoundedRect(context, offset?);
  1087. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1088. }
  1089. }
  1090. declare module BABYLON.GUI {
  1091. /** Class used to create 2D ellipse containers */
  1092. class Ellipse extends Container {
  1093. name: string | undefined;
  1094. private _thickness;
  1095. /** Gets or sets border thickness */
  1096. thickness: number;
  1097. /**
  1098. * Creates a new Ellipse
  1099. * @param name defines the control name
  1100. */
  1101. constructor(name?: string | undefined);
  1102. protected _getTypeName(): string;
  1103. protected _localDraw(context: CanvasRenderingContext2D): void;
  1104. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1105. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1106. }
  1107. }
  1108. declare module BABYLON.GUI {
  1109. /** Class used to render 2D lines */
  1110. class Line extends Control {
  1111. name: string | undefined;
  1112. private _lineWidth;
  1113. private _x1;
  1114. private _y1;
  1115. private _x2;
  1116. private _y2;
  1117. private _dash;
  1118. private _connectedControl;
  1119. private _connectedControlDirtyObserver;
  1120. /** Gets or sets the dash pattern */
  1121. dash: Array<number>;
  1122. /** Gets or sets the control connected with the line end */
  1123. connectedControl: Control;
  1124. /** Gets or sets start coordinates on X axis */
  1125. x1: string | number;
  1126. /** Gets or sets start coordinates on Y axis */
  1127. y1: string | number;
  1128. /** Gets or sets end coordinates on X axis */
  1129. x2: string | number;
  1130. /** Gets or sets end coordinates on Y axis */
  1131. y2: string | number;
  1132. /** Gets or sets line width */
  1133. lineWidth: number;
  1134. /** Gets or sets horizontal alignment */
  1135. horizontalAlignment: number;
  1136. /** Gets or sets vertical alignment */
  1137. verticalAlignment: number;
  1138. private readonly _effectiveX2;
  1139. private readonly _effectiveY2;
  1140. /**
  1141. * Creates a new Line
  1142. * @param name defines the control name
  1143. */
  1144. constructor(name?: string | undefined);
  1145. protected _getTypeName(): string;
  1146. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1147. _measure(): void;
  1148. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1149. /**
  1150. * Move one end of the line given 3D cartesian coordinates.
  1151. * @param position Targeted world position
  1152. * @param scene Scene
  1153. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1154. */
  1155. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  1156. /**
  1157. * Move one end of the line to a position in screen absolute space.
  1158. * @param projectedPosition Position in screen absolute space (X, Y)
  1159. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1160. */
  1161. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  1162. }
  1163. }
  1164. declare module BABYLON.GUI {
  1165. /**
  1166. * Class used to create slider controls
  1167. */
  1168. class Slider extends Control {
  1169. name: string | undefined;
  1170. private _thumbWidth;
  1171. private _minimum;
  1172. private _maximum;
  1173. private _value;
  1174. private _background;
  1175. private _borderColor;
  1176. private _barOffset;
  1177. private _isThumbCircle;
  1178. private _isThumbClamped;
  1179. /** Observable raised when the sldier value changes */
  1180. onValueChangedObservable: Observable<number>;
  1181. /** Gets or sets border color */
  1182. borderColor: string;
  1183. /** Gets or sets background color */
  1184. background: string;
  1185. /** Gets or sets main bar offset */
  1186. barOffset: string | number;
  1187. /** Gets main bar offset in pixels*/
  1188. readonly barOffsetInPixels: number;
  1189. /** Gets or sets thumb width */
  1190. thumbWidth: string | number;
  1191. /** Gets thumb width in pixels */
  1192. readonly thumbWidthInPixels: number;
  1193. /** Gets or sets minimum value */
  1194. minimum: number;
  1195. /** Gets or sets maximum value */
  1196. maximum: number;
  1197. /** Gets or sets current value */
  1198. value: number;
  1199. /** Gets or sets a boolean indicating if the thumb should be round or square */
  1200. isThumbCircle: boolean;
  1201. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  1202. isThumbClamped: boolean;
  1203. /**
  1204. * Creates a new Slider
  1205. * @param name defines the control name
  1206. */
  1207. constructor(name?: string | undefined);
  1208. protected _getTypeName(): string;
  1209. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1210. private _pointerIsDown;
  1211. private _updateValueFromPointer(x, y);
  1212. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1213. _onPointerMove(target: Control, coordinates: Vector2): void;
  1214. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1215. }
  1216. }
  1217. declare module BABYLON.GUI {
  1218. /**
  1219. * Class used to represent a 2D checkbox
  1220. */
  1221. class Checkbox extends Control {
  1222. name: string | undefined;
  1223. private _isChecked;
  1224. private _background;
  1225. private _checkSizeRatio;
  1226. private _thickness;
  1227. /** Gets or sets border thickness */
  1228. thickness: number;
  1229. /**
  1230. * Observable raised when isChecked property changes
  1231. */
  1232. onIsCheckedChangedObservable: Observable<boolean>;
  1233. /** Gets or sets a value indicating the ratio between overall size and check size */
  1234. checkSizeRatio: number;
  1235. /** Gets or sets background color */
  1236. background: string;
  1237. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1238. isChecked: boolean;
  1239. /**
  1240. * Creates a new CheckBox
  1241. * @param name defines the control name
  1242. */
  1243. constructor(name?: string | undefined);
  1244. protected _getTypeName(): string;
  1245. /** @hidden */
  1246. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1247. /** @hidden */
  1248. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON.GUI {
  1252. /**
  1253. * Class used to create radio button controls
  1254. */
  1255. class RadioButton extends Control {
  1256. name: string | undefined;
  1257. private _isChecked;
  1258. private _background;
  1259. private _checkSizeRatio;
  1260. private _thickness;
  1261. /** Gets or sets border thickness */
  1262. thickness: number;
  1263. /** Gets or sets group name */
  1264. group: string;
  1265. /** Observable raised when isChecked is changed */
  1266. onIsCheckedChangedObservable: Observable<boolean>;
  1267. /** Gets or sets a value indicating the ratio between overall size and check size */
  1268. checkSizeRatio: number;
  1269. /** Gets or sets background color */
  1270. background: string;
  1271. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1272. isChecked: boolean;
  1273. /**
  1274. * Creates a new RadioButton
  1275. * @param name defines the control name
  1276. */
  1277. constructor(name?: string | undefined);
  1278. protected _getTypeName(): string;
  1279. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1280. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON.GUI {
  1284. /**
  1285. * Class used to create text block control
  1286. */
  1287. class TextBlock extends Control {
  1288. /**
  1289. * Defines the name of the control
  1290. */
  1291. name: string | undefined;
  1292. private _text;
  1293. private _textWrapping;
  1294. private _textHorizontalAlignment;
  1295. private _textVerticalAlignment;
  1296. private _lines;
  1297. private _resizeToFit;
  1298. private _lineSpacing;
  1299. private _outlineWidth;
  1300. private _outlineColor;
  1301. /**
  1302. * An event triggered after the text is changed
  1303. */
  1304. onTextChangedObservable: Observable<TextBlock>;
  1305. /**
  1306. * An event triggered after the text was broken up into lines
  1307. */
  1308. onLinesReadyObservable: Observable<TextBlock>;
  1309. /**
  1310. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1311. */
  1312. readonly lines: any[];
  1313. /**
  1314. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1315. */
  1316. /**
  1317. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1318. */
  1319. resizeToFit: boolean;
  1320. /**
  1321. * Gets or sets a boolean indicating if text must be wrapped
  1322. */
  1323. /**
  1324. * Gets or sets a boolean indicating if text must be wrapped
  1325. */
  1326. textWrapping: boolean;
  1327. /**
  1328. * Gets or sets text to display
  1329. */
  1330. /**
  1331. * Gets or sets text to display
  1332. */
  1333. text: string;
  1334. /**
  1335. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1336. */
  1337. /**
  1338. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1339. */
  1340. textHorizontalAlignment: number;
  1341. /**
  1342. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1343. */
  1344. /**
  1345. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1346. */
  1347. textVerticalAlignment: number;
  1348. /**
  1349. * Gets or sets line spacing value
  1350. */
  1351. /**
  1352. * Gets or sets line spacing value
  1353. */
  1354. lineSpacing: string | number;
  1355. /**
  1356. * Gets or sets outlineWidth of the text to display
  1357. */
  1358. /**
  1359. * Gets or sets outlineWidth of the text to display
  1360. */
  1361. outlineWidth: number;
  1362. /**
  1363. * Gets or sets outlineColor of the text to display
  1364. */
  1365. /**
  1366. * Gets or sets outlineColor of the text to display
  1367. */
  1368. outlineColor: string;
  1369. /**
  1370. * Creates a new TextBlock object
  1371. * @param name defines the name of the control
  1372. * @param text defines the text to display (emptry string by default)
  1373. */
  1374. constructor(
  1375. /**
  1376. * Defines the name of the control
  1377. */
  1378. name?: string | undefined, text?: string);
  1379. protected _getTypeName(): string;
  1380. private _drawText(text, textWidth, y, context);
  1381. /** @hidden */
  1382. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1383. protected _applyStates(context: CanvasRenderingContext2D): void;
  1384. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1385. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1386. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  1387. protected _renderLines(context: CanvasRenderingContext2D): void;
  1388. dispose(): void;
  1389. }
  1390. }
  1391. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  1392. declare module BABYLON.GUI {
  1393. /**
  1394. * Class used to create 2D images
  1395. */
  1396. class Image extends Control {
  1397. name: string | undefined;
  1398. private _domImage;
  1399. private _imageWidth;
  1400. private _imageHeight;
  1401. private _loaded;
  1402. private _stretch;
  1403. private _source;
  1404. private _autoScale;
  1405. private _sourceLeft;
  1406. private _sourceTop;
  1407. private _sourceWidth;
  1408. private _sourceHeight;
  1409. private _cellWidth;
  1410. private _cellHeight;
  1411. private _cellId;
  1412. /**
  1413. * Gets or sets the left coordinate in the source image
  1414. */
  1415. sourceLeft: number;
  1416. /**
  1417. * Gets or sets the top coordinate in the source image
  1418. */
  1419. sourceTop: number;
  1420. /**
  1421. * Gets or sets the width to capture in the source image
  1422. */
  1423. sourceWidth: number;
  1424. /**
  1425. * Gets or sets the height to capture in the source image
  1426. */
  1427. sourceHeight: number;
  1428. /**
  1429. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1430. * @see http://doc.babylonjs.com/how_to/gui#image
  1431. */
  1432. autoScale: boolean;
  1433. /** Gets or sets the streching mode used by the image */
  1434. stretch: number;
  1435. /**
  1436. * Gets or sets the internal DOM image used to render the control
  1437. */
  1438. domImage: HTMLImageElement;
  1439. private _onImageLoaded();
  1440. /**
  1441. * Gets or sets image source url
  1442. */
  1443. source: Nullable<string>;
  1444. /**
  1445. * Gets or sets the cell width to use when animation sheet is enabled
  1446. * @see http://doc.babylonjs.com/how_to/gui#image
  1447. */
  1448. cellWidth: number;
  1449. /**
  1450. * Gets or sets the cell height to use when animation sheet is enabled
  1451. * @see http://doc.babylonjs.com/how_to/gui#image
  1452. */
  1453. cellHeight: number;
  1454. /**
  1455. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1456. * @see http://doc.babylonjs.com/how_to/gui#image
  1457. */
  1458. cellId: number;
  1459. /**
  1460. * Creates a new Image
  1461. * @param name defines the control name
  1462. * @param url defines the image url
  1463. */
  1464. constructor(name?: string | undefined, url?: Nullable<string>);
  1465. protected _getTypeName(): string;
  1466. /** Force the control to synchronize with its content */
  1467. synchronizeSizeWithContent(): void;
  1468. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1469. private static _STRETCH_NONE;
  1470. private static _STRETCH_FILL;
  1471. private static _STRETCH_UNIFORM;
  1472. private static _STRETCH_EXTEND;
  1473. /** STRETCH_NONE */
  1474. static readonly STRETCH_NONE: number;
  1475. /** STRETCH_FILL */
  1476. static readonly STRETCH_FILL: number;
  1477. /** STRETCH_UNIFORM */
  1478. static readonly STRETCH_UNIFORM: number;
  1479. /** STRETCH_EXTEND */
  1480. static readonly STRETCH_EXTEND: number;
  1481. }
  1482. }
  1483. declare module BABYLON.GUI {
  1484. /**
  1485. * Class used to create 2D buttons
  1486. */
  1487. class Button extends Rectangle {
  1488. name: string | undefined;
  1489. /**
  1490. * Function called to generate a pointer enter animation
  1491. */
  1492. pointerEnterAnimation: () => void;
  1493. /**
  1494. * Function called to generate a pointer out animation
  1495. */
  1496. pointerOutAnimation: () => void;
  1497. /**
  1498. * Function called to generate a pointer down animation
  1499. */
  1500. pointerDownAnimation: () => void;
  1501. /**
  1502. * Function called to generate a pointer up animation
  1503. */
  1504. pointerUpAnimation: () => void;
  1505. /**
  1506. * Creates a new Button
  1507. * @param name defines the name of the button
  1508. */
  1509. constructor(name?: string | undefined);
  1510. protected _getTypeName(): string;
  1511. /** @hidden */
  1512. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1513. /** @hidden */
  1514. _onPointerEnter(target: Control): boolean;
  1515. /** @hidden */
  1516. _onPointerOut(target: Control): void;
  1517. /** @hidden */
  1518. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1519. /** @hidden */
  1520. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1521. /**
  1522. * Creates a new button made with an image and a text
  1523. * @param name defines the name of the button
  1524. * @param text defines the text of the button
  1525. * @param imageUrl defines the url of the image
  1526. * @returns a new Button
  1527. */
  1528. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1529. /**
  1530. * Creates a new button made with an image
  1531. * @param name defines the name of the button
  1532. * @param imageUrl defines the url of the image
  1533. * @returns a new Button
  1534. */
  1535. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1536. /**
  1537. * Creates a new button made with a text
  1538. * @param name defines the name of the button
  1539. * @param text defines the text of the button
  1540. * @returns a new Button
  1541. */
  1542. static CreateSimpleButton(name: string, text: string): Button;
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1551. }
  1552. }
  1553. declare module BABYLON.GUI {
  1554. /** Class used to create color pickers */
  1555. class ColorPicker extends Control {
  1556. name: string | undefined;
  1557. private _colorWheelCanvas;
  1558. private _value;
  1559. private _tmpColor;
  1560. private _pointerStartedOnSquare;
  1561. private _pointerStartedOnWheel;
  1562. private _squareLeft;
  1563. private _squareTop;
  1564. private _squareSize;
  1565. private _h;
  1566. private _s;
  1567. private _v;
  1568. /**
  1569. * Observable raised when the value changes
  1570. */
  1571. onValueChangedObservable: Observable<Color3>;
  1572. /** Gets or sets the color of the color picker */
  1573. value: Color3;
  1574. /** Gets or sets control width */
  1575. width: string | number;
  1576. /** Gets or sets control height */
  1577. height: string | number;
  1578. /** Gets or sets control size */
  1579. size: string | number;
  1580. /**
  1581. * Creates a new ColorPicker
  1582. * @param name defines the control name
  1583. */
  1584. constructor(name?: string | undefined);
  1585. protected _getTypeName(): string;
  1586. private _updateSquareProps();
  1587. private _drawGradientSquare(hueValue, left, top, width, height, context);
  1588. private _drawCircle(centerX, centerY, radius, context);
  1589. private _createColorWheelCanvas(radius, thickness);
  1590. private _RGBtoHSV(color, result);
  1591. private _HSVtoRGB(hue, saturation, value, result);
  1592. /** @hidden */
  1593. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1594. private _pointerIsDown;
  1595. private _updateValueFromPointer(x, y);
  1596. private _isPointOnSquare(coordinates);
  1597. private _isPointOnWheel(coordinates);
  1598. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1599. _onPointerMove(target: Control, coordinates: Vector2): void;
  1600. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1601. }
  1602. }
  1603. declare module BABYLON.GUI {
  1604. /**
  1605. * Class used to create input text control
  1606. */
  1607. class InputText extends Control implements IFocusableControl {
  1608. name: string | undefined;
  1609. private _text;
  1610. private _placeholderText;
  1611. private _background;
  1612. private _focusedBackground;
  1613. private _placeholderColor;
  1614. private _thickness;
  1615. private _margin;
  1616. private _autoStretchWidth;
  1617. private _maxWidth;
  1618. private _isFocused;
  1619. private _blinkTimeout;
  1620. private _blinkIsEven;
  1621. private _cursorOffset;
  1622. private _scrollLeft;
  1623. private _textWidth;
  1624. private _clickedCoordinate;
  1625. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1626. promptMessage: string;
  1627. /** Observable raised when the text changes */
  1628. onTextChangedObservable: Observable<InputText>;
  1629. /** Observable raised when the control gets the focus */
  1630. onFocusObservable: Observable<InputText>;
  1631. /** Observable raised when the control loses the focus */
  1632. onBlurObservable: Observable<InputText>;
  1633. /** Gets or sets the maximum width allowed by the control */
  1634. maxWidth: string | number;
  1635. /** Gets the maximum width allowed by the control in pixels */
  1636. readonly maxWidthInPixels: number;
  1637. /** Gets or sets control margin */
  1638. margin: string;
  1639. /** Gets control margin in pixels */
  1640. readonly marginInPixels: number;
  1641. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  1642. autoStretchWidth: boolean;
  1643. /** Gets or sets border thickness */
  1644. thickness: number;
  1645. /** Gets or sets the background color when focused */
  1646. focusedBackground: string;
  1647. /** Gets or sets the background color */
  1648. background: string;
  1649. /** Gets or sets the placeholder color */
  1650. placeholderColor: string;
  1651. /** Gets or sets the text displayed when the control is empty */
  1652. placeholderText: string;
  1653. /** Gets or sets the text displayed in the control */
  1654. text: string;
  1655. /** Gets or sets control width */
  1656. width: string | number;
  1657. /**
  1658. * Creates a new InputText
  1659. * @param name defines the control name
  1660. * @param text defines the text of the control
  1661. */
  1662. constructor(name?: string | undefined, text?: string);
  1663. /** @hidden */
  1664. onBlur(): void;
  1665. /** @hidden */
  1666. onFocus(): void;
  1667. protected _getTypeName(): string;
  1668. /** @hidden */
  1669. processKey(keyCode: number, key?: string): void;
  1670. /** @hidden */
  1671. processKeyboard(evt: KeyboardEvent): void;
  1672. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1673. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1674. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1675. dispose(): void;
  1676. }
  1677. }
  1678. declare module BABYLON.GUI {
  1679. /**
  1680. * Class used to store key control properties
  1681. */
  1682. class KeyPropertySet {
  1683. /** Width */
  1684. width?: string;
  1685. /** Height */
  1686. height?: string;
  1687. /** Left padding */
  1688. paddingLeft?: string;
  1689. /** Right padding */
  1690. paddingRight?: string;
  1691. /** Top padding */
  1692. paddingTop?: string;
  1693. /** Bottom padding */
  1694. paddingBottom?: string;
  1695. /** Foreground color */
  1696. color?: string;
  1697. /** Background color */
  1698. background?: string;
  1699. }
  1700. /**
  1701. * Class used to create virtual keyboard
  1702. */
  1703. class VirtualKeyboard extends StackPanel {
  1704. /** Observable raised when a key is pressed */
  1705. onKeyPressObservable: Observable<string>;
  1706. /** Gets or sets default key button width */
  1707. defaultButtonWidth: string;
  1708. /** Gets or sets default key button height */
  1709. defaultButtonHeight: string;
  1710. /** Gets or sets default key button left padding */
  1711. defaultButtonPaddingLeft: string;
  1712. /** Gets or sets default key button right padding */
  1713. defaultButtonPaddingRight: string;
  1714. /** Gets or sets default key button top padding */
  1715. defaultButtonPaddingTop: string;
  1716. /** Gets or sets default key button bottom padding */
  1717. defaultButtonPaddingBottom: string;
  1718. /** Gets or sets default key button foreground color */
  1719. defaultButtonColor: string;
  1720. /** Gets or sets default key button background color */
  1721. defaultButtonBackground: string;
  1722. /** Gets or sets shift button foreground color */
  1723. shiftButtonColor: string;
  1724. /** Gets or sets shift button thickness*/
  1725. selectedShiftThickness: number;
  1726. /** Gets shift key state */
  1727. shiftState: number;
  1728. protected _getTypeName(): string;
  1729. private _createKey(key, propertySet);
  1730. /**
  1731. * Adds a new row of keys
  1732. * @param keys defines the list of keys to add
  1733. * @param propertySets defines the associated property sets
  1734. */
  1735. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1736. /**
  1737. * Set the shift key to a specific state
  1738. * @param shiftState defines the new shift state
  1739. */
  1740. applyShiftState(shiftState: number): void;
  1741. private _connectedInputText;
  1742. private _onFocusObserver;
  1743. private _onBlurObserver;
  1744. private _onKeyPressObserver;
  1745. /** Gets the input text control attached with the keyboard */
  1746. readonly connectedInputText: Nullable<InputText>;
  1747. /**
  1748. * Connects the keyboard with an input text control
  1749. * @param input defines the target control
  1750. */
  1751. connect(input: InputText): void;
  1752. /**
  1753. * Disconnects the keyboard from an input text control
  1754. */
  1755. disconnect(): void;
  1756. /**
  1757. * Creates a new keyboard using a default layout
  1758. * @returns a new VirtualKeyboard
  1759. */
  1760. static CreateDefaultLayout(): VirtualKeyboard;
  1761. }
  1762. }
  1763. declare module BABYLON.GUI {
  1764. /**
  1765. * Class used to create multi line control
  1766. */
  1767. class MultiLine extends Control {
  1768. name: string | undefined;
  1769. private _lineWidth;
  1770. private _dash;
  1771. private _points;
  1772. private _minX;
  1773. private _minY;
  1774. private _maxX;
  1775. private _maxY;
  1776. /**
  1777. * Creates a new MultiLine
  1778. * @param name defines the control name
  1779. */
  1780. constructor(name?: string | undefined);
  1781. /** Gets or sets dash pattern */
  1782. dash: Array<number>;
  1783. /**
  1784. * Gets point stored at specified index
  1785. * @param index defines the index to look for
  1786. * @returns the requested point if found
  1787. */
  1788. getAt(index: number): MultiLinePoint;
  1789. /** Function called when a point is updated */
  1790. onPointUpdate: () => void;
  1791. /**
  1792. * Adds new points to the point collection
  1793. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  1794. * @returns the list of created MultiLinePoint
  1795. */
  1796. add(...items: (AbstractMesh | Control | {
  1797. x: string | number;
  1798. y: string | number;
  1799. })[]): MultiLinePoint[];
  1800. /**
  1801. * Adds a new point to the point collection
  1802. * @param item defines the item (mesh, control or 2d coordiantes) to add
  1803. * @returns the created MultiLinePoint
  1804. */
  1805. push(item?: (AbstractMesh | Control | {
  1806. x: string | number;
  1807. y: string | number;
  1808. })): MultiLinePoint;
  1809. /**
  1810. * Remove a specific value or point from the active point collection
  1811. * @param value defines the value or point to remove
  1812. */
  1813. remove(value: number | MultiLinePoint): void;
  1814. /** Gets or sets line width */
  1815. lineWidth: number;
  1816. horizontalAlignment: number;
  1817. verticalAlignment: number;
  1818. protected _getTypeName(): string;
  1819. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1820. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1821. _measure(): void;
  1822. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1823. dispose(): void;
  1824. }
  1825. }
  1826. declare module BABYLON.GUI {
  1827. /**
  1828. * Class used to manage 3D user interface
  1829. * @see http://doc.babylonjs.com/how_to/gui3d
  1830. */
  1831. class GUI3DManager implements BABYLON.IDisposable {
  1832. private _scene;
  1833. private _sceneDisposeObserver;
  1834. private _utilityLayer;
  1835. private _rootContainer;
  1836. private _pointerObserver;
  1837. /** @hidden */
  1838. _lastPickedControl: Control3D;
  1839. /** @hidden */
  1840. _lastControlOver: {
  1841. [pointerId: number]: Control3D;
  1842. };
  1843. /** @hidden */
  1844. _lastControlDown: {
  1845. [pointerId: number]: Control3D;
  1846. };
  1847. /**
  1848. * Observable raised when the point picked by the pointer events changed
  1849. */
  1850. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  1851. /** @hidden */
  1852. _sharedMaterials: {
  1853. [key: string]: Material;
  1854. };
  1855. /** Gets the hosting scene */
  1856. readonly scene: Scene;
  1857. /** Gets associated utility layer */
  1858. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  1859. /**
  1860. * Creates a new GUI3DManager
  1861. * @param scene
  1862. */
  1863. constructor(scene?: Scene);
  1864. private _doPicking(type, pointerEvent, ray?);
  1865. /**
  1866. * Gets the root container
  1867. */
  1868. readonly rootContainer: Container3D;
  1869. /**
  1870. * Gets a boolean indicating if the given control is in the root child list
  1871. * @param control defines the control to check
  1872. * @returns true if the control is in the root child list
  1873. */
  1874. containsControl(control: Control3D): boolean;
  1875. /**
  1876. * Adds a control to the root child list
  1877. * @param control defines the control to add
  1878. * @returns the current manager
  1879. */
  1880. addControl(control: Control3D): GUI3DManager;
  1881. /**
  1882. * Removes a control from the root child list
  1883. * @param control defines the control to remove
  1884. * @returns the current container
  1885. */
  1886. removeControl(control: Control3D): GUI3DManager;
  1887. /**
  1888. * Releases all associated resources
  1889. */
  1890. dispose(): void;
  1891. }
  1892. }
  1893. declare module BABYLON.GUI {
  1894. /** @hidden */
  1895. class FluentMaterialDefines extends MaterialDefines {
  1896. INNERGLOW: boolean;
  1897. BORDER: boolean;
  1898. HOVERLIGHT: boolean;
  1899. constructor();
  1900. }
  1901. /**
  1902. * Class used to render controls with fluent desgin
  1903. */
  1904. class FluentMaterial extends PushMaterial {
  1905. /**
  1906. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  1907. */
  1908. innerGlowColorIntensity: number;
  1909. /**
  1910. * Gets or sets the inner glow color (white by default)
  1911. */
  1912. innerGlowColor: Color3;
  1913. /**
  1914. * Gets or sets alpha value (default is 1.0)
  1915. */
  1916. alpha: number;
  1917. /**
  1918. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  1919. */
  1920. albedoColor: Color3;
  1921. /**
  1922. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  1923. */
  1924. renderBorders: boolean;
  1925. /**
  1926. * Gets or sets border width (default is 0.5)
  1927. */
  1928. borderWidth: number;
  1929. /**
  1930. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  1931. */
  1932. edgeSmoothingValue: number;
  1933. /**
  1934. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  1935. */
  1936. borderMinValue: number;
  1937. /**
  1938. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  1939. */
  1940. renderHoverLight: boolean;
  1941. /**
  1942. * Gets or sets the radius used to render the hover light (default is 0.15)
  1943. */
  1944. hoverRadius: number;
  1945. /**
  1946. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  1947. */
  1948. hoverColor: Color4;
  1949. /**
  1950. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  1951. */
  1952. hoverPosition: Vector3;
  1953. /**
  1954. * Creates a new Fluent material
  1955. * @param name defines the name of the material
  1956. * @param scene defines the hosting scene
  1957. */
  1958. constructor(name: string, scene: Scene);
  1959. needAlphaBlending(): boolean;
  1960. needAlphaTesting(): boolean;
  1961. getAlphaTestTexture(): Nullable<BaseTexture>;
  1962. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  1963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  1964. getActiveTextures(): BaseTexture[];
  1965. hasTexture(texture: BaseTexture): boolean;
  1966. dispose(forceDisposeEffect?: boolean): void;
  1967. clone(name: string): FluentMaterial;
  1968. serialize(): any;
  1969. getClassName(): string;
  1970. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  1971. }
  1972. }
  1973. declare module BABYLON.GUI {
  1974. /**
  1975. * Class used to transport Vector3 information for pointer events
  1976. */
  1977. class Vector3WithInfo extends Vector3 {
  1978. /** defines the current mouse button index */
  1979. buttonIndex: number;
  1980. /**
  1981. * Creates a new Vector3WithInfo
  1982. * @param source defines the vector3 data to transport
  1983. * @param buttonIndex defines the current mouse button index
  1984. */
  1985. constructor(source: Vector3,
  1986. /** defines the current mouse button index */
  1987. buttonIndex?: number);
  1988. }
  1989. }
  1990. declare module BABYLON.GUI {
  1991. /**
  1992. * Class used as base class for controls
  1993. */
  1994. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  1995. /** Defines the control name */
  1996. name: string | undefined;
  1997. /** @hidden */
  1998. _host: GUI3DManager;
  1999. private _node;
  2000. private _downCount;
  2001. private _enterCount;
  2002. private _downPointerIds;
  2003. private _isVisible;
  2004. /** Gets or sets the control position in world space */
  2005. position: Vector3;
  2006. /** Gets or sets the control scaling in world space */
  2007. scaling: Vector3;
  2008. /** Callback used to start pointer enter animation */
  2009. pointerEnterAnimation: () => void;
  2010. /** Callback used to start pointer out animation */
  2011. pointerOutAnimation: () => void;
  2012. /** Callback used to start pointer down animation */
  2013. pointerDownAnimation: () => void;
  2014. /** Callback used to start pointer up animation */
  2015. pointerUpAnimation: () => void;
  2016. /**
  2017. * An event triggered when the pointer move over the control
  2018. */
  2019. onPointerMoveObservable: Observable<Vector3>;
  2020. /**
  2021. * An event triggered when the pointer move out of the control
  2022. */
  2023. onPointerOutObservable: Observable<Control3D>;
  2024. /**
  2025. * An event triggered when the pointer taps the control
  2026. */
  2027. onPointerDownObservable: Observable<Vector3WithInfo>;
  2028. /**
  2029. * An event triggered when pointer is up
  2030. */
  2031. onPointerUpObservable: Observable<Vector3WithInfo>;
  2032. /**
  2033. * An event triggered when a control is clicked on (with a mouse)
  2034. */
  2035. onPointerClickObservable: Observable<Vector3WithInfo>;
  2036. /**
  2037. * An event triggered when pointer enters the control
  2038. */
  2039. onPointerEnterObservable: Observable<Control3D>;
  2040. /**
  2041. * Gets or sets the parent container
  2042. */
  2043. parent: Nullable<Container3D>;
  2044. private _behaviors;
  2045. /**
  2046. * Gets the list of attached behaviors
  2047. * @see http://doc.babylonjs.com/features/behaviour
  2048. */
  2049. readonly behaviors: Behavior<Control3D>[];
  2050. /**
  2051. * Attach a behavior to the control
  2052. * @see http://doc.babylonjs.com/features/behaviour
  2053. * @param behavior defines the behavior to attach
  2054. * @returns the current control
  2055. */
  2056. addBehavior(behavior: Behavior<Control3D>): Control3D;
  2057. /**
  2058. * Remove an attached behavior
  2059. * @see http://doc.babylonjs.com/features/behaviour
  2060. * @param behavior defines the behavior to attach
  2061. * @returns the current control
  2062. */
  2063. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  2064. /**
  2065. * Gets an attached behavior by name
  2066. * @param name defines the name of the behavior to look for
  2067. * @see http://doc.babylonjs.com/features/behaviour
  2068. * @returns null if behavior was not found else the requested behavior
  2069. */
  2070. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  2071. /** Gets or sets a boolean indicating if the control is visible */
  2072. isVisible: boolean;
  2073. /**
  2074. * Creates a new control
  2075. * @param name defines the control name
  2076. */
  2077. constructor(
  2078. /** Defines the control name */
  2079. name?: string | undefined);
  2080. /**
  2081. * Gets a string representing the class name
  2082. */
  2083. readonly typeName: string;
  2084. protected _getTypeName(): string;
  2085. /**
  2086. * Gets the transform node used by this control
  2087. */
  2088. readonly node: Nullable<TransformNode>;
  2089. /**
  2090. * Gets the mesh used to render this control
  2091. */
  2092. readonly mesh: Nullable<AbstractMesh>;
  2093. /**
  2094. * Link the control as child of the given node
  2095. * @param node defines the node to link to. Use null to unlink the control
  2096. * @returns the current control
  2097. */
  2098. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  2099. /** @hidden **/
  2100. _prepareNode(scene: Scene): void;
  2101. /**
  2102. * Node creation.
  2103. * Can be overriden by children
  2104. * @param scene defines the scene where the node must be attached
  2105. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  2106. */
  2107. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2108. /**
  2109. * Affect a material to the given mesh
  2110. * @param mesh defines the mesh which will represent the control
  2111. */
  2112. protected _affectMaterial(mesh: AbstractMesh): void;
  2113. /** @hidden */
  2114. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  2115. /** @hidden */
  2116. _onPointerEnter(target: Control3D): boolean;
  2117. /** @hidden */
  2118. _onPointerOut(target: Control3D): void;
  2119. /** @hidden */
  2120. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  2121. /** @hidden */
  2122. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2123. /** @hidden */
  2124. forcePointerUp(pointerId?: Nullable<number>): void;
  2125. /** @hidden */
  2126. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  2127. /**
  2128. * Releases all associated resources
  2129. */
  2130. dispose(): void;
  2131. }
  2132. }
  2133. declare module BABYLON.GUI {
  2134. /**
  2135. * Class used to create containers for controls
  2136. */
  2137. class Container3D extends Control3D {
  2138. /**
  2139. * Gets the list of child controls
  2140. */
  2141. protected _children: Control3D[];
  2142. /**
  2143. * Creates a new container
  2144. * @param name defines the container name
  2145. */
  2146. constructor(name?: string);
  2147. /**
  2148. * Gets a boolean indicating if the given control is in the children of this control
  2149. * @param control defines the control to check
  2150. * @returns true if the control is in the child list
  2151. */
  2152. containsControl(control: Control3D): boolean;
  2153. /**
  2154. * Adds a control to the children of this control
  2155. * @param control defines the control to add
  2156. * @returns the current container
  2157. */
  2158. addControl(control: Control3D): Container3D;
  2159. /**
  2160. * This function will be called everytime a new control is added
  2161. */
  2162. protected _arrangeChildren(): void;
  2163. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2164. /**
  2165. * Removes a control from the children of this control
  2166. * @param control defines the control to remove
  2167. * @returns the current container
  2168. */
  2169. removeControl(control: Control3D): Container3D;
  2170. protected _getTypeName(): string;
  2171. /**
  2172. * Releases all associated resources
  2173. */
  2174. dispose(): void;
  2175. }
  2176. }
  2177. declare module BABYLON.GUI {
  2178. /**
  2179. * Class used to create a button in 3D
  2180. */
  2181. class Button3D extends Control3D {
  2182. /** @hidden */
  2183. protected _currentMaterial: Material;
  2184. private _facadeTexture;
  2185. private _content;
  2186. private _contentResolution;
  2187. private _contentScaleRatio;
  2188. /**
  2189. * Gets or sets the texture resolution used to render content (512 by default)
  2190. */
  2191. contentResolution: int;
  2192. /**
  2193. * Gets or sets the texture scale ratio used to render content (2 by default)
  2194. */
  2195. contentScaleRatio: number;
  2196. private _resetContent();
  2197. /**
  2198. * Creates a new button
  2199. * @param name defines the control name
  2200. */
  2201. constructor(name?: string);
  2202. /**
  2203. * Gets or sets the GUI 2D content used to display the button's facade
  2204. */
  2205. content: Control;
  2206. /**
  2207. * Apply the facade texture (created from the content property).
  2208. * This function can be overloaded by child classes
  2209. * @param facadeTexture defines the AdvancedDynamicTexture to use
  2210. */
  2211. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2212. protected _getTypeName(): string;
  2213. protected _createNode(scene: Scene): TransformNode;
  2214. protected _affectMaterial(mesh: AbstractMesh): void;
  2215. /**
  2216. * Releases all associated resources
  2217. */
  2218. dispose(): void;
  2219. }
  2220. }
  2221. declare module BABYLON.GUI {
  2222. /**
  2223. * Class used to create a holographic button in 3D
  2224. */
  2225. class HolographicButton extends Button3D {
  2226. private _backPlate;
  2227. private _textPlate;
  2228. private _frontPlate;
  2229. private _text;
  2230. private _imageUrl;
  2231. private _shareMaterials;
  2232. private _frontMaterial;
  2233. private _backMaterial;
  2234. private _plateMaterial;
  2235. private _pickedPointObserver;
  2236. /**
  2237. * Gets or sets text for the button
  2238. */
  2239. text: string;
  2240. /**
  2241. * Gets or sets the image url for the button
  2242. */
  2243. imageUrl: string;
  2244. /**
  2245. * Gets the back material used by this button
  2246. */
  2247. readonly backMaterial: FluentMaterial;
  2248. /**
  2249. * Gets the front material used by this button
  2250. */
  2251. readonly frontMaterial: FluentMaterial;
  2252. /**
  2253. * Gets the plate material used by this button
  2254. */
  2255. readonly plateMaterial: StandardMaterial;
  2256. /**
  2257. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  2258. */
  2259. readonly shareMaterials: boolean;
  2260. /**
  2261. * Creates a new button
  2262. * @param name defines the control name
  2263. */
  2264. constructor(name?: string, shareMaterials?: boolean);
  2265. protected _getTypeName(): string;
  2266. private _rebuildContent();
  2267. protected _createNode(scene: Scene): TransformNode;
  2268. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2269. private _createBackMaterial(mesh);
  2270. private _createFrontMaterial(mesh);
  2271. private _createPlateMaterial(mesh);
  2272. protected _affectMaterial(mesh: Mesh): void;
  2273. /**
  2274. * Releases all associated resources
  2275. */
  2276. dispose(): void;
  2277. }
  2278. }
  2279. declare module BABYLON.GUI {
  2280. /**
  2281. * Class used to create a stack panel in 3D on XY plane
  2282. */
  2283. class StackPanel3D extends Container3D {
  2284. private _isVertical;
  2285. /**
  2286. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  2287. */
  2288. isVertical: boolean;
  2289. /**
  2290. * Gets or sets the distance between elements
  2291. */
  2292. margin: number;
  2293. /**
  2294. * Creates new StackPanel
  2295. * @param isVertical
  2296. */
  2297. constructor();
  2298. protected _arrangeChildren(): void;
  2299. }
  2300. }