itowns 2.44.3-next.3 → 2.44.3-next.30
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/CODING.md +1 -1
- package/CONTRIBUTORS.md +1 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.LICENSE.txt +0 -2
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/3dtiles_loader.html +109 -45
- package/examples/config.json +2 -10
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/images/itowns_logo.svg +123 -0
- package/examples/js/plugins/COGParser.js +1 -1
- package/examples/jsm/OGC3DTilesHelper.js +1 -1
- package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
- package/examples/source_file_geojson_3d.html +0 -1
- package/examples/source_stream_wfs_raster.html +0 -7
- package/lib/Controls/GlobeControls.js +45 -28
- package/lib/Controls/StateControl.js +5 -2
- package/lib/Converter/Feature2Mesh.js +10 -4
- package/lib/Converter/Feature2Texture.js +3 -1
- package/lib/Converter/convertToTile.js +3 -8
- package/lib/Converter/textureConverter.js +3 -4
- package/lib/Core/Deprecated/Undeprecator.js +0 -1
- package/lib/Core/Feature.js +1 -2
- package/lib/Core/Geographic/Coordinates.js +143 -132
- package/lib/Core/Geographic/Crs.js +140 -145
- package/lib/Core/Geographic/Extent.js +72 -267
- package/lib/Core/Geographic/GeoidGrid.js +1 -1
- package/lib/Core/Math/Ellipsoid.js +62 -21
- package/lib/Core/Prefab/Globe/Atmosphere.js +4 -8
- package/lib/Core/Prefab/Globe/GlobeLayer.js +22 -15
- package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
- package/lib/Core/Prefab/GlobeView.js +2 -7
- package/lib/Core/Prefab/Planar/PlanarLayer.js +17 -11
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
- package/lib/Core/Prefab/TileBuilder.js +27 -32
- package/lib/Core/Prefab/computeBufferTileGeometry.js +189 -130
- package/lib/Core/Style.js +3 -3
- package/lib/Core/Tile/Tile.js +219 -0
- package/lib/Core/Tile/TileGrid.js +43 -0
- package/lib/Core/TileGeometry.js +112 -28
- package/lib/Core/TileMesh.js +3 -3
- package/lib/Core/View.js +15 -8
- package/lib/Layer/C3DTilesLayer.js +20 -16
- package/lib/Layer/ColorLayer.js +35 -9
- package/lib/Layer/CopcLayer.js +5 -0
- package/lib/Layer/ElevationLayer.js +39 -7
- package/lib/Layer/EntwinePointTileLayer.js +12 -5
- package/lib/Layer/FeatureGeometryLayer.js +20 -6
- package/lib/Layer/GeometryLayer.js +42 -11
- package/lib/Layer/LabelLayer.js +19 -9
- package/lib/Layer/Layer.js +83 -57
- package/lib/Layer/OGC3DTilesLayer.js +81 -30
- package/lib/Layer/OrientedImageLayer.js +11 -5
- package/lib/Layer/PointCloudLayer.js +74 -30
- package/lib/Layer/Potree2Layer.js +7 -2
- package/lib/Layer/PotreeLayer.js +8 -3
- package/lib/Layer/RasterLayer.js +12 -2
- package/lib/Layer/TiledGeometryLayer.js +69 -13
- package/lib/Main.js +2 -2
- package/lib/Parser/GeoJsonParser.js +1 -1
- package/lib/Parser/VectorTileParser.js +1 -1
- package/lib/Parser/XbilParser.js +14 -2
- package/lib/Provider/Fetcher.js +5 -1
- package/lib/Provider/URLBuilder.js +22 -11
- package/lib/Renderer/Camera.js +1 -1
- package/lib/Renderer/OBB.js +11 -13
- package/lib/Renderer/PointsMaterial.js +1 -1
- package/lib/Renderer/RasterTile.js +1 -2
- package/lib/Renderer/SphereHelper.js +0 -6
- package/lib/Source/CopcSource.js +13 -2
- package/lib/Source/EntwinePointTileSource.js +14 -4
- package/lib/Source/FileSource.js +1 -4
- package/lib/Source/Source.js +1 -4
- package/lib/Source/TMSSource.js +10 -9
- package/lib/Source/VectorTilesSource.js +3 -5
- package/lib/Source/WFSSource.js +15 -10
- package/lib/Source/WMSSource.js +56 -18
- package/lib/Source/WMTSSource.js +13 -7
- package/lib/Utils/CameraUtils.js +1 -1
- package/lib/Utils/gui/C3DTilesStyle.js +2 -3
- package/lib/Utils/placeObjectOnGround.js +0 -1
- package/package.json +13 -6
- package/examples/3dtiles_25d.html +0 -120
- package/examples/3dtiles_basic.html +0 -94
- package/examples/3dtiles_batch_table.html +0 -86
- package/examples/3dtiles_ion.html +0 -126
- package/examples/3dtiles_pointcloud.html +0 -95
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
package/lib/Core/TileGeometry.js
CHANGED
|
@@ -1,40 +1,124 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import computeBuffers,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
2
|
+
import { computeBuffers, getBufferIndexSize } from "./Prefab/computeBufferTileGeometry.js";
|
|
3
|
+
import Coordinates from "./Geographic/Coordinates.js";
|
|
4
|
+
function defaultBuffers(builder, params) {
|
|
5
|
+
const fullParams = {
|
|
6
|
+
disableSkirt: false,
|
|
7
|
+
hideSkirt: false,
|
|
8
|
+
buildIndexAndUv_0: true,
|
|
9
|
+
segments: 16,
|
|
10
|
+
coordinates: new Coordinates(builder.crs),
|
|
11
|
+
center: builder.center(params.extent).clone(),
|
|
12
|
+
...params
|
|
13
|
+
};
|
|
14
|
+
const buffers = computeBuffers(builder, fullParams);
|
|
15
|
+
const bufferAttributes = {
|
|
16
|
+
index: buffers.index ? new THREE.BufferAttribute(buffers.index, 1) : null,
|
|
17
|
+
uvs: [...(buffers.uvs[0] ? [new THREE.BufferAttribute(buffers.uvs[0], 2)] : []), ...(buffers.uvs[1] ? [new THREE.BufferAttribute(buffers.uvs[1], 1)] : [])],
|
|
18
|
+
position: new THREE.BufferAttribute(buffers.position, 3),
|
|
19
|
+
normal: new THREE.BufferAttribute(buffers.normal, 3)
|
|
20
|
+
};
|
|
21
|
+
return bufferAttributes;
|
|
15
22
|
}
|
|
16
|
-
class TileGeometry extends THREE.BufferGeometry {
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
export class TileGeometry extends THREE.BufferGeometry {
|
|
24
|
+
/** Oriented Bounding Box of the tile geometry. */
|
|
25
|
+
|
|
26
|
+
/** Ground area covered by this tile geometry. */
|
|
27
|
+
|
|
28
|
+
/** Resolution of the tile geometry in segments per side. */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* [TileGeometry] instances are shared between tiles. Since a geometry
|
|
32
|
+
* handles its own GPU resource, it needs a reference counter to dispose of
|
|
33
|
+
* that resource only when it is discarded by every single owner of a
|
|
34
|
+
* reference to the geometry.
|
|
35
|
+
*/
|
|
36
|
+
// https://github.com/iTowns/itowns/pull/2440#discussion_r1860743294
|
|
37
|
+
// TODO: Remove nullability by reworking OBB:setFromExtent
|
|
38
|
+
|
|
39
|
+
constructor(builder, params) {
|
|
40
|
+
let bufferAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultBuffers(builder, params);
|
|
19
41
|
super();
|
|
20
|
-
this.center = params.center;
|
|
21
42
|
this.extent = params.extent;
|
|
22
43
|
this.segments = params.segments;
|
|
23
|
-
this.setIndex(
|
|
24
|
-
this.setAttribute('position',
|
|
25
|
-
this.setAttribute('normal',
|
|
26
|
-
this.setAttribute('uv',
|
|
27
|
-
for (let i = 1; i <
|
|
28
|
-
this.setAttribute(`uv_${i}`,
|
|
44
|
+
this.setIndex(bufferAttributes.index);
|
|
45
|
+
this.setAttribute('position', bufferAttributes.position);
|
|
46
|
+
this.setAttribute('normal', bufferAttributes.normal);
|
|
47
|
+
this.setAttribute('uv', bufferAttributes.uvs[0]);
|
|
48
|
+
for (let i = 1; i < bufferAttributes.uvs.length; i++) {
|
|
49
|
+
this.setAttribute(`uv_${i}`, bufferAttributes.uvs[i]);
|
|
29
50
|
}
|
|
30
51
|
this.computeBoundingBox();
|
|
31
|
-
this.OBB =
|
|
52
|
+
this.OBB = null;
|
|
32
53
|
if (params.hideSkirt) {
|
|
33
54
|
this.hideSkirt = params.hideSkirt;
|
|
34
55
|
}
|
|
56
|
+
this._refCount = null;
|
|
35
57
|
}
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Enables or disables skirt rendering.
|
|
61
|
+
*
|
|
62
|
+
* @param toggle - Whether to hide the skirt; true hides, false shows.
|
|
63
|
+
*/
|
|
64
|
+
set hideSkirt(toggle) {
|
|
65
|
+
this.setDrawRange(0, getBufferIndexSize(this.segments, toggle));
|
|
38
66
|
}
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Initialize reference count for this geometry if it is currently null.
|
|
70
|
+
*
|
|
71
|
+
* @param cacheTile - The [Cache] used to store this geometry.
|
|
72
|
+
* @param keys - The [south, level, epsg] key of this geometry.
|
|
73
|
+
*/
|
|
74
|
+
initRefCount(cacheTile, keys) {
|
|
75
|
+
if (this._refCount !== null) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this._refCount = {
|
|
79
|
+
count: 0,
|
|
80
|
+
fn: () => {
|
|
81
|
+
this._refCount.count--;
|
|
82
|
+
if (this._refCount.count <= 0) {
|
|
83
|
+
// To avoid remove index buffer and attribute buffer uv
|
|
84
|
+
// error un-bound buffer in webgl with VAO rendering.
|
|
85
|
+
// Could be removed if the attribute buffer deleting is
|
|
86
|
+
// taken into account in the buffer binding state
|
|
87
|
+
// (in THREE.WebGLBindingStates code).
|
|
88
|
+
this.index = null;
|
|
89
|
+
delete this.attributes.uv;
|
|
90
|
+
cacheTile.delete(...keys);
|
|
91
|
+
super.dispose();
|
|
92
|
+
// THREE.BufferGeometry.prototype.dispose.call(this);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Increase reference count.
|
|
100
|
+
*
|
|
101
|
+
* @throws If reference count has not been initialized.
|
|
102
|
+
*/
|
|
103
|
+
increaseRefCount() {
|
|
104
|
+
if (this._refCount === null) {
|
|
105
|
+
throw new Error('[TileGeometry::increaseRefCount] ' + 'Tried to increment an unitialized reference count.');
|
|
106
|
+
}
|
|
107
|
+
this._refCount.count++;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The current reference count of this [TileGeometry] if it has been
|
|
112
|
+
* initialized.
|
|
113
|
+
*/
|
|
114
|
+
get refCount() {
|
|
115
|
+
return this._refCount?.count;
|
|
116
|
+
}
|
|
117
|
+
dispose() {
|
|
118
|
+
if (this._refCount == null) {
|
|
119
|
+
super.dispose();
|
|
120
|
+
} else {
|
|
121
|
+
this._refCount.fn();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
package/lib/Core/TileMesh.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import CRS from "./Geographic/Crs.js";
|
|
3
2
|
import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
|
|
3
|
+
import { tiledCovering } from "./Tile/Tile.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A TileMesh is a THREE.Mesh with a geometricError and an OBB
|
|
@@ -29,7 +29,7 @@ class TileMesh extends THREE.Mesh {
|
|
|
29
29
|
this.boundingSphere = new THREE.Sphere();
|
|
30
30
|
this.obb.box3D.getBoundingSphere(this.boundingSphere);
|
|
31
31
|
for (const tms of layer.tileMatrixSets) {
|
|
32
|
-
this.#_tms.set(tms, this.extent
|
|
32
|
+
this.#_tms.set(tms, tiledCovering(this.extent, tms));
|
|
33
33
|
}
|
|
34
34
|
this.frustumCulled = false;
|
|
35
35
|
this.matrixAutoUpdate = false;
|
|
@@ -70,7 +70,7 @@ class TileMesh extends THREE.Mesh {
|
|
|
70
70
|
this.obb.box3D.getBoundingSphere(this.boundingSphere);
|
|
71
71
|
}
|
|
72
72
|
getExtentsByProjection(crs) {
|
|
73
|
-
return this.#_tms.get(
|
|
73
|
+
return this.#_tms.get(crs);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
package/lib/Core/View.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
+
import * as CRS from "./Geographic/Crs.js";
|
|
2
3
|
import Camera from "../Renderer/Camera.js";
|
|
3
4
|
import initializeWebXR from "../Renderer/WebXR.js";
|
|
4
5
|
import MainLoop, { MAIN_LOOP_EVENTS, RENDERING_PAUSED } from "./MainLoop.js";
|
|
@@ -6,7 +7,6 @@ import Capabilities from "./System/Capabilities.js";
|
|
|
6
7
|
import { COLOR_LAYERS_ORDER_CHANGED } from "../Renderer/ColorLayersOrdering.js";
|
|
7
8
|
import c3DEngine from "../Renderer/c3DEngine.js";
|
|
8
9
|
import RenderMode from "../Renderer/RenderMode.js";
|
|
9
|
-
import CRS from "./Geographic/Crs.js";
|
|
10
10
|
import Coordinates from "./Geographic/Coordinates.js";
|
|
11
11
|
import FeaturesUtils from "../Utils/FeaturesUtils.js";
|
|
12
12
|
import { getMaxColorSamplerUnitsCount } from "../Renderer/LayeredMaterial.js";
|
|
@@ -30,7 +30,8 @@ export const VIEW_EVENTS = {
|
|
|
30
30
|
LAYER_ADDED: 'layer-added',
|
|
31
31
|
INITIALIZED: 'initialized',
|
|
32
32
|
COLOR_LAYERS_ORDER_CHANGED,
|
|
33
|
-
CAMERA_MOVED: 'camera-moved'
|
|
33
|
+
CAMERA_MOVED: 'camera-moved',
|
|
34
|
+
DISPOSED: 'disposed'
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -52,7 +53,7 @@ function _preprocessLayer(view, layer, parentLayer) {
|
|
|
52
53
|
// Find crs projection layer, this is projection destination
|
|
53
54
|
layer.crs = view.referenceCrs;
|
|
54
55
|
} else if (!layer.crs) {
|
|
55
|
-
if (parentLayer && parentLayer.tileMatrixSets && parentLayer.tileMatrixSets.includes(
|
|
56
|
+
if (parentLayer && parentLayer.tileMatrixSets && parentLayer.tileMatrixSets.includes(source.crs)) {
|
|
56
57
|
layer.crs = source.crs;
|
|
57
58
|
} else {
|
|
58
59
|
layer.crs = parentLayer && parentLayer.extent.crs;
|
|
@@ -109,9 +110,11 @@ const coordinates = new Coordinates('EPSG:4326');
|
|
|
109
110
|
const viewers = [];
|
|
110
111
|
// Size of the camera frustrum, in meters
|
|
111
112
|
let screenMeters;
|
|
113
|
+
let id = 0;
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
|
-
* @property {
|
|
116
|
+
* @property {number} id - The id of the view. It's incremented at each new view instance, starting at 0.
|
|
117
|
+
* @property {HTMLElement} domElement - The domElement holding the canvas where the view is displayed
|
|
115
118
|
* @property {String} referenceCrs - The coordinate reference system of the view
|
|
116
119
|
* @property {MainLoop} mainLoop - itowns mainloop scheduling the operations
|
|
117
120
|
* @property {THREE.Scene} scene - threejs scene of the view
|
|
@@ -136,10 +139,10 @@ class View extends THREE.EventDispatcher {
|
|
|
136
139
|
* var view = itowns.View('EPSG:4326', viewerDiv, { camera: { type: itowns.CAMERA_TYPE.ORTHOGRAPHIC } });
|
|
137
140
|
* var customControls = itowns.THREE.OrbitControls(view.camera3D, viewerDiv);
|
|
138
141
|
*
|
|
139
|
-
* @param {
|
|
142
|
+
* @param {String} crs - The default CRS of Three.js coordinates. Should be a cartesian CRS.
|
|
140
143
|
* @param {HTMLElement} viewerDiv - Where to instanciate the Three.js scene in the DOM
|
|
141
144
|
* @param {Object} [options] - Optional properties.
|
|
142
|
-
* @param {
|
|
145
|
+
* @param {Object} [options.camera] - Options for the camera associated to the view. See {@link Camera} options.
|
|
143
146
|
* @param {MainLoop} [options.mainLoop] - {@link MainLoop} instance to use, otherwise a default one will be constructed
|
|
144
147
|
* @param {WebGLRenderer|Object} [options.renderer] - {@link WebGLRenderer} instance to use, otherwise
|
|
145
148
|
* a default one will be constructed. In this case, if options.renderer is an object, it will be used to
|
|
@@ -159,6 +162,7 @@ class View extends THREE.EventDispatcher {
|
|
|
159
162
|
}
|
|
160
163
|
super();
|
|
161
164
|
this.domElement = viewerDiv;
|
|
165
|
+
this.id = id++;
|
|
162
166
|
this.referenceCrs = crs;
|
|
163
167
|
let engine;
|
|
164
168
|
// options.renderer can be 2 separate things:
|
|
@@ -272,8 +276,6 @@ class View extends THREE.EventDispatcher {
|
|
|
272
276
|
}
|
|
273
277
|
// remove alls frameRequester
|
|
274
278
|
this.removeAllFrameRequesters();
|
|
275
|
-
// remove alls events
|
|
276
|
-
this.removeAllEvents();
|
|
277
279
|
// remove all layers
|
|
278
280
|
const layers = this.getLayers(l => !l.isTiledGeometryLayer && !l.isAtmosphere);
|
|
279
281
|
for (const layer of layers) {
|
|
@@ -290,6 +292,11 @@ class View extends THREE.EventDispatcher {
|
|
|
290
292
|
viewers.splice(id, 1);
|
|
291
293
|
// Remove remaining objects in the scene (e.g. helpers, debug, etc.)
|
|
292
294
|
this.scene.traverse(ObjectRemovalHelper.cleanup);
|
|
295
|
+
this.dispatchEvent({
|
|
296
|
+
type: VIEW_EVENTS.DISPOSED
|
|
297
|
+
});
|
|
298
|
+
// remove alls events
|
|
299
|
+
this.removeAllEvents();
|
|
293
300
|
}
|
|
294
301
|
|
|
295
302
|
/**
|
|
@@ -51,11 +51,14 @@ function findTileID(object) {
|
|
|
51
51
|
function object3DHasFeature(object3d) {
|
|
52
52
|
return object3d.geometry && object3d.geometry.attributes._BATCHID;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @extends GeometryLayer
|
|
57
|
+
*/
|
|
54
58
|
class C3DTilesLayer extends GeometryLayer {
|
|
55
59
|
#fillColorMaterialsBuffer;
|
|
56
60
|
/**
|
|
57
61
|
* @deprecated Deprecated 3D Tiles layer. Use {@link OGC3DTilesLayer} instead.
|
|
58
|
-
* @extends GeometryLayer
|
|
59
62
|
*
|
|
60
63
|
* @example
|
|
61
64
|
* // Create a new 3d-tiles layer from a web server
|
|
@@ -83,7 +86,7 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
83
86
|
* {@link View} that already has a layer going by that id.
|
|
84
87
|
* @param {object} config configuration, all elements in it
|
|
85
88
|
* will be merged as is in the layer.
|
|
86
|
-
* @param {
|
|
89
|
+
* @param {C3DTilesSource} config.source The source of 3d Tiles.
|
|
87
90
|
*
|
|
88
91
|
* name.
|
|
89
92
|
* @param {Number} [config.sseThreshold=16] The [Screen Space Error](https://github.com/CesiumGS/3d-tiles/blob/main/specification/README.md#geometric-error)
|
|
@@ -102,6 +105,7 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
102
105
|
* @param {View} view The view
|
|
103
106
|
*/
|
|
104
107
|
constructor(id, config, view) {
|
|
108
|
+
console.warn('C3DTilesLayer is deprecated and will be removed in iTowns 3.0 version. Use OGC3DTilesLayer instead.');
|
|
105
109
|
super(id, new THREE.Group(), {
|
|
106
110
|
source: config.source
|
|
107
111
|
});
|
|
@@ -142,7 +146,7 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
/** @type {Style} */
|
|
149
|
+
/** @type {Style | null} */
|
|
146
150
|
this._style = config.style || null;
|
|
147
151
|
|
|
148
152
|
/** @type {Map<string, THREE.MeshStandardMaterial>} */
|
|
@@ -368,21 +372,15 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
368
372
|
if (c3DTileFeature.object3d != object3d) {
|
|
369
373
|
continue; // this feature do not belong to object3d
|
|
370
374
|
}
|
|
375
|
+
this._style.context.setGeometry({
|
|
376
|
+
properties: c3DTileFeature
|
|
377
|
+
});
|
|
378
|
+
|
|
371
379
|
/** @type {THREE.Color} */
|
|
372
|
-
|
|
373
|
-
if (typeof this._style.fill.color === 'function') {
|
|
374
|
-
color = new THREE.Color(this._style.fill.color(c3DTileFeature));
|
|
375
|
-
} else {
|
|
376
|
-
color = new THREE.Color(this._style.fill.color);
|
|
377
|
-
}
|
|
380
|
+
const color = new THREE.Color(this._style.fill.color);
|
|
378
381
|
|
|
379
382
|
/** @type {number} */
|
|
380
|
-
|
|
381
|
-
if (typeof this._style.fill.opacity === 'function') {
|
|
382
|
-
opacity = this._style.fill.opacity(c3DTileFeature);
|
|
383
|
-
} else {
|
|
384
|
-
opacity = this._style.fill.opacity;
|
|
385
|
-
}
|
|
383
|
+
const opacity = this._style.fill.opacity;
|
|
386
384
|
const materialId = color.getHexString() + opacity;
|
|
387
385
|
let material = null;
|
|
388
386
|
if (this.#fillColorMaterialsBuffer.has(materialId)) {
|
|
@@ -445,7 +443,13 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
445
443
|
return this.#fillColorMaterialsBuffer.size;
|
|
446
444
|
}
|
|
447
445
|
set style(value) {
|
|
448
|
-
|
|
446
|
+
if (value instanceof Style) {
|
|
447
|
+
this._style = value;
|
|
448
|
+
} else if (!value) {
|
|
449
|
+
this._style = null;
|
|
450
|
+
} else {
|
|
451
|
+
this._style = new Style(value);
|
|
452
|
+
}
|
|
449
453
|
this.updateStyle();
|
|
450
454
|
}
|
|
451
455
|
get style() {
|
package/lib/Layer/ColorLayer.js
CHANGED
|
@@ -44,6 +44,8 @@ import { deprecatedColorLayerOptions } from "../Core/Deprecated/Undeprecator.js"
|
|
|
44
44
|
* * `1`: used to amplify the transparency effect.
|
|
45
45
|
* * `2`: unused.
|
|
46
46
|
* * `3`: could be used by your own glsl code.
|
|
47
|
+
*
|
|
48
|
+
* @extends RasterLayer
|
|
47
49
|
*/
|
|
48
50
|
class ColorLayer extends RasterLayer {
|
|
49
51
|
/**
|
|
@@ -51,8 +53,6 @@ class ColorLayer extends RasterLayer {
|
|
|
51
53
|
* it can be an aerial view of the ground or a simple transparent layer with the
|
|
52
54
|
* roads displayed.
|
|
53
55
|
*
|
|
54
|
-
* @extends Layer
|
|
55
|
-
*
|
|
56
56
|
* @param {string} id - The id of the layer, that should be unique. It is
|
|
57
57
|
* not mandatory, but an error will be emitted if this layer is added a
|
|
58
58
|
* {@link View} that already has a layer going by that id.
|
|
@@ -92,15 +92,41 @@ class ColorLayer extends RasterLayer {
|
|
|
92
92
|
constructor(id) {
|
|
93
93
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
94
94
|
deprecatedColorLayerOptions(config);
|
|
95
|
-
|
|
95
|
+
const {
|
|
96
|
+
effect_type = 0,
|
|
97
|
+
effect_parameter = 1.0,
|
|
98
|
+
transparent,
|
|
99
|
+
...rasterConfig
|
|
100
|
+
} = config;
|
|
101
|
+
super(id, rasterConfig);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @type {boolean}
|
|
105
|
+
* @readonly
|
|
106
|
+
*/
|
|
96
107
|
this.isColorLayer = true;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @type {boolean}
|
|
111
|
+
*/
|
|
112
|
+
this.visible = true;
|
|
113
|
+
this.defineLayerProperty('visible', this.visible);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @type {number}
|
|
117
|
+
*/
|
|
118
|
+
this.opacity = 1.0;
|
|
119
|
+
this.defineLayerProperty('opacity', this.opacity);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @type {number}
|
|
123
|
+
*/
|
|
124
|
+
this.sequence = 0;
|
|
125
|
+
this.defineLayerProperty('sequence', this.sequence);
|
|
126
|
+
this.transparent = transparent || this.opacity < 1.0;
|
|
101
127
|
this.noTextureParentOutsideLimit = config.source ? config.source.isFileSource : false;
|
|
102
|
-
this.effect_type =
|
|
103
|
-
this.effect_parameter =
|
|
128
|
+
this.effect_type = effect_type;
|
|
129
|
+
this.effect_parameter = effect_parameter;
|
|
104
130
|
|
|
105
131
|
// Feature options
|
|
106
132
|
this.buildExtent = true;
|
package/lib/Layer/CopcLayer.js
CHANGED
|
@@ -30,6 +30,11 @@ class CopcLayer extends PointCloudLayer {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(id, config) {
|
|
32
32
|
super(id, config);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @readonly
|
|
37
|
+
*/
|
|
33
38
|
this.isCopcLayer = true;
|
|
34
39
|
const resolve = () => this;
|
|
35
40
|
this.whenReady = this.source.whenReady.then((/** @type {CopcSource} */source) => {
|
|
@@ -22,14 +22,14 @@ import { RasterElevationTile } from "../Renderer/RasterTile.js";
|
|
|
22
22
|
* ```
|
|
23
23
|
* @property {number} colorTextureElevationMinZ - elevation minimum in `useColorTextureElevation` mode.
|
|
24
24
|
* @property {number} colorTextureElevationMaxZ - elevation maximum in `useColorTextureElevation` mode.
|
|
25
|
+
*
|
|
26
|
+
* @extends RasterLayer
|
|
25
27
|
*/
|
|
26
28
|
class ElevationLayer extends RasterLayer {
|
|
27
29
|
/**
|
|
28
30
|
* A simple layer, managing an elevation texture to add some reliefs on the
|
|
29
31
|
* plane or globe view for example.
|
|
30
32
|
*
|
|
31
|
-
* @extends Layer
|
|
32
|
-
*
|
|
33
33
|
* @param {string} id - The id of the layer, that should be unique. It is
|
|
34
34
|
* not mandatory, but an error will be emitted if this layer is added a
|
|
35
35
|
* {@link View} that already has a layer going by that id.
|
|
@@ -60,14 +60,46 @@ class ElevationLayer extends RasterLayer {
|
|
|
60
60
|
*/
|
|
61
61
|
constructor(id) {
|
|
62
62
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
|
-
|
|
63
|
+
const {
|
|
64
|
+
scale = 1.0,
|
|
65
|
+
noDataValue,
|
|
66
|
+
clampValues,
|
|
67
|
+
useRgbaTextureElevation,
|
|
68
|
+
useColorTextureElevation,
|
|
69
|
+
colorTextureElevationMinZ,
|
|
70
|
+
colorTextureElevationMaxZ,
|
|
71
|
+
bias,
|
|
72
|
+
mode,
|
|
73
|
+
...rasterConfig
|
|
74
|
+
} = config;
|
|
75
|
+
super(id, rasterConfig);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {boolean}
|
|
79
|
+
* @readonly
|
|
80
|
+
*/
|
|
81
|
+
this.isElevationLayer = true;
|
|
82
|
+
this.noDataValue = noDataValue;
|
|
64
83
|
if (config.zmin || config.zmax) {
|
|
65
84
|
console.warn('Config using zmin and zmax are deprecated, use {clampValues: {min, max}} structure.');
|
|
66
85
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @type {number | undefined}
|
|
89
|
+
*/
|
|
90
|
+
this.zmin = clampValues?.min ?? config.zmin;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @type {number | undefined}
|
|
94
|
+
*/
|
|
95
|
+
this.zmax = clampValues?.max ?? config.zmax;
|
|
96
|
+
this.defineLayerProperty('scale', scale);
|
|
97
|
+
this.useRgbaTextureElevation = useRgbaTextureElevation;
|
|
98
|
+
this.useColorTextureElevation = useColorTextureElevation;
|
|
99
|
+
this.colorTextureElevationMinZ = colorTextureElevationMinZ;
|
|
100
|
+
this.colorTextureElevationMaxZ = colorTextureElevationMaxZ;
|
|
101
|
+
this.bias = bias;
|
|
102
|
+
this.mode = mode;
|
|
71
103
|
}
|
|
72
104
|
|
|
73
105
|
/**
|
|
@@ -10,13 +10,13 @@ bboxMesh.geometry.boundingBox = box3;
|
|
|
10
10
|
* @property {boolean} isEntwinePointTileLayer - Used to checkout whether this
|
|
11
11
|
* layer is a EntwinePointTileLayer. Default is `true`. You should not change
|
|
12
12
|
* this, as it is used internally for optimisation.
|
|
13
|
+
*
|
|
14
|
+
* @extends PointCloudLayer
|
|
13
15
|
*/
|
|
14
16
|
class EntwinePointTileLayer extends PointCloudLayer {
|
|
15
17
|
/**
|
|
16
18
|
* Constructs a new instance of Entwine Point Tile layer.
|
|
17
19
|
*
|
|
18
|
-
* @extends PointCloudLayer
|
|
19
|
-
*
|
|
20
20
|
* @example
|
|
21
21
|
* // Create a new point cloud layer
|
|
22
22
|
* const points = new EntwinePointTileLayer('EPT',
|
|
@@ -36,15 +36,22 @@ class EntwinePointTileLayer extends PointCloudLayer {
|
|
|
36
36
|
* contains three elements `name, protocol, extent`, these elements will be
|
|
37
37
|
* available using `layer.name` or something else depending on the property
|
|
38
38
|
* name. See the list of properties to know which one can be specified.
|
|
39
|
-
* @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
|
|
39
|
+
* @param {string} [config.crs='ESPG:4326'] - The CRS of the {@link View} this
|
|
40
40
|
* layer will be attached to. This is used to determine the extent of this
|
|
41
41
|
* layer. Default to `EPSG:4326`.
|
|
42
|
-
* @param {number} [config.skip=1] - Read one point from every `skip` points
|
|
43
|
-
* - see {@link LASParser}.
|
|
44
42
|
*/
|
|
45
43
|
constructor(id, config) {
|
|
46
44
|
super(id, config);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @type {boolean}
|
|
48
|
+
* @readonly
|
|
49
|
+
*/
|
|
47
50
|
this.isEntwinePointTileLayer = true;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @type {THREE.Vector3}
|
|
54
|
+
*/
|
|
48
55
|
this.scale = new THREE.Vector3(1, 1, 1);
|
|
49
56
|
const resolve = this.addInitializationStep();
|
|
50
57
|
this.whenReady = this.source.whenReady.then(() => {
|
|
@@ -12,10 +12,11 @@ import Feature2Mesh from "../Converter/Feature2Mesh.js";
|
|
|
12
12
|
* @property {boolean} isFeatureGeometryLayer - Used to checkout whether this layer is
|
|
13
13
|
* a FeatureGeometryLayer. Default is true. You should not change this, as it is used
|
|
14
14
|
* internally for optimisation.
|
|
15
|
+
*
|
|
16
|
+
* @extends GeometryLayer
|
|
15
17
|
*/
|
|
16
18
|
class FeatureGeometryLayer extends GeometryLayer {
|
|
17
19
|
/**
|
|
18
|
-
* @extends GeometryLayer
|
|
19
20
|
*
|
|
20
21
|
* @param {string} id - The id of the layer, that should be unique. It is
|
|
21
22
|
* not mandatory, but an error will be emitted if this layer is added a
|
|
@@ -28,6 +29,9 @@ class FeatureGeometryLayer extends GeometryLayer {
|
|
|
28
29
|
* @param {THREE.Object3D} [options.object3d=new THREE.Group()] root object3d layer.
|
|
29
30
|
* @param {function} [options.onMeshCreated] this callback is called when the mesh is created. The callback parameters are the
|
|
30
31
|
* `mesh` and the `context`.
|
|
32
|
+
* @param {function} [options.filter] callback which filters the features of
|
|
33
|
+
* this layer. It takes an object with a `properties` property as argument
|
|
34
|
+
* and shall return a boolean.
|
|
31
35
|
* @param {boolean} [options.accurate=TRUE] If `accurate` is `true`, data are re-projected with maximum geographical accuracy.
|
|
32
36
|
* With `true`, `proj4` is used to transform data source.
|
|
33
37
|
*
|
|
@@ -45,14 +49,24 @@ class FeatureGeometryLayer extends GeometryLayer {
|
|
|
45
49
|
*/
|
|
46
50
|
constructor(id) {
|
|
47
51
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
batchId
|
|
52
|
+
const {
|
|
53
|
+
object3d,
|
|
54
|
+
batchId,
|
|
55
|
+
onMeshCreated,
|
|
56
|
+
accurate = true,
|
|
57
|
+
filter,
|
|
58
|
+
...geometryOptions
|
|
59
|
+
} = options;
|
|
60
|
+
super(id, object3d || new Group(), geometryOptions);
|
|
61
|
+
this.update = FeatureProcessing.update;
|
|
62
|
+
this.convert = Feature2Mesh.convert({
|
|
63
|
+
batchId
|
|
51
64
|
});
|
|
52
|
-
|
|
65
|
+
this.onMeshCreated = onMeshCreated;
|
|
53
66
|
this.isFeatureGeometryLayer = true;
|
|
54
|
-
this.accurate =
|
|
67
|
+
this.accurate = accurate;
|
|
55
68
|
this.buildExtent = !this.accurate;
|
|
69
|
+
this.filter = filter;
|
|
56
70
|
}
|
|
57
71
|
preUpdate(context, sources) {
|
|
58
72
|
if (sources.has(this.parent)) {
|
|
@@ -23,8 +23,6 @@ class GeometryLayer extends Layer {
|
|
|
23
23
|
* A layer usually managing a geometry to display on a view. For example, it
|
|
24
24
|
* can be a layer of buildings extruded from a a WFS stream.
|
|
25
25
|
*
|
|
26
|
-
* @extends Layer
|
|
27
|
-
*
|
|
28
26
|
* @param {string} id - The id of the layer, that should be unique. It is
|
|
29
27
|
* not mandatory, but an error will be emitted if this layer is added a
|
|
30
28
|
* {@link View} that already has a layer going by that id.
|
|
@@ -36,7 +34,10 @@ class GeometryLayer extends Layer {
|
|
|
36
34
|
* contains three elements `name, protocol, extent`, these elements will be
|
|
37
35
|
* available using `layer.name` or something else depending on the property
|
|
38
36
|
* name.
|
|
39
|
-
* @param {Source}
|
|
37
|
+
* @param {Source} config.source - Description and options of the source.
|
|
38
|
+
* @param {number} [config.cacheLifeTime=Infinity] - set life time value in cache.
|
|
39
|
+
* This value is used for [Cache]{@link Cache} expiration mechanism.
|
|
40
|
+
* @param {boolean} [config.visible]
|
|
40
41
|
*
|
|
41
42
|
* @throws {Error} `object3d` must be a valid `THREE.Object3d`.
|
|
42
43
|
*
|
|
@@ -55,12 +56,21 @@ class GeometryLayer extends Layer {
|
|
|
55
56
|
*/
|
|
56
57
|
constructor(id, object3d) {
|
|
57
58
|
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
58
|
-
|
|
59
|
+
const {
|
|
60
|
+
cacheLifeTime = CACHE_POLICIES.GEOMETRY,
|
|
61
|
+
visible = true,
|
|
62
|
+
opacity = 1.0,
|
|
63
|
+
...layerConfig
|
|
64
|
+
} = config;
|
|
65
|
+
super(id, {
|
|
66
|
+
...layerConfig,
|
|
67
|
+
cacheLifeTime
|
|
68
|
+
});
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
/**
|
|
71
|
+
* @type {boolean}
|
|
72
|
+
* @readonly
|
|
73
|
+
*/
|
|
64
74
|
this.isGeometryLayer = true;
|
|
65
75
|
if (!object3d || !object3d.isObject3D) {
|
|
66
76
|
throw new Error(`Missing/Invalid object3d parameter (must be a
|
|
@@ -69,15 +79,36 @@ class GeometryLayer extends Layer {
|
|
|
69
79
|
if (object3d.type === 'Group' && object3d.name === '') {
|
|
70
80
|
object3d.name = id;
|
|
71
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @type {THREE.Object3D}
|
|
85
|
+
* @readonly
|
|
86
|
+
*/
|
|
87
|
+
this.object3d = object3d;
|
|
72
88
|
Object.defineProperty(this, 'object3d', {
|
|
73
|
-
value: object3d,
|
|
74
89
|
writable: false,
|
|
75
90
|
configurable: true
|
|
76
91
|
});
|
|
77
|
-
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @type {number}
|
|
95
|
+
*/
|
|
96
|
+
this.opacity = opacity;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @type {boolean}
|
|
100
|
+
*/
|
|
78
101
|
this.wireframe = false;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @type {Layer[]}
|
|
105
|
+
*/
|
|
79
106
|
this.attachedLayers = [];
|
|
80
|
-
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @type {boolean}
|
|
110
|
+
*/
|
|
111
|
+
this.visible = visible;
|
|
81
112
|
Object.defineProperty(this.zoom, 'max', {
|
|
82
113
|
value: Infinity,
|
|
83
114
|
writable: false
|