babylon.gui.d.ts 94 KB

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