babylon.gui.d.ts 129 KB

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