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,375 @@
1
+ /**
2
+ * @webxr-input-profiles/motion-controllers 1.0.0 https://github.com/immersive-web/webxr-input-profiles
3
+ */
4
+
5
+ const Constants = {
6
+ Handedness: Object.freeze({
7
+ NONE: 'none',
8
+ LEFT: 'left',
9
+ RIGHT: 'right'
10
+ }),
11
+ ComponentState: Object.freeze({
12
+ DEFAULT: 'default',
13
+ TOUCHED: 'touched',
14
+ PRESSED: 'pressed'
15
+ }),
16
+ ComponentProperty: Object.freeze({
17
+ BUTTON: 'button',
18
+ X_AXIS: 'xAxis',
19
+ Y_AXIS: 'yAxis',
20
+ STATE: 'state'
21
+ }),
22
+ ComponentType: Object.freeze({
23
+ TRIGGER: 'trigger',
24
+ SQUEEZE: 'squeeze',
25
+ TOUCHPAD: 'touchpad',
26
+ THUMBSTICK: 'thumbstick',
27
+ BUTTON: 'button'
28
+ }),
29
+ ButtonTouchThreshold: 0.05,
30
+ AxisTouchThreshold: 0.1,
31
+ VisualResponseProperty: Object.freeze({
32
+ TRANSFORM: 'transform',
33
+ VISIBILITY: 'visibility'
34
+ })
35
+ };
36
+
37
+ /**
38
+ * @description Static helper function to fetch a JSON file and turn it into a JS object
39
+ * @param {string} path - Path to JSON file to be fetched
40
+ */
41
+ async function fetchJsonFile(path) {
42
+ const response = await fetch(path);
43
+ if (!response.ok) {
44
+ throw new Error(response.statusText);
45
+ } else {
46
+ return response.json();
47
+ }
48
+ }
49
+ async function fetchProfilesList(basePath) {
50
+ if (!basePath) {
51
+ throw new Error('No basePath supplied');
52
+ }
53
+ const profilesList = await fetchJsonFile(`${basePath}/${'profilesList.json'}`);
54
+ return profilesList;
55
+ }
56
+ async function fetchProfile(xrInputSource, basePath) {
57
+ let defaultProfile = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
58
+ let getAssetPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
59
+ if (!xrInputSource) {
60
+ throw new Error('No xrInputSource supplied');
61
+ }
62
+ if (!basePath) {
63
+ throw new Error('No basePath supplied');
64
+ }
65
+
66
+ // Get the list of profiles
67
+ const supportedProfilesList = await fetchProfilesList(basePath);
68
+
69
+ // Find the relative path to the first requested profile that is recognized
70
+ let match;
71
+ xrInputSource.profiles.some(profileId => {
72
+ const supportedProfile = supportedProfilesList[profileId];
73
+ if (supportedProfile) {
74
+ match = {
75
+ profileId,
76
+ profilePath: `${basePath}/${supportedProfile.path}`,
77
+ deprecated: !!supportedProfile.deprecated
78
+ };
79
+ }
80
+ return !!match;
81
+ });
82
+ if (!match) {
83
+ if (!defaultProfile) {
84
+ throw new Error('No matching profile name found');
85
+ }
86
+ const supportedProfile = supportedProfilesList[defaultProfile];
87
+ if (!supportedProfile) {
88
+ throw new Error(`No matching profile name found and default profile "${defaultProfile}" missing.`);
89
+ }
90
+ match = {
91
+ profileId: defaultProfile,
92
+ profilePath: `${basePath}/${supportedProfile.path}`,
93
+ deprecated: !!supportedProfile.deprecated
94
+ };
95
+ }
96
+ const profile = await fetchJsonFile(match.profilePath);
97
+ let assetPath;
98
+ if (getAssetPath) {
99
+ let layout;
100
+ if (xrInputSource.handedness === 'any') {
101
+ layout = profile.layouts[Object.keys(profile.layouts)[0]];
102
+ } else {
103
+ layout = profile.layouts[xrInputSource.handedness];
104
+ }
105
+ if (!layout) {
106
+ throw new Error(`No matching handedness, ${xrInputSource.handedness}, in profile ${match.profileId}`);
107
+ }
108
+ if (layout.assetPath) {
109
+ assetPath = match.profilePath.replace('profile.json', layout.assetPath);
110
+ }
111
+ }
112
+ return {
113
+ profile,
114
+ assetPath
115
+ };
116
+ }
117
+
118
+ /** @constant {Object} */
119
+ const defaultComponentValues = {
120
+ xAxis: 0,
121
+ yAxis: 0,
122
+ button: 0,
123
+ state: Constants.ComponentState.DEFAULT
124
+ };
125
+
126
+ /**
127
+ * @description Converts an X, Y coordinate from the range -1 to 1 (as reported by the Gamepad
128
+ * API) to the range 0 to 1 (for interpolation). Also caps the X, Y values to be bounded within
129
+ * a circle. This ensures that thumbsticks are not animated outside the bounds of their physical
130
+ * range of motion and touchpads do not report touch locations off their physical bounds.
131
+ * @param {number} x The original x coordinate in the range -1 to 1
132
+ * @param {number} y The original y coordinate in the range -1 to 1
133
+ */
134
+ function normalizeAxes() {
135
+ let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
136
+ let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
137
+ let xAxis = x;
138
+ let yAxis = y;
139
+
140
+ // Determine if the point is outside the bounds of the circle
141
+ // and, if so, place it on the edge of the circle
142
+ const hypotenuse = Math.sqrt(x * x + y * y);
143
+ if (hypotenuse > 1) {
144
+ const theta = Math.atan2(y, x);
145
+ xAxis = Math.cos(theta);
146
+ yAxis = Math.sin(theta);
147
+ }
148
+
149
+ // Scale and move the circle so values are in the interpolation range. The circle's origin moves
150
+ // from (0, 0) to (0.5, 0.5). The circle's radius scales from 1 to be 0.5.
151
+ const result = {
152
+ normalizedXAxis: xAxis * 0.5 + 0.5,
153
+ normalizedYAxis: yAxis * 0.5 + 0.5
154
+ };
155
+ return result;
156
+ }
157
+
158
+ /**
159
+ * Contains the description of how the 3D model should visually respond to a specific user input.
160
+ * This is accomplished by initializing the object with the name of a node in the 3D model and
161
+ * property that need to be modified in response to user input, the name of the nodes representing
162
+ * the allowable range of motion, and the name of the input which triggers the change. In response
163
+ * to the named input changing, this object computes the appropriate weighting to use for
164
+ * interpolating between the range of motion nodes.
165
+ */
166
+ class VisualResponse {
167
+ constructor(visualResponseDescription) {
168
+ this.componentProperty = visualResponseDescription.componentProperty;
169
+ this.states = visualResponseDescription.states;
170
+ this.valueNodeName = visualResponseDescription.valueNodeName;
171
+ this.valueNodeProperty = visualResponseDescription.valueNodeProperty;
172
+ if (this.valueNodeProperty === Constants.VisualResponseProperty.TRANSFORM) {
173
+ this.minNodeName = visualResponseDescription.minNodeName;
174
+ this.maxNodeName = visualResponseDescription.maxNodeName;
175
+ }
176
+
177
+ // Initializes the response's current value based on default data
178
+ this.value = 0;
179
+ this.updateFromComponent(defaultComponentValues);
180
+ }
181
+
182
+ /**
183
+ * Computes the visual response's interpolation weight based on component state
184
+ * @param {Object} componentValues - The component from which to update
185
+ * @param {number} xAxis - The reported X axis value of the component
186
+ * @param {number} yAxis - The reported Y axis value of the component
187
+ * @param {number} button - The reported value of the component's button
188
+ * @param {string} state - The component's active state
189
+ */
190
+ updateFromComponent(_ref) {
191
+ let {
192
+ xAxis,
193
+ yAxis,
194
+ button,
195
+ state
196
+ } = _ref;
197
+ const {
198
+ normalizedXAxis,
199
+ normalizedYAxis
200
+ } = normalizeAxes(xAxis, yAxis);
201
+ switch (this.componentProperty) {
202
+ case Constants.ComponentProperty.X_AXIS:
203
+ this.value = this.states.includes(state) ? normalizedXAxis : 0.5;
204
+ break;
205
+ case Constants.ComponentProperty.Y_AXIS:
206
+ this.value = this.states.includes(state) ? normalizedYAxis : 0.5;
207
+ break;
208
+ case Constants.ComponentProperty.BUTTON:
209
+ this.value = this.states.includes(state) ? button : 0;
210
+ break;
211
+ case Constants.ComponentProperty.STATE:
212
+ if (this.valueNodeProperty === Constants.VisualResponseProperty.VISIBILITY) {
213
+ this.value = this.states.includes(state);
214
+ } else {
215
+ this.value = this.states.includes(state) ? 1.0 : 0.0;
216
+ }
217
+ break;
218
+ default:
219
+ throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`);
220
+ }
221
+ }
222
+ }
223
+ class Component {
224
+ /**
225
+ * @param {Object} componentId - Id of the component
226
+ * @param {Object} componentDescription - Description of the component to be created
227
+ */
228
+ constructor(componentId, componentDescription) {
229
+ if (!componentId || !componentDescription || !componentDescription.visualResponses || !componentDescription.gamepadIndices || Object.keys(componentDescription.gamepadIndices).length === 0) {
230
+ throw new Error('Invalid arguments supplied');
231
+ }
232
+ this.id = componentId;
233
+ this.type = componentDescription.type;
234
+ this.rootNodeName = componentDescription.rootNodeName;
235
+ this.touchPointNodeName = componentDescription.touchPointNodeName;
236
+
237
+ // Build all the visual responses for this component
238
+ this.visualResponses = {};
239
+ Object.keys(componentDescription.visualResponses).forEach(responseName => {
240
+ const visualResponse = new VisualResponse(componentDescription.visualResponses[responseName]);
241
+ this.visualResponses[responseName] = visualResponse;
242
+ });
243
+
244
+ // Set default values
245
+ this.gamepadIndices = Object.assign({}, componentDescription.gamepadIndices);
246
+ this.values = {
247
+ state: Constants.ComponentState.DEFAULT,
248
+ button: this.gamepadIndices.button !== undefined ? 0 : undefined,
249
+ xAxis: this.gamepadIndices.xAxis !== undefined ? 0 : undefined,
250
+ yAxis: this.gamepadIndices.yAxis !== undefined ? 0 : undefined
251
+ };
252
+ }
253
+ get data() {
254
+ const data = {
255
+ id: this.id,
256
+ ...this.values
257
+ };
258
+ return data;
259
+ }
260
+
261
+ /**
262
+ * @description Poll for updated data based on current gamepad state
263
+ * @param {Object} gamepad - The gamepad object from which the component data should be polled
264
+ */
265
+ updateFromGamepad(gamepad) {
266
+ // Set the state to default before processing other data sources
267
+ this.values.state = Constants.ComponentState.DEFAULT;
268
+
269
+ // Get and normalize button
270
+ if (this.gamepadIndices.button !== undefined && gamepad.buttons.length > this.gamepadIndices.button) {
271
+ const gamepadButton = gamepad.buttons[this.gamepadIndices.button];
272
+ this.values.button = gamepadButton.value;
273
+ this.values.button = this.values.button < 0 ? 0 : this.values.button;
274
+ this.values.button = this.values.button > 1 ? 1 : this.values.button;
275
+
276
+ // Set the state based on the button
277
+ if (gamepadButton.pressed || this.values.button === 1) {
278
+ this.values.state = Constants.ComponentState.PRESSED;
279
+ } else if (gamepadButton.touched || this.values.button > Constants.ButtonTouchThreshold) {
280
+ this.values.state = Constants.ComponentState.TOUCHED;
281
+ }
282
+ }
283
+
284
+ // Get and normalize x axis value
285
+ if (this.gamepadIndices.xAxis !== undefined && gamepad.axes.length > this.gamepadIndices.xAxis) {
286
+ this.values.xAxis = gamepad.axes[this.gamepadIndices.xAxis];
287
+ this.values.xAxis = this.values.xAxis < -1 ? -1 : this.values.xAxis;
288
+ this.values.xAxis = this.values.xAxis > 1 ? 1 : this.values.xAxis;
289
+
290
+ // If the state is still default, check if the xAxis makes it touched
291
+ if (this.values.state === Constants.ComponentState.DEFAULT && Math.abs(this.values.xAxis) > Constants.AxisTouchThreshold) {
292
+ this.values.state = Constants.ComponentState.TOUCHED;
293
+ }
294
+ }
295
+
296
+ // Get and normalize Y axis value
297
+ if (this.gamepadIndices.yAxis !== undefined && gamepad.axes.length > this.gamepadIndices.yAxis) {
298
+ this.values.yAxis = gamepad.axes[this.gamepadIndices.yAxis];
299
+ this.values.yAxis = this.values.yAxis < -1 ? -1 : this.values.yAxis;
300
+ this.values.yAxis = this.values.yAxis > 1 ? 1 : this.values.yAxis;
301
+
302
+ // If the state is still default, check if the yAxis makes it touched
303
+ if (this.values.state === Constants.ComponentState.DEFAULT && Math.abs(this.values.yAxis) > Constants.AxisTouchThreshold) {
304
+ this.values.state = Constants.ComponentState.TOUCHED;
305
+ }
306
+ }
307
+
308
+ // Update the visual response weights based on the current component data
309
+ Object.values(this.visualResponses).forEach(visualResponse => {
310
+ visualResponse.updateFromComponent(this.values);
311
+ });
312
+ }
313
+ }
314
+
315
+ /**
316
+ * @description Builds a motion controller with components and visual responses based on the
317
+ * supplied profile description. Data is polled from the xrInputSource's gamepad.
318
+ * @author Nell Waliczek / https://github.com/NellWaliczek
319
+ */
320
+ class MotionController {
321
+ /**
322
+ * @param {Object} xrInputSource - The XRInputSource to build the MotionController around
323
+ * @param {Object} profile - The best matched profile description for the supplied xrInputSource
324
+ * @param {Object} assetUrl
325
+ */
326
+ constructor(xrInputSource, profile, assetUrl) {
327
+ if (!xrInputSource) {
328
+ throw new Error('No xrInputSource supplied');
329
+ }
330
+ if (!profile) {
331
+ throw new Error('No profile supplied');
332
+ }
333
+ this.xrInputSource = xrInputSource;
334
+ this.assetUrl = assetUrl;
335
+ this.id = profile.profileId;
336
+
337
+ // Build child components as described in the profile description
338
+ this.layoutDescription = profile.layouts[xrInputSource.handedness];
339
+ this.components = {};
340
+ Object.keys(this.layoutDescription.components).forEach(componentId => {
341
+ const componentDescription = this.layoutDescription.components[componentId];
342
+ this.components[componentId] = new Component(componentId, componentDescription);
343
+ });
344
+
345
+ // Initialize components based on current gamepad state
346
+ this.updateFromGamepad();
347
+ }
348
+ get gripSpace() {
349
+ return this.xrInputSource.gripSpace;
350
+ }
351
+ get targetRaySpace() {
352
+ return this.xrInputSource.targetRaySpace;
353
+ }
354
+
355
+ /**
356
+ * @description Returns a subset of component data for simplified debugging
357
+ */
358
+ get data() {
359
+ const data = [];
360
+ Object.values(this.components).forEach(component => {
361
+ data.push(component.data);
362
+ });
363
+ return data;
364
+ }
365
+
366
+ /**
367
+ * @description Poll for updated data based on current gamepad state
368
+ */
369
+ updateFromGamepad() {
370
+ Object.values(this.components).forEach(component => {
371
+ component.updateFromGamepad(this.xrInputSource.gamepad);
372
+ });
373
+ }
374
+ }
375
+ export { Constants, MotionController, fetchProfile, fetchProfilesList };
@@ -0,0 +1,6 @@
1
+ export { Q as ZSTDDecoder };
2
+ declare class Q {
3
+ init(): any;
4
+ _init(A: any): void;
5
+ decode(A: any, g?: number): any;
6
+ }
@@ -74,6 +74,32 @@ class DDSLoader extends CompressedTextureLoader {
74
74
  }
75
75
  return byteArray;
76
76
  }
77
+ function loadRGBMip(buffer, dataOffset, width, height) {
78
+ const dataLength = width * height * 3;
79
+ const srcBuffer = new Uint8Array(buffer, dataOffset, dataLength);
80
+ const byteArray = new Uint8Array(width * height * 4);
81
+ let dst = 0;
82
+ let src = 0;
83
+ for (let y = 0; y < height; y++) {
84
+ for (let x = 0; x < width; x++) {
85
+ const b = srcBuffer[src];
86
+ src++;
87
+ const g = srcBuffer[src];
88
+ src++;
89
+ const r = srcBuffer[src];
90
+ src++;
91
+ byteArray[dst] = r;
92
+ dst++; //r
93
+ byteArray[dst] = g;
94
+ dst++; //g
95
+ byteArray[dst] = b;
96
+ dst++; //b
97
+ byteArray[dst] = 255;
98
+ dst++; //a
99
+ }
100
+ }
101
+ return byteArray;
102
+ }
77
103
  const FOURCC_DXT1 = fourCCToInt32('DXT1');
78
104
  const FOURCC_DXT3 = fourCCToInt32('DXT3');
79
105
  const FOURCC_DXT5 = fourCCToInt32('DXT5');
@@ -86,6 +112,11 @@ class DDSLoader extends CompressedTextureLoader {
86
112
 
87
113
  // const off_pfFlags = 20;
88
114
 
115
+ const off_RGBBitCount = 22;
116
+ const off_RBitMask = 23;
117
+ const off_GBitMask = 24;
118
+ const off_BBitMask = 25;
119
+
89
120
  // const off_caps = 27;
90
121
 
91
122
  // const off_caps3 = 29;
@@ -103,6 +134,7 @@ class DDSLoader extends CompressedTextureLoader {
103
134
  let blockBytes;
104
135
  const fourCC = header[21];
105
136
  let isRGBAUncompressed = false;
137
+ let isRGBUncompressed = false;
106
138
  let dataOffset = header[1] + 4;
107
139
  switch (fourCC) {
108
140
  case FOURCC_DXT1:
@@ -146,10 +178,14 @@ class DDSLoader extends CompressedTextureLoader {
146
178
  }
147
179
  break;
148
180
  default:
149
- if (header[22] === 32 && header[23] & 0xff0000 && header[24] & 0xff00 && header[25] & 0xff && header[26] & 0xff000000) {
181
+ if (header[off_RGBBitCount] === 32 && header[off_RBitMask] & 0xff0000 && header[off_GBitMask] & 0xff00 && header[off_BBitMask] & 0xff && header[26] & 0xff000000) {
150
182
  isRGBAUncompressed = true;
151
183
  blockBytes = 64;
152
184
  dds.format = RGBAFormat;
185
+ } else if (header[off_RGBBitCount] === 24 && header[off_RBitMask] & 0xff0000 && header[off_GBitMask] & 0xff00 && header[off_BBitMask] & 0xff) {
186
+ isRGBUncompressed = true;
187
+ blockBytes = 64;
188
+ dds.format = RGBAFormat;
153
189
  } else {
154
190
  console.error('THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC(fourCC));
155
191
  return dds;
@@ -179,6 +215,9 @@ class DDSLoader extends CompressedTextureLoader {
179
215
  if (isRGBAUncompressed) {
180
216
  byteArray = loadARGBMip(buffer, dataOffset, width, height);
181
217
  dataLength = byteArray.length;
218
+ } else if (isRGBUncompressed) {
219
+ byteArray = loadRGBMip(buffer, dataOffset, width, height);
220
+ dataLength = width * height * 3;
182
221
  } else {
183
222
  dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
184
223
  byteArray = new Uint8Array(buffer, dataOffset, dataLength);
@@ -0,0 +1,41 @@
1
+ export class DRACOLoader extends Loader<any, string> {
2
+ constructor(manager: any);
3
+ decoderPath: string;
4
+ decoderConfig: {};
5
+ decoderBinary: any;
6
+ decoderPending: Promise<void> | null;
7
+ workerLimit: number;
8
+ workerPool: any[];
9
+ workerNextTaskID: number;
10
+ workerSourceURL: string;
11
+ defaultAttributeIDs: {
12
+ position: string;
13
+ normal: string;
14
+ color: string;
15
+ uv: string;
16
+ };
17
+ defaultAttributeTypes: {
18
+ position: string;
19
+ normal: string;
20
+ color: string;
21
+ uv: string;
22
+ };
23
+ setDecoderPath(path: any): this;
24
+ setDecoderConfig(config: any): this;
25
+ setWorkerLimit(workerLimit: any): this;
26
+ load(url: any, onLoad: any, onProgress: any, onError: any): void;
27
+ parse(buffer: any, onLoad: any, onError?: () => void): void;
28
+ decodeDracoFile(buffer: any, callback: any, attributeIDs: any, attributeTypes: any, vertexColorSpace?: "srgb-linear", onError?: () => void): any;
29
+ decodeGeometry(buffer: any, taskConfig: any): any;
30
+ _createGeometry(geometryData: any): BufferGeometry<import("three").NormalBufferAttributes>;
31
+ _assignVertexColorSpace(attribute: any, inputColorSpace: any): void;
32
+ _loadLibrary(url: any, responseType: any): Promise<any>;
33
+ preload(): this;
34
+ _initDecoder(): Promise<void>;
35
+ _getWorker(taskID: any, taskCost: any): Promise<any>;
36
+ _releaseTask(worker: any, taskID: any): void;
37
+ debug(): void;
38
+ dispose(): this;
39
+ }
40
+ import { Loader } from 'three';
41
+ import { BufferGeometry } from 'three';
@@ -0,0 +1,16 @@
1
+ export class GLTFLoader extends Loader<any, string> {
2
+ constructor(manager: any);
3
+ dracoLoader: any;
4
+ ktx2Loader: any;
5
+ meshoptDecoder: any;
6
+ pluginCallbacks: any[];
7
+ load(url: any, onLoad: any, onProgress: any, onError: any): void;
8
+ setDRACOLoader(dracoLoader: any): this;
9
+ setKTX2Loader(ktx2Loader: any): this;
10
+ setMeshoptDecoder(meshoptDecoder: any): this;
11
+ register(callback: any): this;
12
+ unregister(callback: any): this;
13
+ parse(data: any, path: any, onLoad: any, onError: any): void;
14
+ parseAsync(data: any, path: any): Promise<any>;
15
+ }
16
+ import { Loader } from 'three';
@@ -329,7 +329,6 @@ class GLTFLightsExtension {
329
329
  // Some lights (e.g. spot) default to a position other than the origin. Reset the position
330
330
  // here, because node-level parsing will only override position if explicitly specified.
331
331
  lightNode.position.set(0, 0, 0);
332
- lightNode.decay = 2;
333
332
  assignExtrasToUserData(lightNode, lightDef);
334
333
  if (lightDef.intensity !== undefined) lightNode.intensity = lightDef.intensity;
335
334
  lightNode.name = parser.createUniqueName(lightDef.name || 'light_' + lightIndex);
@@ -1353,6 +1352,9 @@ const ALPHA_MODES = {
1353
1352
 
1354
1353
  /**
1355
1354
  * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
1355
+ *
1356
+ * @param {Object<string, Material>} cache
1357
+ * @return {Material}
1356
1358
  */
1357
1359
  function createDefaultMaterial(cache) {
1358
1360
  if (cache['DefaultMaterial'] === undefined) {
@@ -1677,6 +1679,9 @@ class GLTFParser {
1677
1679
  * Textures) can be reused directly and are not marked here.
1678
1680
  *
1679
1681
  * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
1682
+ *
1683
+ * @param {Object} cache
1684
+ * @param {Object3D} index
1680
1685
  */
1681
1686
  _addNodeRef(cache, index) {
1682
1687
  if (index === undefined) return;
@@ -1686,7 +1691,14 @@ class GLTFParser {
1686
1691
  cache.refs[index]++;
1687
1692
  }
1688
1693
 
1689
- /** Returns a reference to a shared resource, cloning it if necessary. */
1694
+ /**
1695
+ * Returns a reference to a shared resource, cloning it if necessary.
1696
+ *
1697
+ * @param {Object} cache
1698
+ * @param {number} index
1699
+ * @param {Object} object
1700
+ * @return {Object}
1701
+ */
1690
1702
  _getNodeRef(cache, index, object) {
1691
1703
  if (cache.refs[index] <= 1) return object;
1692
1704
  const ref = object.clone();
@@ -2050,9 +2062,11 @@ class GLTFParser {
2050
2062
 
2051
2063
  /**
2052
2064
  * Asynchronously assigns a texture to the given material parameters.
2065
+ *
2053
2066
  * @param {Object} materialParams
2054
2067
  * @param {string} mapName
2055
2068
  * @param {Object} mapDef
2069
+ * @param {string} colorSpace
2056
2070
  * @return {Promise<Texture>}
2057
2071
  */
2058
2072
  assignTexture(materialParams, mapName, mapDef, colorSpace) {
@@ -2241,7 +2255,12 @@ class GLTFParser {
2241
2255
  });
2242
2256
  }
2243
2257
 
2244
- /** When Object3D instances are targeted by animation, they need unique names. */
2258
+ /**
2259
+ * When Object3D instances are targeted by animation, they need unique names.
2260
+ *
2261
+ * @param {string} originalName
2262
+ * @return {string}
2263
+ */
2245
2264
  createUniqueName(originalName) {
2246
2265
  const sanitizedName = PropertyBinding.sanitizeNodeName(originalName || '');
2247
2266
  if (sanitizedName in this.nodeNamesUsed) {