babylon.gui.d.ts 123 KB

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