itowns 2.45.1 → 2.45.2-next.0

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 (220) 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/view_3d_map_webxr.html +2 -5
  21. package/lib/Controls/FirstPersonControls.d.ts +90 -0
  22. package/lib/Controls/FlyControls.d.ts +36 -0
  23. package/lib/Controls/GlobeControls.d.ts +274 -0
  24. package/lib/Controls/PlanarControls.d.ts +339 -0
  25. package/lib/Controls/StateControl.d.ts +140 -0
  26. package/lib/Controls/StreetControls.d.ts +134 -0
  27. package/lib/Controls/VRControls.d.ts +56 -0
  28. package/lib/Controls/VRControls.js +409 -0
  29. package/lib/Converter/Feature2Mesh.d.ts +42 -0
  30. package/lib/Converter/Feature2Texture.d.ts +5 -0
  31. package/lib/Converter/convertToTile.d.ts +5 -0
  32. package/lib/Converter/convertToTile.js +2 -2
  33. package/lib/Converter/textureConverter.d.ts +4 -0
  34. package/lib/Core/3DTiles/C3DTBatchTable.d.ts +49 -0
  35. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.d.ts +37 -0
  36. package/lib/Core/3DTiles/C3DTBoundingVolume.d.ts +39 -0
  37. package/lib/Core/3DTiles/C3DTExtensions.d.ts +75 -0
  38. package/lib/Core/3DTiles/C3DTFeature.d.ts +47 -0
  39. package/lib/Core/3DTiles/C3DTilesEnums.d.ts +14 -0
  40. package/lib/Core/3DTiles/C3DTileset.d.ts +46 -0
  41. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.d.ts +14 -0
  42. package/lib/Core/AnimationPlayer.d.ts +53 -0
  43. package/lib/Core/CopcNode.d.ts +67 -0
  44. package/lib/Core/CopcNode.js +50 -69
  45. package/lib/Core/Deprecated/Undeprecator.d.ts +6 -0
  46. package/lib/Core/EntwinePointTileNode.d.ts +58 -0
  47. package/lib/Core/EntwinePointTileNode.js +6 -34
  48. package/lib/Core/Feature.d.ts +323 -0
  49. package/lib/Core/Geographic/GeoidGrid.d.ts +86 -0
  50. package/lib/Core/Label.d.ts +86 -0
  51. package/lib/Core/MainLoop.d.ts +23 -0
  52. package/lib/Core/Picking.d.ts +6 -0
  53. package/lib/Core/Picking.js +4 -0
  54. package/lib/Core/PointCloudNode.d.ts +14 -0
  55. package/lib/Core/PointCloudNode.js +28 -0
  56. package/lib/Core/Potree2Node.d.ts +11 -0
  57. package/lib/Core/Potree2Node.js +3 -57
  58. package/lib/Core/Potree2PointAttributes.d.ts +97 -0
  59. package/lib/Core/PotreeNode.d.ts +13 -0
  60. package/lib/Core/PotreeNode.js +17 -17
  61. package/lib/Core/Prefab/Globe/Atmosphere.d.ts +66 -0
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +10 -5
  63. package/lib/Core/Prefab/Globe/GlobeLayer.d.ts +48 -0
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.d.ts +38 -0
  65. package/lib/Core/Prefab/Globe/SkyShader.d.ts +5 -0
  66. package/lib/Core/Prefab/Globe/SkyShader.js +3 -3
  67. package/lib/Core/Prefab/GlobeView.d.ts +65 -0
  68. package/lib/Core/Prefab/GlobeView.js +9 -0
  69. package/lib/Core/Prefab/Planar/PlanarLayer.d.ts +38 -0
  70. package/lib/Core/Prefab/Planar/PlanarTileBuilder.d.ts +32 -0
  71. package/lib/Core/Prefab/PlanarView.d.ts +33 -0
  72. package/lib/Core/Prefab/TileBuilder.d.ts +63 -0
  73. package/lib/Core/Prefab/computeBufferTileGeometry.d.ts +17 -0
  74. package/lib/Core/Scheduler/Cache.d.ts +25 -0
  75. package/lib/Core/Scheduler/CancelledCommandException.d.ts +12 -0
  76. package/lib/Core/Scheduler/Scheduler.d.ts +106 -0
  77. package/lib/Core/Style.d.ts +248 -0
  78. package/lib/Core/StyleOptions.d.ts +455 -0
  79. package/lib/Core/System/Capabilities.d.ts +9 -0
  80. package/lib/Core/Tile/Tile.d.ts +70 -0
  81. package/lib/Core/Tile/TileGrid.d.ts +12 -0
  82. package/lib/Core/TileGeometry.d.ts +46 -0
  83. package/lib/Core/TileMesh.d.ts +50 -0
  84. package/lib/Core/TileMesh.js +2 -4
  85. package/lib/Core/View.d.ts +403 -0
  86. package/lib/Core/View.js +1 -7
  87. package/lib/Layer/C3DTilesLayer.d.ts +140 -0
  88. package/lib/Layer/ColorLayer.d.ts +128 -0
  89. package/lib/Layer/ColorLayer.js +4 -4
  90. package/lib/Layer/CopcLayer.d.ts +42 -0
  91. package/lib/Layer/CopcLayer.js +3 -6
  92. package/lib/Layer/ElevationLayer.d.ts +96 -0
  93. package/lib/Layer/ElevationLayer.js +3 -3
  94. package/lib/Layer/EntwinePointTileLayer.d.ts +56 -0
  95. package/lib/Layer/EntwinePointTileLayer.js +4 -3
  96. package/lib/Layer/FeatureGeometryLayer.d.ts +62 -0
  97. package/lib/Layer/GeoidLayer.d.ts +41 -0
  98. package/lib/Layer/GeometryLayer.d.ts +120 -0
  99. package/lib/Layer/InfoLayer.d.ts +24 -0
  100. package/lib/Layer/InfoLayer.js +1 -1
  101. package/lib/Layer/LabelLayer.d.ts +93 -0
  102. package/lib/Layer/LabelLayer.js +2 -2
  103. package/lib/Layer/Layer.d.ts +185 -0
  104. package/lib/Layer/LayerUpdateState.d.ts +24 -0
  105. package/lib/Layer/LayerUpdateStrategy.d.ts +11 -0
  106. package/lib/Layer/LayerUpdateStrategy.js +2 -7
  107. package/lib/Layer/OGC3DTilesLayer.d.ts +277 -0
  108. package/lib/Layer/OGC3DTilesLayer.js +21 -0
  109. package/lib/Layer/OrientedImageLayer.d.ts +53 -0
  110. package/lib/Layer/PointCloudLayer.d.ts +103 -0
  111. package/lib/Layer/PointCloudLayer.js +1 -1
  112. package/lib/Layer/Potree2Layer.d.ts +56 -0
  113. package/lib/Layer/PotreeLayer.d.ts +55 -0
  114. package/lib/Layer/RasterLayer.d.ts +8 -0
  115. package/lib/Layer/RasterLayer.js +2 -2
  116. package/lib/Layer/ReferencingLayerProperties.d.ts +2 -0
  117. package/lib/Layer/ReferencingLayerProperties.js +0 -12
  118. package/lib/Layer/TiledGeometryLayer.d.ts +192 -0
  119. package/lib/Layer/TiledGeometryLayer.js +4 -3
  120. package/lib/Main.d.ts +89 -0
  121. package/lib/Main.js +3 -1
  122. package/lib/Parser/B3dmParser.d.ts +26 -0
  123. package/lib/Parser/CameraCalibrationParser.d.ts +32 -0
  124. package/lib/Parser/GDFParser.d.ts +24 -0
  125. package/lib/Parser/GTXParser.d.ts +28 -0
  126. package/lib/Parser/GeoJsonParser.d.ts +12 -0
  127. package/lib/Parser/GpxParser.d.ts +12 -0
  128. package/lib/Parser/ISGParser.d.ts +23 -0
  129. package/lib/Parser/KMLParser.d.ts +12 -0
  130. package/lib/Parser/LASParser.d.ts +61 -0
  131. package/lib/Parser/MapBoxUrlParser.d.ts +9 -0
  132. package/lib/Parser/PntsParser.d.ts +4 -0
  133. package/lib/Parser/Potree2BinParser.d.ts +8 -0
  134. package/lib/Parser/PotreeBinParser.d.ts +4 -0
  135. package/lib/Parser/PotreeCinParser.d.ts +4 -0
  136. package/lib/Parser/ShapefileParser.d.ts +25 -0
  137. package/lib/Parser/VectorTileParser.d.ts +34 -0
  138. package/lib/Parser/XbilParser.d.ts +18 -0
  139. package/lib/Parser/deprecated/LegacyGLTFLoader.d.ts +32 -0
  140. package/lib/Parser/iGLTFLoader.d.ts +104 -0
  141. package/lib/Process/3dTilesProcessing.d.ts +43 -0
  142. package/lib/Process/FeatureProcessing.d.ts +4 -0
  143. package/lib/Process/LayeredMaterialNodeProcessing.d.ts +3 -0
  144. package/lib/Process/LayeredMaterialNodeProcessing.js +12 -12
  145. package/lib/Process/ObjectRemovalHelper.d.ts +32 -0
  146. package/lib/Process/handlerNodeError.d.ts +1 -0
  147. package/lib/Provider/3dTilesProvider.d.ts +7 -0
  148. package/lib/Provider/DataSourceProvider.d.ts +4 -0
  149. package/lib/Provider/Fetcher.d.ts +101 -0
  150. package/lib/Provider/PointCloudProvider.d.ts +4 -0
  151. package/lib/Provider/TileProvider.d.ts +4 -0
  152. package/lib/Provider/URLBuilder.d.ts +28 -0
  153. package/lib/Renderer/Camera.d.ts +95 -0
  154. package/lib/Renderer/Color.d.ts +3 -0
  155. package/lib/Renderer/ColorLayersOrdering.d.ts +38 -0
  156. package/lib/Renderer/ColorLayersOrdering.js +2 -2
  157. package/lib/Renderer/CommonMaterial.d.ts +6 -0
  158. package/lib/Renderer/Label2DRenderer.d.ts +31 -0
  159. package/lib/Renderer/LayeredMaterial.d.ts +121 -0
  160. package/lib/Renderer/LayeredMaterial.js +221 -141
  161. package/lib/Renderer/OBB.d.ts +65 -0
  162. package/lib/Renderer/OrientedImageCamera.d.ts +36 -0
  163. package/lib/Renderer/OrientedImageMaterial.d.ts +68 -0
  164. package/lib/Renderer/PointsMaterial.d.ts +226 -0
  165. package/lib/Renderer/PointsMaterial.js +60 -22
  166. package/lib/Renderer/RasterTile.d.ts +53 -0
  167. package/lib/Renderer/RasterTile.js +8 -9
  168. package/lib/Renderer/RenderMode.d.ts +11 -0
  169. package/lib/Renderer/RenderMode.js +1 -0
  170. package/lib/Renderer/Shader/ShaderChunk.d.ts +78 -0
  171. package/lib/Renderer/Shader/ShaderUtils.d.ts +5 -0
  172. package/lib/Renderer/WebXR.d.ts +33 -0
  173. package/lib/Renderer/WebXR.js +128 -47
  174. package/lib/Renderer/c3DEngine.d.ts +55 -0
  175. package/lib/Renderer/c3DEngine.js +5 -1
  176. package/lib/Source/C3DTilesGoogleSource.d.ts +38 -0
  177. package/lib/Source/C3DTilesIonSource.d.ts +31 -0
  178. package/lib/Source/C3DTilesSource.d.ts +17 -0
  179. package/lib/Source/CopcSource.d.ts +79 -0
  180. package/lib/Source/EntwinePointTileSource.d.ts +40 -0
  181. package/lib/Source/EntwinePointTileSource.js +0 -5
  182. package/lib/Source/FileSource.d.ts +118 -0
  183. package/lib/Source/OGC3DTilesGoogleSource.d.ts +24 -0
  184. package/lib/Source/OGC3DTilesIonSource.d.ts +26 -0
  185. package/lib/Source/OGC3DTilesSource.d.ts +21 -0
  186. package/lib/Source/OrientedImageSource.d.ts +48 -0
  187. package/lib/Source/Potree2Source.d.ts +157 -0
  188. package/lib/Source/PotreeSource.d.ts +69 -0
  189. package/lib/Source/Source.d.ts +122 -0
  190. package/lib/Source/TMSSource.d.ts +77 -0
  191. package/lib/Source/VectorTilesSource.d.ts +56 -0
  192. package/lib/Source/WFSSource.d.ts +110 -0
  193. package/lib/Source/WMSSource.d.ts +85 -0
  194. package/lib/Source/WMTSSource.d.ts +65 -0
  195. package/lib/ThreeExtended/capabilities/WebGL.d.ts +9 -0
  196. package/lib/ThreeExtended/libs/ktx-parse.module.d.ts +274 -0
  197. package/lib/ThreeExtended/libs/motion-controllers.module.d.ts +64 -0
  198. package/lib/ThreeExtended/libs/motion-controllers.module.js +375 -0
  199. package/lib/ThreeExtended/libs/zstddec.module.d.ts +6 -0
  200. package/lib/ThreeExtended/loaders/DDSLoader.js +40 -1
  201. package/lib/ThreeExtended/loaders/DRACOLoader.d.ts +41 -0
  202. package/lib/ThreeExtended/loaders/GLTFLoader.d.ts +16 -0
  203. package/lib/ThreeExtended/loaders/GLTFLoader.js +22 -3
  204. package/lib/ThreeExtended/loaders/KTX2Loader.d.ts +116 -0
  205. package/lib/ThreeExtended/loaders/KTX2Loader.js +9 -2
  206. package/lib/ThreeExtended/math/ColorSpaces.d.ts +56 -0
  207. package/lib/ThreeExtended/utils/BufferGeometryUtils.d.ts +62 -0
  208. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +2 -2
  209. package/lib/ThreeExtended/utils/WorkerPool.d.ts +19 -0
  210. package/lib/ThreeExtended/webxr/XRControllerModelFactory.d.ts +25 -0
  211. package/lib/ThreeExtended/webxr/XRControllerModelFactory.js +209 -0
  212. package/lib/Utils/CameraUtils.d.ts +132 -0
  213. package/lib/Utils/DEMUtils.d.ts +84 -0
  214. package/lib/Utils/DEMUtils.js +2 -2
  215. package/lib/Utils/FeaturesUtils.d.ts +17 -0
  216. package/lib/Utils/Gradients.d.ts +13 -0
  217. package/lib/Utils/ThreeUtils.d.ts +14 -0
  218. package/lib/Utils/placeObjectOnGround.d.ts +28 -0
  219. package/lib/global.d.js +0 -0
  220. package/package.json +18 -15
