babylon.gui.d.ts 122 KB

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