itowns 2.45.1 → 2.45.2-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/455.js +1 -1
  2. package/dist/455.js.map +1 -1
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.LICENSE.txt +8 -2
  5. package/dist/debug.js.map +1 -1
  6. package/dist/itowns.js +1 -1
  7. package/dist/itowns.js.LICENSE.txt +1 -1
  8. package/dist/itowns.js.map +1 -1
  9. package/dist/itowns_lasparser.js +1 -1
  10. package/dist/itowns_lasparser.js.map +1 -1
  11. package/dist/itowns_lasworker.js +1 -1
  12. package/dist/itowns_lasworker.js.map +1 -1
  13. package/dist/itowns_potree2worker.js +1 -1
  14. package/dist/itowns_potree2worker.js.map +1 -1
  15. package/dist/itowns_widgets.js +1 -1
  16. package/dist/itowns_widgets.js.map +1 -1
  17. package/examples/copc_simple_loader.html +3 -3
  18. package/examples/entwine_3d_loader.html +2 -2
  19. package/examples/entwine_simple_loader.html +10 -6
  20. package/examples/potree2_25d_map.html +2 -2
  21. package/examples/potree_25d_map.html +2 -2
  22. package/examples/potree_3d_map.html +2 -2
  23. package/examples/view_3d_map_webxr.html +2 -5
  24. package/lib/Controls/FirstPersonControls.d.ts +90 -0
  25. package/lib/Controls/FlyControls.d.ts +36 -0
  26. package/lib/Controls/GlobeControls.d.ts +274 -0
  27. package/lib/Controls/PlanarControls.d.ts +339 -0
  28. package/lib/Controls/StateControl.d.ts +140 -0
  29. package/lib/Controls/StreetControls.d.ts +134 -0
  30. package/lib/Controls/VRControls.d.ts +56 -0
  31. package/lib/Controls/VRControls.js +409 -0
  32. package/lib/Converter/Feature2Mesh.d.ts +42 -0
  33. package/lib/Converter/Feature2Texture.d.ts +5 -0
  34. package/lib/Converter/convertToTile.d.ts +5 -0
  35. package/lib/Converter/convertToTile.js +2 -2
  36. package/lib/Converter/textureConverter.d.ts +4 -0
  37. package/lib/Core/3DTiles/C3DTBatchTable.d.ts +49 -0
  38. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.d.ts +37 -0
  39. package/lib/Core/3DTiles/C3DTBoundingVolume.d.ts +39 -0
  40. package/lib/Core/3DTiles/C3DTExtensions.d.ts +75 -0
  41. package/lib/Core/3DTiles/C3DTFeature.d.ts +47 -0
  42. package/lib/Core/3DTiles/C3DTilesEnums.d.ts +14 -0
  43. package/lib/Core/3DTiles/C3DTileset.d.ts +46 -0
  44. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.d.ts +14 -0
  45. package/lib/Core/AnimationPlayer.d.ts +53 -0
  46. package/lib/Core/CopcNode.d.ts +68 -0
  47. package/lib/Core/CopcNode.js +57 -74
  48. package/lib/Core/Deprecated/Undeprecator.d.ts +6 -0
  49. package/lib/Core/EntwinePointTileNode.d.ts +59 -0
  50. package/lib/Core/EntwinePointTileNode.js +16 -41
  51. package/lib/Core/Feature.d.ts +323 -0
  52. package/lib/Core/Geographic/GeoidGrid.d.ts +86 -0
  53. package/lib/Core/Label.d.ts +86 -0
  54. package/lib/Core/MainLoop.d.ts +23 -0
  55. package/lib/Core/Picking.d.ts +6 -0
  56. package/lib/Core/Picking.js +4 -0
  57. package/lib/Core/PointCloudNode.d.ts +16 -0
  58. package/lib/Core/PointCloudNode.js +34 -4
  59. package/lib/Core/Potree2Node.d.ts +11 -0
  60. package/lib/Core/Potree2Node.js +5 -60
  61. package/lib/Core/Potree2PointAttributes.d.ts +97 -0
  62. package/lib/Core/PotreeNode.d.ts +14 -0
  63. package/lib/Core/PotreeNode.js +28 -18
  64. package/lib/Core/Prefab/Globe/Atmosphere.d.ts +66 -0
  65. package/lib/Core/Prefab/Globe/Atmosphere.js +10 -5
  66. package/lib/Core/Prefab/Globe/GlobeLayer.d.ts +48 -0
  67. package/lib/Core/Prefab/Globe/GlobeTileBuilder.d.ts +38 -0
  68. package/lib/Core/Prefab/Globe/SkyShader.d.ts +5 -0
  69. package/lib/Core/Prefab/Globe/SkyShader.js +3 -3
  70. package/lib/Core/Prefab/GlobeView.d.ts +65 -0
  71. package/lib/Core/Prefab/GlobeView.js +9 -0
  72. package/lib/Core/Prefab/Planar/PlanarLayer.d.ts +38 -0
  73. package/lib/Core/Prefab/Planar/PlanarTileBuilder.d.ts +32 -0
  74. package/lib/Core/Prefab/PlanarView.d.ts +33 -0
  75. package/lib/Core/Prefab/TileBuilder.d.ts +63 -0
  76. package/lib/Core/Prefab/computeBufferTileGeometry.d.ts +17 -0
  77. package/lib/Core/Scheduler/Cache.d.ts +25 -0
  78. package/lib/Core/Scheduler/CancelledCommandException.d.ts +12 -0
  79. package/lib/Core/Scheduler/Scheduler.d.ts +106 -0
  80. package/lib/Core/Style.d.ts +248 -0
  81. package/lib/Core/StyleOptions.d.ts +455 -0
  82. package/lib/Core/System/Capabilities.d.ts +9 -0
  83. package/lib/Core/Tile/Tile.d.ts +70 -0
  84. package/lib/Core/Tile/TileGrid.d.ts +12 -0
  85. package/lib/Core/TileGeometry.d.ts +46 -0
  86. package/lib/Core/TileMesh.d.ts +50 -0
  87. package/lib/Core/TileMesh.js +2 -4
  88. package/lib/Core/View.d.ts +403 -0
  89. package/lib/Core/View.js +1 -7
  90. package/lib/Layer/C3DTilesLayer.d.ts +140 -0
  91. package/lib/Layer/ColorLayer.d.ts +128 -0
  92. package/lib/Layer/ColorLayer.js +4 -4
  93. package/lib/Layer/CopcLayer.d.ts +42 -0
  94. package/lib/Layer/CopcLayer.js +3 -6
  95. package/lib/Layer/ElevationLayer.d.ts +96 -0
  96. package/lib/Layer/ElevationLayer.js +3 -3
  97. package/lib/Layer/EntwinePointTileLayer.d.ts +56 -0
  98. package/lib/Layer/EntwinePointTileLayer.js +4 -3
  99. package/lib/Layer/FeatureGeometryLayer.d.ts +62 -0
  100. package/lib/Layer/GeoidLayer.d.ts +41 -0
  101. package/lib/Layer/GeometryLayer.d.ts +120 -0
  102. package/lib/Layer/InfoLayer.d.ts +24 -0
  103. package/lib/Layer/InfoLayer.js +1 -1
  104. package/lib/Layer/LabelLayer.d.ts +93 -0
  105. package/lib/Layer/LabelLayer.js +2 -2
  106. package/lib/Layer/Layer.d.ts +185 -0
  107. package/lib/Layer/LayerUpdateState.d.ts +24 -0
  108. package/lib/Layer/LayerUpdateStrategy.d.ts +11 -0
  109. package/lib/Layer/LayerUpdateStrategy.js +2 -7
  110. package/lib/Layer/OGC3DTilesLayer.d.ts +277 -0
  111. package/lib/Layer/OGC3DTilesLayer.js +21 -0
  112. package/lib/Layer/OrientedImageLayer.d.ts +53 -0
  113. package/lib/Layer/PointCloudLayer.d.ts +103 -0
  114. package/lib/Layer/PointCloudLayer.js +8 -11
  115. package/lib/Layer/Potree2Layer.d.ts +56 -0
  116. package/lib/Layer/Potree2Layer.js +0 -2
  117. package/lib/Layer/PotreeLayer.d.ts +55 -0
  118. package/lib/Layer/RasterLayer.d.ts +8 -0
  119. package/lib/Layer/RasterLayer.js +2 -2
  120. package/lib/Layer/ReferencingLayerProperties.d.ts +2 -0
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -12
  122. package/lib/Layer/TiledGeometryLayer.d.ts +192 -0
  123. package/lib/Layer/TiledGeometryLayer.js +4 -3
  124. package/lib/Main.d.ts +89 -0
  125. package/lib/Main.js +3 -1
  126. package/lib/Parser/B3dmParser.d.ts +26 -0
  127. package/lib/Parser/CameraCalibrationParser.d.ts +32 -0
  128. package/lib/Parser/GDFParser.d.ts +24 -0
  129. package/lib/Parser/GTXParser.d.ts +28 -0
  130. package/lib/Parser/GeoJsonParser.d.ts +12 -0
  131. package/lib/Parser/GpxParser.d.ts +12 -0
  132. package/lib/Parser/ISGParser.d.ts +23 -0
  133. package/lib/Parser/KMLParser.d.ts +12 -0
  134. package/lib/Parser/LASParser.d.ts +61 -0
  135. package/lib/Parser/MapBoxUrlParser.d.ts +9 -0
  136. package/lib/Parser/PntsParser.d.ts +4 -0
  137. package/lib/Parser/Potree2BinParser.d.ts +8 -0
  138. package/lib/Parser/PotreeBinParser.d.ts +4 -0
  139. package/lib/Parser/PotreeCinParser.d.ts +4 -0
  140. package/lib/Parser/ShapefileParser.d.ts +25 -0
  141. package/lib/Parser/VectorTileParser.d.ts +34 -0
  142. package/lib/Parser/XbilParser.d.ts +18 -0
  143. package/lib/Parser/deprecated/LegacyGLTFLoader.d.ts +32 -0
  144. package/lib/Parser/iGLTFLoader.d.ts +104 -0
  145. package/lib/Process/3dTilesProcessing.d.ts +43 -0
  146. package/lib/Process/FeatureProcessing.d.ts +4 -0
  147. package/lib/Process/LayeredMaterialNodeProcessing.d.ts +3 -0
  148. package/lib/Process/LayeredMaterialNodeProcessing.js +12 -12
  149. package/lib/Process/ObjectRemovalHelper.d.ts +32 -0
  150. package/lib/Process/handlerNodeError.d.ts +1 -0
  151. package/lib/Provider/3dTilesProvider.d.ts +7 -0
  152. package/lib/Provider/DataSourceProvider.d.ts +4 -0
  153. package/lib/Provider/Fetcher.d.ts +101 -0
  154. package/lib/Provider/PointCloudProvider.d.ts +4 -0
  155. package/lib/Provider/TileProvider.d.ts +4 -0
  156. package/lib/Provider/URLBuilder.d.ts +28 -0
  157. package/lib/Renderer/Camera.d.ts +95 -0
  158. package/lib/Renderer/Color.d.ts +3 -0
  159. package/lib/Renderer/ColorLayersOrdering.d.ts +38 -0
  160. package/lib/Renderer/ColorLayersOrdering.js +2 -2
  161. package/lib/Renderer/CommonMaterial.d.ts +6 -0
  162. package/lib/Renderer/Label2DRenderer.d.ts +31 -0
  163. package/lib/Renderer/LayeredMaterial.d.ts +121 -0
  164. package/lib/Renderer/LayeredMaterial.js +221 -141
  165. package/lib/Renderer/OBB.d.ts +65 -0
  166. package/lib/Renderer/OrientedImageCamera.d.ts +36 -0
  167. package/lib/Renderer/OrientedImageMaterial.d.ts +68 -0
  168. package/lib/Renderer/PointsMaterial.d.ts +226 -0
  169. package/lib/Renderer/PointsMaterial.js +60 -22
  170. package/lib/Renderer/RasterTile.d.ts +53 -0
  171. package/lib/Renderer/RasterTile.js +8 -9
  172. package/lib/Renderer/RenderMode.d.ts +11 -0
  173. package/lib/Renderer/RenderMode.js +1 -0
  174. package/lib/Renderer/Shader/ShaderChunk.d.ts +78 -0
  175. package/lib/Renderer/Shader/ShaderUtils.d.ts +5 -0
  176. package/lib/Renderer/WebXR.d.ts +33 -0
  177. package/lib/Renderer/WebXR.js +128 -47
  178. package/lib/Renderer/c3DEngine.d.ts +55 -0
  179. package/lib/Renderer/c3DEngine.js +5 -1
  180. package/lib/Source/C3DTilesGoogleSource.d.ts +38 -0
  181. package/lib/Source/C3DTilesIonSource.d.ts +31 -0
  182. package/lib/Source/C3DTilesSource.d.ts +17 -0
  183. package/lib/Source/CopcSource.d.ts +79 -0
  184. package/lib/Source/EntwinePointTileSource.d.ts +40 -0
  185. package/lib/Source/EntwinePointTileSource.js +0 -5
  186. package/lib/Source/FileSource.d.ts +118 -0
  187. package/lib/Source/OGC3DTilesGoogleSource.d.ts +24 -0
  188. package/lib/Source/OGC3DTilesIonSource.d.ts +26 -0
  189. package/lib/Source/OGC3DTilesSource.d.ts +21 -0
  190. package/lib/Source/OrientedImageSource.d.ts +48 -0
  191. package/lib/Source/Potree2Source.d.ts +157 -0
  192. package/lib/Source/PotreeSource.d.ts +69 -0
  193. package/lib/Source/Source.d.ts +122 -0
  194. package/lib/Source/TMSSource.d.ts +77 -0
  195. package/lib/Source/VectorTilesSource.d.ts +56 -0
  196. package/lib/Source/WFSSource.d.ts +110 -0
  197. package/lib/Source/WMSSource.d.ts +85 -0
  198. package/lib/Source/WMTSSource.d.ts +65 -0
  199. package/lib/ThreeExtended/capabilities/WebGL.d.ts +9 -0
  200. package/lib/ThreeExtended/libs/ktx-parse.module.d.ts +274 -0
  201. package/lib/ThreeExtended/libs/motion-controllers.module.d.ts +64 -0
  202. package/lib/ThreeExtended/libs/motion-controllers.module.js +375 -0
  203. package/lib/ThreeExtended/libs/zstddec.module.d.ts +6 -0
  204. package/lib/ThreeExtended/loaders/DDSLoader.js +40 -1
  205. package/lib/ThreeExtended/loaders/DRACOLoader.d.ts +41 -0
  206. package/lib/ThreeExtended/loaders/GLTFLoader.d.ts +16 -0
  207. package/lib/ThreeExtended/loaders/GLTFLoader.js +22 -3
  208. package/lib/ThreeExtended/loaders/KTX2Loader.d.ts +116 -0
  209. package/lib/ThreeExtended/loaders/KTX2Loader.js +9 -2
  210. package/lib/ThreeExtended/math/ColorSpaces.d.ts +56 -0
  211. package/lib/ThreeExtended/utils/BufferGeometryUtils.d.ts +62 -0
  212. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +2 -2
  213. package/lib/ThreeExtended/utils/WorkerPool.d.ts +19 -0
  214. package/lib/ThreeExtended/webxr/XRControllerModelFactory.d.ts +25 -0
  215. package/lib/ThreeExtended/webxr/XRControllerModelFactory.js +209 -0
  216. package/lib/Utils/CameraUtils.d.ts +132 -0
  217. package/lib/Utils/DEMUtils.d.ts +84 -0
  218. package/lib/Utils/DEMUtils.js +2 -2
  219. package/lib/Utils/FeaturesUtils.d.ts +17 -0
  220. package/lib/Utils/Gradients.d.ts +13 -0
  221. package/lib/Utils/ThreeUtils.d.ts +14 -0
  222. package/lib/Utils/placeObjectOnGround.d.ts +28 -0
  223. package/lib/global.d.js +0 -0
  224. package/package.json +18 -15