@@ -0,0 +1,409 @@
1
+ import * as THREE from 'three';
2
+ import { Coordinates } from '@itowns/geographic';
3
+ import DEMUtils from "../Utils/DEMUtils.js";
4
+ import { XRControllerModelFactory } from "../ThreeExtended/webxr/XRControllerModelFactory.js";
5
+
6
+ /**
7
+ * @property {Array} controllers - WebXR controllers list
8
+ * */
9
+ class VRControls {
10
+ static MIN_DELTA_ALTITUDE = 1.8;
11
+ static MAX_NUMBER_CONTROLLERS = 2; // For now, we are fully supporting a maximum of 2 controllers.
12
+ /**
13
+ * Requires a contextXR variable.
14
+ * @param {*} _view itowns view object
15
+ * @param {*} _groupXR XR 3D object group
16
+ */
17
+ constructor(_view) {
18
+ let _groupXR = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ // Store instance references.
20
+ this.view = _view;
21
+ this.groupXR = _groupXR;
22
+ this.webXRManager = _view.mainLoop.gfxEngine.renderer.xr;
23
+ this.rightButtonPressed = false;
24
+ this.controllers = [];
25
+ this.initControllers();
26
+ }
27
+
28
+ // Static factory method:
29
+ static init(view, vrHeadSet) {
30
+ return new VRControls(view, vrHeadSet);
31
+ }
32
+ initControllers() {
33
+ // Add a light for the controllers
34
+ this.groupXR.add(new THREE.HemisphereLight(0xa5a5a5, 0x898989, 3));
35
+ const controllerModelFactory = new XRControllerModelFactory();
36
+ for (let i = 0; i < VRControls.MAX_NUMBER_CONTROLLERS; i++) {
37
+ const controller = this.webXRManager.getController(i);
38
+ controller.addEventListener('connected', event => {
39
+ controller.name = event.data.handedness; // Left or right
40
+ controller.userData.handedness = event.data.handedness;
41
+ controller.gamepad = event.data.gamepad;
42
+ this.groupXR.add(controller);
43
+ const gripController = this.webXRManager.getControllerGrip(i);
44
+ gripController.name = `${controller.name}GripController`;
45
+ gripController.userData.handedness = event.data.handedness;
46
+ this.bindGripController(controllerModelFactory, gripController, this.groupXR);
47
+ this.controllers.push(controller);
48
+ this.groupXR.add(gripController);
49
+
50
+ // Event listeners
51
+ this.setupEventListeners(controller);
52
+ });
53
+ controller.addEventListener('disconnected', function () {
54
+ this.remove(this.children[0]);
55
+ });
56
+ }
57
+ }
58
+ bindGripController(controllerModelFactory, gripController, vrHeadSet) {
59
+ gripController.add(controllerModelFactory.createControllerModel(gripController));
60
+ vrHeadSet.add(gripController);
61
+ }
62
+
63
+ // Register event listeners for controllers.
64
+ setupEventListeners(controller) {
65
+ controller.addEventListener('itowns-xr-axes-changed', e => this.onAxisChanged(e));
66
+ controller.addEventListener('itowns-xr-axes-stop', e => this.onAxisStop(e));
67
+ controller.addEventListener('itowns-xr-button-pressed', e => this.onButtonPressed(e));
68
+ controller.addEventListener('itowns-xr-button-released', e => this.onButtonReleased(e));
69
+ controller.addEventListener('selectstart', e => this.onSelectStart(e));
70
+ controller.addEventListener('selectend', e => this.onSelectEnd(e));
71
+ }
72
+
73
+ /*
74
+ Listening {XRInputSource} and emit changes for convenience user binding,
75
+ There is NO JOYSTICK Events so we need to check it ourselves
76
+ Adding a few internal states for reactivity
77
+ - controller.isStickActive {boolean} true when a controller stick is not on initial state.
78
+ */
79
+
80
+ listenGamepad() {
81
+ for (const controller of this.controllers) {
82
+ if (!controller.gamepad) {
83
+ return;
84
+ }
85
+ // gamepad.axes = [0, 0, x, y];
86
+
87
+ const gamepad = controller.gamepad;
88
+ const activeValue = gamepad.axes.some(value => value !== 0);
89
+
90
+ // Handle stick activity state
91
+ if (controller.isStickActive && !activeValue && controller.gamepad.endGamePadtrackEmit) {
92
+ controller.dispatchEvent({
93
+ type: 'itowns-xr-axes-stop',
94
+ message: {
95
+ controller
96
+ }
97
+ });
98
+ controller.isStickActive = false;
99
+ return;
100
+ } else if (!controller.isStickActive && activeValue) {
101
+ controller.gamepad.endGamePadtrackEmit = false;
102
+ controller.isStickActive = true;
103
+ } else if (controller.isStickActive && !activeValue) {
104
+ controller.gamepad.endGamePadtrackEmit = true;
105
+ }
106
+ if (activeValue) {
107
+ controller.dispatchEvent({
108
+ type: 'itowns-xr-axes-changed',
109
+ message: {
110
+ controller
111
+ }
112
+ });
113
+ }
114
+ for (const [index, button] of gamepad.buttons.entries()) {
115
+ if (button.pressed) {
116
+ // 0 - trigger
117
+ // 1 - grip
118
+ // 3 - stick pressed
119
+ // 4 - bottom button
120
+ // 5 - upper button
121
+ controller.dispatchEvent({
122
+ type: 'itowns-xr-button-pressed',
123
+ message: {
124
+ controller,
125
+ buttonIndex: index,
126
+ button
127
+ }
128
+ });
129
+ controller.lastButtonItem = button;
130
+ } else if (controller.lastButtonItem && controller.lastButtonItem === button) {
131
+ controller.dispatchEvent({
132
+ type: 'itowns-xr-button-released',
133
+ message: {
134
+ controller,
135
+ buttonIndex: index,
136
+ button
137
+ }
138
+ });
139
+ controller.lastButtonItem = undefined;
140
+ }
141
+ if (button.touched) {
142
+ // triggered really often
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ // Clamp a translation to ground and then apply the transformation.
149
+ clampAndApplyTransformationToXR(trans, offsetRotation) {
150
+ const transClamped = this.clampToGround(trans);
151
+ this.applyTransformationToXR(transClamped, offsetRotation);
152
+ }
153
+
154
+ // Apply a translation and rotation to the XR group.
155
+ applyTransformationToXR(trans, offsetRotation) {
156
+ this.groupXR.position.copy(trans);
157
+ this.groupXR.quaternion.copy(offsetRotation);
158
+ this.groupXR.updateMatrixWorld(true);
159
+ }
160
+
161
+ /**
162
+ * Clamp the given translation vector so that the camera remains at or above ground level.
163
+ * @param {THREE.Vector3} trans - The translation vector.
164
+ * @returns {THREE.Vector3} The clamped coordinates as a Vector3.
165
+ */
166
+ clampToGround(trans) {
167
+ const transCoordinate = new Coordinates(this.view.referenceCrs, trans.x, trans.y, trans.z);
168
+ const terrainElevation = DEMUtils.getElevationValueAt(this.view.tileLayer, transCoordinate, DEMUtils.PRECISE_READ_Z) || 0;
169
+ if (this.view.controls.getCameraCoordinate) {
170
+ const coordsProjected = transCoordinate.as(this.view.controls.getCameraCoordinate().crs);
171
+ if (coordsProjected.altitude - terrainElevation - VRControls.MIN_DELTA_ALTITUDE <= 0) {
172
+ coordsProjected.altitude = terrainElevation + VRControls.MIN_DELTA_ALTITUDE;
173
+ }
174
+ return coordsProjected.as(this.view.referenceCrs).toVector3();
175
+ } else {
176
+ return trans;
177
+ }
178
+ }
179
+
180
+ // Calculate a speed factor based on the camera's altitude.
181
+ getSpeedFactor() {
182
+ const altitude = this.view.controls.getCameraCoordinate ? this.view.controls.getCameraCoordinate().altitude : 1;
183
+ return Math.min(Math.max(altitude / 50, 2), 2000); // TODO: Adjust if needed -> add as a config ?
184
+ }
185
+
186
+ // Calculate a yaw rotation quaternion based on an axis value from the joystick.
187
+ getRotationYaw(axisValue) {
188
+ // Clone the current XR group's orientation.
189
+ const baseOrientation = this.groupXR.quaternion.clone().normalize();
190
+ let deltaRotation = 0;
191
+ if (axisValue) {
192
+ deltaRotation = -Math.PI * axisValue / 140; // Adjust sensitivity as needed.
193
+ }
194
+ // Get the "up" direction from the camera coordinate. // TODO should we handle other than globe ?
195
+ const upAxis = this.groupXR.position.clone().normalize();
196
+ // Create a quaternion representing a yaw rotation about the up axis.
197
+ const yawQuaternion = new THREE.Quaternion().setFromAxisAngle(upAxis, deltaRotation).normalize();
198
+ // Apply the yaw rotation.
199
+ baseOrientation.premultiply(yawQuaternion);
200
+ return baseOrientation;
201
+ }
202
+
203
+ // Calculate a pitch rotation quaternion based on an axis value from the joystick.
204
+ getRotationPitch(axisValue) {
205
+ // Clone the current XR group's orientation.
206
+ const baseOrientation = this.groupXR.quaternion.clone().normalize();
207
+ let deltaRotation = 0;
208
+ if (axisValue) {
209
+ deltaRotation = -Math.PI * axisValue / 140; // Adjust sensitivity as needed.
210
+ }
211
+
212
+ // Compute the right axis from the current orientation.
213
+ // (Assuming (1, 0, 0) is the right direction in local space.)
214
+ const rightAxis = new THREE.Vector3(1, 0, 0).applyQuaternion(baseOrientation).normalize();
215
+
216
+ // Create a quaternion representing a pitch rotation about the right axis.
217
+ const pitchQuaternion = new THREE.Quaternion().setFromAxisAngle(rightAxis, deltaRotation).normalize();
218
+
219
+ // Apply the pitch rotation.
220
+ baseOrientation.premultiply(pitchQuaternion);
221
+ return baseOrientation;
222
+ }
223
+
224
+ // Compute a translation vector for vertical adjustment.
225
+ getTranslationElevation(axisValue, speedFactor) {
226
+ const direction = this.view.camera3D.position.clone().normalize();
227
+ direction.multiplyScalar(-(axisValue * speedFactor));
228
+ return direction;
229
+ }
230
+
231
+ // Handles camera flying based on controller input.
232
+ cameraOnFly(ctrl) {
233
+ let directionX = new THREE.Vector3();
234
+ let directionZ = new THREE.Vector3();
235
+ const speedFactor = this.getSpeedFactor();
236
+ if (ctrl.gamepad.axes[3] !== 0) {
237
+ const speed = ctrl.gamepad.axes[3] * speedFactor;
238
+ directionZ = new THREE.Vector3(0, 0, 1).applyQuaternion(this.view.camera3D.quaternion.clone().normalize()).multiplyScalar(speed);
239
+ }
240
+ if (ctrl.gamepad.axes[2] !== 0) {
241
+ const speed = ctrl.gamepad.axes[2] * speedFactor;
242
+ directionX = new THREE.Vector3(1, 0, 0).applyQuaternion(this.view.camera3D.quaternion.clone().normalize()).multiplyScalar(speed);
243
+ }
244
+ const offsetRotation = this.groupXR.quaternion.clone();
245
+ const trans = this.groupXR.position.clone().add(directionX.add(directionZ));
246
+ // this.applyTransformationToXR(trans, offsetRotation);
247
+ this.clampAndApplyTransformationToXR(trans, offsetRotation);
248
+ }
249
+
250
+ /* =======================
251
+ Event Handler Methods
252
+ ======================= */
253
+
254
+ // Right select ends.
255
+ /* c8 ignore next 3 */
256
+ onSelectRightEnd() {
257
+ // Uncomment and implement teleportation if needed:
258
+ }
259
+
260
+ // Right select starts.
261
+ /* c8 ignore next 3 */
262
+ onSelectRightStart() {
263
+ // No operation needed yet.
264
+ }
265
+
266
+ // Left select starts.
267
+ /* c8 ignore next 3 */
268
+ onSelectLeftStart() {
269
+ // No operation needed yet.
270
+ }
271
+
272
+ // Left select ends.
273
+ /* c8 ignore next 3 */
274
+ onSelectLeftEnd() {
275
+ // No operation needed yet.
276
+ }
277
+ onSelectStart(data) {
278
+ const ctrl = data.target;
279
+ if (ctrl.userData.handedness === 'left') {
280
+ this.onSelectLeftStart(ctrl);
281
+ } else if (ctrl.userData.handedness === 'right') {
282
+ this.onSelectRightStart(ctrl);
283
+ }
284
+ }
285
+ onSelectEnd(data) {
286
+ const ctrl = data.target;
287
+ if (ctrl.userData.handedness === 'left') {
288
+ this.onSelectRightEnd(ctrl);
289
+ } else if (ctrl.userData.handedness === 'right') {
290
+ this.onSelectLeftEnd(ctrl);
291
+ }
292
+ }
293
+ onButtonPressed(data) {
294
+ const ctrl = data.target;
295
+ if (ctrl.userData.handedness === 'left') {
296
+ this.onLeftButtonPressed(data);
297
+ } else if (ctrl.userData.handedness === 'right') {
298
+ this.onRightButtonPressed(data);
299
+ }
300
+ }
301
+
302
+ // Right button pressed.
303
+ onRightButtonPressed(data) {
304
+ const ctrl = data.target;
305
+ if (data.message.buttonIndex === 1) {
306
+ // Activate vertical adjustment.
307
+ if (ctrl.gamepad.axes[3] === 0) {
308
+ return;
309
+ }
310
+ this.rightButtonPressed = true;
311
+ }
312
+ }
313
+
314
+ // Left button pressed.
315
+ /* c8 ignore next 3 */
316
+ onLeftButtonPressed() {
317
+ // No operation defined.
318
+ }
319
+
320
+ // Axis changed.
321
+ onAxisChanged(data) {
322
+ const ctrl = data.target;
323
+ if (ctrl.gamepad.axes[2] === 0 && ctrl.gamepad.axes[3] === 0) {
324
+ return;
325
+ }
326
+ if (ctrl.userData.handedness === 'left') {
327
+ this.onLeftAxisChanged(ctrl);
328
+ } else if (ctrl.userData.handedness === 'right') {
329
+ this.onRightAxisChanged(ctrl);
330
+ }
331
+ }
332
+
333
+ // Right axis changed.
334
+ onRightAxisChanged(ctrl) {
335
+ if (ctrl.userData.handedness !== 'right') {
336
+ return;
337
+ }
338
+ // Check if GRIP is pressed
339
+ if (this.rightButtonPressed) {
340
+ const offsetRotation = this.groupXR.quaternion.clone();
341
+ const speedFactor = this.getSpeedFactor();
342
+ const deltaTransl = this.getTranslationElevation(ctrl.gamepad.axes[3], speedFactor);
343
+ const trans = this.groupXR.position.clone().add(deltaTransl);
344
+ this.clampAndApplyTransformationToXR(trans, offsetRotation);
345
+ } else {
346
+ this.cameraOnFly(ctrl);
347
+ }
348
+ }
349
+
350
+ // Left axis changed.
351
+ onLeftAxisChanged(ctrl) {
352
+ if (ctrl.userData.handedness !== 'left') {
353
+ return;
354
+ }
355
+ const trans = this.groupXR.position.clone();
356
+ let offsetRotation;
357
+
358
+ // Only apply rotation on 1 axis at the time
359
+ if (Math.abs(ctrl.gamepad.axes[2]) > Math.abs(ctrl.gamepad.axes[3])) {
360
+ offsetRotation = this.getRotationYaw(ctrl.gamepad.axes[2]);
361
+ } else {
362
+ offsetRotation = this.getRotationPitch(ctrl.gamepad.axes[3]);
363
+ }
364
+ this.applyTransformationToXR(trans, offsetRotation);
365
+ }
366
+
367
+ // Right axis stops.
368
+ onAxisStop(data) {
369
+ const ctrl = data.target;
370
+ if (ctrl.userData.handedness === 'left') {
371
+ this.onLeftAxisStop(ctrl);
372
+ } else if (ctrl.userData.handedness === 'right') {
373
+ this.onRightAxisStop(ctrl);
374
+ }
375
+ }
376
+
377
+ // Right axis stops.
378
+ /* c8 ignore next 3 */
379
+ onRightAxisStop() {
380
+ // No operation defined.
381
+ }
382
+
383
+ // Left axis stops.
384
+ /* c8 ignore next 3 */
385
+ onLeftAxisStop() {
386
+ // No operation defined.
387
+ }
388
+
389
+ // Button released.
390
+ onButtonReleased(data) {
391
+ const ctrl = data.target;
392
+ if (ctrl.userData.handedness === 'left') {
393
+ this.onLeftButtonReleased(ctrl);
394
+ } else if (ctrl.userData.handedness === 'right') {
395
+ this.onRightButtonReleased(ctrl);
396
+ }
397
+ }
398
+ // Right button released.
399
+ onRightButtonReleased() {
400
+ this.rightButtonPressed = false;
401
+ }
402
+
403
+ // Left button released.
404
+ /* c8 ignore next 3 */
405
+ onLeftButtonReleased() {
406
+ // No operation defined.
407
+ }
408
+ }
409
+ export default VRControls;
@@ -0,0 +1,42 @@
1
+ declare namespace _default {
2
+ /**
3
+ * Return a function that converts [Features]{@link module:GeoJsonParser} to Meshes. Feature collection will be converted to a
4
+ * a THREE.Group.
5
+ *
6
+ * @param {Object} options - options controlling the conversion
7
+ * @param {function} [options.batchId] - optional function to create batchId attribute.
8
+ * It is passed the feature property and the feature index. As the batchId is using an unsigned int structure on 32 bits,
9
+ * the batchId could be between 0 and 4,294,967,295.
10
+ * @param {StyleOptions} [options.style] - optional style properties. Only needed if the convert is used without instancing
11
+ * a layer beforehand.
12
+ * @return {function}
13
+ * @example <caption>Example usage of batchId with featureId.</caption>
14
+ * view.addLayer({
15
+ * id: 'WFS Buildings',
16
+ * type: 'geometry',
17
+ * update: itowns.FeatureProcessing.update,
18
+ * convert: itowns.Feature2Mesh.convert({
19
+ * batchId: (property, featureId) => featureId,
20
+ * }),
21
+ * filter: acceptFeature,
22
+ * source,
23
+ * });
24
+ *
25
+ * @example <caption>Example usage of batchId with property.</caption>
26
+ * view.addLayer({
27
+ * id: 'WFS Buildings',
28
+ * type: 'geometry',
29
+ * update: itowns.FeatureProcessing.update,
30
+ * convert: itowns.Feature2Mesh.convert({
31
+ * batchId: (property, featureId) => property.house ? 10 : featureId,
32
+ * }),
33
+ * filter: acceptFeature,
34
+ * source,
35
+ * });
36
+ */
37
+ function convert(options?: {
38
+ batchId?: Function | undefined;
39
+ style?: any;
40
+ }): Function;
41
+ }
42
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ function createTextureFromFeature(collection: any, extent: any, sizeTexture: any, layerStyle: any, backgroundColor: any): THREE.Texture;
3
+ }
4
+ export default _default;
5
+ import * as THREE from 'three';
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ function convert(requester: any, extent: any, layer: any): Promise<TileMesh>;
3
+ }
4
+ export default _default;
5
+ import TileMesh from '../Core/TileMesh';
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import TileMesh from "../Core/TileMesh.js";
3
- import LayeredMaterial from "../Renderer/LayeredMaterial.js";
3
+ import { LayeredMaterial } from "../Renderer/LayeredMaterial.js";
4
4
  import { newTileGeometry } from "../Core/Prefab/TileBuilder.js";
5
5
  import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
6
6
  import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
@@ -62,7 +62,7 @@ export default {
62
62
  max: parent.obb.z.max,
63
63
  geoidHeight
64
64
  });
65
- tile.material.geoidHeight = geoidHeight;
65
+ tile.material.setUniform('geoidHeight', geoidHeight);
66
66
  }
