itowns 2.44.3-next.7 → 2.44.3-next.9
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/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/3dtiles_loader.html +104 -43
- package/examples/config.json +2 -10
- package/lib/Layer/C3DTilesLayer.js +15 -14
- package/lib/Layer/OGC3DTilesLayer.js +31 -6
- package/lib/Renderer/PointsMaterial.js +1 -1
- package/lib/Utils/gui/C3DTilesStyle.js +2 -3
- package/package.json +1 -1
- 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
|
@@ -11,7 +11,15 @@
|
|
|
11
11
|
<style type="text/css">
|
|
12
12
|
#description {
|
|
13
13
|
z-index: 2;
|
|
14
|
-
|
|
14
|
+
left: 10px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#featureInfoText {
|
|
18
|
+
font-size: small;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#description .marg {
|
|
22
|
+
margin: 10px;
|
|
15
23
|
}
|
|
16
24
|
</style>
|
|
17
25
|
|
|
@@ -21,12 +29,17 @@
|
|
|
21
29
|
<div id="viewerDiv"></div>
|
|
22
30
|
<div id="description">Specify the URL of a tileset to load:
|
|
23
31
|
<input type="text" id="url" />
|
|
24
|
-
<button onclick="
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
<button onclick="readURL()">Load</button>
|
|
33
|
+
<div class="marg">
|
|
34
|
+
<button onClick="loadLyon()">Load Lyon 1 (Mesh)</button>
|
|
35
|
+
<button onClick="loadSete()">Load Sete (Point Cloud)</button>
|
|
36
|
+
<button onClick="loadLille()">Load Lille (Mesh)</button>
|
|
37
|
+
<div id="share"></div>
|
|
38
|
+
</div>
|
|
27
39
|
<hr />
|
|
40
|
+
<p id="featureInfoText" class="marg"><em>Display feature information by clicking on it</em></p>
|
|
28
41
|
<p><b>Feature Information:</b></p>
|
|
29
|
-
<div id="featureInfo"></div>
|
|
42
|
+
<div id="featureInfo" class="marg"></div>
|
|
30
43
|
</div>
|
|
31
44
|
|
|
32
45
|
<script src="js/GUI/GuiTools.js"></script>
|
|
@@ -52,28 +65,17 @@
|
|
|
52
65
|
|
|
53
66
|
const {
|
|
54
67
|
TMSSource, WMTSSource, OGC3DTilesSource,
|
|
55
|
-
ColorLayer, ElevationLayer, OGC3DTilesLayer,
|
|
68
|
+
ColorLayer, ElevationLayer, OGC3DTilesLayer, PNTS_SIZE_MODE,
|
|
56
69
|
GlobeView, Coordinates, Fetcher,
|
|
57
70
|
} = itowns;
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
const state = {
|
|
61
|
-
// URL to tileset JSON
|
|
62
|
-
tileset: uri.searchParams.get('tileset'),
|
|
63
|
-
// Cesium ION /
|
|
64
|
-
assetId: uri.searchParams.get('assetId'),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
function setURL(url) {
|
|
68
|
-
if (!url) return;
|
|
72
|
+
window.layer = null; // 3D Tiles layer
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
history.pushState(null, '', `?${uri.searchParams.toString()}`);
|
|
74
|
+
const uri = new URL(location);
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
}
|
|
76
|
+
window.gui = new dat.GUI();
|
|
75
77
|
|
|
76
|
-
// ----
|
|
78
|
+
// ---- Create a GlobeView ----
|
|
77
79
|
|
|
78
80
|
// Define camera initial position
|
|
79
81
|
const placement = {
|
|
@@ -85,7 +87,17 @@
|
|
|
85
87
|
const viewerDiv = document.getElementById('viewerDiv');
|
|
86
88
|
|
|
87
89
|
// Create a GlobeView
|
|
88
|
-
const view = new GlobeView(viewerDiv, placement, {
|
|
90
|
+
const view = new GlobeView(viewerDiv, placement, {
|
|
91
|
+
controls: {
|
|
92
|
+
minDistance: 100,
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Enable various compression support for 3D Tiles tileset:
|
|
97
|
+
// - `KHR_draco_mesh_compression` mesh compression extension
|
|
98
|
+
// - `KHR_texture_basisu` texture compresion extension
|
|
99
|
+
itowns.enableDracoLoader('./libs/draco/');
|
|
100
|
+
itowns.enableKtx2Loader('./lib/basis/', view.renderer);
|
|
89
101
|
|
|
90
102
|
// Add ambient light to globally illuminates all objects
|
|
91
103
|
const light = new AmbientLight(0x404040, 15);
|
|
@@ -94,36 +106,68 @@
|
|
|
94
106
|
// Setup loading screen
|
|
95
107
|
setupLoadingScreen(viewerDiv, view);
|
|
96
108
|
|
|
97
|
-
//
|
|
98
|
-
const menuGlobe = new GuiTools('menuDiv', view, 300);
|
|
99
|
-
debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// ---- ADD A BASEMAP ----
|
|
109
|
+
// ---- Add a basemap ----
|
|
103
110
|
|
|
104
111
|
// Add one imagery layer to the scene. This layer's properties are
|
|
105
112
|
// defined in a json file, but it cou ld be defined as a plain js
|
|
106
113
|
// object. See `Layer` documentation for more info.
|
|
107
114
|
Fetcher.json('./layers/JSONLayers/OPENSM.json').then((config) => {
|
|
108
|
-
const
|
|
115
|
+
const colorLayer = new ColorLayer('Ortho', {
|
|
109
116
|
...config,
|
|
110
117
|
source: new TMSSource(config.source),
|
|
111
118
|
});
|
|
112
|
-
view.addLayer(
|
|
119
|
+
view.addLayer(colorLayer);
|
|
113
120
|
});
|
|
114
121
|
|
|
115
|
-
// ----
|
|
122
|
+
// ---- Add 3D terrain ----
|
|
116
123
|
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
// Add two elevation layers: world terrain and a more precise terrain for france
|
|
125
|
+
// These will deform iTowns globe geometry to represent terrain elevation.
|
|
126
|
+
function addElevationLayerFromConfig(config) {
|
|
127
|
+
config.source = new itowns.WMTSSource(config.source);
|
|
128
|
+
var elevationLayer = new itowns.ElevationLayer(config.id, config);
|
|
129
|
+
view.addLayer(elevationLayer);
|
|
130
|
+
}
|
|
131
|
+
itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
|
|
132
|
+
itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
|
|
133
|
+
|
|
134
|
+
// ---------- 3D Tiles loading
|
|
135
|
+
|
|
136
|
+
function readURL() {
|
|
137
|
+
const url = document.getElementById('url').value;
|
|
138
|
+
|
|
139
|
+
if (url) {
|
|
140
|
+
setUrl(url);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function setUrl(url) {
|
|
145
|
+
if (!url) return;
|
|
146
|
+
|
|
147
|
+
const input_url = document.getElementById('url');
|
|
148
|
+
if (!input_url) return;
|
|
149
|
+
|
|
150
|
+
uri.searchParams.set('copc', url);
|
|
151
|
+
history.replaceState(null, null, `?${uri.searchParams.toString()}`);
|
|
152
|
+
|
|
153
|
+
input_url.value = url;
|
|
154
|
+
load(url);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function load(url) {
|
|
159
|
+
const source = new OGC3DTilesSource({ url });
|
|
122
160
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
161
|
+
if (window.layer) {
|
|
162
|
+
gui.removeFolder('Layer 3DTiles');
|
|
163
|
+
view.removeLayer('3DTiles');
|
|
164
|
+
view.notifyChange();
|
|
165
|
+
window.layer.delete();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
window.layer = new OGC3DTilesLayer('3DTiles', {
|
|
126
169
|
source,
|
|
170
|
+
pntsSizeMode: PNTS_SIZE_MODE.ATTENUATED,
|
|
127
171
|
});
|
|
128
172
|
|
|
129
173
|
// Add an event for picking the 3D Tiles layer and displaying
|
|
@@ -131,20 +175,37 @@
|
|
|
131
175
|
const pickingArgs = {
|
|
132
176
|
htmlDiv: document.getElementById('featureInfo'),
|
|
133
177
|
view,
|
|
134
|
-
layer,
|
|
178
|
+
layer: window.layer,
|
|
135
179
|
};
|
|
136
180
|
|
|
137
181
|
// Add the layer to our view
|
|
138
|
-
view.addLayer(layer).then((layer) => {
|
|
182
|
+
view.addLayer(window.layer).then((layer) => {
|
|
139
183
|
zoomToLayer(view, layer);
|
|
140
184
|
window.addEventListener('click',
|
|
141
185
|
(event) => fillHTMLWithPickingInfo(event, pickingArgs), false);
|
|
142
186
|
});
|
|
143
187
|
|
|
144
|
-
|
|
188
|
+
window.layer.whenReady
|
|
189
|
+
.then(() => debug.createOGC3DTilesDebugUI(gui, view, window.layer));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function loadLyon() {
|
|
193
|
+
setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/refs/heads/master/3DTiles/lyon1-4978/tileset.json");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function loadSete() {
|
|
197
|
+
setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json");
|
|
145
198
|
}
|
|
146
199
|
|
|
147
|
-
|
|
200
|
+
function loadLille() {
|
|
201
|
+
setUrl("https://webimaging.lillemetropole.fr/externe/maillage/2020_mel_5cm/tileset.json");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
window.readURL = readURL;
|
|
205
|
+
window.loadLyon = loadLyon;
|
|
206
|
+
window.loadSete = loadSete;
|
|
207
|
+
window.loadLille = loadLille;
|
|
208
|
+
|
|
148
209
|
</script>
|
|
149
210
|
</body>
|
|
150
211
|
</html>
|
package/examples/config.json
CHANGED
|
@@ -14,16 +14,8 @@
|
|
|
14
14
|
"geoid_geoidLayer": "Display geoid heights"
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"3dtiles_25d": "On 2.5D map",
|
|
20
|
-
"3dtiles_batch_table": "Batch table Hierarchy extension",
|
|
21
|
-
"3dtiles_ion": "From Cesium ion",
|
|
22
|
-
"3dtiles_pointcloud": "Pointcloud classification"
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
"3D Tiles (new)": {
|
|
26
|
-
"3dtiles_loader": "3D Tiles tileset loader"
|
|
17
|
+
"3D Tiles": {
|
|
18
|
+
"3dtiles_loader": "3D Tiles loader"
|
|
27
19
|
},
|
|
28
20
|
|
|
29
21
|
"Pointcloud": {
|
|
@@ -102,6 +102,7 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
102
102
|
* @param {View} view The view
|
|
103
103
|
*/
|
|
104
104
|
constructor(id, config, view) {
|
|
105
|
+
console.warn('C3DTilesLayer is deprecated and will be removed in iTowns 3.0 version. Use OGC3DTilesLayer instead.');
|
|
105
106
|
super(id, new THREE.Group(), {
|
|
106
107
|
source: config.source
|
|
107
108
|
});
|
|
@@ -143,7 +144,7 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/** @type {Style} */
|
|
146
|
-
this.
|
|
147
|
+
this.style = config.style || null;
|
|
147
148
|
|
|
148
149
|
/** @type {Map<string, THREE.MeshStandardMaterial>} */
|
|
149
150
|
this.#fillColorMaterialsBuffer = new Map();
|
|
@@ -368,21 +369,15 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
368
369
|
if (c3DTileFeature.object3d != object3d) {
|
|
369
370
|
continue; // this feature do not belong to object3d
|
|
370
371
|
}
|
|
372
|
+
this._style.context.setGeometry({
|
|
373
|
+
properties: c3DTileFeature
|
|
374
|
+
});
|
|
375
|
+
|
|
371
376
|
/** @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
|
-
}
|
|
377
|
+
const color = new THREE.Color(this._style.fill.color);
|
|
378
378
|
|
|
379
379
|
/** @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
|
-
}
|
|
380
|
+
const opacity = this._style.fill.opacity;
|
|
386
381
|
const materialId = color.getHexString() + opacity;
|
|
387
382
|
let material = null;
|
|
388
383
|
if (this.#fillColorMaterialsBuffer.has(materialId)) {
|
|
@@ -445,7 +440,13 @@ class C3DTilesLayer extends GeometryLayer {
|
|
|
445
440
|
return this.#fillColorMaterialsBuffer.size;
|
|
446
441
|
}
|
|
447
442
|
set style(value) {
|
|
448
|
-
|
|
443
|
+
if (value instanceof Style) {
|
|
444
|
+
this._style = value;
|
|
445
|
+
} else if (!value) {
|
|
446
|
+
this._style = null;
|
|
447
|
+
} else {
|
|
448
|
+
this._style = new Style(value);
|
|
449
|
+
}
|
|
449
450
|
this.updateStyle();
|
|
450
451
|
}
|
|
451
452
|
get style() {
|
|
@@ -52,7 +52,19 @@ export const OGC3DTILES_LAYER_EVENTS = {
|
|
|
52
52
|
* @property {Object} tile - the tile metadata from the tileset
|
|
53
53
|
* @property {boolean} visible - the tile visible state
|
|
54
54
|
*/
|
|
55
|
-
TILE_VISIBILITY_CHANGE: 'tile-visibility-change'
|
|
55
|
+
TILE_VISIBILITY_CHANGE: 'tile-visibility-change',
|
|
56
|
+
/**
|
|
57
|
+
* Fired when a new batch of tiles start loading (can be fired multiple times, e.g. when the camera moves and new tiles
|
|
58
|
+
* start loading)
|
|
59
|
+
* @event OGC3DTilesLayer#tiles-load-start
|
|
60
|
+
*/
|
|
61
|
+
TILES_LOAD_START: 'tiles-load-start',
|
|
62
|
+
/**
|
|
63
|
+
* Fired when all visible tiles are loaded (can be fired multiple times, e.g. when the camera moves and new tiles
|
|
64
|
+
* are loaded)
|
|
65
|
+
* @event OGC3DTilesLayer#tiles-load-end
|
|
66
|
+
*/
|
|
67
|
+
TILES_LOAD_END: 'tiles-load-end'
|
|
56
68
|
};
|
|
57
69
|
|
|
58
70
|
/**
|
|
@@ -95,6 +107,13 @@ export function enableKtx2Loader(path, renderer) {
|
|
|
95
107
|
class OGC3DTilesLayer extends GeometryLayer {
|
|
96
108
|
/**
|
|
97
109
|
* Layer for [3D Tiles](https://www.ogc.org/standard/3dtiles/) datasets.
|
|
110
|
+
*
|
|
111
|
+
* Advanced configuration note: 3D Tiles rendering is delegated to 3DTilesRendererJS that exposes several
|
|
112
|
+
* configuration options accessible through the tilesRenderer property of this class. see the
|
|
113
|
+
* [3DTilesRendererJS doc](https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/README.md). Also note that
|
|
114
|
+
* the cache is shared amongst 3D tiles layers and can be configured through tilesRenderer.lruCache (see the
|
|
115
|
+
* [following documentation](https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/README.md#lrucache-1).
|
|
116
|
+
*
|
|
98
117
|
* @extends Layer
|
|
99
118
|
*
|
|
100
119
|
* @param {String} id - unique layer id.
|
|
@@ -109,8 +128,8 @@ class OGC3DTilesLayer extends GeometryLayer {
|
|
|
109
128
|
* @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode (passed to {@link PointsMaterial}).
|
|
110
129
|
* Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance
|
|
111
130
|
* from point to camera.
|
|
112
|
-
* @param {Number} [config.pntsMinAttenuatedSize=
|
|
113
|
-
* @param {Number} [config.pntsMaxAttenuatedSize=
|
|
131
|
+
* @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode.
|
|
132
|
+
* @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode.
|
|
114
133
|
*/
|
|
115
134
|
constructor(id, config) {
|
|
116
135
|
super(id, new THREE.Group(), {
|
|
@@ -169,8 +188,8 @@ class OGC3DTilesLayer extends GeometryLayer {
|
|
|
169
188
|
this.pntsShape = config.pntsShape ?? PNTS_SHAPE.CIRCLE;
|
|
170
189
|
this.classification = config.classification ?? ClassificationScheme.DEFAULT;
|
|
171
190
|
this.pntsSizeMode = config.pntsSizeMode ?? PNTS_SIZE_MODE.VALUE;
|
|
172
|
-
this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize ||
|
|
173
|
-
this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize ||
|
|
191
|
+
this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 3;
|
|
192
|
+
this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 10;
|
|
174
193
|
}
|
|
175
194
|
|
|
176
195
|
/**
|
|
@@ -350,7 +369,13 @@ class OGC3DTilesLayer extends GeometryLayer {
|
|
|
350
369
|
_raycaster.near = camera.near;
|
|
351
370
|
_raycaster.far = camera.far;
|
|
352
371
|
_raycaster.firstHitOnly = true;
|
|
353
|
-
_raycaster.intersectObject(this.tilesRenderer.group, true
|
|
372
|
+
const picked = _raycaster.intersectObject(this.tilesRenderer.group, true);
|
|
373
|
+
// Store the layer of the picked object to conform to the interface of what's returned by Picking.js (used for
|
|
374
|
+
// other GeometryLayers
|
|
375
|
+
picked.forEach(p => {
|
|
376
|
+
p.layer = this;
|
|
377
|
+
});
|
|
378
|
+
target.push(...picked);
|
|
354
379
|
return target;
|
|
355
380
|
}
|
|
356
381
|
|
|
@@ -258,7 +258,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
|
|
|
258
258
|
/**
|
|
259
259
|
* @class PointsMaterial
|
|
260
260
|
* @param {object} [options={}] The options
|
|
261
|
-
* @param {number} [options.size=
|
|
261
|
+
* @param {number} [options.size=1] point size
|
|
262
262
|
* @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
|
|
263
263
|
* @param {number} [options.shape=PNTS_SHAPE.CIRCLE] rendered points shape.
|
|
264
264
|
* @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Style from "../../Core/Style.js";
|
|
2
1
|
import { C3DTILES_LAYER_EVENTS } from "../../Layer/C3DTilesLayer.js";
|
|
3
2
|
import Widget from "./Widget.js";
|
|
4
3
|
const DEFAULT_OPTIONS = {
|
|
@@ -187,7 +186,7 @@ class C3DTilesStyle extends Widget {
|
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
// set style
|
|
190
|
-
c3DTilesLayer.style =
|
|
189
|
+
c3DTilesLayer.style = {
|
|
191
190
|
fill: {
|
|
192
191
|
color: c3DTileFeature => {
|
|
193
192
|
let result = null;
|
|
@@ -204,7 +203,7 @@ class C3DTilesStyle extends Widget {
|
|
|
204
203
|
return result;
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
|
-
}
|
|
206
|
+
};
|
|
208
207
|
});
|
|
209
208
|
});
|
|
210
209
|
updateSelectedLayer();
|
package/package.json
CHANGED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Itowns - 3D Tiles on 2.5D map example</title>
|
|
4
|
-
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<link rel="stylesheet" type="text/css" href="css/example.css">
|
|
7
|
-
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="viewerDiv" class="viewer"></div>
|
|
13
|
-
<script src="../dist/itowns.js"></script>
|
|
14
|
-
<script src="js/GUI/LoadingScreen.js"></script>
|
|
15
|
-
<script src="../dist/debug.js"></script>
|
|
16
|
-
<script src="js/GUI/GuiTools.js"></script>
|
|
17
|
-
<script src="js/3dTilesHelper.js"></script>
|
|
18
|
-
<script type="text/javascript">
|
|
19
|
-
// Define crs projection that we will use (taken from https://epsg.io/3946, Proj4js section)
|
|
20
|
-
itowns.proj4.defs('EPSG:3946', '+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
|
|
21
|
-
|
|
22
|
-
// Define geographic extent: CRS, min/max X, min/max Y
|
|
23
|
-
var extent = new itowns.Extent( 'EPSG:3946',
|
|
24
|
-
1837816.94334, 1847692.32501,
|
|
25
|
-
5170036.4587, 5178412.82698);
|
|
26
|
-
|
|
27
|
-
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
|
|
28
|
-
var viewerDiv = document.getElementById('viewerDiv');
|
|
29
|
-
|
|
30
|
-
// Instanciate PlanarView*
|
|
31
|
-
var cameraCoord = new itowns.Coordinates('EPSG:3946', 1841980,
|
|
32
|
-
5175682, 3000)
|
|
33
|
-
var view = new itowns.PlanarView(viewerDiv, extent, { placement: {
|
|
34
|
-
coord: cameraCoord, heading: 30, range: 4000, tilt: 30 } });
|
|
35
|
-
|
|
36
|
-
setupLoadingScreen(viewerDiv, view);
|
|
37
|
-
|
|
38
|
-
// Add a WMS imagery source
|
|
39
|
-
var wmsImagerySource = new itowns.WMSSource({
|
|
40
|
-
extent: extent,
|
|
41
|
-
name: 'ortho_latest',
|
|
42
|
-
url: 'https://imagerie.data.grandlyon.com/wms/grandlyon',
|
|
43
|
-
version: '1.3.0',
|
|
44
|
-
crs: 'EPSG:3946',
|
|
45
|
-
format: 'image/jpeg',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Add a WMS imagery layer
|
|
49
|
-
var wmsImageryLayer = new itowns.ColorLayer('wms_imagery', {
|
|
50
|
-
updateStrategy: {
|
|
51
|
-
type: itowns.STRATEGY_DICHOTOMY,
|
|
52
|
-
options: {},
|
|
53
|
-
},
|
|
54
|
-
source: wmsImagerySource,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
view.addLayer(wmsImageryLayer);
|
|
58
|
-
|
|
59
|
-
// Add a WMS elevation source
|
|
60
|
-
var wmsElevationSource = new itowns.WMSSource({
|
|
61
|
-
extent: extent,
|
|
62
|
-
url: 'https://imagerie.data.grandlyon.com/wms/grandlyon',
|
|
63
|
-
name: 'MNT2018_Altitude_2m',
|
|
64
|
-
crs: 'EPSG:3946',
|
|
65
|
-
width: 256,
|
|
66
|
-
format: 'image/jpeg',
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Add a WMS elevation layer
|
|
70
|
-
var wmsElevationLayer = new itowns.ElevationLayer('wms_elevation', {
|
|
71
|
-
useColorTextureElevation: true,
|
|
72
|
-
colorTextureElevationMinZ: 144,
|
|
73
|
-
colorTextureElevationMaxZ: 622,
|
|
74
|
-
source: wmsElevationSource,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
view.addLayer(wmsElevationLayer);
|
|
78
|
-
|
|
79
|
-
// Add 3D Tiles layer
|
|
80
|
-
// This 3D Tiles tileset uses the draco compression that is an
|
|
81
|
-
// extension of gltf. We need to enable it.
|
|
82
|
-
itowns.enableDracoLoader('./libs/draco/');
|
|
83
|
-
|
|
84
|
-
var $3dTilesLayer = new itowns.C3DTilesLayer(
|
|
85
|
-
'3d-tiles-layer-building', {
|
|
86
|
-
name: 'Lyon-2015-building',
|
|
87
|
-
source: new itowns.C3DTilesSource({
|
|
88
|
-
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/' +
|
|
89
|
-
'3DTiles/lyon_1_3946_textured_draco/tileset.json',
|
|
90
|
-
}),
|
|
91
|
-
}, view);
|
|
92
|
-
|
|
93
|
-
// Lights
|
|
94
|
-
var dirLight = new itowns.THREE.DirectionalLight(0xffffff, 1);
|
|
95
|
-
dirLight.position.set(-0.9, 0.3, 1);
|
|
96
|
-
dirLight.updateMatrixWorld();
|
|
97
|
-
view.scene.add( dirLight );
|
|
98
|
-
|
|
99
|
-
var ambLight = new itowns.THREE.AmbientLight(0xffffff, 0.2);
|
|
100
|
-
view.scene.add( ambLight );
|
|
101
|
-
|
|
102
|
-
// Pick 3D Tiles features when hovering them with the mouse and
|
|
103
|
-
// display their semantic information in an html div
|
|
104
|
-
var pickingArgs = {};
|
|
105
|
-
pickingArgs.htmlDiv = document.getElementById('featureInfo');
|
|
106
|
-
pickingArgs.view = view;
|
|
107
|
-
pickingArgs.layer = $3dTilesLayer;
|
|
108
|
-
itowns.View.prototype.addLayer.call(view, $3dTilesLayer);
|
|
109
|
-
|
|
110
|
-
// Request redraw
|
|
111
|
-
view.notifyChange();
|
|
112
|
-
|
|
113
|
-
// Add a debug UI
|
|
114
|
-
var menu = new GuiTools('menuDiv', view);
|
|
115
|
-
var d = new debug.Debug(view, menu.gui);
|
|
116
|
-
debug.createTileDebugUI(menu.gui, view, view.tileLayer, d);
|
|
117
|
-
debug.create3dTilesDebugUI(menu.gui, view, $3dTilesLayer);
|
|
118
|
-
</script>
|
|
119
|
-
</body>
|
|
120
|
-
</html>
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Itowns - 3d-tiles example</title>
|
|
5
|
-
|
|
6
|
-
<meta charset="UTF-8">
|
|
7
|
-
<link rel="stylesheet" type="text/css" href="css/example.css">
|
|
8
|
-
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
|
|
9
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
10
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
<div id="viewerDiv"></div>
|
|
14
|
-
<div id="description">
|
|
15
|
-
<p><b>Feature Information:</b></p>
|
|
16
|
-
<div id="featureInfo"></div>
|
|
17
|
-
</div>
|
|
18
|
-
<script src="js/GUI/GuiTools.js"></script>
|
|
19
|
-
<script src="../dist/itowns.js"></script>
|
|
20
|
-
<script src="js/GUI/LoadingScreen.js"></script>
|
|
21
|
-
<script src="../dist/debug.js"></script>
|
|
22
|
-
<script src="js/3dTilesHelper.js"></script>
|
|
23
|
-
<script type="text/javascript">
|
|
24
|
-
/* global itowns,document,GuiTools*/
|
|
25
|
-
var placement = {
|
|
26
|
-
coord: new itowns.Coordinates('EPSG:4326', -75.6114, 40.03428, 0),
|
|
27
|
-
range: 4000,
|
|
28
|
-
tilt: 22,
|
|
29
|
-
heading: 180
|
|
30
|
-
}
|
|
31
|
-
// iTowns namespace defined here
|
|
32
|
-
var viewerDiv = document.getElementById('viewerDiv');
|
|
33
|
-
|
|
34
|
-
var view = new itowns.GlobeView(viewerDiv, placement);
|
|
35
|
-
view.camera3D.near = 5;
|
|
36
|
-
setupLoadingScreen(viewerDiv, view);
|
|
37
|
-
|
|
38
|
-
var menuGlobe = new GuiTools('menuDiv', view, 300);
|
|
39
|
-
|
|
40
|
-
itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
|
|
41
|
-
config.source = new itowns.TMSSource(config.source);
|
|
42
|
-
var layer = new itowns.ColorLayer('Ortho', config);
|
|
43
|
-
view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Create a new Layer 3d-tiles For DiscreteLOD
|
|
47
|
-
// -------------------------------------------
|
|
48
|
-
var $3dTilesLayerDiscreteLOD = new itowns.C3DTilesLayer('3d-tiles-discrete-lod', {
|
|
49
|
-
name: 'DiscreteLOD',
|
|
50
|
-
sseThreshold: 0.05,
|
|
51
|
-
source: new itowns.C3DTilesSource({
|
|
52
|
-
url: 'https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/master/1.0/TilesetWithDiscreteLOD/tileset.json',
|
|
53
|
-
}),
|
|
54
|
-
}, view);
|
|
55
|
-
|
|
56
|
-
itowns.View.prototype.addLayer.call(view, $3dTilesLayerDiscreteLOD);
|
|
57
|
-
|
|
58
|
-
// Create a new Layer 3d-tiles For Viewer Request Volume
|
|
59
|
-
// -----------------------------------------------------
|
|
60
|
-
|
|
61
|
-
var $3dTilesLayerRequestVolume = new itowns.C3DTilesLayer('3d-tiles-request-volume', {
|
|
62
|
-
name: 'RequestVolume',
|
|
63
|
-
source: new itowns.C3DTilesSource({
|
|
64
|
-
url: 'https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/master/1.0/TilesetWithRequestVolume/tileset.json',
|
|
65
|
-
}),
|
|
66
|
-
sseThreshold: 1,
|
|
67
|
-
}, view);
|
|
68
|
-
|
|
69
|
-
// add an event for picking the 3D Tiles layer and displaying
|
|
70
|
-
// information about the picked feature in an html div
|
|
71
|
-
var pickingArgs = {};
|
|
72
|
-
pickingArgs.htmlDiv = document.getElementById('featureInfo');
|
|
73
|
-
pickingArgs.view = view;
|
|
74
|
-
pickingArgs.layer = $3dTilesLayerRequestVolume;
|
|
75
|
-
itowns.View.prototype.addLayer.call(view,
|
|
76
|
-
$3dTilesLayerRequestVolume).then(function _() {
|
|
77
|
-
window.addEventListener('mousemove',
|
|
78
|
-
(event) => fillHTMLWithPickingInfo(event, pickingArgs),false);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Add the UI Debug
|
|
82
|
-
var d = new debug.Debug(view, menuGlobe.gui);
|
|
83
|
-
debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer, d);
|
|
84
|
-
debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerDiscreteLOD);
|
|
85
|
-
debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerRequestVolume);
|
|
86
|
-
d.zoom = function() {
|
|
87
|
-
view.camera3D.position.set(1215013.9, -4736315.5, 4081597.5);
|
|
88
|
-
view.camera3D.quaternion.set(0.9108514448729665, 0.13456816437801225, 0.1107206134840362, 0.3741416847378546);
|
|
89
|
-
view.notifyChange(view.camera3D);
|
|
90
|
-
}
|
|
91
|
-
menuGlobe.gui.add(d, 'zoom').name('Go to point cloud');
|
|
92
|
-
</script>
|
|
93
|
-
</body>
|
|
94
|
-
</html>
|