Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * MARTINS.js
  3. * GPU-accelerated Augmented Reality for the web
  4. * Copyright (C) 2022-2024 Alexandre Martins <alemartf(at)gmail.com>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * main.ts
  20. * Entry point
  21. */
  22. import Speedy from 'speedy-vision';
  23. import { SpeedyPromise } from 'speedy-vision/types/core/speedy-promise';
  24. import { Settings } from './core/settings';
  25. import { Session, SessionOptions } from './core/session';
  26. import { TrackerFactory } from './trackers/tracker-factory';
  27. import { SourceFactory } from './sources/source-factory';
  28. import { Viewport, ViewportSettings, BaseViewport } from './core/viewport';
  29. import { Utils } from './utils/utils';
  30. declare const __MARTINS_VERSION__: string;
  31. declare const __MARTINS_DEVELOPMENT_MODE__: string;
  32. declare const __MARTINS_WEBSITE__: string;
  33. /**
  34. * GPU-accelerated Augmented Reality for the web
  35. */
  36. export default class Martins
  37. {
  38. /**
  39. * Start a new session
  40. * @param options
  41. * @returns a promise that resolves to a new session
  42. */
  43. static startSession(options?: SessionOptions): SpeedyPromise<Session>
  44. {
  45. return Session.instantiate(options);
  46. }
  47. /**
  48. * Trackers
  49. */
  50. static get Tracker(): typeof TrackerFactory
  51. {
  52. return TrackerFactory;
  53. }
  54. /**
  55. * Sources of data
  56. */
  57. static get Source(): typeof SourceFactory
  58. {
  59. return SourceFactory;
  60. }
  61. /**
  62. * Create a viewport
  63. * @param settings
  64. * @returns a new viewport with the specified settings
  65. */
  66. static Viewport(settings: ViewportSettings): Viewport
  67. {
  68. return new BaseViewport(settings);
  69. }
  70. /**
  71. * Global Settings
  72. */
  73. static get Settings(): typeof Settings
  74. {
  75. return Settings;
  76. }
  77. /**
  78. * Engine version
  79. */
  80. static get version(): string
  81. {
  82. if(__MARTINS_DEVELOPMENT_MODE__)
  83. return __MARTINS_VERSION__ + '-dev';
  84. else
  85. return __MARTINS_VERSION__;
  86. }
  87. /**
  88. * Speedy Vision
  89. */
  90. static get Speedy(): typeof Speedy
  91. {
  92. return Speedy;
  93. }
  94. /**
  95. * Checks if the engine can be run in the browser the client is using
  96. * @returns true if the engine is compatible with the browser
  97. */
  98. static isSupported(): boolean
  99. {
  100. return Session.isSupported();
  101. }
  102. }
  103. // Freeze the namespace
  104. Object.freeze(Martins);
  105. // Add Speedy Vision to global scope
  106. ((window: any) => window.Speedy = window.Speedy || Speedy)(window);
  107. // Display a notice
  108. Utils.log(
  109. `MARTINS.js version ${Martins.version}. ` +
  110. `GPU-accelerated Augmented Reality for the web by Alexandre Martins. ` +
  111. __MARTINS_WEBSITE__
  112. );