babylon.gui.d.ts 86 KB

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