67
67
  return tile;
68
68
  });
@@ -0,0 +1,4 @@
1
+ declare namespace _default {
2
+ function convert(data: any, destinationTile: any, layer: any): any;
3
+ }
4
+ export default _default;
@@ -0,0 +1,49 @@
1
+ export default C3DTBatchTable;
2
+ /**
3
+ * A 3D Tiles
4
+ * [batch
5
+ * table](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/BatchTable).
6
+ * @property {C3DTilesTypes} type - Used by 3D Tiles extensions
7
+ * (e.g. {@link C3DTBatchTableHierarchyExtension}) to know in which context
8
+ * (i.e. for which 3D Tiles class) the parsing of the extension should be done.
9
+ * @property {number} batchLength - the length of the batch.
10
+ * @property {object} content - the content of the batch table in the form:
11
+ * {property1: values[], property2: values[], ...}.
12
+ * @property {object} extensions - 3D Tiles extensions of the batch table
13
+ * stored in the following format:
14
+ * {extensioName1: extensionObject1, extensioName2: extensionObject2, ...}
15
+ */
16
+ declare class C3DTBatchTable {
17
+ /**
18
+ * @param {ArrayBuffer} [buffer=new ArrayBuffer()] - batch table buffer to parse
19
+ * @param {number} [jsonLength=0] - batch table json part length
20
+ * @param {number} [binaryLength=0] - batch table binary part length
21
+ * @param {number} [batchLength=0] - the length of the batch.
22
+ * @param {Object} [registeredExtensions] - extensions registered to the layer
23
+ */
24
+ constructor(buffer?: ArrayBuffer, jsonLength?: number, binaryLength?: number, batchLength?: number, registeredExtensions?: Object, ...args: any[]);
25
+ type: string;
26
+ batchLength: number;
27
+ extensions: any;
28
+ content: any;
29
+ /**
30
+ * Creates and returns a javascript object holding the displayable
31
+ * information from the batch table and from extensions of the batch table,
32
+ * for a given feature (identified with its batchID).
33
+ * @param {integer} batchID - id of the feature
34
+ * @returns {Object} - displayable information relative to the batch
35
+ * table and its extensions. Object is formatted as follow:
36
+ * {batchTable:
37
+ * {property1: value1
38
+ * property2: value2
39
+ * ...}
40
+ * extensions:
41
+ * {extension1:
42
+ * {property1: value1
43
+ * ...}
44
+ * extension2: {...}
45
+ * ...}
46
+ * }
47
+ */
48
+ getInfoById(batchID: integer): Object;
49
+ }
@@ -0,0 +1,37 @@
1
+ export default C3DTBatchTableHierarchyExtension;
2
+ /**
3
+ * Batch Table part of the 3D Tiles
4
+ * [Batch Table Hierarchy Extension](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/extensions/3DTILES_batch_table_hierarchy)
5
+ * @property {object} classes - The classes as defined in the specification.
6
+ * @property {object} inverseHierarchy - InverseHierarchy contains for each
7
+ * instance (i.e. georgraphic feature e.g. building, roof, etc.) an array of the
8
+ * indexes of its parents. For example, the parents of the instance 0 can be
9
+ * found using inverseHierarchy[0].
10
+ * @property {number[]} instancesIdxs - For each instance of the extension,
11
+ * contains a javascript object with classId and instanceIdx. classId is the id
12
+ * of the class (from this.classes) of the instance. instanceIdx is the index of
13
+ * the instance in this class. Goal: Ease the retrieval of the properties of an
14
+ * instance.
15
+ */
16
+ declare class C3DTBatchTableHierarchyExtension {
17
+ /**
18
+ * Constructor of the C3DTBatchTableHierarchyExtension class.
19
+ * @param {Object} json - The parsed json of the batch table part of the 3D
20
+ * Tiles [Batch Table Hierarchy Extension](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/extensions/3DTILES_batch_table_hierarchy)
21
+ */
22
+ constructor(json: Object);
23
+ classes: any;
24
+ inverseHierarchy: {};
25
+ instancesIdxs: {
26
+ classId: any;
27
+ instanceIdx: any;
28
+ }[];
29
+ /**
30
+ * Creates and returns a javascript object holding the displayable
31
+ * information relative to this extension for a given feature.
32
+ * @param {integer} featureId - id of the feature
33
+ * @returns {Object} - displayable information relative to this
34
+ * extension, for the feature with id=featureId and for its parents
35
+ */
36
+ getInfoById(featureId: integer): Object;
37
+ }
@@ -0,0 +1,39 @@
1
+ export default C3DTBoundingVolume;
2
+ /**
3
+ * [bounding volume](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json)
4
+ * Used to represent bounding volumes and viewer request volumes. The input bounding volume (from the dataset) can be a
5
+ * box, a sphere or a region. Regions are transformed to spheres internally for simplification of parsing and to speed
6
+ * up computations such as culling.
7
+ * @property {C3DTilesTypes} type - Used by 3D Tiles extensions
8
+ * (e.g. {@link C3DTBatchTableHierarchyExtension}) to know in which context
9
+ * (i.e. for which 3D Tiles class) the parsing of the extension should be done.
10
+ * @property {String} initialVolumeType - the initial volume type to be able to dissociate spheres
11
+ * and regions if needed since both are converted to spheres (one of {@link C3DTilesBoundingVolumeTypes})
12
+ * @property {THREE.Box3|THREE.Sphere} volume - The 3D bounding volume created. Can be a THREE.Box3 for bounding volumes
13
+ * of types box or a THREE.Sphere for bounding volumes of type sphere or region.
14
+ * @property {object} extensions - 3D Tiles extensions of the bounding volume
15
+ * stored in the following format:
16
+ * {extensioName1: extensionObject1, extensioName2: extensionObject2, ...}
17
+ */
18
+ declare class C3DTBoundingVolume {
19
+ constructor(json: any, tileMatrixInverse: any, registeredExtensions: any);
20
+ type: string;
21
+ initialVolumeType: string;
22
+ volume: THREE.Box3 | THREE.Sphere;
23
+ extensions: any;
24
+ /**
25
+ * Performs camera frustum culling on bounding volumes.
26
+ * @param {Camera} camera - the camera to perform culling for
27
+ * @param {THREE.Matrix4} tileMatrixWorld - the world matrix of the tile
28
+ * @returns {boolean} true if the tile should be culled out (bounding volume not in camera frustum), false otherwise.
29
+ */
30
+ boundingVolumeCulling(camera: Camera, tileMatrixWorld: THREE.Matrix4): boolean;
31
+ /**
32
+ * Checks if the camera is inside the [viewer request volumes](https://github.com/CesiumGS/3d-tiles/tree/main/specification#viewer-request-volume).
33
+ * @param {Camera} camera - the camera to perform culling for
34
+ * @param {THREE.Matrix4} tileMatrixWorld - the world matrix of the tile
35
+ * @returns {boolean} true if the camera is outside the viewer request volume, false otherwise.
36
+ */
37
+ viewerRequestVolumeCulling(camera: Camera, tileMatrixWorld: THREE.Matrix4): boolean;
38
+ }
39
+ import * as THREE from 'three';