textureDome.d.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import type { Scene } from "../scene";
  2. import { TransformNode } from "../Meshes/transformNode";
  3. import { Mesh } from "../Meshes/mesh";
  4. import { Texture } from "../Materials/Textures/texture";
  5. import { BackgroundMaterial } from "../Materials/Background/backgroundMaterial";
  6. import type { Nullable } from "../types";
  7. import { Observable } from "../Misc/observable";
  8. /**
  9. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  10. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  11. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  12. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13. */
  14. export declare abstract class TextureDome<T extends Texture> extends TransformNode {
  15. protected onError: Nullable<(message?: string, exception?: any) => void>;
  16. /**
  17. * Define the source as a Monoscopic panoramic 360/180.
  18. */
  19. static readonly MODE_MONOSCOPIC = 0;
  20. /**
  21. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  22. */
  23. static readonly MODE_TOPBOTTOM = 1;
  24. /**
  25. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  26. */
  27. static readonly MODE_SIDEBYSIDE = 2;
  28. private _halfDome;
  29. private _crossEye;
  30. protected _useDirectMapping: boolean;
  31. /**
  32. * The texture being displayed on the sphere
  33. */
  34. protected _texture: T;
  35. /**
  36. * Gets the texture being displayed on the sphere
  37. */
  38. get texture(): T;
  39. /**
  40. * Sets the texture being displayed on the sphere
  41. */
  42. set texture(newTexture: T);
  43. /**
  44. * The skybox material
  45. */
  46. protected _material: BackgroundMaterial;
  47. /**
  48. * The surface used for the dome
  49. */
  50. protected _mesh: Mesh;
  51. /**
  52. * Gets the mesh used for the dome.
  53. */
  54. get mesh(): Mesh;
  55. /**
  56. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57. */
  58. private _halfDomeMask;
  59. /**
  60. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61. * Also see the options.resolution property.
  62. */
  63. get fovMultiplier(): number;
  64. set fovMultiplier(value: number);
  65. protected _textureMode: number;
  66. /**
  67. * Gets or set the current texture mode for the texture. It can be:
  68. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  69. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  70. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  71. */
  72. get textureMode(): number;
  73. /**
  74. * Sets the current texture mode for the texture. It can be:
  75. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  76. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  77. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  78. */
  79. set textureMode(value: number);
  80. /**
  81. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  82. */
  83. get halfDome(): boolean;
  84. /**
  85. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  86. */
  87. set halfDome(enabled: boolean);
  88. /**
  89. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  90. */
  91. set crossEye(enabled: boolean);
  92. /**
  93. * Is it a cross-eye texture?
  94. */
  95. get crossEye(): boolean;
  96. /**
  97. * The background material of this dome.
  98. */
  99. get material(): BackgroundMaterial;
  100. /**
  101. * Oberserver used in Stereoscopic VR Mode.
  102. */
  103. private _onBeforeCameraRenderObserver;
  104. /**
  105. * Observable raised when an error occurred while loading the texture
  106. */
  107. onLoadErrorObservable: Observable<string>;
  108. /**
  109. * Observable raised when the texture finished loading
  110. */
  111. onLoadObservable: Observable<void>;
  112. /**
  113. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  114. * @param name Element's name, child elements will append suffixes for their own names.
  115. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  116. * @param options An object containing optional or exposed sub element properties
  117. * @param options.resolution
  118. * @param options.clickToPlay
  119. * @param options.autoPlay
  120. * @param options.loop
  121. * @param options.size
  122. * @param options.poster
  123. * @param options.faceForward
  124. * @param options.useDirectMapping
  125. * @param options.halfDomeMode
  126. * @param options.crossEyeMode
  127. * @param options.generateMipMaps
  128. * @param options.mesh
  129. * @param scene
  130. * @param onError
  131. */
  132. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  133. resolution?: number;
  134. clickToPlay?: boolean;
  135. autoPlay?: boolean;
  136. loop?: boolean;
  137. size?: number;
  138. poster?: string;
  139. faceForward?: boolean;
  140. useDirectMapping?: boolean;
  141. halfDomeMode?: boolean;
  142. crossEyeMode?: boolean;
  143. generateMipMaps?: boolean;
  144. mesh?: Mesh;
  145. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  146. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  147. protected _changeTextureMode(value: number): void;
  148. /**
  149. * Releases resources associated with this node.
  150. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  151. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  152. */
  153. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  154. }