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
@@ -1,51 +1,132 @@
1
1
  import * as THREE from 'three';
2
- async function shutdownXR(session) {
3
- if (session) {
4
- await session.end();
5
- }
2
+ import VRControls from "../Controls/VRControls.js";
3
+
4
+ // TODO handle xr session end
5
+ export const VR_EVENTS = {
6
+ CONTROLS_INITIALIZED: 'vrControls-initialized'
7
+ };
8
+ function updateCamera3D(xr, view) {
9
+ /* This is what's done in updateUserCamera the WebXRManager.js of threejs
10
+ Update projectionMatrix, could be replaced by:
11
+ camera.projectionMatrix.copy( cameraXR.projectionMatrix );
12
+ camera.projectionMatrixInverse.copy( cameraXR.projectionMatrixInverse );
13
+ But it safer to also change all the attributes, in case of another call to updateProjectionMatrix
14
+ */
15
+
16
+ const {
17
+ near,
18
+ far,
19
+ aspect,
20
+ fov
21
+ } = extractCameraAttributesFromProjectionMatrix(view._camXR.projectionMatrix);
22
+ view.camera3D.near = near;
23
+ view.camera3D.far = far;
24
+ view.camera3D.aspect = aspect;
25
+ view.camera3D.fov = fov;
26
+ view.camera3D.zoom = 1;
27
+ view.camera3D.updateProjectionMatrix();
28
+ xr.getCamera().getWorldPosition(view.camera3D.position);
29
+ xr.getCamera().getWorldQuaternion(view.camera3D.quaternion);
30
+
31
+ // Update the local transformation matrix for the object itself
32
+ view.camera3D.updateMatrix();
33
+
34
+ // // Update the world transformation matrix, ensuring it reflects global transforms
35
+ view.camera3D.updateMatrixWorld(true);
36
+ view.notifyChange(view.camera3D, true);
6
37
  }
7
- const initializeWebXR = (view, options) => {
8
- const scale = options.scale || 1.0;
9
- const xr = view.mainLoop.gfxEngine.renderer.xr;
10
- xr.addEventListener('sessionstart', () => {
11
- const camera = view.camera.camera3D;
12
- const exitXRSession = event => {
13
- if (event.key === 'Escape') {
14
- document.removeEventListener('keydown', exitXRSession);
15
- xr.enabled = false;
16
- view.camera.camera3D = camera;
17
- view.scene.scale.multiplyScalar(1 / scale);
18
- view.scene.updateMatrixWorld();
19
- shutdownXR(xr.getSession());
20
- view.notifyChange(view.camera.camera3D, true);
21
- }
22
- };
23
- view.scene.scale.multiplyScalar(scale);
24
- view.scene.updateMatrixWorld();
25
- xr.enabled = true;
26
- xr.getReferenceSpace('local');
27
- const position = view.camera.position();
28
- const geodesicNormal = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 0, 1), position.geodesicNormal).invert();
29
- const quat = new THREE.Quaternion(-1, 0, 0, 1).normalize().multiply(geodesicNormal);
30
- const trans = camera.position.clone().multiplyScalar(-scale).applyQuaternion(quat);
31
- const transform = new XRRigidTransform(trans, quat);
32
- const baseReferenceSpace = xr.getReferenceSpace();
33
- const teleportSpaceOffset = baseReferenceSpace.getOffsetReferenceSpace(transform);
34
- xr.setReferenceSpace(teleportSpaceOffset);
35
- view.camera.camera3D = xr.getCamera();
36
- view.camera.resize(view.camera.width, view.camera.height);
37
- document.addEventListener('keydown', exitXRSession, false);
38
-
39
- // TODO Fix asynchronization between xr and MainLoop render loops.
40
- // (see MainLoop#scheduleViewUpdate).
41
- xr.setAnimationLoop(timestamp => {
42
- if (xr.isPresenting && view.camera.camera3D.cameras[0]) {
43
- view.camera.camera3D.updateMatrix();
44
- view.camera.camera3D.updateMatrixWorld(true);
45
- view.notifyChange(view.camera.camera3D, true);
38
+ // Note: WebXR cameras are perspective cameras
39
+ function extractCameraAttributesFromProjectionMatrix(projectionMatrix) {
40
+ const m = projectionMatrix.elements;
41
+
42
+ // Extract near and far
43
+ const near = m[14] / (m[10] - 1);
44
+ const far = m[14] / (m[10] + 1);
45
+
46
+ // Extract vertical FOV
47
+ const fovY = 2 * Math.atan(1 / m[5]); // m[5] = 1 / tan(fovY / 2)
48
+ const fov = THREE.MathUtils.radToDeg(fovY); // Convert to degrees
49
+
50
+ // Extract aspect ratio
51
+ const aspect = m[5] / m[0]; // m[0] = 1 / (tan(fovY / 2) * aspect)
52
+
53
+ return {
54
+ near,
55
+ far,
56
+ aspect,
57
+ fov
58
+ };
59
+ }
60
+ /**
61
+ * @property {VRControls} vrControls - WebXR controllers handler
62
+ * */
63
+ class WebXR extends THREE.EventDispatcher {
64
+ /**
65
+ * Handler of a webXR session
66
+ *
67
+ *
68
+ * @param {GlobeView} view - The view where the webXR session will be started
69
+ * @param {Object} [options] - WebXR configuration - its presence alone
70
+ * enable WebXR to switch on VR visualization.
71
+ * @param {function} [options.callback] - WebXR rendering callback (optional).
72
+ * @param {boolean} [options.controllers] - Enable the webXR controllers handling (optional).
73
+ */
74
+ constructor(view, options) {
75
+ super();
76
+ this.view = view;
77
+ this.options = options;
78
+ this.renderCb = options.callback;
79
+ this.vrControls = null;
80
+ }
81
+
82
+ // Start the webXR handler
83
+ initializeWebXR = () => {
84
+ const xr = this.view.renderer.xr;
85
+ xr.addEventListener('sessionstart', () => {
86
+ xr.enabled = true;
87
+ xr.getReferenceSpace('local');
88
+
89
+ // To avoid controllers precision issues, headset should handle camera position
90
+ const vrHeadSet = new THREE.Object3D();
91
+ vrHeadSet.name = 'xrHeadset';
92
+ this.view.scene.add(vrHeadSet);
93
+ this.view.camera3D.getWorldPosition(vrHeadSet.position);
94
+ this.view.camera3D.getWorldQuaternion(vrHeadSet.quaternion);
95
+ vrHeadSet.updateMatrixWorld(true);
96
+ vrHeadSet.add(xr.getCamera());
97
+
98
+ // Placeholder camera to initialize correctly the vr, which needs a parent
99
+ this.view._camXR = this.view.camera3D.clone();
100
+
101
+ // Important to see the controllers -> maybe could be improved
102
+ this.view._camXR.far = 2000000;
103
+ this.view._camXR.near = 0.1;
104
+ this.view._camXR.updateProjectionMatrix();
105
+ vrHeadSet.add(this.view._camXR);
106
+ this.view.notifyChange();
107
+ if (this.options.controllers) {
108
+ this.vrControls = new VRControls(this.view, vrHeadSet);
109
+ this.dispatchEvent({
110
+ type: 'vrControls-initialized'
111
+ });
46
112
  }
47
- view.mainLoop.step(view, timestamp);
113
+ xr.setAnimationLoop(timestamp => {
114
+ if (xr.isPresenting && xr.getCamera().cameras.length > 0) {
115
+ // TODO should be called only once, but the first values are wrong because the camL&camR weren't updated
116
+ updateCamera3D(xr, this.view);
117
+
118
+ // This will also update the controllers position
119
+ vrHeadSet.updateMatrixWorld(true);
120
+ if (this.vrControls) {
121
+ this.vrControls.listenGamepad();
122
+ }
123
+ if (this.renderCb) {
124
+ this.renderCb();
125
+ }
126
+ }
127
+ this.view.mainLoop.step(this.view, timestamp);
128
+ });
48
129
  });
49
- });
50
- };
51
- export default initializeWebXR;
130
+ };
131
+ }
132
+ export default WebXR;
@@ -0,0 +1,55 @@
1
+ export default c3DEngine;
2
+ declare class c3DEngine {
3
+ constructor(rendererOrDiv: any, options?: {});
4
+ width: any;
5
+ height: any;
6
+ positionBuffer: any;
7
+ _nextThreejsLayer: number;
8
+ fullSizeRenderTarget: THREE.WebGLRenderTarget<THREE.Texture>;
9
+ renderView: (view: any) => void;
10
+ /**
11
+ * @type {function}
12
+ * @param {number} w
13
+ * @param {number} h
14
+ */
15
+ onWindowResize: Function;
16
+ label2dRenderer: Label2DRenderer;
17
+ renderer: any;
18
+ getWindowSize(): THREE.Vector2;
19
+ /**
20
+ * return renderer THREE.js
21
+ * @returns {THREE.WebGLRenderer}
22
+ */
23
+ getRenderer(): THREE.WebGLRenderer;
24
+ /**
25
+ * Render view to a Uint8Array.
26
+ *
27
+ * @param {View} view - The view to render
28
+ * @param {object} [zone] - partial zone to render
29
+ * @param {number} zone.x - x (in view coordinate)
30
+ * @param {number} zone.y - y (in view coordinate)
31
+ * @param {number} zone.width - width of area to render (in pixels)
32
+ * @param {number} zone.height - height of area to render (in pixels)
33
+ * @return {THREE.RenderTarget} - Uint8Array, 4 bytes per pixel. The first pixel in
34
+ * the array is the bottom-left pixel.
35
+ */
36
+ renderViewToBuffer(view: View, zone?: {
37
+ x: number;
38
+ y: number;
39
+ width: number;
40
+ height: number;
41
+ }): THREE.RenderTarget;
42
+ /**
43
+ * Render view to a THREE.RenderTarget.
44
+ *
45
+ * @param {View} view - The view to render
46
+ * @param {THREE.RenderTarget} [target] - destination render target. Default value: full size render target owned by c3DEngine.
47
+ * @param {object} [zone] - partial zone to render (zone x/y uses view coordinates) Note: target must contain complete zone
48
+ * @return {THREE.RenderTarget} - the destination render target
49
+ */
50
+ renderViewToRenderTarget(view: View, target?: THREE.RenderTarget, zone?: object): THREE.RenderTarget;
51
+ bufferToImage(pixelBuffer: any, width: any, height: any): HTMLImageElement;
52
+ depthBufferRGBAValueToOrthoZ(depthBufferRGBA: any, camera: any): number;
53
+ }
54
+ import * as THREE from 'three';
55
+ import Label2DRenderer from '../Renderer/Label2DRenderer';
@@ -51,7 +51,11 @@ class c3DEngine {
51
51
  this.fullSizeRenderTarget.depthTexture.type = THREE.UnsignedShortType;
52
52
  this.renderView = function (view) {
53
53
  this.renderer.clear();
54
- this.renderer.render(view.scene, view.camera3D);
54
+ if (view._camXR) {
55
+ this.renderer.render(view.scene, view._camXR);
56
+ } else {
57
+ this.renderer.render(view.scene, view.camera3D);
58
+ }
55
59
  if (view.tileLayer) {
56
60
  this.label2dRenderer.render(view.tileLayer.object3d, view.camera3D);
57
61
  }
@@ -0,0 +1,38 @@
1
+ export default C3DTilesGoogleSource;
2
+ /**
3
+ * An object defining the source connection to a 3DTiles asset from a [Google api](https://tile.googleapis.com).
4
+ *
5
+ * @extends C3DTilesSource
6
+ *
7
+ * @property {boolean} isC3DTilesGoogleSource - Used to checkout whether this source is a C3DTilesGoogleSource. Default is
8
+ * true. You should not change this, as it is used internally for optimisation.
9
+ * @property {string} url - The URL to the tileset json.
10
+ * @property {string} baseUrl - The base URL to access tiles.
11
+ */
12
+ declare class C3DTilesGoogleSource extends C3DTilesSource {
13
+ /**
14
+ * Create a new Source for 3D Tiles data from Google api (experimental).
15
+ *
16
+ * @extends C3DTilesSource
17
+ *
18
+ * @property {boolean} isC3DTilesGoogleSource - Used to checkout whether this source is a C3DTilesGoogleSource. Default is
19
+ * true. You should not change this, as it is used internally for optimisation.
20
+ * @param {Object} source An object that can contain all properties of a C3DTilesGoogleSource and {@link Source}.
21
+ * @param {String} source.key Your google tiles map API access key
22
+ */
23
+ constructor(source: {
24
+ key: string;
25
+ });
26
+ isC3DTilesGoogleSource: boolean;
27
+ baseUrl: string;
28
+ key: string;
29
+ sessionId: any;
30
+ /**
31
+ * Adds the key and session to the tile url (non-standard behaviour, that is specific to Google 3D tiles),
32
+ * see https://github.com/CesiumGS/3d-tiles/issues/746
33
+ * @param {String} url the tile url
34
+ * @returns {String} the tile url with Google map tiles api key and session parameters added at the end of the url
35
+ */
36
+ getTileUrl(url: string): string;
37
+ }
38
+ import C3DTilesSource from './C3DTilesSource';
@@ -0,0 +1,31 @@
1
+ export default C3DTilesIonSource;
2
+ /**
3
+ * An object defining the source connection to a 3DTiles asset of a [Cesium ion server](https://cesium.com/learn/ion/).
4
+ *
5
+ * @extends Source
6
+ *
7
+ * @property {boolean} isC3DTilesIonSource - Used to checkout whether this source is a C3DTilesIonSource. Default is
8
+ * true. You should not change this, as it is used internally for optimisation.
9
+ * @property {string} url - The URL of the tileset json.
10
+ * @property {string} baseUrl - The base URL to access tiles.
11
+ * @property {string} accessToken - The Cesium ion access token used to retrieve the resource.
12
+ * @property {string} assetId - The id of the asset on Cesium ion.
13
+ */
14
+ declare class C3DTilesIonSource {
15
+ /**
16
+ * Create a new Source for 3D Tiles data from Cesium ion.
17
+ *
18
+ * @extends Source
19
+ *
20
+ * @param {Object} source An object that can contain all properties of a C3DTilesIonSource and {@link Source}.
21
+ * Only `accessToken` and `assetId` are mandatory.
22
+ */
23
+ constructor(source: Object);
24
+ isC3DTilesIonSource: boolean;
25
+ accessToken: any;
26
+ assetId: any;
27
+ whenReady: Promise<Object>;
28
+ url: any;
29
+ baseUrl: any;
30
+ attribution: any;
31
+ }
@@ -0,0 +1,17 @@
1
+ export default C3DTilesSource;
2
+ /**
3
+ * An object defining the source connection to a 3DTiles dataset from a web server.
4
+ *
5
+ * @extends Source
6
+ *
7
+ * @property {boolean} isC3DTilesSource - Used to checkout whether this source is a isC3DTilesSource. Default is
8
+ * true. You should not change this, as it is used internally for optimisation.
9
+ * @property {string} url - The URL of the tileset json.
10
+ * @property {string} baseUrl - The base URL to access tiles.
11
+ */
12
+ declare class C3DTilesSource extends Source {
13
+ isC3DTilesSource: boolean;
14
+ baseUrl: any;
15
+ whenReady: Promise<Object>;
16
+ }
17
+ import Source from '../Source/Source';
@@ -0,0 +1,79 @@
1
+ export default CopcSource;
2
+ /**
3
+ * A source for [Cloud Optimised Point Cloud](https://copc.io/) (COPC) data.
4
+ * Such data consists of a [LAZ 1.4](https://www.ogc.org/standard/las/) file
5
+ * that stores compressed points data organized in a clustered octree.
6
+ *
7
+ * A freshly created source fetches and parses portions of the file
8
+ * corresponding to the LAS 1.4 header, all the Variable Length Record (VLR)
9
+ * headers as well the following VLRs:
10
+ * - COPC [`info`](https://copc.io/#info-vlr) record (mandatory)
11
+ * - LAS 1.4 `OGC Coordinate System WKT` record (mandatory, see [Las 1.4
12
+ * spec](https://portal.ogc.org/files/?artifact_id=74523))
13
+ * - LAS 1.4 `Extra Bytes` record (optional, see [Las 1.4
14
+ * spec](https://portal.ogc.org/files/?artifact_id=74523))
15
+ *
16
+ * @extends {Source}
17
+ *
18
+ * @property {boolean} isCopcSource - Read-only flag to check that a given
19
+ * object is of type CopcSource.
20
+ * @property {Object} header - LAS header of the source.
21
+ * @property {Object[]} eb - List of headers of each Variable Length Records
22
+ * (VLRs).
23
+ * @property {Object} info - COPC `info` VLR.
24
+ * @property {number[]} info.cube - Bounding box of the octree as a 6-elements.
25
+ * tuple `[minX, minY, minZ, maxX, maxY, maxZ]`. Computed from `center_x`,
26
+ * `center_y`, `center_z` and `halfSize` properties.
27
+ * @property {Object} info.rootHierarchyPage - Hierarchy page of the root node.
28
+ * @property {number} info.rootHierarchyPage.pageOffset - Absolute Offset to the
29
+ * root node data chunk.
30
+ * @property {number} info.rootHierarchyPage.pageOffset - Size (in bytes) of the
31
+ * root node data chunk.
32
+ * @property {number[]} gpsTimeRange - A 2-element tuple denoting the minimum
33
+ * and maximum values of attribute `gpsTime`.
34
+ */
35
+ declare class CopcSource extends Source {
36
+ /**
37
+ * @param {Object} config - Source configuration
38
+ * @param {string} config.url - URL of the COPC resource.
39
+ * @param {8 | 16} [config.colorDepth=16] - Encoding of the `color`
40
+ * attribute. Either `8` or `16` bits.
41
+ * @param {string} [config._lazPerfBaseUrl] - (experimental) Overrides base
42
+ * url of the `las-zip.wasm` file of the `laz-perf` library.
43
+ * @param {string} [config.crs='EPSG:4326'] - Native CRS of the COPC
44
+ * ressource. Note that this is not for now inferred from the COPC header.
45
+ * @param {RequestInit} [config.networkOptions] - Fetch options (passed
46
+ * directly to `fetch()`), see [the syntax for more information](
47
+ * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
48
+ * @param {Object} [config.attribution] - Attribution of the data.
49
+ */
50
+ constructor(config: {
51
+ url: string;
52
+ colorDepth?: 8 | 16 | undefined;
53
+ _lazPerfBaseUrl?: string | undefined;
54
+ crs?: string | undefined;
55
+ networkOptions?: RequestInit | undefined;
56
+ attribution?: Object | undefined;
57
+ });
58
+ isCopcSource: boolean;
59
+ parser: (data: ArrayBuffer, options?: {
60
+ in: {
61
+ pointCount: number;
62
+ header: {
63
+ pointDataRecordFormat: number;
64
+ pointDataRecordLength: number;
65
+ };
66
+ };
67
+ eb?: Object | undefined;
68
+ }) => Promise<THREE.BufferGeometry>;
69
+ fetcher: (url: any, options?: {}) => Promise<ArrayBuffer>;
70
+ colorDepth: 8 | 16;
71
+ whenReady: Promise<this>;
72
+ header: Las.Header;
73
+ info: Info;
74
+ eb: Las.ExtraBytes[];
75
+ }
76
+ import Source from '../Source/Source';
77
+ import * as THREE from 'three';
78
+ import { Las } from 'copc';
79
+ import { Info } from 'copc';
@@ -0,0 +1,40 @@
1
+ export default EntwinePointTileSource;
2
+ /**
3
+ * An object defining the source of Entwine Point Tile data. It fetches and
4
+ * parses the main configuration file of Entwine Point Tile format,
5
+ * [`ept.json`](https://entwine.io/entwine-point-tile.html#ept-json).
6
+ *
7
+ * @extends Source
8
+ *
9
+ * @property {boolean} isEntwinePointTileSource - Used to checkout whether this
10
+ * source is a EntwinePointTileSource. Default is true. You should not change
11
+ * this, as it is used internally for optimisation.
12
+ * @property {string} url - The URL of the directory containing the whole
13
+ * Entwine Point Tile structure.
14
+ */
15
+ declare class EntwinePointTileSource extends Source {
16
+ /**
17
+ * @param {Object} config - The configuration, see {@link Source} for
18
+ * available values.
19
+ * @param {number|string} [config.colorDepth='auto'] - Does the color
20
+ * encoding is known ? Is it `8` or `16` bits ? By default it is to
21
+ * `'auto'`, but it will be more performant if a specific value is set.
22
+ */
23
+ constructor(config: {
24
+ colorDepth?: string | number | undefined;
25
+ });
26
+ isEntwinePointTileSource: boolean;
27
+ colorDepth: string | number | undefined;
28
+ whenReady: Promise<this>;
29
+ parse: ((buffer: ArrayBuffer, options: Object) => Promise<any>) | ((data: ArrayBuffer, options?: {
30
+ in?: {
31
+ colorDepth?: 8 | 16 | undefined;
32
+ } | undefined;
33
+ }) => Promise<any>);
34
+ extension: string;
35
+ boundsConforming: any;
36
+ bounds: any;
37
+ span: any;
38
+ fetcher: (url: any, options?: {}) => Promise<ArrayBuffer>;
39
+ }
40
+ import Source from '../Source/Source';
@@ -56,11 +56,6 @@ class EntwinePointTileSource extends Source {
56
56
  console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
57
57
  }
58
58
  }
59
-
60
- // NOTE: this spacing is kinda arbitrary here, we take the width and
61
- // length (height can be ignored), and we divide by the specified
62
- // span in ept.json. This needs improvements.
63
- this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0]) + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
64
59
  this.boundsConforming = metadata.boundsConforming;
65
60
  this.bounds = metadata.bounds;
66
61
  this.span = metadata.span;
@@ -0,0 +1,118 @@
1
+ export default FileSource;
2
+ /**
3
+ * An object defining the source of a single resource to get from a direct
4
+ * access. It inherits from {@link Source}. There is multiple ways of adding a
5
+ * resource here:
6
+ * <ul>
7
+ * <li>add the file like any other sources, using the `url` property.</li>
8
+ * <li>fetch the file, and give the data to the source using the `fetchedData`
9
+ * property.</li>
10
+ * <li>fetch the file, parse it and git the parsed data to the source using the
11
+ * `features` property.</li>
12
+ * </ul>
13
+ * See the examples below for real use cases.
14
+ *
15
+ * @extends Source
16
+ *
17
+ * @property {boolean} isFileSource - Used to checkout whether this source is a
18
+ * FileSource. Default is true. You should not change this, as it is used
19
+ * internally for optimisation.
20
+ * @property {*} fetchedData - Once the file has been loaded, the resulting data
21
+ * is stored in this property.
22
+ * @property {*} features - Once the file has been loaded and parsed, the
23
+ * resulting data is stored in this property.
24
+ *
25
+ * @example <caption>Simple: create a source, a layer, and let iTowns taking
26
+ * care of everything.</caption>
27
+ * const kmlSource = new itowns.FileSource({
28
+ * url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
29
+ * crs: 'EPSG:4326',
30
+ * fetcher: itowns.Fetcher.xml,
31
+ * parser: itowns.KMLParser.parse,
32
+ * });
33
+ *
34
+ * const kmlLayer = new itowns.ColorLayer('Kml', {
35
+ * name: 'kml',
36
+ * transparent: true,
37
+ * crs: view.tileLayer.extent.crs,
38
+ * source: kmlSource,
39
+ * });
40
+ *
41
+ * view.addLayer(kmlLayer);
42
+ *
43
+ * @example <caption>Advanced: fetch some data, create a source, a layer, and
44
+ * let iTowns do the parsing and converting.</caption>
45
+ * // Parse and Convert by iTowns
46
+ * itowns.Fetcher.xml('https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx')
47
+ * .then(function _(gpx) {
48
+ * const gpxSource = new itowns.FileSource({
49
+ * data: gpx,
50
+ * crs: 'EPSG:4326',
51
+ * parser: itowns.GpxParser.parse,
52
+ * });
53
+ *
54
+ * const gpxLayer = new itowns.ColorLayer('Gpx', {
55
+ * name: 'Ultra 2009',
56
+ * transparent: true,
57
+ * source: gpxSource,
58
+ * });
59
+ *
60
+ * return view.addLayer(gpxLayer);
61
+ * });
62
+ *
63
+ * @example <caption>More advanced: create a layer, fetch some data, parse the
64
+ * data, append a source to the layer and add the layer to iTowns.</caption>
65
+ * // Create a layer
66
+ * const ariege = new itowns.GeometryLayer('ariege', new itowns.THREE.Group());
67
+ *
68
+ * // Specify update method and conversion
69
+ * ariege.update = itowns.FeatureProcessing.update;
70
+ * ariege.convert = itowns.Feature2Mesh.convert({
71
+ * color: () => new itowns.THREE.Color(0xffcc00),
72
+ * extrude: () => 5000,
73
+ * });
74
+ *
75
+ * itowns.Fetcher.json('https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson')
76
+ * .then(function _(geojson) {
77
+ * return itowns.GeoJsonParser.parse(geojson, {
78
+ * in: { crs: 'EPSG:4326' },
79
+ * out: { crs: view.tileLayer.extent.crs,
80
+ * style: new itowns.Style({
81
+ * fill: {
82
+ * color: new itowns.THREE.Color(0xffcc00),
83
+ * extrusion_height: () => 5000,
84
+ * }),
85
+ * },
86
+ * },
87
+ * });
88
+ * }).then(function _(features) {
89
+ * ariege.source = new itowns.FileSource({
90
+ * crs: 'EPSG:4326',
91
+ * features,
92
+ * });
93
+ *
94
+ * return view.addLayer(ariegeLayer);
95
+ * });
96
+ */
97
+ declare class FileSource extends Source {
98
+ isFileSource: boolean;
99
+ fetchedData: any;
100
+ whenReady: any;
101
+ zoom: {
102
+ min: number;
103
+ max: number;
104
+ };
105
+ urlFromExtent(): any;
106
+ onLayerAdded(options: any): void;
107
+ /**
108
+ * load data from cache or Fetch/Parse data.
109
+ * The loaded data is a Feature or Texture.
110
+ *
111
+ * @param {Extent} extent extent requested parsed data.
112
+ * @param {FeatureBuildingOptions|Layer} out The feature returned options
113
+ * @return {FeatureCollection|Texture} The parsed data.
114
+ */
115
+ loadData(extent: Extent, out: FeatureBuildingOptions | Layer): FeatureCollection | Texture;
116
+ extentInsideLimit(extent: any): any;
117
+ }
118
+ import Source from '../Source/Source';
@@ -0,0 +1,24 @@
1
+ export default OGC3DTilesGoogleSource;
2
+ declare class OGC3DTilesGoogleSource extends OGC3DTilesSource {
3
+ /**
4
+ * An object defining the source connection to a 3D Tiles asset from [Google Tiles API](https://tile.googleapis.com).
5
+ *
6
+ * @extends OGC3DTilesSource
7
+ *
8
+ * @property {boolean} isOGC3DTilesGoogleSource - Used to check if this source is an OGC3DTilesGoogleSource. Set to true.
9
+ * You should not change this, as it is used internally for optimisation.
10
+ * @property {string} url - The URL to the tileset json.
11
+ * @property {string} baseUrl - The base URL to access tiles.
12
+ *
13
+ * @property {boolean} isOGC3DTilesGoogleSource - Used to check if this source is an OGC3DTilesGoogleSource. Set to
14
+ * true. You should not change this, as it is used internally for optimisation.
15
+ * @param {Object} source An object that can contain all properties of an OGC3DTilesGoogleSource and {@link Source}.
16
+ * @param {String} source.key Your google tiles map API access key
17
+ */
18
+ constructor(source: {
19
+ key: string;
20
+ });
21
+ isOGC3DTilesGoogleSource: boolean;
22
+ key: string;
23
+ }
24
+ import OGC3DTilesSource from './OGC3DTilesSource';
@@ -0,0 +1,26 @@
1
+ export default OGC3DTilesIonSource;
2
+ declare class OGC3DTilesIonSource extends OGC3DTilesSource {
3
+ /**
4
+ * An object defining the source connection to a 3DTiles asset of a [Cesium ion server](https://cesium.com/learn/ion/).
5
+ *
6
+ * @extends Source
7
+ *
8
+ * @property {boolean} isOGC3DTilesIonSource - Used to check if this source is an OGC3DTilesIonSource. Set to true.
9
+ * You should not change this, as it is used internally for optimisation.
10
+ * @property {string} accessToken - The Cesium ion access token used to retrieve the resource.
11
+ * @property {string} assetId - The id of the asset on Cesium ion.
12
+ *
13
+ * @param {Object} source An object that can contain all properties of an OGC3DTilesIonSource and {@link Source}.
14
+ * Only `accessToken` and `assetId` are mandatory.
15
+ * @param {string} source.accessToken - The Cesium ion access token used to retrieve the resource.
16
+ * @param {string} source.assetId - The id of the asset on Cesium ion.
17
+ */
18
+ constructor(source: {
19
+ accessToken: string;
20
+ assetId: string;
21
+ });
22
+ isOGC3DTilesIonSource: boolean;
23
+ accessToken: string;
24
+ assetId: string;
25
+ }
26
+ import OGC3DTilesSource from './OGC3DTilesSource';
@@ -0,0 +1,21 @@
1
+ export default OGC3DTilesSource;
2
+ declare class OGC3DTilesSource extends Source {
3
+ /**
4
+ * An object defining the source connection to a 3DTiles dataset from a web server.
5
+ *
6
+ * @extends Source
7
+ *
8
+ * @property {boolean} isOGC3DTilesSource - Used to check if this source is an isOGC3DTilesSource. Set to true.
9
+ * You should not change this, as it is used internally for optimisation.
10
+ * @property {string} url - The URL of the tileset json.
11
+ *
12
+ * @param {Object} source An object that can contain all properties of OGC3DTilesSource and of {@link Source}.
13
+ * Only `url` is mandatory.
14
+ * @param {string} source.url - The URL of the tileset json.
15
+ */
16
+ constructor(source: {
17
+ url: string;
18
+ });
19
+ isOGC3DTilesSource: boolean;
20
+ }
21
+ import Source from '../Source/Source';