babylon.gui.d.ts 118 KB

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