babylon.gui.d.ts 16 KB

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