@@ -0,0 +1,403 @@
1
+ export namespace VIEW_EVENTS {
2
+ export let LAYERS_INITIALIZED: string;
3
+ export let LAYER_REMOVED: string;
4
+ export let LAYER_ADDED: string;
5
+ export let INITIALIZED: string;
6
+ export { COLOR_LAYERS_ORDER_CHANGED };
7
+ export let CAMERA_MOVED: string;
8
+ export let DISPOSED: string;
9
+ }
10
+ export default View;
11
+ import { COLOR_LAYERS_ORDER_CHANGED } from '../Renderer/ColorLayersOrdering';
12
+ /**
13
+ * @property {number} id - The id of the view. It's incremented at each new view instance, starting at 0.
14
+ * @property {HTMLElement} domElement - The domElement holding the canvas where the view is displayed
15
+ * @property {String} referenceCrs - The coordinate reference system of the view
16
+ * @property {MainLoop} mainLoop - itowns mainloop scheduling the operations
17
+ * @property {THREE.Scene} scene - threejs scene of the view
18
+ * @property {Camera} camera - itowns camera (that holds a threejs camera that is directly accessible with View.camera3D)
19
+ * @property {THREE.Camera} camera3D - threejs camera that is stored in itowns camera
20
+ * @property {THREE.WebGLRenderer} renderer - threejs webglrenderer rendering this view
21
+ */
22
+ declare class View extends THREE.EventDispatcher<any> {
23
+ /**
24
+ * Constructs an Itowns View instance
25
+ *
26
+ * @example <caption><b>Create a view with a custom Three.js camera.</b></caption>
27
+ * var viewerDiv = document.getElementById('viewerDiv');
28
+ * var customCamera = itowns.THREE.PerspectiveCamera();
29
+ * var view = itowns.View('EPSG:4326', viewerDiv, { camera: { cameraThree: customCamera } });
30
+ *
31
+ * @example <caption><b>Create a view with an orthographic camera, and grant it with Three.js custom controls.</b></caption>
32
+ * var viewerDiv = document.getElementById('viewerDiv');
33
+ * var view = itowns.View('EPSG:4326', viewerDiv, { camera: { type: itowns.CAMERA_TYPE.ORTHOGRAPHIC } });
34
+ * var customControls = itowns.THREE.OrbitControls(view.camera3D, viewerDiv);
35
+ *
36
+ * @param {String} crs - The default CRS of Three.js coordinates. Should be a cartesian CRS.
37
+ * @param {HTMLElement} viewerDiv - Where to instanciate the Three.js scene in the DOM
38
+ * @param {Object} [options] - Optional properties.
39
+ * @param {Object} [options.camera] - Options for the camera associated to the view. See {@link Camera} options.
40
+ * @param {MainLoop} [options.mainLoop] - {@link MainLoop} instance to use, otherwise a default one will be constructed
41
+ * @param {WebGLRenderer|Object} [options.renderer] - {@link WebGLRenderer} instance to use, otherwise
42
+ * a default one will be constructed. In this case, if options.renderer is an object, it will be used to
43
+ * configure the renderer (see {@link c3DEngine}. If not present, a new &lt;canvas> will be created and
44
+ * added to viewerDiv (mutually exclusive with mainLoop)
45
+ * @param {Scene} [options.scene3D] - [THREE.Scene](https://threejs.org/docs/#api/en/scenes/Scene) instance to use, otherwise a default one will be constructed
46
+ * @param {Color} [options.diffuse] - [THREE.Color](https://threejs.org/docs/?q=color#api/en/math/Color) Diffuse color terrain material.
47
+ * This color is applied to terrain if there isn't color layer on terrain extent (by example on pole).
48
+ * @param {boolean} [options.enableFocusOnStart=true] - enable focus on dom element on start.
49
+ */
50
+ constructor(crs: string, viewerDiv: HTMLElement, options?: {
51
+ camera?: Object | undefined;
52
+ mainLoop?: MainLoop | undefined;
53
+ renderer?: WebGLRenderer | Object;
54
+ scene3D?: any;
55
+ diffuse?: any;
56
+ enableFocusOnStart?: boolean | undefined;
57
+ });
58
+ domElement: HTMLElement;
59
+ id: number;
60
+ referenceCrs: string;
61
+ mainLoop: MainLoop;
62
+ scene: any;
63
+ camera: Camera;
64
+ _frameRequesters: {};
65
+ _resizeListener: () => void;
66
+ _changeSources: Set<any>;
67
+ isDebugMode: boolean | undefined;
68
+ _delayedFrameRequesterRemoval: any[];
69
+ _allLayersAreReadyCallback: () => void;
70
+ /**
71
+ * Get the Threejs renderer used to render this view.
72
+ * @returns {THREE.WebGLRenderer} the WebGLRenderer used to render this view.
73
+ */
74
+ get renderer(): THREE.WebGLRenderer;
75
+ /**
76
+ * Get the threejs Camera of this view
77
+ * @returns {THREE.Camera} the threejs camera of this view
78
+ */
79
+ get camera3D(): THREE.Camera;
80
+ /**
81
+ * Dispose viewer before delete it.
82
+ *
83
+ * Method dispose all viewer objects
84
+ * - remove control
85
+ * - remove all layers
86
+ * - remove all frame requester
87
+ * - remove all events
88
+ * @param {boolean} [clearCache=false] Whether to clear all the caches or not (layers cache, style cache, tilesCache)
89
+ */
90
+ dispose(clearCache?: boolean): void;
91
+ /**
92
+ * Add layer in viewer.
93
+ * The layer id must be unique.
94
+ *
95
+ * The `layer.whenReady` is a promise that resolves when
96
+ * the layer is done. This promise is also returned by
97
+ * `addLayer` allowing to chain call.
98
+ *
99
+ * @param {LayerOptions|Layer|GeometryLayer} layer The layer to add in view.
100
+ * @param {Layer=} parentLayer it's the layer to which the layer will be attached.
101
+ * @return {Promise} a promise resolved with the new layer object when it is fully initialized or rejected if any error occurred.
102
+ */
103
+ addLayer(layer: LayerOptions | Layer | GeometryLayer, parentLayer?: Layer | undefined): Promise<any>;
104
+ /**
105
+ * Removes a specific imagery layer from the current layer list. This removes layers inserted with attach().
106
+ * @example
107
+ * view.removeLayer('layerId');
108
+ * @param {string} layerId The identifier
109
+ * @param {boolean} [clearCache=false] Whether to clear all the layer cache or not
110
+ * @return {boolean}
111
+ */
112
+ removeLayer(layerId: string, clearCache?: boolean): boolean;
113
+ /**
114
+ * Notifies the scene it needs to be updated due to changes exterior to the
115
+ * scene itself (e.g. camera movement).
116
+ * non-interactive events (e.g: texture loaded)
117
+ * @param {*} changeSource
118
+ * @param {boolean} needsRedraw - indicates if notified change requires a full scene redraw.
119
+ */
120
+ notifyChange(changeSource?: any, needsRedraw?: boolean): void;
121
+ /**
122
+ * Get all layers, with an optionnal filter applied.
123
+ * The filter method will be called with 2 args:
124
+ * - 1st: current layer
125
+ * - 2nd: (optional) the geometry layer to which the current layer is attached
126
+ * @example
127
+ * // get all layers
128
+ * view.getLayers();
129
+ * // get all color layers
130
+ * view.getLayers(layer => layer.isColorLayer);
131
+ * // get all elevation layers
132
+ * view.getLayers(layer => layer.isElevationLayer);
133
+ * // get all geometry layers
134
+ * view.getLayers(layer => layer.isGeometryLayer);
135
+ * // get one layer with id
136
+ * view.getLayers(layer => layer.id === 'itt');
137
+ * @param {function(Layer):boolean} filter
138
+ * @returns {Array<Layer>}
139
+ */
140
+ getLayers(filter: (arg0: Layer) => boolean): Array<Layer>;
141
+ /**
142
+ * Gets the layer by identifier.
143
+ *
144
+ * @param {String} layerId The layer identifier
145
+ * @return {Layer} The layer by identifier.
146
+ */
147
+ getLayerById(layerId: string): Layer;
148
+ /**
149
+ * @name FrameRequester
150
+ * @function
151
+ *
152
+ * @description
153
+ * Method that will be called each time the `MainLoop` updates. This function
154
+ * will be given as parameter the delta (in ms) between this update and the
155
+ * previous one, and whether or not we just started to render again. This update
156
+ * is considered as the "next" update if `view.notifyChange` was called during a
157
+ * precedent update. If `view.notifyChange` has been called by something else
158
+ * (other micro/macrotask, UI events etc...), then this update is considered as
159
+ * being the "first". It can also receive optional arguments, depending on the
160
+ * attach point of this function. Currently only `BEFORE_LAYER_UPDATE /
161
+ * AFTER_LAYER_UPDATE` attach points provide an additional argument: the layer
162
+ * being updated.
163
+ * <br><br>
164
+ *
165
+ * This means that if a `frameRequester` function wants to animate something, it
166
+ * should keep on calling `view.notifyChange` until its task is done.
167
+ * <br><br>
168
+ *
169
+ * Implementors of `frameRequester` should keep in mind that this function will
170
+ * be potentially called at each frame, thus care should be given about
171
+ * performance.
172
+ * <br><br>
173
+ *
174
+ * Typical frameRequesters are controls, module wanting to animate moves or UI
175
+ * elements etc... Basically anything that would want to call
176
+ * requestAnimationFrame.
177
+ *
178
+ * @param {number} dt
179
+ * @param {boolean} updateLoopRestarted
180
+ * @param {...*} args
181
+ */
182
+ /**
183
+ * Add a frame requester to this view.
184
+ *
185
+ * FrameRequesters can activate the MainLoop update by calling view.notifyChange.
186
+ *
187
+ * @param {String} when - decide when the frameRequester should be called during
188
+ * the update cycle. Can be any of {@link MAIN_LOOP_EVENTS}.
189
+ * @param {FrameRequester} frameRequester - this function will be called at each
190
+ * MainLoop update with the time delta between last update, or 0 if the MainLoop
191
+ * has just been relaunched.
192
+ */
193
+ addFrameRequester(when: string, frameRequester: FrameRequester): void;
194
+ /**
195
+ * Remove a frameRequester.
196
+ * The effective removal will happen either later; at worst it'll be at
197
+ * the beginning of the next frame.
198
+ *
199
+ * @param {String} when - attach point of this requester. Can be any of
200
+ * {@link MAIN_LOOP_EVENTS}.
201
+ * @param {FrameRequester} frameRequester
202
+ */
203
+ removeFrameRequester(when: string, frameRequester: FrameRequester): void;
204
+ /**
205
+ * Removes all frame requesters.
206
+ */
207
+ removeAllFrameRequesters(): void;
208
+ /**
209
+ * Removes all viewer events.
210
+ */
211
+ removeAllEvents(): void;
212
+ _listeners: any;
213
+ _executeFrameRequestersRemovals(): void;
214
+ /**
215
+ * Execute a frameRequester.
216
+ *
217
+ * @param {String} when - attach point of this (these) requester(s). Can be any
218
+ * of {@link MAIN_LOOP_EVENTS}.
219
+ * @param {Number} dt - delta between this update and the previous one
220
+ * @param {boolean} updateLoopRestarted
221
+ * @param {...*} args - optional arguments
222
+ */
223
+ execFrameRequesters(when: string, dt: number, updateLoopRestarted: boolean, ...args: any[]): void;
224
+ /**
225
+ * Extract view coordinates from a mouse-event / touch-event
226
+ * @param {event} event - event can be a MouseEvent or a TouchEvent
227
+ * @param {THREE.Vector2} target - the target to set the view coords in
228
+ * @param {number} [touchIdx=0] - finger index when using a TouchEvent
229
+ * @return {THREE.Vector2|undefined} - view coordinates (in pixels, 0-0 = top-left of the View).
230
+ * If the event is neither a `MouseEvent` nor a `TouchEvent`, the return is `undefined`.
231
+ */
232
+ eventToViewCoords(event: Event | undefined, target?: THREE.Vector2, touchIdx?: number): THREE.Vector2 | undefined;
233
+ /**
234
+ * Extract normalized coordinates (NDC) from a mouse-event / touch-event
235
+ * @param {event} event - event can be a MouseEvent or a TouchEvent
236
+ * @param {number} touchIdx - finger index when using a TouchEvent (default: 0)
237
+ * @return {THREE.Vector2} - NDC coordinates (x and y are [-1, 1])
238
+ */
239
+ eventToNormalizedCoords(event: Event | undefined, touchIdx?: number): THREE.Vector2;
240
+ /**
241
+ * Convert view coordinates to normalized coordinates (NDC)
242
+ * @param {THREE.Vector2} viewCoords (in pixels, 0-0 = top-left of the View)
243
+ * @param {THREE.Vector2} target
244
+ * @return {THREE.Vector2} - NDC coordinates (x and y are [-1, 1])
245
+ */
246
+ viewToNormalizedCoords(viewCoords: THREE.Vector2, target?: THREE.Vector2): THREE.Vector2;
247
+ /**
248
+ * Convert NDC coordinates to view coordinates
249
+ * @param {THREE.Vector2} ndcCoords
250
+ * @return {THREE.Vector2} - view coordinates (in pixels, 0-0 = top-left of the View)
251
+ */
252
+ normalizedToViewCoords(ndcCoords: THREE.Vector2): THREE.Vector2;
253
+ /**
254
+ * Searches for objects in {@link GeometryLayer} and specified
255
+ * `THREE.Object3D`, under the mouse or at a specified coordinates, in this
256
+ * view.
257
+ *
258
+ * @param {Object} mouseOrEvt - Mouse position in window coordinates (from
259
+ * the top left corner of the window) or `MouseEvent` or `TouchEvent`.
260
+ * @param {number} [radius=0] - The picking will happen in a circle centered
261
+ * on mouseOrEvt. This is the radius of this circle, in pixels.
262
+ * @param {GeometryLayer|string|Object3D|Array<GeometryLayer|string|Object3D>} [where] - Where to look for
263
+ * objects. It can be a single {@link GeometryLayer}, `THREE.Object3D`, ID of a layer or an array of one of these or
264
+ * of a mix of these. If no location is specified, it will query on all {@link GeometryLayer} present in this `View`.
265
+ *
266
+ * @return {Object[]} - An array of objects. Each element contains at least
267
+ * an object property which is the `THREE.Object3D` under the cursor. Then
268
+ * depending on the queried layer/source, there may be additionnal
269
+ * properties (coming from `THREE.Raycaster` for instance).
270
+ *
271
+ * @example
272
+ * view.pickObjectsAt({ x, y })
273
+ * view.pickObjectsAt({ x, y }, 1, 'wfsBuilding')
274
+ * view.pickObjectsAt({ x, y }, 3, 'wfsBuilding', myLayer)
275
+ */
276
+ pickObjectsAt(mouseOrEvt: Object, radius?: number, where?: GeometryLayer | string | Object3D | Array<GeometryLayer | string | Object3D>): Object[];
277
+ /**
278
+ * Return the current zoom scale at the central point of the view. This
279
+ * function compute the scale of a map.
280
+ *
281
+ * @param {number} pitch - Screen pitch, in millimeters ; 0.28 by default
282
+ *
283
+ * @return {number} The zoom scale.
284
+ */
285
+ getScale(pitch?: number): number;
286
+ getScaleFromDistance(pitch?: number, distance?: number): number;
287
+ /**
288
+ * Given a screen coordinates, get the distance between the projected
289
+ * coordinates and the camera associated to this view.
290
+ *
291
+ * @param {THREE.Vector2} [screenCoord] - The screen coordinate to get the
292
+ * distance at. By default this is the middle of the screen.
293
+ *
294
+ * @return {number} The distance in meters.
295
+ */
296
+ getDistanceFromCamera(screenCoord?: THREE.Vector2): number;
297
+ /**
298
+ * Get, for a specific screen coordinate, the projected distance on the
299
+ * surface of the main layer of the view.
300
+ *
301
+ * @param {number} [pixels=1] - The size, in pixels, to get in meters.
302
+ * @param {THREE.Vector2} [screenCoord] - The screen coordinate to get the
303
+ * projected distance at. By default, this is the middle of the screen.
304
+ *
305
+ * @return {number} The projected distance in meters.
306
+ */
307
+ getPixelsToMeters(pixels?: number, screenCoord?: THREE.Vector2): number;
308
+ getPixelsToMetersFromDistance(pixels?: number, distance?: number): number;
309
+ /**
310
+ * Get, for a specific screen coordinate, the size in pixels of a projected
311
+ * distance on the surface of the main layer of the view.
312
+ *
313
+ * @param {number} [meters=1] - The size, in meters, to get in pixels.
314
+ * @param {THREE.Vector2} [screenCoord] - The screen coordinate to get the
315
+ * projected distance at. By default, this is the middle of the screen.
316
+ *
317
+ * @return {number} The projected distance in pixels.
318
+ */
319
+ getMetersToPixels(meters?: number, screenCoord?: THREE.Vector2): number;
320
+ getMetersToPixelsFromDistance(meters?: number, distance?: number): number;
321
+ /**
322
+ * Searches for {@link FeatureGeometry} in {@link ColorLayer}, under the mouse or at
323
+ * the specified coordinates, in this view. Combining them per layer and in a Feature
324
+ * like format.
325
+ *
326
+ * @param {Object} mouseOrEvt - Mouse position in window coordinates (from
327
+ * the top left corner of the window) or `MouseEvent` or `TouchEvent`.
328
+ * @param {number} [radius=3] - The picking will happen in a circle centered
329
+ * on mouseOrEvt. This is the radius of this circle, in pixels.
330
+ * @param {...ColorLayer|GeometryLayer|string} [where] - The layers to look
331
+ * into. If not specified, all {@link ColorLayer} and {@link GeometryLayer}
332
+ * layers of this view will be looked in.
333
+ *
334
+ * @return {Object} - An object, having one property per layer.
335
+ * For example, looking for features on layers `wfsBuilding` and `wfsRoads`
336
+ * will give an object like `{ wfsBuilding: [...], wfsRoads: [] }`.
337
+ * Each property is made of an array, that can be empty or filled with
338
+ * Feature like objects composed of:
339
+ * - the FeatureGeometry
340
+ * - the feature type
341
+ * - the style
342
+ * - the coordinate if the FeatureGeometry is a point
343
+ *
344
+ * @example
345
+ * view.pickFeaturesAt({ x, y });
346
+ * view.pickFeaturesAt({ x, y }, 1, 'wfsBuilding');
347
+ * view.pickFeaturesAt({ x, y }, 3, 'wfsBuilding', myLayer);
348
+ */
349
+ pickFeaturesAt(mouseOrEvt: Object, radius?: number, ...where?: (ColorLayer | GeometryLayer | string)[]): Object;
350
+ readDepthBuffer(x: any, y: any, width: any, height: any, buffer: any): any;
351
+ /**
352
+ * Returns the world position on the terrain (view's crs: referenceCrs) under view coordinates.
353
+ * This position is computed with depth buffer.
354
+ *
355
+ * @param {THREE.Vector2} mouse position in view coordinates (in pixel), if it's null so it's view's center.
356
+ * @param {THREE.Vector3} [target=THREE.Vector3()] target. the result will be copied into this Vector3. If not present a new one will be created.
357
+ * @return {THREE.Vector3} the world position on the terrain in view's crs: referenceCrs.
358
+ */
359
+ getPickingPositionFromDepth(mouse: THREE.Vector2, target?: THREE.Vector3): THREE.Vector3;
360
+ /**
361
+ * Returns the world {@link Coordinates} of the terrain at given view coordinates.
362
+ *
363
+ * @param {THREE.Vector2|event} [mouse] The view coordinates at which the world coordinates must be returned. This
364
+ * parameter can also be set to a mouse event from which the view coordinates will be deducted. If not specified,
365
+ * it will be defaulted to the view's center coordinates.
366
+ * @param {Coordinates} [target] The result will be copied into this {@link Coordinates} in the coordinate reference
367
+ * system of the given coordinate. If not specified, a new {@link Coordinates} instance will be created (in the
368
+ * view referenceCrs).
369
+ *
370
+ * @returns {Coordinates} The world {@link Coordinates} of the terrain at the given view coordinates in the
371
+ * coordinate reference system of the target or in the view referenceCrs if no target is specified.
372
+ */
373
+ pickTerrainCoordinates(mouse?: THREE.Vector2 | (Event | undefined), target?: Coordinates): Coordinates;
374
+ /**
375
+ * Returns the world {@link Coordinates} of the terrain at given view coordinates.
376
+ *
377
+ * @param {THREE.Vector2|event} [mouse] The view coordinates at which the world coordinates must be
378
+ * returned. This parameter can also be set to a mouse event from
379
+ * which the view coordinates will be deducted. If not specified, it
380
+ * will be defaulted to the view's center coordinates.
381
+ * @param {Coordinates} [target] The result will be copied into this {@link Coordinates}. If not
382
+ * specified, a new {@link Coordinates} instance will be created.
383
+ *
384
+ * @returns {Coordinates} The world {@link Coordinates} of the terrain at the given view coordinates.
385
+ *
386
+ * @deprecated Use View#pickTerrainCoordinates instead.
387
+ */
388
+ pickCoordinates(mouse?: THREE.Vector2 | (Event | undefined), target?: Coordinates): Coordinates;
389
+ /**
390
+ * Resize the viewer.
391
+ *
392
+ * @param {number} [width=viewerDiv.clientWidth] - The width to resize the
393
+ * viewer with. By default it is the `clientWidth` of the `viewerDiv`.
394
+ * @param {number} [height=viewerDiv.clientHeight] - The height to resize
395
+ * the viewer with. By default it is the `clientHeight` of the `viewerDiv`.
396
+ */
397
+ resize(width?: number, height?: number): void;
398
+ #private;
399
+ }
400
+ import * as THREE from 'three';
401
+ import MainLoop from '../Core/MainLoop';
402
+ import Camera from '../Renderer/Camera';
403
+ import { Coordinates } from '@itowns/geographic';
package/lib/Core/View.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { CRS, Coordinates } from '@itowns/geographic';
3
3
  import Camera from "../Renderer/Camera.js";
