itowns 2.44.3-next.27 → 2.44.3-next.29
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/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/examples/3dtiles_loader.html +5 -2
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/lib/Core/Geographic/Crs.js +9 -3
- package/lib/Layer/OGC3DTilesLayer.js +21 -0
- package/lib/Layer/PointCloudLayer.js +5 -7
- package/lib/Main.js +1 -1
- package/lib/Source/CopcSource.js +13 -2
- package/lib/Source/EntwinePointTileSource.js +14 -4
- package/package.json +1 -1
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.165.0/examples/jsm/"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
</script>
|
|
58
58
|
|
|
59
59
|
<script type="module">
|
|
60
60
|
import { AmbientLight } from 'three';
|
|
61
|
+
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
|
|
61
62
|
import {
|
|
62
63
|
zoomToLayer,
|
|
63
64
|
fillHTMLWithPickingInfo,
|
|
@@ -95,9 +96,11 @@
|
|
|
95
96
|
|
|
96
97
|
// Enable various compression support for 3D Tiles tileset:
|
|
97
98
|
// - `KHR_draco_mesh_compression` mesh compression extension
|
|
98
|
-
// - `KHR_texture_basisu` texture
|
|
99
|
+
// - `KHR_texture_basisu` texture compression extension
|
|
100
|
+
// - `EXT_meshopt_compression` data compression extension
|
|
99
101
|
itowns.enableDracoLoader('./libs/draco/');
|
|
100
102
|
itowns.enableKtx2Loader('./lib/basis/', view.renderer);
|
|
103
|
+
itowns.enableMeshoptDecoder(MeshoptDecoder);
|
|
101
104
|
|
|
102
105
|
// Add ambient light to globally illuminates all objects
|
|
103
106
|
const light = new AmbientLight(0x404040, 40);
|
|
@@ -87,8 +87,10 @@
|
|
|
87
87
|
eptSource = new itowns.EntwinePointTileSource({ url });
|
|
88
88
|
|
|
89
89
|
if (eptLayer) {
|
|
90
|
-
|
|
90
|
+
debugGui.removeFolder(eptLayer.debugUI);
|
|
91
|
+
view.removeLayer('Entwine Point Tile');
|
|
91
92
|
view.notifyChange();
|
|
93
|
+
eptLayer.delete();
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
eptLayer = new itowns.EntwinePointTileLayer('Entwine Point Tile', {
|
|
@@ -35,7 +35,11 @@ export const UNIT = {
|
|
|
35
35
|
/**
|
|
36
36
|
* Distance unit in meter.
|
|
37
37
|
*/
|
|
38
|
-
METER: 2
|
|
38
|
+
METER: 2,
|
|
39
|
+
/**
|
|
40
|
+
* Distance unit in foot.
|
|
41
|
+
*/
|
|
42
|
+
FOOT: 3
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -50,8 +54,10 @@ export function is4326(crs) {
|
|
|
50
54
|
function unitFromProj4Unit(proj) {
|
|
51
55
|
if (proj.units === 'degrees') {
|
|
52
56
|
return UNIT.DEGREE;
|
|
53
|
-
} else if (proj.units === 'm') {
|
|
57
|
+
} else if (proj.units === 'm' || proj.units === 'meter') {
|
|
54
58
|
return UNIT.METER;
|
|
59
|
+
} else if (proj.units === 'foot') {
|
|
60
|
+
return UNIT.FOOT;
|
|
55
61
|
} else if (proj.units === undefined && proj.to_meter === undefined) {
|
|
56
62
|
// See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
|
|
57
63
|
// > The default unit for projected coordinates is the meter.
|
|
@@ -65,7 +71,7 @@ function unitFromProj4Unit(proj) {
|
|
|
65
71
|
* Returns the horizontal coordinates system units associated with this CRS.
|
|
66
72
|
*
|
|
67
73
|
* @param crs - The CRS to extract the unit from.
|
|
68
|
-
* @returns Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
|
|
74
|
+
* @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
|
|
69
75
|
*/
|
|
70
76
|
export function getUnit(crs) {
|
|
71
77
|
mustBeString(crs);
|
|
@@ -105,6 +105,27 @@ export function enableKtx2Loader(path, renderer) {
|
|
|
105
105
|
ktx2Loader.detectSupport(renderer);
|
|
106
106
|
itownsGLTFLoader.setKTX2Loader(ktx2Loader);
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Enable loading 3D Tiles and GLTF with
|
|
111
|
+
* [meshopt](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_meshopt_compression/README.md) compression extension.
|
|
112
|
+
*
|
|
113
|
+
* @param {MeshOptDecoder.constructor} MeshOptDecoder - The Meshopt decoder
|
|
114
|
+
* module.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* import * as itowns from 'itowns';
|
|
118
|
+
* import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
|
|
119
|
+
*
|
|
120
|
+
* // Enable support of EXT_meshopt_compression
|
|
121
|
+
* itowns.enableMeshoptDecoder(MeshoptDecoder);
|
|
122
|
+
*/
|
|
123
|
+
export function enableMeshoptDecoder(MeshOptDecoder) {
|
|
124
|
+
if (!MeshOptDecoder) {
|
|
125
|
+
throw new Error('MeshOptDecoder module is mandatory');
|
|
126
|
+
}
|
|
127
|
+
itownsGLTFLoader.setMeshoptDecoder(MeshOptDecoder);
|
|
128
|
+
}
|
|
108
129
|
class OGC3DTilesLayer extends GeometryLayer {
|
|
109
130
|
/**
|
|
110
131
|
* Layer for [3D Tiles](https://www.ogc.org/standard/3dtiles/) datasets.
|
|
@@ -291,9 +291,6 @@ class PointCloudLayer extends GeometryLayer {
|
|
|
291
291
|
redraw: true,
|
|
292
292
|
earlyDropFunction: cmd => !cmd.requester.visible || !this.visible
|
|
293
293
|
}).then(pts => {
|
|
294
|
-
if (this.onPointsCreated) {
|
|
295
|
-
this.onPointsCreated(layer, pts);
|
|
296
|
-
}
|
|
297
294
|
elt.obj = pts;
|
|
298
295
|
// store tightbbox to avoid ping-pong (bbox = larger => visible, tight => invisible)
|
|
299
296
|
elt.tightbbox = pts.tightbbox;
|
|
@@ -302,11 +299,12 @@ class PointCloudLayer extends GeometryLayer {
|
|
|
302
299
|
// be added nor cleaned
|
|
303
300
|
this.group.add(elt.obj);
|
|
304
301
|
elt.obj.updateMatrixWorld(true);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
elt.promise = null;
|
|
302
|
+
}).catch(err => {
|
|
303
|
+
if (!err.isCancelledCommandException) {
|
|
304
|
+
return err;
|
|
309
305
|
}
|
|
306
|
+
}).finally(() => {
|
|
307
|
+
elt.promise = null;
|
|
310
308
|
});
|
|
311
309
|
}
|
|
312
310
|
}
|
package/lib/Main.js
CHANGED
|
@@ -53,7 +53,7 @@ export { default as PointCloudLayer } from "./Layer/PointCloudLayer.js";
|
|
|
53
53
|
export { default as PotreeLayer } from "./Layer/PotreeLayer.js";
|
|
54
54
|
export { default as Potree2Layer } from "./Layer/Potree2Layer.js";
|
|
55
55
|
export { default as C3DTilesLayer, C3DTILES_LAYER_EVENTS } from "./Layer/C3DTilesLayer.js";
|
|
56
|
-
export { default as OGC3DTilesLayer, OGC3DTILES_LAYER_EVENTS, enableDracoLoader, enableKtx2Loader } from "./Layer/OGC3DTilesLayer.js";
|
|
56
|
+
export { default as OGC3DTilesLayer, OGC3DTILES_LAYER_EVENTS, enableDracoLoader, enableKtx2Loader, enableMeshoptDecoder } from "./Layer/OGC3DTilesLayer.js";
|
|
57
57
|
export { default as TiledGeometryLayer } from "./Layer/TiledGeometryLayer.js";
|
|
58
58
|
export { default as OrientedImageLayer } from "./Layer/OrientedImageLayer.js";
|
|
59
59
|
export { STRATEGY_MIN_NETWORK_TRAFFIC, STRATEGY_GROUP, STRATEGY_PROGRESSIVE, STRATEGY_DICHOTOMY } from "./Layer/LayerUpdateStrategy.js";
|
package/lib/Source/CopcSource.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import proj4 from 'proj4';
|
|
1
2
|
import { Binary, Info, Las } from 'copc';
|
|
2
3
|
import Extent from "../Core/Geographic/Extent.js";
|
|
3
4
|
import Fetcher from "../Provider/Fetcher.js";
|
|
@@ -102,8 +103,18 @@ class CopcSource extends Source {
|
|
|
102
103
|
this.header = metadata.header;
|
|
103
104
|
this.info = metadata.info;
|
|
104
105
|
this.eb = metadata.eb;
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
proj4.defs('unknown', metadata.wkt);
|
|
107
|
+
let projCS;
|
|
108
|
+
if (proj4.defs('unknown').type === 'COMPD_CS') {
|
|
109
|
+
console.warn('CopcSource: compound coordinate system is not yet supported.');
|
|
110
|
+
projCS = proj4.defs('unknown').PROJCS;
|
|
111
|
+
} else {
|
|
112
|
+
projCS = proj4.defs('unknown');
|
|
113
|
+
}
|
|
114
|
+
this.crs = projCS.title || projCS.name || 'EPSG:4326';
|
|
115
|
+
if (!(this.crs in proj4.defs)) {
|
|
116
|
+
proj4.defs(this.crs, projCS);
|
|
117
|
+
}
|
|
107
118
|
const bbox = new THREE.Box3();
|
|
108
119
|
bbox.min.fromArray(this.info.cube, 0);
|
|
109
120
|
bbox.max.fromArray(this.info.cube, 3);
|
|
@@ -38,10 +38,19 @@ class EntwinePointTileSource extends Source {
|
|
|
38
38
|
// Set parser and its configuration from schema
|
|
39
39
|
this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
|
|
40
40
|
this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
|
|
41
|
-
if (metadata.srs
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
proj4.defs(this.crs
|
|
41
|
+
if (metadata.srs) {
|
|
42
|
+
if (metadata.srs.authority && metadata.srs.horizontal) {
|
|
43
|
+
this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
|
|
44
|
+
if (!proj4.defs(this.crs)) {
|
|
45
|
+
proj4.defs(this.crs, metadata.srs.wkt);
|
|
46
|
+
}
|
|
47
|
+
} else if (metadata.srs.wkt) {
|
|
48
|
+
proj4.defs('unknown', metadata.srs.wkt);
|
|
49
|
+
const projCS = proj4.defs('unknown');
|
|
50
|
+
this.crs = projCS.title || projCS.name;
|
|
51
|
+
if (!(this.crs in proj4.defs)) {
|
|
52
|
+
proj4.defs(this.crs, projCS);
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
|
|
47
56
|
console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
|
|
@@ -53,6 +62,7 @@ class EntwinePointTileSource extends Source {
|
|
|
53
62
|
// span in ept.json. This needs improvements.
|
|
54
63
|
this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0]) + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
|
|
55
64
|
this.boundsConforming = metadata.boundsConforming;
|
|
65
|
+
this.bounds = metadata.bounds;
|
|
56
66
|
this.span = metadata.span;
|
|
57
67
|
return this;
|
|
58
68
|
});
|