babylon.gui.d.ts 125 KB

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