4
- import initializeWebXR from "../Renderer/WebXR.js";
5
4
  import MainLoop, { MAIN_LOOP_EVENTS, RENDERING_PAUSED } from "./MainLoop.js";
6
5
  import Capabilities from "./System/Capabilities.js";
7
6
  import { COLOR_LAYERS_ORDER_CHANGED } from "../Renderer/ColorLayersOrdering.js";
@@ -147,8 +146,6 @@ class View extends THREE.EventDispatcher {
147
146
  * a default one will be constructed. In this case, if options.renderer is an object, it will be used to
148
147
  * configure the renderer (see {@link c3DEngine}. If not present, a new &lt;canvas> will be created and
149
148
  * added to viewerDiv (mutually exclusive with mainLoop)
150
- * @param {Object} [options.webXR] - enable webxr button to switch on VR visualization.
151
- * @param {number} [options.webXR.scale=1.0] - apply webxr scale tranformation.
152
149
  * @param {Scene} [options.scene3D] - [THREE.Scene](https://threejs.org/docs/#api/en/scenes/Scene) instance to use, otherwise a default one will be constructed
153
150
  * @param {Color} [options.diffuse] - [THREE.Color](https://threejs.org/docs/?q=color#api/en/math/Color) Diffuse color terrain material.
154
151
  * This color is applied to terrain if there isn't color layer on terrain extent (by example on pole).
@@ -226,9 +223,6 @@ class View extends THREE.EventDispatcher {
226
223
 
227
224
  // push all viewer to keep source.cache
228
225
  viewers.push(this);
229
- if (options.webXR) {
230
- initializeWebXR(this, options.webXR);
231
- }
232
226
  }
233
227
 
234
228
  /**
@@ -915,7 +909,7 @@ class View extends THREE.EventDispatcher {
915
909
  if (!tile.object.material) {
916
910
  continue;
917
911
  }
918
- for (const materialLayer of tile.object.material.getLayers(layers)) {
912
+ for (const materialLayer of tile.object.material.getTiles(layers)) {
919
913
  for (const texture of materialLayer.textures) {
920
914
  if (!texture.features) {
921
915
  continue;
@@ -0,0 +1,140 @@
1
+ export namespace C3DTILES_LAYER_EVENTS {
2
+ let ON_TILE_CONTENT_LOADED: object;
3
+ let ON_TILE_REQUESTED: object;
4
+ }
5
+ export default C3DTilesLayer;
6
+ /**
7
+ * @extends GeometryLayer
8
+ */
9
+ declare class C3DTilesLayer extends GeometryLayer {
10
+ /**
11
+ * @deprecated Deprecated 3D Tiles layer. Use {@link OGC3DTilesLayer} instead.
12
+ *
13
+ * @example
14
+ * // Create a new 3d-tiles layer from a web server
15
+ * const l3dt = new C3DTilesLayer('3dtiles', {
16
+ * name: '3dtl',
17
+ * source: new C3DTilesSource({
18
+ * url: 'https://tileset.json'
19
+ * })
20
+ * }, view);
21
+ * View.prototype.addLayer.call(view, l3dt);
22
+ *
23
+ * // Create a new 3d-tiles layer from a Cesium ion server
24
+ * const l3dt = new C3DTilesLayer('3dtiles', {
25
+ * name: '3dtl',
26
+ * source: new C3DTilesIonSource({
27
+ * accessToken: 'myAccessToken',
28
+ assetId: 12
29
+ * })
30
+ * }, view);
31
+ * View.prototype.addLayer.call(view, l3dt);
32
+ *
33
+ * @param {string} id - The id of the layer, that should be unique.
34
+ * It is not mandatory, but an error will be emitted if this layer is
35
+ * added a
36
+ * {@link View} that already has a layer going by that id.
37
+ * @param {object} config configuration, all elements in it
38
+ * will be merged as is in the layer.
39
+ * @param {C3DTilesSource} config.source The source of 3d Tiles.
40
+ *
41
+ * name.
42
+ * @param {Number} [config.sseThreshold=16] The [Screen Space Error](https://github.com/CesiumGS/3d-tiles/blob/main/specification/README.md#geometric-error)
43
+ * threshold at which child nodes of the current node will be loaded and added to the scene.
44
+ * @param {Number} [config.cleanupDelay=1000] The time (in ms) after which a tile content (and its children) are
45
+ * removed from the scene.
46
+ * @param {C3DTExtensions} [config.registeredExtensions] 3D Tiles extensions managers registered for this tileset.
47
+ * @param {String} [config.pntsMode= PNTS_MODE.COLOR] {@link PointsMaterial} Point cloud coloring mode.
48
+ * Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points,
49
+ * CLASSIFICATION uses a classification property of the batch table to color points.
50
+ * @param {String} [config.pntsShape= PNTS_SHAPE.CIRCLE] Point cloud point shape. Only 'CIRCLE' or 'SQUARE' are possible.
51
+ * @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera.
52
+ * @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode
53
+ * @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode
54
+ * @param {Style} [config.style=null] - style used for this layer
55
+ * @param {View} view The view
56
+ */
57
+ constructor(id: string, config: {
58
+ source: C3DTilesSource;
59
+ sseThreshold?: number | undefined;
60
+ cleanupDelay?: number | undefined;
61
+ registeredExtensions?: C3DTExtensions | undefined;
62
+ pntsMode?: string | undefined;
63
+ pntsShape?: string | undefined;
64
+ pntsSizeMode?: string | undefined;
65
+ pntsMinAttenuatedSize?: number | undefined;
66
+ pntsMaxAttenuatedSize?: number | undefined;
67
+ style?: Style | undefined;
68
+ }, view: View);
69
+ isC3DTilesLayer: boolean;
70
+ sseThreshold: number;
71
+ cleanupDelay: number;
72
+ protocol: string;
73
+ name: any;
74
+ registeredExtensions: C3DTExtensions;
75
+ pntsMode: string | number;
76
+ pntsShape: string | number;
77
+ classification: any;
78
+ pntsSizeMode: string | number;
79
+ pntsMinAttenuatedSize: number;
80
+ pntsMaxAttenuatedSize: number;
81
+ /** @type {Style | null} */
82
+ _style: Style | null;
83
+ /**
84
+ * Map all C3DTFeature of the layer according their tileId and their batchId
85
+ * Map< tileId, Map< batchId, C3DTFeature>>
86
+ *
87
+ * @type {Map<number, Map<number,C3DTFeature>>}
88
+ */
89
+ tilesC3DTileFeatures: Map<number, Map<number, C3DTFeature>>;
90
+ overrideMaterials: any;
91
+ _cleanableTiles: any[];
92
+ tileset: C3DTileset;
93
+ preUpdate(context: any): any[];
94
+ update(context: any, layer: any, node: any): any;
95
+ getObjectToUpdateForAttachedLayers(meta: any): {
96
+ elements: any[];
97
+ parent: any;
98
+ } | {
99
+ elements: any[];
100
+ parent?: undefined;
101
+ } | undefined;
102
+ /**
103
+ * Get the closest c3DTileFeature of an intersects array.
104
+ * @param {Array} intersects - @return An array containing all
105
+ * targets picked under specified coordinates. Intersects can be
106
+ * computed with view.pickObjectsAt(..). See fillHTMLWithPickingInfo()
107
+ * in 3dTilesHelper.js for an example.
108
+ *
109
+ * @returns {C3DTileFeature} - the closest C3DTileFeature of the intersects array
110
+ */
111
+ getC3DTileFeatureFromIntersectsArray(intersects: any[]): C3DTFeature | null | undefined;
112
+ /**
113
+ * Called when a tile content is loaded
114
+ * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
115
+ */
116
+ onTileContentLoaded(tileContent: THREE.Object3D): void;
117
+ /**
118
+ * Initialize C3DTileFeatures from tileContent
119
+ * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
120
+ */
121
+ initC3DTileFeatures(tileContent: THREE.Object3D): void;
122
+ /**
123
+ * Update style of the C3DTFeatures, an allowList of tile id can be passed to only update certain tile.
124
+ * Note that this function only update THREE.Object3D materials, in order to see style changes you should call view.notifyChange()
125
+ * @param {Array<number>|null} [allowTileIdList] - tile ids to allow in updateStyle computation if null all tiles are updated
126
+ *
127
+ * @returns {boolean} true if style updated false otherwise
128
+ */
129
+ updateStyle(allowTileIdList?: Array<number> | null): boolean;
130
+ get materialCount(): number;
131
+ set style(value: Style | null);
132
+ get style(): Style | null;
133
+ #private;
134
+ }
135
+ import GeometryLayer from '../Layer/GeometryLayer';
136
+ import C3DTExtensions from '../Core/3DTiles/C3DTExtensions';
137
+ import Style from '../Core/Style';
138
+ import C3DTFeature from '../Core/3DTiles/C3DTFeature';
139
+ import C3DTileset from '../Core/3DTiles/C3DTileset';
140
+ import * as THREE from 'three';