itowns 2.44.3-next.40 → 2.44.3-next.41

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,97 +0,0 @@
1
- /**
2
- * Class for managing
3
- * [3D Tiles extensions](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/extensions).
4
- * Extensions used in a 3D Tiles tileset must be registered in the iTowns' layer
5
- * holding the tileset by the user with the {@link registerExtension}
6
- * method. The extension must be registered together with a class holding the
7
- * code to interpret the extension.
8
- * An example of extension class is {@link C3DTBatchTableHierarchyExtension}.
9
- * This extension has only one part situated in the batch table (but other
10
- * extensions can have multiple parts, stored in different 3D Tiles classes
11
- * such as tileset or bounding volume).
12
- * @example
13
- * // Create a C3DTExtensions object
14
- * const extensions = new itowns.C3DTExtensions();
15
- * // Register an extension to it named "3DTILES_batch_table_hierarchy" and
16
- * // a class itowns.C3DTBatchTableHierarchyExtension to the batch table part
17
- * // (with [itowns.C3DTilesTypes.batchtable]). see {@link C3DTilesTypes}
18
- * extensions.registerExtension("3DTILES_batch_table_hierarchy",
19
- * { [itowns.C3DTilesTypes.batchtable]: itowns.C3DTBatchTableHierarchyExtension });
20
- *
21
- * // Create a 3D Tiles layer with registered extensions
22
- * var $3dTilesLayerBTHierarchy = new itowns.C3DTilesLayer('3d-tiles-bt-hierarchy', {
23
- * name: 'BTHierarchy',
24
- * source: new itowns.C3DTilesSource({
25
- * url: 'https://raw.githubusercontent.com/AnalyticalGraphicsInc/cesium/master/Apps/SampleData/Cesium3DTiles/Hierarchy/BatchTableHierarchy/tileset.json',
26
- * }),
27
- * registeredExtensions: extensions,
28
- * },
29
- * view);
30
- */
31
-
32
- class C3DTExtensions {
33
- /**
34
- * Register a 3D Tiles extension: Maps an extension name to the
35
- * extensionsManagers (i.e. one class per 3D Tiles class (e.g.
36
- * batch table or bounding volume).
37
- * @param {string} extensionName - Name of the extension
38
- * @param {object} extensionManagers - An object mapping 3D Tiles
39
- * classes names (see @link{C3DTilesTypes} to the extension managers
40
- * corresponding to this class. These extension managers should be able
41
- * to parse the extension fragment (done in the constructor) and should
42
- * have a getInfoById method if they are related to the batch table class.
43
- * See {@link C3DTBatchTableHierarchyExtension} for an example of
44
- * extension class.
45
- */
46
- registerExtension(extensionName, extensionManagers) {
47
- this[extensionName] = extensionManagers;
48
- }
49
-
50
- /**
51
- * Get an extension manager from its name and C3DTilesType
52
- * @param {string} extensionName - name of the extension.
53
- * @param {C3DTilesTypes} type - type of 3DTiles class (e.g. batch
54
- * table, bounding volume, tileset, etc.)
55
- * @returns {object} - the extension manager corresponding to the
56
- * extensioNname and type.
57
- */
58
- getExtension(extensionName, type) {
59
- if (this[extensionName] && this[extensionName][type]) {
60
- return this[extensionName][type];
61
- } else {
62
- console.error(`${'No extension manager registered for' + ' extension '} ${extensionName} and for class ${type}`);
63
- }
64
- }
65
-
66
- /**
67
- * Test if an extension is registered
68
- * @param {string} extensionName - Name of the extension
69
- * @returns {boolean} - true if the extension is registered and false
70
- * otherwise.
71
- */
72
- isExtensionRegistered(extensionName) {
73
- return this[extensionName];
74
- }
75
-
76
- /**
77
- * Parses the extensions from a given JSON (extensionsJSON) by
78
- * instanciating the right class from the registered extensions.
79
- * @param {object} extensionsJSON - the JSON to parse extensions from.
80
- * @param {C3DTilesTypes} type - type of class asking for extensions parsing
81
- * has been called. For instance, if {@link C3DTBatchTable} needs to
82
- * parse its extensions, it will call parseExtension with the JSON to
83
- * parse and C3DTilesTypes.batchtable as type.
84
- * @returns {object} - An object with keys being the names of the
85
- * extensions and values the instances of the extensions managers.
86
- */
87
- parseExtensions(extensionsJSON, type) {
88
- const parsedExtensions = {};
89
- for (const extName in extensionsJSON) {
90
- if (Object.prototype.hasOwnProperty.call(extensionsJSON, extName)) {
91
- parsedExtensions[extName] = new (this.getExtension(extName, type))(extensionsJSON[extName]);
92
- }
93
- }
94
- return parsedExtensions;
95
- }
96
- }
97
- export default C3DTExtensions;
@@ -1,110 +0,0 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import { Object3D, Box3 } from 'three';
3
-
4
- /**
5
- * Finds the batch table of an object in a 3D Tiles layer. This is
6
- * for instance needed when picking because we pick the geometric
7
- * object which is not at the same level in the layer structure as
8
- * the batch table.
9
- * @param {THREE.Object3D} object - a 3D geometric object
10
- * @returns {C3DTBatchTable|null} - the batch table of the object
11
- */
12
- function findBatchTable(object) {
13
- if (object.batchTable) {
14
- return object.batchTable;
15
- }
16
- if (object.parent) {
17
- return findBatchTable(object.parent);
18
- }
19
- return null;
20
- }
21
-
22
- /**
23
- * C3DTFeature is a feature of a 3DTiles
24
- *
25
- * @class C3DTFeature
26
- * @param {number} tileId - tileId
27
- * @param {number} batchId - batch id
28
- * @param {Array<{start:number,count:number}>} groups - groups in geometry.attributes matching batchId
29
- * @param {object} [userData] - some userData
30
- * @param {Object3D} object3d - object3d in which feature is present
31
- * @property {number} tileId - tile id
32
- * @property {Object3D} object3d - object3d in which feature is present
33
- * @property {number} batchId - batch id
34
- * @property {Array<{start:number,count:number}>} groups - groups in geometry.attributes matching batchId
35
- * @property {object} [userData] - some userData
36
- */
37
- class C3DTFeature {
38
- #info;
39
- constructor(tileId, batchId, groups, userData, object3d) {
40
- /** @type {Object3D} */
41
- this.object3d = object3d;
42
-
43
- /** @type {number} */
44
- this.batchId = batchId;
45
-
46
- /** @type {Array<{start:number,count:number}>} */
47
- this.groups = groups;
48
-
49
- /** @type {object} */
50
- this.userData = userData;
51
-
52
- /** @type {number} */
53
- this.tileId = tileId;
54
-
55
- // Lazy-loaded batch table information for this.batchId.
56
- this.#info = null;
57
- }
58
-
59
- /**
60
- * Compute world box3 of this
61
- *
62
- * @param {Box3} target - target of the result
63
- * @returns {Box3}
64
- */
65
- computeWorldBox3() {
66
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Box3();
67
- // reset
68
- target.max.x = -Infinity;
69
- target.max.y = -Infinity;
70
- target.max.z = -Infinity;
71
- target.min.x = Infinity;
72
- target.min.y = Infinity;
73
- target.min.z = Infinity;
74
- this.groups.forEach(group => {
75
- const positionIndexStart = group.start * this.object3d.geometry.attributes.position.itemSize;
76
- const positionIndexCount = (group.start + group.count) * this.object3d.geometry.attributes.position.itemSize;
77
- for (let index = positionIndexStart; index < positionIndexCount; index++) {
78
- const x = this.object3d.geometry.attributes.position.getX(index);
79
- const y = this.object3d.geometry.attributes.position.getY(index);
80
- const z = this.object3d.geometry.attributes.position.getZ(index);
81
- target.max.x = Math.max(x, target.max.x);
82
- target.max.y = Math.max(y, target.max.y);
83
- target.max.z = Math.max(z, target.max.z);
84
- target.min.x = Math.min(x, target.min.x);
85
- target.min.y = Math.min(y, target.min.y);
86
- target.min.z = Math.min(z, target.min.z);
87
- }
88
- });
89
- target.applyMatrix4(this.object3d.matrixWorld);
90
- return target;
91
- }
92
-
93
- /**
94
- * Gets the information from the tile batch table for this C3DTFeature batch id.
95
- * @returns {object} - batchTable info
96
- */
97
- getInfo() {
98
- if (this.#info) {
99
- return this.#info;
100
- }
101
- const batchTable = findBatchTable(this.object3d);
102
- if (!batchTable) {
103
- console.warn(`[C3DTFeature]: No batch table found for tile ${this.tileId}.`);
104
- return null; // or return undefined;
105
- }
106
- this.#info = batchTable.getInfoById(this.batchId);
107
- return this.#info;
108
- }
109
- }
110
- export default C3DTFeature;
@@ -1,20 +0,0 @@
1
- /**
2
- * Enumeration of implemented 3D Tiles classes. Used in C3DTExtensions to
3
- * now which classes ask for extension parsing.
4
- *
5
- * @enum {Object} C3DTilesTypes
6
- *
7
- * @property {String} tileset - value: 'tileset'
8
- * @property {String} batchtable - value: 'batchtable'
9
- * @property {String} boundingVolume - value: 'bounding volume'
10
- */
11
- export const C3DTilesTypes = {
12
- tileset: 'tileset',
13
- batchtable: 'batchtable',
14
- boundingVolume: 'boundingVolume'
15
- };
16
- export const C3DTilesBoundingVolumeTypes = {
17
- region: 'region',
18
- box: 'box',
19
- sphere: 'sphere'
20
- };
@@ -1,99 +0,0 @@
1
- import * as THREE from 'three';
2
- import C3DTBoundingVolume from "./C3DTBoundingVolume.js";
3
- import { C3DTilesTypes } from "./C3DTilesEnums.js";
4
-
5
- // Inverse transform of a tile, computed from the tile transform and used when parsing the bounding volume of a tile
6
- // if the bounding volume is a region (https://github.com/CesiumGS/3d-tiles/tree/main/specification#region) which is
7
- // in global coordinates and other bounding volumes are not. To harmonize, we transform back the bounding volume region
8
- // to a reference local to the tile.
9
- const tileMatrixInverse = new THREE.Matrix4();
10
-
11
- /**
12
- * A 3D Tiles
13
- * [Tileset](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/tileset.schema.json).
14
- * @property {C3DTilesTypes} type - Used by 3D Tiles extensions
15
- * (e.g. {@link C3DTBatchTableHierarchyExtension}) to know in which context
16
- * (i.e. for which 3D Tiles class) the parsing of the extension should be done.
17
- * @property {object} asset - Generic information about the tileset, see
18
- * [asset specification]https://github.com/CesiumGS/3d-tiles/blob/master/specification/schema/asset.schema.json
19
- * @property {object} properties - Properties associated with the tileset, see
20
- * [tileset specification](https://github.com/CesiumGS/3d-tiles/blob/master/specification/schema/tileset.schema.json#L11)
21
- * @property {number} geometricError - see [tileset
22
- * specification](https://github.com/CesiumGS/3d-tiles/blob/master/specification/schema/tileset.schema.json#L18)
23
- * @property {string[]} extensionsUsed - see [tileset
24
- * specification](https://github.com/CesiumGS/3d-tiles/blob/master/specification/schema/tileset.schema.json#L27)
25
- * @property {array} extensionsRequired - see [tileset specification](https://github.com/CesiumGS/3d-tiles/blob/master/specification/schema/tileset.schema.json#L36)
26
- * @property {object[]} tiles - an array holding all the
27
- * [tiles](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/tile.schema.json)
28
- * (not their content which is stored in the attribute object3d of the
29
- * layer). This list represents a flattened tileset.
30
- * @property {object} extensions - Extensions of the tileset in the form:
31
- * {extensioName1: extensionObject1, extensioName2: extensionObject2, ...}
32
- */
33
- class C3DTileset {
34
- constructor(json, baseURL, registeredExtensions) {
35
- this.type = C3DTilesTypes.tileset;
36
- this.asset = json.asset;
37
- this.properties = json.properties;
38
- this.geometricError = json.geometricError;
39
- this.extensionsUsed = json.extensionsUsed;
40
- this.extensionsRequired = json.extensionsRequired;
41
- this.tiles = [];
42
- this.parseTiles(json.root, baseURL, undefined, registeredExtensions);
43
- if (json.extensions) {
44
- this.extensions = registeredExtensions.parseExtensions(json.extensions, this.type);
45
- }
46
- }
47
-
48
- /**
49
- * Recursion on the 3DTiles tileset (which is a tree) to parse the tiles
50
- * (nodes of the tree).
51
- * @param {object} tile - current tile
52
- * @param {string} baseURL - url of the source tileset and tiles
53
- * @param {object} parent - parent tile (used for computing the transform
54
- * matrix from local to global coordinates)
55
- * @param {object} registeredExtensions - 3D Tiles extensions registered
56
- * in the C3DTilesLayer (see {@link C3DTExtensions}
57
- */
58
- parseTiles(tile, baseURL, parent, registeredExtensions) {
59
- // compute transform (will become Object3D.matrix when the object is
60
- // downloaded)
61
- tile.transform = tile.transform ? new THREE.Matrix4().fromArray(tile.transform) : undefined;
62
-
63
- // The only reason to store _worldFromLocalTransform is because of
64
- // extendTileset where we need the transform chain for one tile.
65
- tile._worldFromLocalTransform = tile.transform;
66
- if (parent && parent._worldFromLocalTransform) {
67
- if (tile.transform) {
68
- tile._worldFromLocalTransform = new THREE.Matrix4().multiplyMatrices(parent._worldFromLocalTransform, tile.transform);
69
- } else {
70
- tile._worldFromLocalTransform = parent._worldFromLocalTransform;
71
- }
72
- }
73
-
74
- // tileMatrixInverse is only used for volume.region
75
- if (tile.viewerRequestVolume && tile.viewerRequestVolume.region || tile.boundingVolume && tile.boundingVolume.region) {
76
- if (tile._worldFromLocalTransform) {
77
- tileMatrixInverse.copy(tile._worldFromLocalTransform).invert();
78
- } else {
79
- tileMatrixInverse.identity();
80
- }
81
- }
82
- tile.viewerRequestVolume = tile.viewerRequestVolume ? new C3DTBoundingVolume(tile.viewerRequestVolume, tileMatrixInverse, registeredExtensions) : null;
83
- tile.boundingVolume = tile.boundingVolume ? new C3DTBoundingVolume(tile.boundingVolume, tileMatrixInverse, registeredExtensions) : null;
84
- this.tiles.push(tile);
85
- tile.tileId = this.tiles.length - 1;
86
- tile.baseURL = baseURL;
87
- if (tile.children) {
88
- for (const child of tile.children) {
89
- this.parseTiles(child, baseURL, tile, registeredExtensions);
90
- }
91
- }
92
- }
93
- extendTileset(tileset, nodeId, baseURL, registeredExtensions) {
94
- this.parseTiles(tileset.root, baseURL, this.tiles[nodeId], registeredExtensions);
95
- this.tiles[nodeId].children = [tileset.root];
96
- this.tiles[nodeId].isTileset = true;
97
- }
98
- }
99
- export default C3DTileset;
@@ -1,100 +0,0 @@
1
- import { Vector2, Vector3, Vector4 } from 'three';
2
-
3
- /**
4
- * @enum {Object} componentTypeBytesSize - Size in byte of a component type.
5
- */
6
- const componentTypeBytesSize = {
7
- BYTE: 1,
8
- UNSIGNED_BYTE: 1,
9
- SHORT: 2,
10
- UNSIGNED_SHORT: 2,
11
- INT: 4,
12
- UNSIGNED_INT: 4,
13
- FLOAT: 4,
14
- DOUBLE: 8
15
- };
16
-
17
- /**
18
- * @enum {Object} componentTypeConstructor - TypedArray constructor for each 3D Tiles binary componentType
19
- */
20
- const componentTypeConstructor = {
21
- BYTE: Int8Array,
22
- UNSIGNED_BYTE: Uint8Array,
23
- SHORT: Int16Array,
24
- UNSIGNED_SHORT: Uint16Array,
25
- INT: Int32Array,
26
- UNSIGNED_INT: Uint32Array,
27
- FLOAT: Float32Array,
28
- DOUBLE: Float64Array
29
- };
30
-
31
- /**
32
- * @enum {Object} typeComponentsNumber - Number of components for a given type.
33
- */
34
- const typeComponentsNumber = {
35
- SCALAR: 1,
36
- VEC2: 2,
37
- VEC3: 3,
38
- VEC4: 4
39
- };
40
-
41
- /**
42
- * @enum {Object} typeConstructor - constructor for types (only for vectors since scalar will be converted to a single
43
- * value)
44
- */
45
- const typeConstructor = {
46
- // SCALAR: no constructor, just create a value (int, float, etc. depending on componentType)
47
- VEC2: Vector2,
48
- VEC3: Vector3,
49
- VEC4: Vector4
50
- };
51
-
52
- /**
53
- * Parses a 3D Tiles binary property. Used for batch table and feature table parsing. See the 3D Tiles spec for more
54
- * information on how these values are encoded:
55
- * [3D Tiles spec](https://github.com/CesiumGS/3d-tiles/blob/main/specification/TileFormats/BatchTable/README.md#binary-body))
56
- * @param {ArrayBuffer} buffer The buffer to parse values from.
57
- * @param {Number} batchLength number of objects in the batch (= number of elements to parse).
58
- * @param {Number} byteOffset the offset in bytes into the buffer.
59
- * @param {String} componentType the type of component to parse (one of componentTypeBytesSize keys)
60
- * @param {String} type the type of element to parse (one of typeComponentsNumber keys)
61
- * @returns {Array} an array of values parsed from the buffer. An array of componentType if type is SCALAR. An array
62
- * of Threejs Vector2, Vector3 or Vector4 if type is VEC2, VEC3 or VEC4 respectively.
63
- */
64
- function binaryPropertyAccessor(buffer, batchLength, byteOffset, componentType, type) {
65
- if (!buffer) {
66
- throw new Error('Buffer is mandatory to parse binary property.');
67
- }
68
- if (typeof batchLength === 'undefined' || batchLength === null) {
69
- throw new Error('batchLength is mandatory to parse binary property.');
70
- }
71
- if (typeof byteOffset === 'undefined' || byteOffset === null) {
72
- throw new Error('byteOffset is mandatory to parse binary property.');
73
- }
74
- if (!componentTypeBytesSize[componentType]) {
75
- throw new Error(`Uknown component type: ${componentType}. Cannot access binary property.`);
76
- }
77
- if (!typeComponentsNumber[type]) {
78
- throw new Error(`Uknown type: ${type}. Cannot access binary property.`);
79
- }
80
- const typeNb = typeComponentsNumber[type];
81
- // Number of elements to parse in the buffer
82
-
83
- const typedArray = new componentTypeConstructor[componentType](buffer, byteOffset, batchLength * typeNb);
84
- if (type === 'SCALAR') {
85
- return Array.from(typedArray);
86
- } else {
87
- // return an array of threejs vectors, depending on type (see typeConstructor)
88
- const array = [];
89
- // iteration step of 2, 3 or 4, depending on the type (VEC2, VEC3 or VEC4)
90
- for (let i = 0; i <= typedArray.length - typeNb; i += typeNb) {
91
- const vector = new typeConstructor[type]();
92
- // Create a vector from an array, starting at the offset i and takes the right number of elements depending
93
- // on its type (Vector2, Vector3, Vector 4)
94
- vector.fromArray(typedArray, i);
95
- array.push(vector);
96
- }
97
- return array;
98
- }
99
- }
100
- export default binaryPropertyAccessor;
@@ -1,142 +0,0 @@
1
- import * as THREE from 'three';
2
- const FRAMERATE = 60;
3
- const FRAME_DURATION = 1000 / FRAMERATE;
4
-
5
- // player statut
6
- const PLAYER_STATE = {
7
- // player is stopped
8
- STOP: 0,
9
- // player plays animation
10
- PLAY: 1,
11
- // player is at the end of an animation
12
- END: 2,
13
- // player is paused
14
- PAUSE: 3
15
- };
16
-
17
- // Private functions
18
- // stop timer and re-init parameter
19
- const resetTimer = function (player) {
20
- if (player.id) {
21
- clearInterval(player.id);
22
- player.id = undefined;
23
- }
24
- if (player.waitTimer) {
25
- clearInterval(player.waitTimer);
26
- player.waitTimer = undefined;
27
- }
28
- player.keyframe = 0;
29
- };
30
-
31
- // finish animation and re-init parameter
32
- const finishAnimation = function (player) {
33
- resetTimer(player);
34
- if (player.isEnded()) {
35
- player.dispatchEvent({
36
- type: 'animation-ended'
37
- });
38
- }
39
- player.dispatchEvent({
40
- type: 'animation-stopped'
41
- });
42
- player.duration = 0;
43
- };
44
-
45
- /**
46
- * It can play, pause or stop Animation or AnimationExpression (See below).
47
- * AnimationPlayer is needed to use Animation or AnimationExpression
48
- * AnimationPlayer emits events :
49
- * - for each animation's frame;
50
- * - when Animation is stopped
51
- * - when Animation is ending
52
- */
53
- class AnimationPlayer extends THREE.EventDispatcher {
54
- constructor() {
55
- super();
56
- this.id = null;
57
- this.keyframe = 0;
58
- this.duration = 0;
59
- this.state = PLAYER_STATE.STOP;
60
- this.waitTimer = null;
61
- this.callback = () => {};
62
- }
63
- isPlaying() {
64
- return this.state === PLAYER_STATE.PLAY;
65
- }
66
- isStopped() {
67
- return this.state === PLAYER_STATE.STOP;
68
- }
69
- isEnded() {
70
- return this.state === PLAYER_STATE.END;
71
- }
72
-
73
- // Public functions
74
-
75
- /**
76
- * Set the Player `callback` property. This callback is executed at each animation frame.
77
- *
78
- * @param {function} callback - The callback to execute at each animation frame.
79
- */
80
- setCallback(callback) {
81
- this.callback = callback;
82
- }
83
-
84
- /**
85
- * Play one animation.
86
- * If another animation is playing, it's stopped and the new animation is played.
87
- *
88
- * @param {number} duration - The duration to play
89
- */
90
- play(duration) {
91
- this.duration = duration;
92
- this.dispatchEvent({
93
- type: 'animation-started'
94
- });
95
- this.state = PLAYER_STATE.PLAY;
96
- resetTimer(this);
97
- this.id = setInterval(this.frame.bind(this), FRAME_DURATION);
98
- }
99
-
100
- /**
101
- * Play an animation after a number of frames.
102
- *
103
- * @param {number} duration The duration to play
104
- * @param {number} waitingFrame The waiting time before start animation (time in frame)
105
- */
106
- playLater(duration, waitingFrame) {
107
- const timew = Math.floor(FRAME_DURATION * waitingFrame);
108
- window.clearInterval(this.waitTimer);
109
- const self = this;
110
- this.waitTimer = window.setTimeout(() => {
111
- self.play(duration);
112
- }, timew);
113
- }
114
-
115
- /**
116
- * Stop the current animation.
117
- *
118
- */
119
- stop() {
120
- this.state = PLAYER_STATE.STOP;
121
- finishAnimation(this);
122
- }
123
-
124
- /**
125
- * Executed for each frame.
126
- *
127
- * @private
128
- */
129
- frame() {
130
- if (this.keyframe < this.duration) {
131
- this.keyframe++;
132
- this.dispatchEvent({
133
- type: 'animation-frame'
134
- });
135
- this.callback();
136
- } else {
137
- this.state = PLAYER_STATE.END;
138
- finishAnimation(this);
139
- }
140
- }
141
- }
142
- export default AnimationPlayer;