babylon.gui.d.ts 119 KB

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