babylon.gui.d.ts 124 KB

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