itowns 2.42.1-next.8 → 2.43.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.
- package/changelog.md +90 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/examples/effects_stereo.html +2 -2
- package/examples/misc_collada.html +2 -2
- package/examples/source_stream_wfs_25d.html +11 -11
- package/examples/source_stream_wfs_3d.html +1 -1
- package/examples/view_25d_map.html +2 -2
- package/examples/view_3d_map.html +2 -2
- package/examples/view_3d_map_webxr.html +1 -1
- package/examples/view_3d_mns_map.html +2 -2
- package/examples/view_immersive.html +1 -1
- package/examples/view_multi_25d.html +2 -2
- package/examples/widgets_searchbar.html +2 -2
- package/lib/Controls/FirstPersonControls.js +5 -12
- package/lib/Controls/FlyControls.js +4 -13
- package/lib/Controls/GlobeControls.js +33 -43
- package/lib/Controls/PlanarControls.js +9 -20
- package/lib/Controls/StateControl.js +2 -11
- package/lib/Controls/StreetControls.js +14 -24
- package/lib/Converter/Feature2Mesh.js +28 -38
- package/lib/Converter/Feature2Texture.js +15 -25
- package/lib/Converter/convertToTile.js +16 -26
- package/lib/Converter/textureConverter.js +9 -19
- package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
- package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
- package/lib/Core/3DTiles/C3DTFeature.js +3 -10
- package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
- package/lib/Core/3DTiles/C3DTileset.js +7 -16
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
- package/lib/Core/AnimationPlayer.js +2 -11
- package/lib/Core/Deprecated/Undeprecator.js +9 -20
- package/lib/Core/EntwinePointTileNode.js +6 -16
- package/lib/Core/Feature.js +16 -30
- package/lib/Core/Geographic/CoordStars.js +3 -12
- package/lib/Core/Geographic/Coordinates.js +12 -22
- package/lib/Core/Geographic/Crs.js +7 -15
- package/lib/Core/Geographic/Extent.js +36 -47
- package/lib/Core/Geographic/GeoidGrid.js +6 -16
- package/lib/Core/Label.js +7 -17
- package/lib/Core/MainLoop.js +7 -16
- package/lib/Core/Math/Ellipsoid.js +6 -17
- package/lib/Core/Picking.js +10 -20
- package/lib/Core/PointCloudNode.js +2 -11
- package/lib/Core/PotreeNode.js +4 -13
- package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
- package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
- package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
- package/lib/Core/Prefab/GlobeView.js +27 -45
- package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
- package/lib/Core/Prefab/PlanarView.js +10 -25
- package/lib/Core/Prefab/TileBuilder.js +13 -22
- package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
- package/lib/Core/Scheduler/Cache.js +2 -10
- package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
- package/lib/Core/Scheduler/Scheduler.js +15 -23
- package/lib/Core/Style.js +24 -38
- package/lib/Core/System/Capabilities.js +2 -13
- package/lib/Core/TileGeometry.js +13 -15
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -58
- package/lib/Layer/C3DTilesLayer.js +29 -41
- package/lib/Layer/ColorLayer.js +10 -16
- package/lib/Layer/ElevationLayer.js +7 -14
- package/lib/Layer/EntwinePointTileLayer.js +9 -18
- package/lib/Layer/FeatureGeometryLayer.js +9 -16
- package/lib/Layer/GeoidLayer.js +6 -15
- package/lib/Layer/GeometryLayer.js +11 -17
- package/lib/Layer/InfoLayer.js +5 -14
- package/lib/Layer/LabelLayer.js +22 -32
- package/lib/Layer/Layer.js +16 -26
- package/lib/Layer/LayerUpdateState.js +1 -8
- package/lib/Layer/LayerUpdateStrategy.js +7 -18
- package/lib/Layer/OrientedImageLayer.js +15 -25
- package/lib/Layer/PointCloudLayer.js +9 -19
- package/lib/Layer/PotreeLayer.js +8 -18
- package/lib/Layer/RasterLayer.js +9 -17
- package/lib/Layer/ReferencingLayerProperties.js +1 -8
- package/lib/Layer/TiledGeometryLayer.js +37 -33
- package/lib/Main.js +87 -708
- package/lib/MainBundle.js +4 -34
- package/lib/Parser/B3dmParser.js +80 -131
- package/lib/Parser/CameraCalibrationParser.js +5 -14
- package/lib/Parser/GDFParser.js +11 -22
- package/lib/Parser/GLTFParser.js +88 -0
- package/lib/Parser/GTXParser.js +9 -21
- package/lib/Parser/GeoJsonParser.js +14 -22
- package/lib/Parser/GpxParser.js +7 -14
- package/lib/Parser/ISGParser.js +19 -28
- package/lib/Parser/KMLParser.js +7 -14
- package/lib/Parser/LASLoader.js +20 -21
- package/lib/Parser/LASParser.js +6 -15
- package/lib/Parser/MapBoxUrlParser.js +2 -9
- package/lib/Parser/PntsParser.js +4 -14
- package/lib/Parser/PotreeBinParser.js +8 -16
- package/lib/Parser/PotreeCinParser.js +3 -12
- package/lib/Parser/ShapefileParser.js +11 -18
- package/lib/Parser/VectorTileParser.js +23 -31
- package/lib/Parser/XbilParser.js +5 -13
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
- package/lib/Process/3dTilesProcessing.js +14 -27
- package/lib/Process/FeatureProcessing.js +14 -22
- package/lib/Process/LayeredMaterialNodeProcessing.js +14 -26
- package/lib/Process/ObjectRemovalHelper.js +2 -9
- package/lib/Process/handlerNodeError.js +1 -7
- package/lib/Provider/3dTilesProvider.js +32 -29
- package/lib/Provider/DataSourceProvider.js +2 -9
- package/lib/Provider/Fetcher.js +40 -22
- package/lib/Provider/PointCloudProvider.js +7 -19
- package/lib/Provider/TileProvider.js +4 -12
- package/lib/Provider/URLBuilder.js +4 -12
- package/lib/Renderer/Camera.js +7 -17
- package/lib/Renderer/Color.js +3 -11
- package/lib/Renderer/ColorLayersOrdering.js +14 -22
- package/lib/Renderer/CommonMaterial.js +3 -12
- package/lib/Renderer/Label2DRenderer.js +5 -16
- package/lib/Renderer/LayeredMaterial.js +33 -53
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +17 -35
- package/lib/Renderer/PointsMaterial.js +37 -60
- package/lib/Renderer/RasterTile.js +16 -29
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +5 -23
- package/lib/Renderer/Shader/ShaderUtils.js +2 -9
- package/lib/Renderer/SphereHelper.js +2 -11
- package/lib/Renderer/WebXR.js +2 -11
- package/lib/Renderer/c3DEngine.js +20 -53
- package/lib/Source/C3DTilesGoogleSource.js +76 -0
- package/lib/Source/C3DTilesIonSource.js +6 -13
- package/lib/Source/C3DTilesSource.js +5 -12
- package/lib/Source/EntwinePointTileSource.js +12 -19
- package/lib/Source/FileSource.js +7 -14
- package/lib/Source/OrientedImageSource.js +6 -14
- package/lib/Source/PotreeSource.js +9 -16
- package/lib/Source/Source.js +26 -39
- package/lib/Source/TMSSource.js +11 -22
- package/lib/Source/VectorTilesSource.js +75 -34
- package/lib/Source/WFSSource.js +7 -14
- package/lib/Source/WMSSource.js +5 -12
- package/lib/Source/WMTSSource.js +3 -10
- package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
- package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
- package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
- package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
- package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
- package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
- package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
- package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
- package/lib/Utils/CameraUtils.js +32 -44
- package/lib/Utils/DEMUtils.js +8 -19
- package/lib/Utils/FeaturesUtils.js +8 -16
- package/lib/Utils/Gradients.js +3 -12
- package/lib/Utils/OrientationUtils.js +8 -18
- package/lib/Utils/ThreeUtils.js +2 -9
- package/lib/Utils/gui/C3DTilesStyle.js +7 -15
- package/lib/Utils/gui/Main.js +7 -48
- package/lib/Utils/gui/Minimap.js +12 -20
- package/lib/Utils/gui/Navigation.js +6 -14
- package/lib/Utils/gui/Scale.js +11 -19
- package/lib/Utils/gui/Searchbar.js +5 -13
- package/lib/Utils/gui/Widget.js +1 -8
- package/lib/Utils/placeObjectOnGround.js +13 -23
- package/package.json +13 -8
package/lib/MainBundle.js
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
THREE: true,
|
|
9
|
-
proj4: true
|
|
10
|
-
};
|
|
11
|
-
exports.THREE = void 0;
|
|
12
|
-
Object.defineProperty(exports, "proj4", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _proj.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
19
|
-
exports.THREE = THREE;
|
|
20
|
-
var _proj = _interopRequireDefault(require("proj4"));
|
|
21
|
-
var _Main = require("./Main.js");
|
|
22
|
-
Object.keys(_Main).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
25
|
-
if (key in exports && exports[key] === _Main[key]) return;
|
|
26
|
-
Object.defineProperty(exports, key, {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _Main[key];
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export { THREE };
|
|
3
|
+
export { default as proj4 } from 'proj4';
|
|
4
|
+
export * from "./Main.js";
|
package/lib/Parser/B3dmParser.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
12
|
-
var _Capabilities = _interopRequireDefault(require("../Core/System/Capabilities"));
|
|
13
|
-
var _GLTFLoader = require("../ThreeExtended/loaders/GLTFLoader");
|
|
14
|
-
var _DRACOLoader = require("../ThreeExtended/loaders/DRACOLoader");
|
|
15
|
-
var _KTX2Loader = require("../ThreeExtended/loaders/KTX2Loader");
|
|
16
|
-
var _LegacyGLTFLoader = _interopRequireDefault(require("./deprecated/LegacyGLTFLoader"));
|
|
17
|
-
var _ShaderUtils = _interopRequireDefault(require("../Renderer/Shader/ShaderUtils"));
|
|
18
|
-
var _C3DTBatchTable = _interopRequireDefault(require("../Core/3DTiles/C3DTBatchTable"));
|
|
19
|
-
var _ReferencingLayerProperties = _interopRequireDefault(require("../Layer/ReferencingLayerProperties"));
|
|
20
|
-
var _ThreeUtils = _interopRequireDefault(require("../Utils/ThreeUtils"));
|
|
21
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
const matrixChangeUpVectorZtoY = new THREE.Matrix4().makeRotationX(Math.PI / 2);
|
|
24
|
-
// For gltf rotation
|
|
25
|
-
const matrixChangeUpVectorZtoX = new THREE.Matrix4().makeRotationZ(-Math.PI / 2);
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import C3DTBatchTable from "../Core/3DTiles/C3DTBatchTable.js";
|
|
3
|
+
import Capabilities from "../Core/System/Capabilities.js";
|
|
4
|
+
import { MeshBasicMaterial } from 'three';
|
|
5
|
+
import disposeThreeMaterial from "../Utils/ThreeUtils.js";
|
|
6
|
+
import shaderUtils from "../Renderer/Shader/ShaderUtils.js";
|
|
7
|
+
import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
|
|
8
|
+
import GLTFParser from "./GLTFParser.js";
|
|
9
|
+
const matrixChangeUpVectorYtoZInv = new THREE.Matrix4().makeRotationX(-Math.PI / 2);
|
|
10
|
+
const matrixChangeUpVectorXtoZ = new THREE.Matrix4().makeRotationZ(-Math.PI / 2);
|
|
26
11
|
const utf8Decoder = new TextDecoder();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 3D Tiles pre-1.0 contain not standardized and specific uniforms that we filter out to avoid shader compilation errors
|
|
15
|
+
* This method is passed to scene.traverse and applied to all 3D objects of the loaded gltf.
|
|
16
|
+
* @param {THREE.Object3D} obj - 3D object of the gltf hierarchy
|
|
17
|
+
*/
|
|
31
18
|
function filterUnsupportedSemantics(obj) {
|
|
32
19
|
// see GLTFLoader GLTFShader.prototype.update function
|
|
33
20
|
const supported = ['MODELVIEW', 'MODELVIEWINVERSETRANSPOSE', 'PROJECTION', 'JOINTMATRIX'];
|
|
@@ -47,67 +34,36 @@ function filterUnsupportedSemantics(obj) {
|
|
|
47
34
|
}
|
|
48
35
|
|
|
49
36
|
/**
|
|
50
|
-
*
|
|
37
|
+
* 3D Tiles pre-1.0 had a gltfUpAxis parameter that defined the up vector of the gltf file that might be different from
|
|
38
|
+
* the standard y-up for gltf. Manage the case when this gltfUpAxis is defined (i.e. apply the correct rotation to the
|
|
39
|
+
* gltf file to have it z-up in the end).
|
|
40
|
+
* @param {THREE.Object3D} gltfScene - the parsed glTF scene
|
|
41
|
+
* @param {String} gltfUpAxis - the gltfUpAxis parameter
|
|
51
42
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @example <caption>Enable draco decoder</caption>
|
|
60
|
-
* // if you copied /itowns/examples/libs/draco/ to the root folder of your project,you can set the path to './'.
|
|
61
|
-
* itowns.enableDracoLoader('./');
|
|
62
|
-
*
|
|
63
|
-
* @param {string} path path to draco library folder.
|
|
64
|
-
* This library is mandatory to load b3dm and gltf with Draco compression.
|
|
65
|
-
* @param {object} config optional configuration for Draco compression.
|
|
66
|
-
*/
|
|
67
|
-
function enableDracoLoader(path, config) {
|
|
68
|
-
if (!path) {
|
|
69
|
-
throw new Error('Path to draco folder is mandatory');
|
|
70
|
-
}
|
|
71
|
-
const dracoLoader = new _DRACOLoader.DRACOLoader();
|
|
72
|
-
dracoLoader.setDecoderPath(path);
|
|
73
|
-
if (config) {
|
|
74
|
-
dracoLoader.setDecoderConfig(config);
|
|
43
|
+
function applyDeprecatedGltfUpAxis(gltfScene, gltfUpAxis) {
|
|
44
|
+
if (gltfUpAxis === 'Z') {
|
|
45
|
+
// If gltf up was already z-up, apply the inverse transform matrix that was applied in the glTFParser
|
|
46
|
+
gltfScene.applyMatrix4(matrixChangeUpVectorYtoZInv);
|
|
47
|
+
} else if (gltfUpAxis === 'X') {
|
|
48
|
+
gltfScene.applyMatrix4(matrixChangeUpVectorYtoZInv);
|
|
49
|
+
gltfScene.applyMatrix4(matrixChangeUpVectorXtoZ);
|
|
75
50
|
}
|
|
76
|
-
glTFLoader.setDRACOLoader(dracoLoader);
|
|
77
51
|
}
|
|
78
52
|
|
|
79
53
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* The KTX2 library files are in folder itowns/examples/libs/basis/.
|
|
83
|
-
* You must indicate this path when you want to enable KTX2 decoding.
|
|
84
|
-
* For more information about KTX2, read /itowns/examples/libs/basis/README.md.
|
|
85
|
-
*
|
|
86
|
-
* @example <caption>Enable ktx2 decoder</caption>
|
|
87
|
-
* // if you copied /itowns/examples/libs/draco/ to the root folder of your project,you can set the path to './'.
|
|
88
|
-
* itowns.enableKtx2Loader('./', view.mainLoop.gfxEngine.renderer);
|
|
89
|
-
*
|
|
90
|
-
* @param {string} path path to KTX2 library folder.
|
|
91
|
-
* @param {THREE.WebGLRenderer} renderer the threejs renderer
|
|
54
|
+
* @module B3dmParser
|
|
92
55
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
throw new Error('Path to ktx2 folder and renderer are mandatory');
|
|
96
|
-
}
|
|
97
|
-
const ktx2Loader = new _KTX2Loader.KTX2Loader();
|
|
98
|
-
ktx2Loader.setTranscoderPath(path);
|
|
99
|
-
ktx2Loader.detectSupport(renderer);
|
|
100
|
-
glTFLoader.setKTX2Loader(ktx2Loader);
|
|
101
|
-
}
|
|
102
|
-
var _default = {
|
|
56
|
+
|
|
57
|
+
export default {
|
|
103
58
|
/** Parse b3dm buffer and extract THREE.Scene and batch table
|
|
104
59
|
* @param {ArrayBuffer} buffer - the b3dm buffer.
|
|
105
60
|
* @param {Object} options - additional properties.
|
|
106
61
|
* @param {string=} [options.gltfUpAxis='Y'] - embedded glTF model up axis.
|
|
107
62
|
* @param {string} options.urlBase - the base url of the b3dm file (used to fetch textures for the embedded glTF model).
|
|
108
|
-
* @param {boolean=} [options.doNotPatchMaterial=
|
|
63
|
+
* @param {boolean=} [options.doNotPatchMaterial=false] - disable patching material with logarithmic depth buffer support.
|
|
109
64
|
* @param {float} [options.opacity=1.0] - the b3dm opacity.
|
|
110
|
-
* @param {boolean
|
|
65
|
+
* @param {boolean=} [options.frustumCulled=false] - enable frustum culling.
|
|
66
|
+
* @param {boolean|Material=} [options.overrideMaterials=false] - override b3dm's embedded glTF materials. If
|
|
111
67
|
* true, a threejs [MeshBasicMaterial](https://threejs.org/docs/index.html?q=meshbasic#api/en/materials/MeshBasicMaterial)
|
|
112
68
|
* is set up. config.overrideMaterials can also be a threejs [Material](https://threejs.org/docs/index.html?q=material#api/en/materials/Material)
|
|
113
69
|
* in which case it will be the material used to override.
|
|
@@ -115,8 +71,7 @@ var _default = {
|
|
|
115
71
|
*
|
|
116
72
|
*/
|
|
117
73
|
parse(buffer, options) {
|
|
118
|
-
const
|
|
119
|
-
const urlBase = options.urlBase;
|
|
74
|
+
const frustumCulled = options.frustumCulled === true;
|
|
120
75
|
if (!buffer) {
|
|
121
76
|
throw new Error('No array buffer provided.');
|
|
122
77
|
}
|
|
@@ -166,71 +121,65 @@ var _default = {
|
|
|
166
121
|
// sizeBegin is an index to the beginning of the batch table
|
|
167
122
|
const sizeBegin = headerByteLength + b3dmHeader.FTJSONLength + b3dmHeader.FTBinaryLength;
|
|
168
123
|
const BTBuffer = buffer.slice(sizeBegin, sizeBegin + b3dmHeader.BTJSONLength + b3dmHeader.BTBinaryLength);
|
|
169
|
-
promises.push(Promise.resolve(new
|
|
124
|
+
promises.push(Promise.resolve(new C3DTBatchTable(BTBuffer, b3dmHeader.BTJSONLength, b3dmHeader.BTBinaryLength, FTJSON.BATCH_LENGTH, options.registeredExtensions)));
|
|
170
125
|
} else {
|
|
171
|
-
promises.push(Promise.resolve(new
|
|
126
|
+
promises.push(Promise.resolve(new C3DTBatchTable()));
|
|
172
127
|
}
|
|
173
128
|
const posGltf = headerByteLength + b3dmHeader.FTJSONLength + b3dmHeader.FTBinaryLength + b3dmHeader.BTJSONLength + b3dmHeader.BTBinaryLength;
|
|
174
129
|
const gltfBuffer = buffer.slice(posGltf);
|
|
175
130
|
const headerView = new DataView(gltfBuffer, 0, 20);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
131
|
+
const init_mesh = function (mesh) {
|
|
132
|
+
mesh.frustumCulled = frustumCulled;
|
|
133
|
+
if (mesh.material) {
|
|
134
|
+
if (options.overrideMaterials) {
|
|
135
|
+
const oldMat = mesh.material;
|
|
136
|
+
// Set up new material
|
|
137
|
+
if (typeof options.overrideMaterials === 'object' && options.overrideMaterials.isMaterial) {
|
|
138
|
+
mesh.material = options.overrideMaterials;
|
|
139
|
+
} else {
|
|
140
|
+
mesh.material = new MeshBasicMaterial();
|
|
141
|
+
}
|
|
142
|
+
disposeThreeMaterial(oldMat);
|
|
143
|
+
} else if (Capabilities.isLogDepthBufferSupported() && mesh.material.isRawShaderMaterial && !options.doNotPatchMaterial) {
|
|
144
|
+
shaderUtils.patchMaterialForLogDepthSupport(mesh.material);
|
|
145
|
+
console.warn('glTF shader has been patched to add log depth buffer support');
|
|
186
146
|
}
|
|
147
|
+
ReferLayerProperties(mesh.material, options.layer);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
promises.push(GLTFParser.parse(gltfBuffer, options).then(gltf => {
|
|
151
|
+
for (const scene of gltf.scenes) {
|
|
152
|
+
scene.traverse(filterUnsupportedSemantics);
|
|
153
|
+
}
|
|
154
|
+
applyDeprecatedGltfUpAxis(gltf.scene, options.gltfUpAxis);
|
|
155
|
+
const shouldBePatchedForLogDepthSupport = Capabilities.isLogDepthBufferSupported() && !options.doNotPatchMaterial;
|
|
156
|
+
if (options.frustumCulling === false || options.overrideMaterials || shouldBePatchedForLogDepthSupport || options.layer) {
|
|
157
|
+
gltf.scene.traverse(init_mesh);
|
|
158
|
+
}
|
|
187
159
|
|
|
188
|
-
|
|
189
|
-
|
|
160
|
+
// Apply relative center from Feature table.
|
|
161
|
+
gltf.scene.position.copy(FT_RTC);
|
|
190
162
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
gltf.scene.traverse(function (mesh) {
|
|
200
|
-
mesh.frustumCulled = false;
|
|
201
|
-
if (mesh.material) {
|
|
202
|
-
if (options.overrideMaterials) {
|
|
203
|
-
const oldMat = mesh.material;
|
|
204
|
-
// Set up new material
|
|
205
|
-
if (typeof options.overrideMaterials === 'object' && options.overrideMaterials.isMaterial) {
|
|
206
|
-
mesh.material = options.overrideMaterials;
|
|
207
|
-
} else {
|
|
208
|
-
mesh.material = new THREE.MeshBasicMaterial();
|
|
209
|
-
}
|
|
210
|
-
(0, _ThreeUtils.default)(oldMat);
|
|
211
|
-
} else if (_Capabilities.default.isLogDepthBufferSupported() && mesh.material.isRawShaderMaterial && !options.doNotPatchMaterial) {
|
|
212
|
-
_ShaderUtils.default.patchMaterialForLogDepthSupport(mesh.material);
|
|
213
|
-
console.warn('b3dm shader has been patched to add log depth buffer support');
|
|
214
|
-
}
|
|
215
|
-
(0, _ReferencingLayerProperties.default)(mesh.material, options.layer);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
resolve(gltf);
|
|
219
|
-
};
|
|
220
|
-
const version = headerView.getUint32(4, true);
|
|
221
|
-
if (version === 1) {
|
|
222
|
-
legacyGLTFLoader.parse(gltfBuffer, urlBase, onload);
|
|
223
|
-
} else {
|
|
224
|
-
glTFLoader.parse(gltfBuffer, urlBase, onload);
|
|
163
|
+
// Apply relative center from gltf json.
|
|
164
|
+
const contentArray = new Uint8Array(gltfBuffer, 20, headerView.getUint32(12, true));
|
|
165
|
+
const content = utf8Decoder.decode(new Uint8Array(contentArray));
|
|
166
|
+
const json = JSON.parse(content);
|
|
167
|
+
if (json.extensions && json.extensions.CESIUM_RTC) {
|
|
168
|
+
gltf.scene.position.fromArray(json.extensions.CESIUM_RTC.center);
|
|
169
|
+
gltf.scene.updateMatrixWorld(true);
|
|
225
170
|
}
|
|
171
|
+
return gltf;
|
|
172
|
+
}).catch(e => {
|
|
173
|
+
throw new Error(e);
|
|
226
174
|
}));
|
|
227
175
|
return Promise.all(promises).then(values => ({
|
|
228
176
|
gltf: values[1],
|
|
229
177
|
batchTable: values[0]
|
|
230
|
-
}))
|
|
178
|
+
})).catch(e => {
|
|
179
|
+
throw new Error(e);
|
|
180
|
+
});
|
|
231
181
|
} else {
|
|
232
182
|
throw new Error('Invalid b3dm file.');
|
|
233
183
|
}
|
|
234
184
|
}
|
|
235
|
-
};
|
|
236
|
-
exports.default = _default;
|
|
185
|
+
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import OrientedImageCamera from "../Renderer/OrientedImageCamera.js";
|
|
2
3
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _OrientedImageCamera = _interopRequireDefault(require("../Renderer/OrientedImageCamera"));
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
4
|
/**
|
|
13
5
|
* The CameraCalibrationParser module provide a [parse]{@link module:CameraCalibrationParser.parse}
|
|
14
6
|
* method that takes a JSON array of camera calibrations in and yields an array of {@link OrientedImageCamera}
|
|
@@ -35,7 +27,7 @@ function parseCalibration(calibration) {
|
|
|
35
27
|
// To transform image space to webGl texture. It could inverse Y axis.
|
|
36
28
|
const center = new THREE.Vector2(proj[2], imageYDown ? size.y - proj[5] : proj[5]);
|
|
37
29
|
const skew = proj[1];
|
|
38
|
-
const camera = new
|
|
30
|
+
const camera = new OrientedImageCamera(size, focal, center, options.near, options.far, skew);
|
|
39
31
|
|
|
40
32
|
// parse extrinsics: Object3d.matrix is from local to world
|
|
41
33
|
// p_world = position + transpose(rotation) * p_local
|
|
@@ -66,7 +58,7 @@ function parseCalibration(calibration) {
|
|
|
66
58
|
}
|
|
67
59
|
return deferred;
|
|
68
60
|
}
|
|
69
|
-
|
|
61
|
+
export default {
|
|
70
62
|
/**
|
|
71
63
|
* Description of a camera calibration in a JSON file.
|
|
72
64
|
*
|
|
@@ -99,5 +91,4 @@ var _default = {
|
|
|
99
91
|
}
|
|
100
92
|
return Promise.all(json.map(calibration => parseCalibration(calibration, options)));
|
|
101
93
|
}
|
|
102
|
-
};
|
|
103
|
-
exports.default = _default;
|
|
94
|
+
};
|
package/lib/Parser/GDFParser.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
exports.getHeaderAttribute = getHeaderAttribute;
|
|
9
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
10
|
-
var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
|
|
11
|
-
var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
|
|
12
|
-
var _GTXParser = require("./GTXParser");
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
function getHeaderAttribute(header, attributeName) {
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import GeoidGrid from "../Core/Geographic/GeoidGrid.js";
|
|
3
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
+
import { BYTES_PER_DOUBLE } from "./GTXParser.js";
|
|
5
|
+
export function getHeaderAttribute(header, attributeName) {
|
|
16
6
|
const attributeRow = header[header.indexOf(header.find(element => element.includes(attributeName)))].split(' ').filter(value => value !== '');
|
|
17
7
|
return parseFloat(attributeRow[attributeRow.length - 1]);
|
|
18
8
|
}
|
|
@@ -24,7 +14,7 @@ function getHeaderAttribute(header, attributeName) {
|
|
|
24
14
|
*
|
|
25
15
|
* @module GDFParser
|
|
26
16
|
*/
|
|
27
|
-
|
|
17
|
+
export default {
|
|
28
18
|
/**
|
|
29
19
|
* Parses a GDF file content and returns a corresponding `{@link GeoidGrid}`.
|
|
30
20
|
*
|
|
@@ -62,22 +52,21 @@ var _default = {
|
|
|
62
52
|
|
|
63
53
|
// ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
|
|
64
54
|
|
|
65
|
-
const data = new DataView(new ArrayBuffer(
|
|
55
|
+
const data = new DataView(new ArrayBuffer(BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
|
|
66
56
|
let index = 0;
|
|
67
57
|
for (let row of rows.slice(firstMeasureLine, rows.length)) {
|
|
68
58
|
row = row.split(' ').filter(value => value !== '');
|
|
69
59
|
if (!row.length) {
|
|
70
60
|
continue;
|
|
71
61
|
}
|
|
72
|
-
data.setFloat64(index *
|
|
62
|
+
data.setFloat64(index * BYTES_PER_DOUBLE, parseFloat(row[2]));
|
|
73
63
|
index++;
|
|
74
64
|
}
|
|
75
65
|
|
|
76
66
|
// ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
|
|
77
67
|
|
|
78
|
-
const dataExtent = new
|
|
68
|
+
const dataExtent = new Extent(options.in.crs || 'EPSG:4326', metadata.minX, metadata.maxX, metadata.minY, metadata.maxY);
|
|
79
69
|
const dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
|
|
80
|
-
return Promise.resolve(new
|
|
70
|
+
return Promise.resolve(new GeoidGrid(dataExtent, dataStep, (verticalIndex, horizontalIndex) => data.getFloat64((metadata.nColumns * (metadata.nRows - verticalIndex - 1) + horizontalIndex) * BYTES_PER_DOUBLE)));
|
|
81
71
|
}
|
|
82
|
-
};
|
|
83
|
-
exports.default = _default;
|
|
72
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { GLTFLoader } from "../ThreeExtended/loaders/GLTFLoader.js";
|
|
3
|
+
import { DRACOLoader } from "../ThreeExtended/loaders/DRACOLoader.js";
|
|
4
|
+
import { KTX2Loader } from "../ThreeExtended/loaders/KTX2Loader.js";
|
|
5
|
+
import LegacyGLTFLoader from "./deprecated/LegacyGLTFLoader.js";
|
|
6
|
+
const matrixChangeUpVectorYtoZ = new THREE.Matrix4().makeRotationX(Math.PI / 2);
|
|
7
|
+
export const glTFLoader = new GLTFLoader();
|
|
8
|
+
export const legacyGLTFLoader = new LegacyGLTFLoader();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @module GLTFParser
|
|
12
|
+
* @description Parses [glTF](https://www.khronos.org/gltf/) 1.0 and 2.0 files.
|
|
13
|
+
*
|
|
14
|
+
* Under the hood, glTF 2.0 files are parsed with THREE.GltfLoader() and GLTF 1.0 are parsed with the previous THREE
|
|
15
|
+
* GltfLoader (for 1.0 glTF) that has been kept and maintained in iTowns.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Enable loading gltf files with [Draco](https://google.github.io/draco/) geometry extension.
|
|
20
|
+
*
|
|
21
|
+
* @param {String} path path to draco library folder containing the JS and WASM decoder libraries. They can be found in
|
|
22
|
+
* [itowns examples](https://github.com/iTowns/itowns/tree/master/examples/libs/draco).
|
|
23
|
+
* @param {Object} [config] optional configuration for Draco decoder (see threejs'
|
|
24
|
+
* [setDecoderConfig](https://threejs.org/docs/index.html?q=draco#examples/en/loaders/DRACOLoader.setDecoderConfig) that
|
|
25
|
+
* is called under the hood with this configuration for details.
|
|
26
|
+
*/
|
|
27
|
+
export function enableDracoLoader(path, config) {
|
|
28
|
+
if (!path) {
|
|
29
|
+
throw new Error('Path to draco folder is mandatory');
|
|
30
|
+
}
|
|
31
|
+
const dracoLoader = new DRACOLoader();
|
|
32
|
+
dracoLoader.setDecoderPath(path);
|
|
33
|
+
if (config) {
|
|
34
|
+
dracoLoader.setDecoderConfig(config);
|
|
35
|
+
}
|
|
36
|
+
glTFLoader.setDRACOLoader(dracoLoader);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Enable loading gltf files with [KTX2](https://www.khronos.org/ktx/) texture extension.
|
|
41
|
+
*
|
|
42
|
+
* @param {String} path path to ktx2 library folder containing the JS and WASM decoder libraries. They can be found in
|
|
43
|
+
* [itowns examples](https://github.com/iTowns/itowns/tree/master/examples/libs/basis).
|
|
44
|
+
* @param {THREE.WebGLRenderer} renderer the threejs renderer
|
|
45
|
+
*/
|
|
46
|
+
export function enableKtx2Loader(path, renderer) {
|
|
47
|
+
if (!path || !renderer) {
|
|
48
|
+
throw new Error('Path to ktx2 folder and renderer are mandatory');
|
|
49
|
+
}
|
|
50
|
+
const ktx2Loader = new KTX2Loader();
|
|
51
|
+
ktx2Loader.setTranscoderPath(path);
|
|
52
|
+
ktx2Loader.detectSupport(renderer);
|
|
53
|
+
glTFLoader.setKTX2Loader(ktx2Loader);
|
|
54
|
+
}
|
|
55
|
+
export default {
|
|
56
|
+
/** Parses a gltf buffer to an object with threejs structures and applies a y-up to z-up conversion to align with
|
|
57
|
+
* itowns convention. Essentially calls THREE.GltfLoader.parse() for glTF 2.0 files and the legacy threejs parser
|
|
58
|
+
* for gtTF 1.0 files.
|
|
59
|
+
* @param {ArrayBuffer} buffer - the glTF asset to parse, as an ArrayBuffer, JSON string or object.
|
|
60
|
+
* @param {String} path - the base path from which to find subsequent glTF resources such as textures and .bin data files.
|
|
61
|
+
* @return {Promise} - a promise that resolves with an object containing an Object that contains loaded parts:
|
|
62
|
+
* .scene, .scenes, .cameras, .animations, and .asset.
|
|
63
|
+
*/
|
|
64
|
+
parse(buffer, path) {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
if (!buffer || !path) {
|
|
67
|
+
reject(new Error('[GLTFParser]: Buffer and path are mandatory to parse a glTF.'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Apply y-up (gltf convention) to z-up (itowns convention) conversion
|
|
72
|
+
const onload = gltf => {
|
|
73
|
+
gltf.scene.applyMatrix4(matrixChangeUpVectorYtoZ);
|
|
74
|
+
resolve(gltf);
|
|
75
|
+
};
|
|
76
|
+
const onError = e => {
|
|
77
|
+
reject(new Error(`[GLTFParser]: Failed to parse gltf with error: ${e}`));
|
|
78
|
+
};
|
|
79
|
+
const headerView = new DataView(buffer, 0, 20);
|
|
80
|
+
const version = headerView.getUint32(4, true);
|
|
81
|
+
if (version === 1) {
|
|
82
|
+
legacyGLTFLoader.parse(buffer, path, onload, onError);
|
|
83
|
+
} else {
|
|
84
|
+
glTFLoader.parse(buffer, path, onload, onError);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
package/lib/Parser/GTXParser.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.BYTES_PER_FLOAT = exports.BYTES_PER_DOUBLE = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
|
|
10
|
-
var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
const BYTES_PER_DOUBLE = 8;
|
|
14
|
-
exports.BYTES_PER_DOUBLE = BYTES_PER_DOUBLE;
|
|
15
|
-
const BYTES_PER_FLOAT = 4;
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import GeoidGrid from "../Core/Geographic/GeoidGrid.js";
|
|
3
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
+
export const BYTES_PER_DOUBLE = 8;
|
|
5
|
+
export const BYTES_PER_FLOAT = 4;
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* The `GTXParser` module provides a `[parse]{@link module:GTXParser.parse}` method. This method takes the content of a
|
|
@@ -21,8 +11,7 @@ const BYTES_PER_FLOAT = 4;
|
|
|
21
11
|
*
|
|
22
12
|
* @module GTXParser
|
|
23
13
|
*/
|
|
24
|
-
|
|
25
|
-
var _default = {
|
|
14
|
+
export default {
|
|
26
15
|
/**
|
|
27
16
|
* Parses a GTX file content and returns a corresponding `{@link GeoidGrid}`.
|
|
28
17
|
*
|
|
@@ -70,9 +59,9 @@ var _default = {
|
|
|
70
59
|
const maxX = metadata.minX + metadata.stepX * (metadata.nColumns - 1);
|
|
71
60
|
// formula for the max latitude : maxLatitude = minLatitude + deltaLatitude * (nRows - 1)
|
|
72
61
|
const maxY = metadata.minY + metadata.stepY * (metadata.nRows - 1);
|
|
73
|
-
const dataExtent = new
|
|
62
|
+
const dataExtent = new Extent(options.in.crs || 'EPSG:4326', metadata.minX, maxX, metadata.minY, maxY);
|
|
74
63
|
const dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
|
|
75
|
-
return Promise.resolve(new
|
|
64
|
+
return Promise.resolve(new GeoidGrid(dataExtent, dataStep, (verticalIndex, horizontalIndex) => {
|
|
76
65
|
// formula to get the index of a geoid height from a latitude and longitude indexes is :
|
|
77
66
|
// ``(nColumns * latIndex + lonIndex) * nBytes``, where nBytes stands for the number of bytes geoid
|
|
78
67
|
// height data are encoded on.
|
|
@@ -83,5 +72,4 @@ var _default = {
|
|
|
83
72
|
}
|
|
84
73
|
}));
|
|
85
74
|
}
|
|
86
|
-
};
|
|
87
|
-
exports.default = _default;
|
|
75
|
+
};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _Coordinates = _interopRequireDefault(require("../Core/Geographic/Coordinates"));
|
|
9
|
-
var _Feature = require("../Core/Feature");
|
|
10
|
-
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
1
|
+
import Coordinates from "../Core/Geographic/Coordinates.js";
|
|
2
|
+
import { FeatureCollection, FEATURE_TYPES } from "../Core/Feature.js";
|
|
3
|
+
import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
|
|
11
4
|
function readCRS(json) {
|
|
12
5
|
if (json.crs) {
|
|
13
6
|
if (json.crs.type.toLowerCase() == 'epsg') {
|
|
@@ -28,9 +21,9 @@ function readCRS(json) {
|
|
|
28
21
|
// assume default crs
|
|
29
22
|
return 'EPSG:4326';
|
|
30
23
|
}
|
|
31
|
-
const coord = new
|
|
32
|
-
const last = new
|
|
33
|
-
const first = new
|
|
24
|
+
const coord = new Coordinates('EPSG:4978', 0, 0, 0);
|
|
25
|
+
const last = new Coordinates('EPSG:4978', 0, 0, 0);
|
|
26
|
+
const first = new Coordinates('EPSG:4978', 0, 0, 0);
|
|
34
27
|
|
|
35
28
|
// filter with the first point
|
|
36
29
|
const firstPtIsOut = (extent, aCoords, crs) => {
|
|
@@ -124,13 +117,13 @@ function toFeatureType(jsonType) {
|
|
|
124
117
|
switch (jsonType) {
|
|
125
118
|
case 'point':
|
|
126
119
|
case 'multipoint':
|
|
127
|
-
return
|
|
120
|
+
return FEATURE_TYPES.POINT;
|
|
128
121
|
case 'linestring':
|
|
129
122
|
case 'multilinestring':
|
|
130
|
-
return
|
|
123
|
+
return FEATURE_TYPES.LINE;
|
|
131
124
|
case 'polygon':
|
|
132
125
|
case 'multipolygon':
|
|
133
|
-
return
|
|
126
|
+
return FEATURE_TYPES.POLYGON;
|
|
134
127
|
case 'geometrycollection':
|
|
135
128
|
default:
|
|
136
129
|
throw new Error(`Unhandled geometry type ${jsonType}`);
|
|
@@ -164,7 +157,7 @@ function jsonFeatureToFeature(crsIn, json, collection) {
|
|
|
164
157
|
return feature;
|
|
165
158
|
}
|
|
166
159
|
function jsonFeaturesToFeatures(crsIn, jsonFeatures, options) {
|
|
167
|
-
const collection = new
|
|
160
|
+
const collection = new FeatureCollection(options);
|
|
168
161
|
const filter = options.filter || (() => true);
|
|
169
162
|
for (const jsonFeature of jsonFeatures) {
|
|
170
163
|
if (filter(jsonFeature.properties, jsonFeature.geometry)) {
|
|
@@ -183,7 +176,7 @@ function jsonFeaturesToFeatures(crsIn, jsonFeatures, options) {
|
|
|
183
176
|
*
|
|
184
177
|
* @module GeoJsonParser
|
|
185
178
|
*/
|
|
186
|
-
|
|
179
|
+
export default {
|
|
187
180
|
/**
|
|
188
181
|
* Parse a GeoJSON file content and return a [FeatureCollection]{@link FeatureCollection}.
|
|
189
182
|
*
|
|
@@ -193,7 +186,7 @@ var _default = {
|
|
|
193
186
|
*/
|
|
194
187
|
parse(json) {
|
|
195
188
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
196
|
-
options =
|
|
189
|
+
options = deprecatedParsingOptionsToNewOne(options);
|
|
197
190
|
options.in = options.in || {};
|
|
198
191
|
const out = options.out;
|
|
199
192
|
const _in = options.in;
|
|
@@ -203,7 +196,7 @@ var _default = {
|
|
|
203
196
|
_in.crs = _in.crs || readCRS(json);
|
|
204
197
|
if (out.filteringExtent) {
|
|
205
198
|
if (typeof out.filteringExtent == 'boolean') {
|
|
206
|
-
out.filterExtent =
|
|
199
|
+
out.filterExtent = options.extent.as(_in.crs);
|
|
207
200
|
} else if (out.filteringExtent.isExtent) {
|
|
208
201
|
out.filterExtent = out.filteringExtent;
|
|
209
202
|
}
|
|
@@ -217,5 +210,4 @@ var _default = {
|
|
|
217
210
|
throw new Error(`Unsupported GeoJSON type: '${json.type}`);
|
|
218
211
|
}
|
|
219
212
|
}
|
|
220
|
-
};
|
|
221
|
-
exports.default = _default;
|
|
213
|
+
};
|