three-loader-3dtiles.d.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import { LoadingManager } from 'three';
  2. import { Material } from 'three';
  3. import { Object3D } from 'three';
  4. import { Shader } from 'three';
  5. import { Stats } from '@probe.gl/stats';
  6. import { Tileset3D } from '@loaders.gl/tiles';
  7. import { Vector3 } from 'three';
  8. import { WebGLRenderer } from 'three';
  9. /** Container object for interfacing with lat/long/height coordinates */
  10. export declare interface GeoCoord {
  11. long: number;
  12. lat: number;
  13. height: number;
  14. }
  15. export declare enum GeoTransform {
  16. Reset = 1,
  17. Mercator = 2,
  18. WGS84Cartesian = 3
  19. }
  20. /** 3D Tiles Loader */
  21. export declare class Loader3DTiles {
  22. /**
  23. * Loads a tileset of 3D Tiles according to the given {@link LoaderProps}
  24. * @public
  25. *
  26. * @param props - Properties for this load call {@link LoaderProps}.
  27. * @returns An object containing the 3D Model to be added to the scene
  28. * and a runtime engine to be updated every frame.
  29. */
  30. static load(props: LoaderProps): Promise<{
  31. model: Object3D;
  32. runtime: Runtime;
  33. }>;
  34. }
  35. /** Advanced loader options */
  36. export declare interface LoaderOptions {
  37. /** A Cesium ION access token when loading tilesets from Cesium ION. */
  38. cesiumIONToken?: string;
  39. /** Whether to check if the tileset was transformed, set to `true` if the model is changes position in runtime. Default: `true` */
  40. updateTransforms?: boolean;
  41. /** Interval in seconds for the traverser to check in an update is needed - Default: `0.1`. */
  42. updateInterval?: number;
  43. /** Maximum GPU memory (MB) to use for displaying tiles. May go over the limit if tiles within the camera viewport exceed that ammount - Default: `32`. */
  44. maximumMemoryUsage?: number;
  45. /** determines the distance from tiles in which they are refined, depending on their geometrical size. increase the value to load lower lod tiles from the same view distance (increases performnace) - default: `16`.*/
  46. maximumScreenSpaceError?: number;
  47. /** 0-1 scale for the LOD quality. A lower value loads tiles from lower LODs (increases performance). */
  48. viewDistanceScale?: number;
  49. /** Maximum worker thread concurrency when processing DRACO-compressed tiles - Default: `1` worker. */
  50. maxConcurrency?: number;
  51. /** Whether to use workers when processing DRACO-compressed tiles - Default: `true`. */
  52. worker?: boolean;
  53. /** Whether to throttle network requests so that tiles got out of the frame before the request launched, would not be requested - Default: `true` */
  54. throttleRequests?: boolean;
  55. /** When thorttling requests, how many requests can launch simultaneously - Default: `64` */
  56. maxRequests?: number;
  57. /** _EXPERIMENTAL_: Skip traversal mechanism, not yet supported. Default: `false` */
  58. skipLevelOfDetail?: boolean;
  59. /** When viewing b3dm (mesh) tiles, which type of {@link Shading} is used - Default: `Shading.FlatTexture` */
  60. shading?: Shading;
  61. /** Whether to set the material as transparent - Default: `false` */
  62. transparent?: boolean;
  63. /** Apply a custom material, supports both b3dm (mesh) tiles and Point Cloud tiles - Default: `undefined` **/
  64. material?: Material;
  65. /** When viewing b3dm (mesh) tiles, a callback to update shader uniforms - Default: `undefined` */
  66. shaderCallback?: (shader: Shader, renderer: WebGLRenderer) => void;
  67. /** When viewing b3dm (mesh) tiles, show meshes as wireframe - Default: `false`. */
  68. wireframe?: boolean;
  69. /** When viewing b3dm (mesh) tiles, compute the vertex normals - Default: `false`. */
  70. computeNormals?: boolean;
  71. /** When viewing Point Cloud tiles, how should the points be colored ({@link PointCloudColoring}) - Default: `PointCloudColoring.White` */
  72. pointCloudColoring?: PointCloudColoring;
  73. /** Point size for Point Cloud tiles - Default: `1.0` */
  74. pointSize?: number;
  75. /** Debug mode: Show tile bounding boxes. Make sure to add the boxes to the scene from {@link Runtime.getTileBoxes} - Default: `false` */
  76. debug?: boolean;
  77. /** A path to that contains the basis universal library. e.g: `https://unpkg.com/three@0.129.0/examples/js/libs/basis` - Default: `undefined` */
  78. basisTranscoderPath?: string;
  79. /** A path to that contains the draco library. e.g: `https://unpkg.com/three@0.129.0/examples/js/libs/draco` - Default: `undefined` */
  80. dracoDecoderPath?: string;
  81. /** How to handle geo transformations: Reset any geo location and place the model at (0,0,0), Apply Mercator projection (for use with ccommon 2D mapping applications, or convert WGS84 long/lat to 3D cartesian coordinates)- Default: `Reset` */
  82. geoTransform?: GeoTransform;
  83. /** When using a three.js loading manager, do not call `onLoad` until this number of tiles were loaded - Default: `undefined` */
  84. preloadTilesCount?: number;
  85. }
  86. /** Properties for loading a tileset */
  87. export declare interface LoaderProps {
  88. /** The URL of the tileset. For example if using Cesium ION,
  89. * it would have the form: `https://assets.cesium.com/[ASSET_ID]/tileset.json`.
  90. */
  91. url: string;
  92. /** Required when using compressed textures (basis universal) for GPU feature detection. */
  93. renderer?: WebGLRenderer;
  94. /** Advanced options for loading the tileset ({@link LoaderOptions}) */
  95. options?: LoaderOptions;
  96. /** a loading progress callback function */
  97. onProgress?(progress: number | ProgressEvent<EventTarget>, total?: number): void;
  98. /** Use a Three JS loading manager */
  99. loadingManager?: LoadingManager;
  100. }
  101. /** Types of coloring used when viewing point cloud tiles */
  102. export declare enum PointCloudColoring {
  103. Intensity = 1,
  104. Classification = 2,
  105. Elevation = 3,
  106. RGB = 4,
  107. White = 5
  108. }
  109. /** Runtime methods that can be used once a tileset is loaded */
  110. export declare interface Runtime {
  111. /**
  112. * Get a reference to the loaders.gl {@link https://github.com/visgl/loaders.gl/blob/master/modules/tiles/docs/api-reference/tileset-3d.md | Tileset3D} object.
  113. *
  114. * @returns {@link https://github.com/visgl/loaders.gl/blob/master/modules/tiles/docs/api-reference/tileset-3d.md | Tileset3D}
  115. */
  116. getTileset(): Tileset3D;
  117. /**
  118. * Get a reference to the probe.gl {@link https://github.com/uber-web/probe.gl/blob/master/docs/api-reference/stats/stats.md | Stats} object.
  119. * @returns {@link https://github.com/uber-web/probe.gl/blob/master/docs/api-reference/stats/stats.md | Stats}
  120. */
  121. getStats(): Stats;
  122. /** Get the tile bounding boxes group when `debug: true` is set. */
  123. getTileBoxes(): Object3D;
  124. /** Show or hide the tile bounding boxes. */
  125. showTiles(boolean: any): void;
  126. /** Enable or disable wireframe mode. */
  127. setWireframe(boolean: any): void;
  128. /** Enable or disable deubg mode. */
  129. setDebug(boolean: any): void;
  130. /** Set the current shading mode for b3dm tiles. See {@link Shading}. */
  131. setShading(Shading: any): void;
  132. /** Set the current view distance scale. See {@link LoaderOptions} */
  133. setViewDistanceScale(number: any): void;
  134. /** In point clouds wher the points are classified as `Ground`, hide the ground level points - Default: `false`.*/
  135. setHideGround(boolean: any): void;
  136. /** In point clouds set the type of coloring used. See {@link PointCloudColoring} */
  137. setPointCloudColoring(PointCloudColoring: any): void;
  138. /** In point clouds when coloring by `PointCloudColoring.Elevation`, set the min/max elevation values - Default: `[0, 400]`. */
  139. setElevationRange(range: ReadonlyArray<number>): void;
  140. /** In point clouds when coloring by `PointCloudColoring.Intensity`, set the max intensity value - Default: `1.0` */
  141. setMaxIntensity(number: any): void;
  142. /** In point clouds when coloring by `PointCloudColoring.Intensity`, set the contrast factor. Default: `1.0`. */
  143. setIntensityContrast(number: any): void;
  144. /** In point clouds when, set the alpha value. Default: `1.0`. */
  145. setPointAlpha(number: any): void;
  146. /** When viewing a Geo-located tileset, get the {@link GeoCoord} value from a world-space `Vector3`. */
  147. getLatLongHeightFromPosition(Vector3: any): GeoCoord;
  148. /** When viewing a Geo-located tileset, world-space `Vector3` from a {@link GeoCoord}. */
  149. getPositionFromLatLongHeight(GeoCoord: any): Vector3;
  150. /** Get the current camera frustum as mesh planes (for debugging purposes). */
  151. getCameraFrustum(Camera: any): Object3D;
  152. /** Update the tileset for rendering. */
  153. update(number: any, WebGLRenderer: any, Camera: any): void;
  154. /** Dispose of all of the tileset's assets in memory. */
  155. dispose(): void;
  156. }
  157. /** Types of shading used when viewing b3dm (mesh) tiles */
  158. export declare enum Shading {
  159. FlatTexture = 1,
  160. ShadedTexture = 2,
  161. ShadedNoTexture = 3
  162. }
  163. export { }