itowns 2.42.1-next.3 → 2.42.1-next.5
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.
|
@@ -59,8 +59,6 @@
|
|
|
59
59
|
this.updateMatrixWorld();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
var waypointGeometry = new itowns.THREE.BoxGeometry(1, 1, 80);
|
|
63
|
-
var waypointMaterial = new itowns.THREE.MeshBasicMaterial({ color: 0xffffff });
|
|
64
62
|
const style = {
|
|
65
63
|
stroke: {
|
|
66
64
|
color: 'red',
|
|
@@ -70,6 +68,8 @@
|
|
|
70
68
|
color: 'white',
|
|
71
69
|
}
|
|
72
70
|
};
|
|
71
|
+
var waypointGeometry = new itowns.THREE.BoxGeometry(1, 1, 80);
|
|
72
|
+
var waypointMaterial = new itowns.THREE.MeshBasicMaterial({ color: 0xffffff });
|
|
73
73
|
// Listen for globe full initialisation event
|
|
74
74
|
view.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function () {
|
|
75
75
|
console.info('Globe initialized');
|
|
@@ -24,8 +24,8 @@ let style;
|
|
|
24
24
|
const dim_ref = new THREE.Vector2();
|
|
25
25
|
const dim = new THREE.Vector2();
|
|
26
26
|
const normal = new THREE.Vector3();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const baseCoord = new THREE.Vector3();
|
|
28
|
+
const topCoord = new THREE.Vector3();
|
|
29
29
|
const inverseScale = new THREE.Vector3();
|
|
30
30
|
const extent = new _Extent.default('EPSG:4326', 0, 0, 0, 0);
|
|
31
31
|
const _color = new THREE.Color();
|
|
@@ -44,13 +44,6 @@ class FeatureMesh extends THREE.Group {
|
|
|
44
44
|
this.#collection = new THREE.Group().add(this.meshes);
|
|
45
45
|
this.#collection.quaternion.copy(collection.quaternion);
|
|
46
46
|
this.#collection.position.copy(collection.position);
|
|
47
|
-
if (collection.crs == 'EPSG:4978') {
|
|
48
|
-
normal.copy(collection.center.geodesicNormal);
|
|
49
|
-
} else {
|
|
50
|
-
normal.set(0, 0, 1);
|
|
51
|
-
}
|
|
52
|
-
normal.multiplyScalar(collection.center.z);
|
|
53
|
-
this.#collection.position.sub(normal);
|
|
54
47
|
this.#collection.scale.copy(collection.scale);
|
|
55
48
|
this.#collection.updateMatrix();
|
|
56
49
|
this.#originalCrs = collection.crs;
|
|
@@ -194,21 +187,27 @@ function featureToPoint(feature, options) {
|
|
|
194
187
|
if (feature.normals) {
|
|
195
188
|
normal.fromArray(feature.normals, v).multiply(inverseScale);
|
|
196
189
|
}
|
|
197
|
-
|
|
190
|
+
const localCoord = context.setLocalCoordinatesFromArray(feature.vertices, v);
|
|
198
191
|
style.setContext(context);
|
|
199
192
|
const {
|
|
200
193
|
base_altitude,
|
|
201
194
|
color,
|
|
202
195
|
radius
|
|
203
196
|
} = style.point;
|
|
204
|
-
coord.
|
|
205
|
-
if (
|
|
206
|
-
|
|
197
|
+
coord.copy(localCoord).applyMatrix4(context.collection.matrixWorld);
|
|
198
|
+
if (coord.crs == 'EPSG:4978') {
|
|
199
|
+
// altitude convertion from geocentered to elevation (from ground)
|
|
200
|
+
coord.as('EPSG:4326', coord);
|
|
207
201
|
}
|
|
208
202
|
|
|
209
|
-
//
|
|
210
|
-
|
|
203
|
+
// Calculate the new coordinates using the elevation shift (baseCoord)
|
|
204
|
+
baseCoord.copy(normal).multiplyScalar(base_altitude - coord.z).add(localCoord)
|
|
205
|
+
// and update the geometry buffer (vertices).
|
|
206
|
+
.toArray(vertices, v);
|
|
211
207
|
toColor(color).multiplyScalar(255).toArray(colors, v);
|
|
208
|
+
if (!pointMaterialSize.includes(radius)) {
|
|
209
|
+
pointMaterialSize.push(radius);
|
|
210
|
+
}
|
|
212
211
|
batchIds[j] = id;
|
|
213
212
|
}
|
|
214
213
|
featureId++;
|
|
@@ -233,7 +232,6 @@ function featureToLine(feature, options) {
|
|
|
233
232
|
let featureId = 0;
|
|
234
233
|
const vertices = new Float32Array(ptsIn.length);
|
|
235
234
|
const geom = new THREE.BufferGeometry();
|
|
236
|
-
geom.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
|
237
235
|
const lineMaterialWidth = [];
|
|
238
236
|
context.setFeature(feature);
|
|
239
237
|
const countIndices = (count - feature.geometries.length) * 2;
|
|
@@ -265,21 +263,27 @@ function featureToLine(feature, options) {
|
|
|
265
263
|
if (feature.normals) {
|
|
266
264
|
normal.fromArray(feature.normals, v).multiply(inverseScale);
|
|
267
265
|
}
|
|
268
|
-
|
|
266
|
+
const localCoord = context.setLocalCoordinatesFromArray(feature.vertices, v);
|
|
269
267
|
style.setContext(context);
|
|
270
268
|
const {
|
|
271
269
|
base_altitude,
|
|
272
270
|
color,
|
|
273
271
|
width
|
|
274
272
|
} = style.stroke;
|
|
275
|
-
coord.
|
|
276
|
-
if (
|
|
277
|
-
|
|
273
|
+
coord.copy(localCoord).applyMatrix4(context.collection.matrixWorld);
|
|
274
|
+
if (coord.crs == 'EPSG:4978') {
|
|
275
|
+
// altitude convertion from geocentered to elevation (from ground)
|
|
276
|
+
coord.as('EPSG:4326', coord);
|
|
278
277
|
}
|
|
279
278
|
|
|
280
|
-
//
|
|
281
|
-
|
|
279
|
+
// Calculate the new coordinates using the elevation shift (baseCoord)
|
|
280
|
+
baseCoord.copy(normal).multiplyScalar(base_altitude - coord.z).add(localCoord)
|
|
281
|
+
// and update the geometry buffer (vertices).
|
|
282
|
+
.toArray(vertices, v);
|
|
282
283
|
toColor(color).multiplyScalar(255).toArray(colors, v);
|
|
284
|
+
if (!lineMaterialWidth.includes(width)) {
|
|
285
|
+
lineMaterialWidth.push(width);
|
|
286
|
+
}
|
|
283
287
|
batchIds[j] = id;
|
|
284
288
|
}
|
|
285
289
|
featureId++;
|
|
@@ -289,6 +293,7 @@ function featureToLine(feature, options) {
|
|
|
289
293
|
// TODO CREATE material for each feature
|
|
290
294
|
console.warn('Too many differents stroke.width, only the first one will be used');
|
|
291
295
|
}
|
|
296
|
+
geom.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
|
292
297
|
geom.setAttribute('color', new THREE.BufferAttribute(colors, 3, true));
|
|
293
298
|
geom.setAttribute('batchId', new THREE.BufferAttribute(batchIds, 1));
|
|
294
299
|
geom.setIndex(new THREE.BufferAttribute(indices, 1));
|
|
@@ -320,18 +325,24 @@ function featureToPolygon(feature, options) {
|
|
|
320
325
|
if (feature.normals) {
|
|
321
326
|
normal.fromArray(feature.normals, i).multiply(inverseScale);
|
|
322
327
|
}
|
|
323
|
-
|
|
328
|
+
const localCoord = context.setLocalCoordinatesFromArray(feature.vertices, i);
|
|
324
329
|
style.setContext(context);
|
|
325
330
|
const {
|
|
326
331
|
base_altitude,
|
|
327
332
|
color
|
|
328
333
|
} = style.fill;
|
|
329
|
-
coord.
|
|
334
|
+
coord.copy(localCoord).applyMatrix4(context.collection.matrixWorld);
|
|
335
|
+
if (coord.crs == 'EPSG:4978') {
|
|
336
|
+
// altitude convertion from geocentered to elevation (from ground)
|
|
337
|
+
coord.as('EPSG:4326', coord);
|
|
338
|
+
}
|
|
330
339
|
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
// Calculate the new coordinates using the elevation shift (baseCoord)
|
|
341
|
+
baseCoord.copy(normal).multiplyScalar(base_altitude - coord.z).add(localCoord)
|
|
342
|
+
// and update the geometry buffer (vertices).
|
|
343
|
+
.toArray(vertices, i);
|
|
334
344
|
toColor(color).multiplyScalar(255).toArray(colors, i);
|
|
345
|
+
batchIds[b] = id;
|
|
335
346
|
}
|
|
336
347
|
featureId++;
|
|
337
348
|
const geomVertices = vertices.slice(start * 3, end * 3);
|
|
@@ -386,21 +397,27 @@ function featureToExtrudedPolygon(feature, options) {
|
|
|
386
397
|
if (feature.normals) {
|
|
387
398
|
normal.fromArray(feature.normals, i).multiply(inverseScale);
|
|
388
399
|
}
|
|
389
|
-
|
|
400
|
+
const localCoord = context.setLocalCoordinatesFromArray(ptsIn, i);
|
|
390
401
|
style.setContext(context);
|
|
391
402
|
const {
|
|
392
403
|
base_altitude,
|
|
393
404
|
extrusion_height,
|
|
394
405
|
color
|
|
395
406
|
} = style.fill;
|
|
396
|
-
coord.
|
|
407
|
+
coord.copy(localCoord).applyMatrix4(context.collection.matrixWorld);
|
|
408
|
+
if (coord.crs == 'EPSG:4978') {
|
|
409
|
+
// altitude convertion from geocentered to elevation (from ground)
|
|
410
|
+
coord.as('EPSG:4326', coord);
|
|
411
|
+
}
|
|
397
412
|
|
|
398
|
-
//
|
|
399
|
-
|
|
413
|
+
// Calculate the new base coordinates using the elevation shift (baseCoord)
|
|
414
|
+
baseCoord.copy(normal).multiplyScalar(base_altitude - coord.z).add(localCoord)
|
|
415
|
+
// and update the geometry buffer (vertices).
|
|
416
|
+
.toArray(vertices, i);
|
|
400
417
|
batchIds[b] = id;
|
|
401
418
|
|
|
402
419
|
// populate top geometry buffers
|
|
403
|
-
|
|
420
|
+
topCoord.copy(normal).multiplyScalar(extrusion_height).add(baseCoord).toArray(vertices, t);
|
|
404
421
|
batchIds[b + totalVertices] = id;
|
|
405
422
|
|
|
406
423
|
// coloring base and top mesh
|
package/lib/Core/Style.js
CHANGED
|
@@ -24,8 +24,8 @@ const matrix = svg.createSVGMatrix();
|
|
|
24
24
|
const inv255 = 1 / 255;
|
|
25
25
|
const canvas = typeof document !== 'undefined' ? document.createElement('canvas') : {};
|
|
26
26
|
function baseAltitudeDefault(properties, ctx) {
|
|
27
|
-
var _ctx$coordinates
|
|
28
|
-
return (ctx === null || ctx === void 0 ? void 0 : (_ctx$coordinates = ctx.coordinates) === null || _ctx$coordinates === void 0 ? void 0 : _ctx$coordinates.z) ||
|
|
27
|
+
var _ctx$coordinates;
|
|
28
|
+
return (ctx === null || ctx === void 0 ? void 0 : (_ctx$coordinates = ctx.coordinates) === null || _ctx$coordinates === void 0 ? void 0 : _ctx$coordinates.z) || 0;
|
|
29
29
|
}
|
|
30
30
|
function readExpression(property, ctx) {
|
|
31
31
|
if (property != undefined) {
|
|
@@ -75,7 +75,8 @@ class RasterTile extends THREE.EventDispatcher {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
dispose(
|
|
78
|
+
dispose() {
|
|
79
|
+
let removeEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
79
80
|
if (removeEvent) {
|
|
80
81
|
this.layer.removeEventListener('visible-property-changed', this._handlerCBEvent);
|
|
81
82
|
this.layer.removeEventListener('opacity-property-changed', this._handlerCBEvent);
|