babylon.gui.module.d.ts 95 KB

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