babylon.gui.d.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. /// <reference path="../../dist/preview release/babylon.d.ts" />
  2. declare module BABYLON.GUI {
  3. class AdvancedDynamicTexture extends DynamicTexture {
  4. private _isDirty;
  5. private _renderObserver;
  6. private _resizeObserver;
  7. private _pointerMoveObserver;
  8. private _pointerObserver;
  9. private _background;
  10. _rootContainer: Container;
  11. _lastControlOver: Control;
  12. _lastControlDown: Control;
  13. _shouldBlockPointer: boolean;
  14. _layerToDispose: Layer;
  15. _linkedControls: Control[];
  16. private _isFullscreen;
  17. background: string;
  18. constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
  19. markAsDirty(): void;
  20. addControl(control: Control): AdvancedDynamicTexture;
  21. removeControl(control: Control): AdvancedDynamicTexture;
  22. dispose(): void;
  23. private _onResize();
  24. private _checkUpdate(camera);
  25. private _render();
  26. private _doPicking(x, y, type);
  27. attach(): void;
  28. attachToMesh(mesh: AbstractMesh): void;
  29. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number): AdvancedDynamicTexture;
  30. static CreateFullscreenUI(name: string, foreground: boolean, scene: Scene): AdvancedDynamicTexture;
  31. }
  32. }
  33. /// <reference path="../../dist/preview release/babylon.d.ts" />
  34. declare module BABYLON.GUI {
  35. class Measure {
  36. left: number;
  37. top: number;
  38. width: number;
  39. height: number;
  40. constructor(left: number, top: number, width: number, height: number);
  41. copyFrom(other: Measure): void;
  42. isEqualsTo(other: Measure): boolean;
  43. static Empty(): Measure;
  44. }
  45. }
  46. /// <reference path="../../dist/preview release/babylon.d.ts" />
  47. declare module BABYLON.GUI {
  48. class Matrix2D {
  49. m: Float32Array;
  50. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  51. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  52. determinant(): number;
  53. invertToRef(result: Matrix2D): Matrix2D;
  54. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  55. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  56. static Identity(): Matrix2D;
  57. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  58. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59. static RotationToRef(angle: number, result: Matrix2D): void;
  60. private static _TempPreTranslationMatrix;
  61. private static _TempPostTranslationMatrix;
  62. private static _TempRotationMatrix;
  63. private static _TempScalingMatrix;
  64. private static _TempCompose0;
  65. private static _TempCompose1;
  66. private static _TempCompose2;
  67. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Matrix2D, result: Matrix2D): void;
  68. }
  69. }
  70. /// <reference path="../../dist/preview release/babylon.d.ts" />
  71. declare module BABYLON.GUI {
  72. class ValueAndUnit {
  73. value: number;
  74. unit: number;
  75. negativeValueAllowed: boolean;
  76. constructor(value?: number, unit?: number, negativeValueAllowed?: boolean);
  77. readonly isPercentage: boolean;
  78. readonly isPixel: boolean;
  79. toString(): string;
  80. fromString(source: string): boolean;
  81. private static _Regex;
  82. private static _UNITMODE_PERCENTAGE;
  83. private static _UNITMODE_PIXEL;
  84. static readonly UNITMODE_PERCENTAGE: number;
  85. static readonly UNITMODE_PIXEL: number;
  86. }
  87. }
  88. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  89. declare module BABYLON.GUI {
  90. class Control {
  91. name: string;
  92. private _alpha;
  93. private _zIndex;
  94. _root: Container;
  95. _host: AdvancedDynamicTexture;
  96. _currentMeasure: Measure;
  97. private _fontFamily;
  98. private _fontSize;
  99. private _font;
  100. private _width;
  101. private _height;
  102. private _lastMeasuredFont;
  103. protected _fontOffset: {
  104. ascent: number;
  105. height: number;
  106. descent: number;
  107. };
  108. private _color;
  109. protected _horizontalAlignment: number;
  110. protected _verticalAlignment: number;
  111. private _isDirty;
  112. private _cachedParentMeasure;
  113. private _marginLeft;
  114. private _marginRight;
  115. private _marginTop;
  116. private _marginBottom;
  117. private _left;
  118. private _top;
  119. private _scaleX;
  120. private _scaleY;
  121. private _rotation;
  122. private _transformCenterX;
  123. private _transformCenterY;
  124. private _transformMatrix;
  125. private _invertTransformMatrix;
  126. private _transformedPosition;
  127. private _isMatrixDirty;
  128. private _cachedOffsetX;
  129. private _cachedOffsetY;
  130. _linkedMesh: AbstractMesh;
  131. isHitTestVisible: boolean;
  132. isPointerBlocker: boolean;
  133. linkOffsetX: number;
  134. linkOffsetY: number;
  135. /**
  136. * An event triggered when the pointer move over the control.
  137. * @type {BABYLON.Observable}
  138. */
  139. onPointerMoveObservable: Observable<Control>;
  140. /**
  141. * An event triggered when the pointer move out of the control.
  142. * @type {BABYLON.Observable}
  143. */
  144. onPointerOutObservable: Observable<Control>;
  145. /**
  146. * An event triggered when the pointer taps the control
  147. * @type {BABYLON.Observable}
  148. */
  149. onPointerDownObservable: Observable<Control>;
  150. /**
  151. * An event triggered when pointer up
  152. * @type {BABYLON.Observable}
  153. */
  154. onPointerUpObservable: Observable<Control>;
  155. /**
  156. * An event triggered when pointer enters the control
  157. * @type {BABYLON.Observable}
  158. */
  159. onPointerEnterObservable: Observable<Control>;
  160. /**
  161. * An event triggered when the control is marked as dirty
  162. * @type {BABYLON.Observable}
  163. */
  164. onDirtyObservable: Observable<Control>;
  165. alpha: number;
  166. scaleX: number;
  167. scaleY: number;
  168. rotation: number;
  169. transformCenterY: number;
  170. transformCenterX: number;
  171. horizontalAlignment: number;
  172. verticalAlignment: number;
  173. width: string;
  174. height: string;
  175. fontFamily: string;
  176. fontSize: number;
  177. color: string;
  178. zIndex: number;
  179. readonly isDirty: boolean;
  180. marginLeft: string;
  181. marginRight: string;
  182. marginTop: string;
  183. marginBottom: string;
  184. left: string;
  185. top: string;
  186. readonly centerX: number;
  187. readonly centerY: number;
  188. constructor(name: string);
  189. linkWithMesh(mesh: AbstractMesh): void;
  190. _moveToProjectedPosition(projectedPosition: Vector3): void;
  191. _markMatrixAsDirty(): void;
  192. protected _markAsDirty(): void;
  193. _link(root: Container, host: AdvancedDynamicTexture): void;
  194. protected _transform(context: CanvasRenderingContext2D): void;
  195. protected _applyStates(context: CanvasRenderingContext2D): void;
  196. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  197. protected _clip(context: CanvasRenderingContext2D): void;
  198. _measure(): void;
  199. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  200. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  201. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  202. contains(x: number, y: number): boolean;
  203. _processPicking(x: number, y: number, type: number): boolean;
  204. protected _onPointerMove(): void;
  205. protected _onPointerEnter(): void;
  206. protected _onPointerOut(): void;
  207. protected _onPointerDown(): void;
  208. protected _onPointerUp(): void;
  209. protected _processObservables(type: number): boolean;
  210. private _prepareFont();
  211. private static _HORIZONTAL_ALIGNMENT_LEFT;
  212. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  213. private static _HORIZONTAL_ALIGNMENT_CENTER;
  214. private static _VERTICAL_ALIGNMENT_TOP;
  215. private static _VERTICAL_ALIGNMENT_BOTTOM;
  216. private static _VERTICAL_ALIGNMENT_CENTER;
  217. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  218. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  219. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  220. static readonly VERTICAL_ALIGNMENT_TOP: number;
  221. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  222. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  223. private static _FontHeightSizes;
  224. static _GetFontOffset(font: string): {
  225. ascent: number;
  226. height: number;
  227. descent: number;
  228. };
  229. }
  230. }
  231. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  232. declare module BABYLON.GUI {
  233. class Container extends Control {
  234. name: string;
  235. protected _children: Control[];
  236. protected _measureForChildren: Measure;
  237. protected _background: string;
  238. background: string;
  239. constructor(name: string);
  240. containsControl(control: Control): boolean;
  241. addControl(control: Control): Container;
  242. removeControl(control: Control): Container;
  243. _reOrderControl(control: Control): void;
  244. _markMatrixAsDirty(): void;
  245. protected _localDraw(context: CanvasRenderingContext2D): void;
  246. _link(root: Container, host: AdvancedDynamicTexture): void;
  247. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  248. _processPicking(x: number, y: number, type: number): boolean;
  249. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  250. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  251. }
  252. }
  253. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  254. declare module BABYLON.GUI {
  255. class StackPanel extends Container {
  256. name: string;
  257. private _isVertical;
  258. isVertical: boolean;
  259. constructor(name: string);
  260. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  261. }
  262. }
  263. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  264. declare module BABYLON.GUI {
  265. class Rectangle extends Container {
  266. name: string;
  267. private _thickness;
  268. private _cornerRadius;
  269. thickness: number;
  270. cornerRadius: number;
  271. background: string;
  272. constructor(name: string);
  273. protected _localDraw(context: CanvasRenderingContext2D): void;
  274. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  275. private _drawRoundedRect(context, offset?);
  276. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  277. }
  278. }
  279. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  280. declare module BABYLON.GUI {
  281. class Ellipse extends Container {
  282. name: string;
  283. private _thickness;
  284. thickness: number;
  285. constructor(name: string);
  286. protected _localDraw(context: CanvasRenderingContext2D): void;
  287. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  288. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  289. }
  290. }
  291. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  292. declare var DOMImage: new (width?: number, height?: number) => HTMLImageElement;
  293. declare module BABYLON.GUI {
  294. class Line extends Control {
  295. name: string;
  296. private _lineWidth;
  297. private _background;
  298. private _x1;
  299. private _y1;
  300. private _x2;
  301. private _y2;
  302. private _dash;
  303. private _connectedControl;
  304. dash: Array<number>;
  305. connectedControl: Control;
  306. x1: number;
  307. y1: number;
  308. x2: number;
  309. y2: number;
  310. lineWidth: number;
  311. horizontalAlignment: number;
  312. verticalAlignment: number;
  313. constructor(name: string);
  314. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  315. _measure(): void;
  316. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  317. _moveToProjectedPosition(projectedPosition: Vector3): void;
  318. }
  319. }
  320. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  321. declare module BABYLON.GUI {
  322. class TextBlock extends Control {
  323. name: string;
  324. private _text;
  325. private _textY;
  326. private _textWrapping;
  327. private _textHorizontalAlignment;
  328. private _textVerticalAlignment;
  329. private _lines;
  330. private _totalHeight;
  331. textWrapping: boolean;
  332. text: string;
  333. textHorizontalAlignment: number;
  334. textVerticalAlignment: number;
  335. constructor(name: string, text: string);
  336. private _drawText(text, textWidth, y, context);
  337. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  338. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  339. protected _renderLines(context: CanvasRenderingContext2D): void;
  340. }
  341. }
  342. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  343. declare var DOMImage: new (width?: number, height?: number) => HTMLImageElement;
  344. declare module BABYLON.GUI {
  345. class Image extends Control {
  346. name: string;
  347. private _domImage;
  348. private _imageWidth;
  349. private _imageHeight;
  350. private _loaded;
  351. private _stretch;
  352. stretch: number;
  353. constructor(name: string, url: string);
  354. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  355. private static _STRETCH_NONE;
  356. private static _STRETCH_FILL;
  357. private static _STRETCH_UNIFORM;
  358. static readonly STRETCH_NONE: number;
  359. static readonly STRETCH_FILL: number;
  360. static readonly STRETCH_UNIFORM: number;
  361. }
  362. }
  363. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  364. declare module BABYLON.GUI {
  365. class Button extends Rectangle {
  366. name: string;
  367. constructor(name: string);
  368. _processPicking(x: number, y: number, type: number): boolean;
  369. protected _onPointerEnter(): void;
  370. protected _onPointerOut(): void;
  371. protected _onPointerDown(): void;
  372. protected _onPointerUp(): void;
  373. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  374. static CreateSimpleButton(name: string, text: string): Button;
  375. }
  376. }