babylon.gui.d.ts 118 KB

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