babylon.gui.module.d.ts 98 KB

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