babylon.gui.d.ts 118 KB

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