itowns 2.34.0 → 2.36.2
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/CONTRIBUTORS.md +1 -0
- package/changelog.md +150 -0
- package/dist/debug.js +2 -16
- package/dist/debug.js.LICENSE.txt +6 -0
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +2 -19
- package/dist/itowns.js.LICENSE.txt +28 -0
- package/dist/itowns.js.map +1 -1
- package/examples/3dtiles_basic.html +2 -2
- package/examples/config.json +2 -1
- package/examples/js/plugins/CSVnVRTParser.js +0 -1
- package/examples/layers/JSONLayers/Administrative.json +1 -1
- package/examples/layers/JSONLayers/Cada.json +1 -1
- package/examples/layers/JSONLayers/EtatMajor.json +1 -1
- package/examples/layers/JSONLayers/IGN_MNT.json +1 -1
- package/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json +1 -1
- package/examples/layers/JSONLayers/Ortho.json +1 -1
- package/examples/layers/JSONLayers/WORLD_DTM.json +1 -1
- package/examples/misc_camera_traveling.html +148 -0
- package/examples/misc_custom_label.html +0 -2
- package/examples/plugins_vrt.html +0 -1
- package/examples/source_file_geojson_raster.html +0 -3
- package/examples/source_file_shapefile.html +0 -1
- package/examples/source_stream_wfs_25d.html +8 -16
- package/examples/vector_tile_raster_2d.html +2 -2
- package/examples/vector_tile_raster_3d.html +2 -2
- package/examples/view_25d_map.html +28 -0
- package/examples/view_multi_25d.html +1 -1
- package/lib/Controls/FirstPersonControls.js +12 -14
- package/lib/Controls/FlyControls.js +2 -10
- package/lib/Controls/GlobeControls.js +231 -303
- package/lib/Controls/PlanarControls.js +5 -16
- package/lib/Controls/StateControl.js +362 -96
- package/lib/Converter/Feature2Mesh.js +20 -5
- package/lib/Converter/Feature2Texture.js +2 -2
- package/lib/Converter/convertToTile.js +1 -1
- package/lib/Core/AnimationPlayer.js +15 -0
- package/lib/Core/Feature.js +39 -38
- package/lib/Core/Geographic/Coordinates.js +56 -0
- package/lib/Core/Geographic/Crs.js +15 -0
- package/lib/Core/Geographic/Extent.js +99 -11
- package/lib/Core/Label.js +1 -1
- package/lib/Core/Math/Ellipsoid.js +26 -8
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +1 -1
- package/lib/Core/Prefab/PlanarView.js +1 -1
- package/lib/Core/Style.js +1 -0
- package/lib/Core/TileMesh.js +3 -2
- package/lib/Core/View.js +3 -3
- package/lib/Layer/ElevationLayer.js +9 -16
- package/lib/Layer/LabelLayer.js +7 -1
- package/lib/Main.js +1 -1
- package/lib/Parser/ShapefileParser.js +1 -2
- package/lib/Parser/VectorTileParser.js +1 -1
- package/lib/Process/3dTilesProcessing.js +8 -8
- package/lib/Process/FeatureProcessing.js +1 -2
- package/lib/Process/ObjectRemovalHelper.js +5 -2
- package/lib/Renderer/Label2DRenderer.js +15 -11
- package/lib/Renderer/LayeredMaterial.js +2 -1
- package/lib/Renderer/OBB.js +2 -2
- package/lib/Renderer/RasterTile.js +22 -4
- package/lib/Renderer/Shader/ShaderChunk.js +3 -3
- package/lib/Renderer/c3DEngine.js +14 -2
- package/lib/Source/FileSource.js +2 -7
- package/lib/Source/VectorTilesSource.js +19 -0
- package/lib/ThreeExtended/loaders/GLTFLoader.js +320 -76
- package/lib/Utils/CameraUtils.js +8 -8
- package/lib/Utils/DEMUtils.js +2 -2
- package/package.json +29 -29
package/lib/Core/View.js
CHANGED
|
@@ -154,7 +154,8 @@ function _preprocessLayer(view, layer, parentLayer) {
|
|
|
154
154
|
style: layer.style,
|
|
155
155
|
zoom: layer.zoom,
|
|
156
156
|
crs: source.crs,
|
|
157
|
-
visible: layer.visible
|
|
157
|
+
visible: layer.visible,
|
|
158
|
+
margin: 15
|
|
158
159
|
});
|
|
159
160
|
layer.addEventListener('visible-property-changed', function () {
|
|
160
161
|
labelLayer.visible = layer.visible;
|
|
@@ -1191,13 +1192,12 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
|
|
|
1191
1192
|
}
|
|
1192
1193
|
|
|
1193
1194
|
this.getPickingPositionFromDepth(mouse, positionVector);
|
|
1194
|
-
var distance = this.camera.camera3D.position.distanceTo(positionVector);
|
|
1195
1195
|
coordinates.setFromVector3(positionVector); // Get the correct precision; the position variable will be set in this
|
|
1196
1196
|
// function.
|
|
1197
1197
|
|
|
1198
1198
|
var precision;
|
|
1199
1199
|
var precisions = {
|
|
1200
|
-
M: this.
|
|
1200
|
+
M: this.getPixelsToMeters(radius, mouse),
|
|
1201
1201
|
D: 0.001 * radius
|
|
1202
1202
|
};
|
|
1203
1203
|
|
|
@@ -87,22 +87,9 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
|
|
|
87
87
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
88
88
|
(0, _classCallCheck2["default"])(this, ElevationLayer);
|
|
89
89
|
_this = _super.call(this, id, config);
|
|
90
|
-
_this.isElevationLayer = true;
|
|
90
|
+
_this.isElevationLayer = true;
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (_this.useColorTextureElevation) {
|
|
95
|
-
baseScale = _this.colorTextureElevationMaxZ - _this.colorTextureElevationMinZ;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
_this.defineLayerProperty('scale', _this.scale || 1.0, function (self) {
|
|
99
|
-
self.parent.object3d.traverse(function (obj) {
|
|
100
|
-
if (obj.layer == self.parent && obj.material) {
|
|
101
|
-
obj.material.setElevationScale(self.scale * baseScale);
|
|
102
|
-
obj.obb.updateScaleZ(self.scale);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
92
|
+
_this.defineLayerProperty('scale', _this.scale || 1.0);
|
|
106
93
|
|
|
107
94
|
return _this;
|
|
108
95
|
}
|
|
@@ -130,7 +117,13 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
|
|
|
130
117
|
|
|
131
118
|
updateBBox(); // listen elevation updating
|
|
132
119
|
|
|
133
|
-
rasterElevationNode.addEventListener('updatedElevation', updateBBox);
|
|
120
|
+
rasterElevationNode.addEventListener('updatedElevation', updateBBox); // listen scaling elevation updating
|
|
121
|
+
|
|
122
|
+
this.addEventListener('scale-property-changed', updateBBox); // remove scaling elevation updating if node is removed
|
|
123
|
+
|
|
124
|
+
node.addEventListener('dispose', function () {
|
|
125
|
+
_this2.removeEventListener('scale-property-changed', updateBBox);
|
|
126
|
+
});
|
|
134
127
|
return rasterElevationNode;
|
|
135
128
|
}
|
|
136
129
|
}, {
|
package/lib/Layer/LabelLayer.js
CHANGED
|
@@ -101,7 +101,12 @@ var LabelLayer = /*#__PURE__*/function (_Layer) {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
_this.buildExtent = true;
|
|
104
|
-
_this.labelDomelement = config.domElement;
|
|
104
|
+
_this.labelDomelement = config.domElement; // The margin property defines a space around each label that cannot be occupied by another label.
|
|
105
|
+
// For example, if some labelLayer has a margin value of 5, there will be at least 10 pixels
|
|
106
|
+
// between each labels of the layer
|
|
107
|
+
// TODO : this property should be moved to Style after refactoring style properties structure
|
|
108
|
+
|
|
109
|
+
_this.margin = config.margin;
|
|
105
110
|
return _this;
|
|
106
111
|
}
|
|
107
112
|
/**
|
|
@@ -186,6 +191,7 @@ var LabelLayer = /*#__PURE__*/function (_Layer) {
|
|
|
186
191
|
|
|
187
192
|
var label = new _Label["default"](content, coord.clone(), style, _this2.source.sprites);
|
|
188
193
|
label.layerId = _this2.id;
|
|
194
|
+
label.padding = _this2.margin || label.padding;
|
|
189
195
|
|
|
190
196
|
if (f.size == 2) {
|
|
191
197
|
label.needsAltitude = true;
|
package/lib/Main.js
CHANGED
|
@@ -690,7 +690,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
690
690
|
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; }
|
|
691
691
|
|
|
692
692
|
var conf = {
|
|
693
|
-
version: '2.
|
|
693
|
+
version: '2.36.2'
|
|
694
694
|
};
|
|
695
695
|
var REVISION = conf.version; // Geographic tools
|
|
696
696
|
|
|
@@ -44,7 +44,6 @@ var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
|
44
44
|
* },
|
|
45
45
|
* out: {
|
|
46
46
|
* crs: view.tileLayer.extent.crs,
|
|
47
|
-
* buildExtent: true,
|
|
48
47
|
* }
|
|
49
48
|
* });
|
|
50
49
|
* }).then(function _(geojson) {
|
|
@@ -86,7 +85,7 @@ var _default = {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
options["in"] = options["in"] || {};
|
|
89
|
-
options["in"].crs = data.prj ? (0, _proj["default"])(data.prj).oProj.datumName :
|
|
88
|
+
options["in"].crs = data.prj ? (0, _proj["default"])(data.prj).oProj.datumName : options["in"].crs;
|
|
90
89
|
return Promise.resolve(result).then(function (res) {
|
|
91
90
|
return _GeoJsonParser["default"].parse(res, options);
|
|
92
91
|
});
|
|
@@ -25,7 +25,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
25
25
|
|
|
26
26
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
27
|
|
|
28
|
-
var worldDimension3857 = _Extent.globalExtentTMS.get('EPSG:3857').
|
|
28
|
+
var worldDimension3857 = _Extent.globalExtentTMS.get('EPSG:3857').planarDimensions();
|
|
29
29
|
|
|
30
30
|
var globalExtent = new _three.Vector3(worldDimension3857.x, worldDimension3857.y, 1);
|
|
31
31
|
var lastPoint = new _three.Vector2();
|
|
@@ -80,12 +80,10 @@ function boundingVolumeToExtent(crs, volume, transform) {
|
|
|
80
80
|
return _Extent["default"].fromBox3(crs, _box);
|
|
81
81
|
} else {
|
|
82
82
|
var sphere = tmpSphere.copy(volume.sphere).applyMatrix4(transform);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
north: sphere.center.y + sphere.radius
|
|
88
|
-
});
|
|
83
|
+
|
|
84
|
+
var _box2 = sphere.getBoundingBox(tmpBox3);
|
|
85
|
+
|
|
86
|
+
return _Extent["default"].fromBox3(crs, _box2);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
|
|
@@ -120,7 +118,8 @@ function _subdivideNodeAdditive(context, layer, node, cullingTest) {
|
|
|
120
118
|
|
|
121
119
|
child.promise = requestNewTile(context.view, context.scheduler, layer, child, node, true).then(function (tile) {
|
|
122
120
|
node.add(tile);
|
|
123
|
-
tile.updateMatrixWorld();
|
|
121
|
+
tile.updateMatrixWorld(); // The extent is calculated but it's never used in 3D tiles process
|
|
122
|
+
|
|
124
123
|
var extent = boundingVolumeToExtent(layer.extent.crs, tile.boundingVolume, tile.matrixWorld);
|
|
125
124
|
tile.traverse(function (obj) {
|
|
126
125
|
obj.extent = extent;
|
|
@@ -379,7 +378,8 @@ function init3dTilesLayer(view, scheduler, layer, rootTile) {
|
|
|
379
378
|
layer.object3d.add(tile);
|
|
380
379
|
tile.updateMatrixWorld();
|
|
381
380
|
layer.tileset.tiles[tile.tileId].loaded = true;
|
|
382
|
-
layer.root = tile;
|
|
381
|
+
layer.root = tile; // The extent is calculated but it's never used in 3D tiles process
|
|
382
|
+
|
|
383
383
|
layer.extent = boundingVolumeToExtent(layer.crs || view.referenceCrs, tile.boundingVolume, tile.matrixWorld);
|
|
384
384
|
layer.onTileContentLoaded(tile);
|
|
385
385
|
});
|
|
@@ -94,8 +94,7 @@ var _default = {
|
|
|
94
94
|
var zoomDest = extentsDestination[0].zoom; // check if it's tile level is equal to display level layer.
|
|
95
95
|
|
|
96
96
|
if (zoomDest != layer.zoom.min || // check if there's data in extent tile.
|
|
97
|
-
!this.source.extentInsideLimit(node.extent, zoomDest) ||
|
|
98
|
-
layer.source.isFileSource && !node.extent.isPointInside(layer.source.extent.center(coord))) {
|
|
97
|
+
!this.source.extentInsideLimit(node.extent, zoomDest) || layer.source.isFileSource && !node.extent.isPointInside(layer.source.extent.center(coord))) {
|
|
99
98
|
// if not, there's not data to add at this tile.
|
|
100
99
|
node.layerUpdateState[layer.id].noMoreUpdatePossible();
|
|
101
100
|
return;
|
|
@@ -31,8 +31,9 @@ function hasLabelChildren(object) {
|
|
|
31
31
|
return cc.isLabel;
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
+
var frustum = new THREE.Frustum(); // A grid to manage labels on the screen.
|
|
36
37
|
|
|
37
38
|
var ScreenGrid = /*#__PURE__*/function () {
|
|
38
39
|
function ScreenGrid() {
|
|
@@ -119,8 +120,7 @@ var ScreenGrid = /*#__PURE__*/function () {
|
|
|
119
120
|
return ScreenGrid;
|
|
120
121
|
}();
|
|
121
122
|
|
|
122
|
-
var
|
|
123
|
-
var vector = new THREE.Vector3();
|
|
123
|
+
var worldPosition = new THREE.Vector3();
|
|
124
124
|
/**
|
|
125
125
|
* This renderer is inspired by the
|
|
126
126
|
* [`THREE.CSS2DRenderer`](https://threejs.org/docs/#examples/en/renderers/CSS2DRenderer).
|
|
@@ -133,6 +133,7 @@ var Label2DRenderer = /*#__PURE__*/function () {
|
|
|
133
133
|
this.domElement = document.createElement('div');
|
|
134
134
|
this.domElement.style.overflow = 'hidden';
|
|
135
135
|
this.domElement.style.position = 'absolute';
|
|
136
|
+
this.domElement.style.top = '0';
|
|
136
137
|
this.domElement.style.height = '100%';
|
|
137
138
|
this.domElement.style.width = '100%';
|
|
138
139
|
this.domElement.style.zIndex = 1; // Used to destroy labels that are not added to the DOM
|
|
@@ -175,9 +176,10 @@ var Label2DRenderer = /*#__PURE__*/function () {
|
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
this.grid.reset();
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
this.grid.reset(); // set camera frustum
|
|
180
|
+
|
|
181
|
+
frustum.setFromProjectionMatrix(camera.projectionMatrix);
|
|
182
|
+
this.culling(scene, this.infoTileLayer.displayed.extent, camera); // sort by order, then by visibility inside those subsets
|
|
181
183
|
// https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-hierarchy
|
|
182
184
|
|
|
183
185
|
this.grid.visible.sort(function (a, b) {
|
|
@@ -205,7 +207,7 @@ var Label2DRenderer = /*#__PURE__*/function () {
|
|
|
205
207
|
}
|
|
206
208
|
}, {
|
|
207
209
|
key: "culling",
|
|
208
|
-
value: function culling(object, extent) {
|
|
210
|
+
value: function culling(object, extent, camera) {
|
|
209
211
|
var _this2 = this;
|
|
210
212
|
|
|
211
213
|
if (!object.isLabel) {
|
|
@@ -220,17 +222,19 @@ var Label2DRenderer = /*#__PURE__*/function () {
|
|
|
220
222
|
|
|
221
223
|
this.showNodeDOM(object);
|
|
222
224
|
object.children.forEach(function (c) {
|
|
223
|
-
return _this2.culling(c, extent);
|
|
225
|
+
return _this2.culling(c, extent, camera);
|
|
224
226
|
}); // the presence of the label inside the visible extent and if children has label, we can filter more labels.
|
|
225
227
|
} else if (!extent.isPointInside(object.coordinates) || hasLabelChildren(object)) {
|
|
228
|
+
this.grid.hidden.push(object); // the presence of the label inside frustum camera.
|
|
229
|
+
} else if (!frustum.containsPoint(object.getWorldPosition(worldPosition).applyMatrix4(camera.matrixWorldInverse))) {
|
|
226
230
|
this.grid.hidden.push(object); // Do some horizon culling (if possible) if the tiles level is small
|
|
227
231
|
// enough. The chosen value of 4 seems to provide a good result.
|
|
228
232
|
} else if (object.parent.level < 4 && object.parent.layer.horizonCulling && object.parent.layer.horizonCulling(object.horizonCullingPoint)) {
|
|
229
233
|
this.grid.hidden.push(object);
|
|
230
234
|
} else {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
object.updateProjectedPosition(
|
|
235
|
+
// projecting world position object
|
|
236
|
+
worldPosition.applyMatrix4(camera.projectionMatrix);
|
|
237
|
+
object.updateProjectedPosition(worldPosition.x * this.halfWidth + this.halfWidth, -worldPosition.y * this.halfHeight + this.halfHeight); // Are considered duplicates, labels that have the same screen
|
|
234
238
|
// coordinates and the same base content.
|
|
235
239
|
|
|
236
240
|
if (this.grid.visible.some(function (l) {
|
package/lib/Renderer/OBB.js
CHANGED
|
@@ -189,7 +189,7 @@ var OBB = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
189
189
|
position = _builder$computeShara.position; // Compute the minimum count of segment to build tile
|
|
190
190
|
|
|
191
191
|
|
|
192
|
-
var segment = Math.max(Math.floor(sharableExtent.
|
|
192
|
+
var segment = Math.max(Math.floor(sharableExtent.planarDimensions(dimension).x / 90 + 1), 2);
|
|
193
193
|
var geometry = new _TileGeometry["default"]({
|
|
194
194
|
extent: sharableExtent,
|
|
195
195
|
level: 0,
|
|
@@ -206,7 +206,7 @@ var OBB = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
206
206
|
this.updateMatrixWorld(true);
|
|
207
207
|
} else if (!_Crs["default"].isTms(extent.crs) && _Crs["default"].isMetricUnit(extent.crs)) {
|
|
208
208
|
extent.center(coord).toVector3(this.position);
|
|
209
|
-
extent.
|
|
209
|
+
extent.planarDimensions(dimension);
|
|
210
210
|
size.set(dimension.x, dimension.y, Math.abs(maxHeight - minHeight));
|
|
211
211
|
this.box3D.setFromCenterAndSize(center, size);
|
|
212
212
|
this.updateMatrixWorld(true);
|
|
@@ -217,6 +217,11 @@ var RasterColorTile = /*#__PURE__*/function (_RasterTile) {
|
|
|
217
217
|
get: function get() {
|
|
218
218
|
return this.layer.effect_parameter;
|
|
219
219
|
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "transparent",
|
|
222
|
+
get: function get() {
|
|
223
|
+
return this.layer.transparent;
|
|
224
|
+
}
|
|
220
225
|
}]);
|
|
221
226
|
return RasterColorTile;
|
|
222
227
|
}(RasterTile);
|
|
@@ -235,19 +240,18 @@ var RasterElevationTile = /*#__PURE__*/function (_RasterTile2) {
|
|
|
235
240
|
_this2 = _super3.call(this, material, layer);
|
|
236
241
|
var defaultEle = {
|
|
237
242
|
bias: 0,
|
|
238
|
-
scale: 1,
|
|
239
243
|
mode: _LayeredMaterial.ELEVATION_MODES.DATA,
|
|
240
244
|
zmin: 0,
|
|
241
245
|
zmax: Infinity
|
|
242
246
|
};
|
|
243
|
-
|
|
247
|
+
_this2.scaleFactor = 1.0; // Define elevation properties
|
|
244
248
|
|
|
245
249
|
if (layer.useRgbaTextureElevation) {
|
|
246
250
|
defaultEle.mode = _LayeredMaterial.ELEVATION_MODES.RGBA;
|
|
247
251
|
defaultEle.zmax = 5000;
|
|
248
252
|
throw new Error('Restore this feature');
|
|
249
253
|
} else if (layer.useColorTextureElevation) {
|
|
250
|
-
scaleFactor = layer.colorTextureElevationMaxZ - layer.colorTextureElevationMinZ;
|
|
254
|
+
_this2.scaleFactor = layer.colorTextureElevationMaxZ - layer.colorTextureElevationMinZ;
|
|
251
255
|
defaultEle.mode = _LayeredMaterial.ELEVATION_MODES.COLOR;
|
|
252
256
|
defaultEle.bias = layer.colorTextureElevationMinZ;
|
|
253
257
|
_this2.min = _this2.layer.colorTextureElevationMinZ;
|
|
@@ -258,14 +262,28 @@ var RasterElevationTile = /*#__PURE__*/function (_RasterTile2) {
|
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
_this2.bias = layer.bias || defaultEle.bias;
|
|
261
|
-
_this2.scale = (layer.scale || defaultEle.scale) * scaleFactor;
|
|
262
265
|
_this2.mode = layer.mode || defaultEle.mode;
|
|
263
266
|
_this2.zmin = layer.zmin || defaultEle.zmin;
|
|
264
267
|
_this2.zmax = layer.zmax || defaultEle.zmax;
|
|
268
|
+
layer.addEventListener('scale-property-changed', _this2._handlerCBEvent);
|
|
265
269
|
return _this2;
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
(0, _createClass2["default"])(RasterElevationTile, [{
|
|
273
|
+
key: "scale",
|
|
274
|
+
get: function get() {
|
|
275
|
+
return this.layer.scale * this.scaleFactor;
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "dispose",
|
|
279
|
+
value: function dispose(removeEvent) {
|
|
280
|
+
(0, _get2["default"])((0, _getPrototypeOf2["default"])(RasterElevationTile.prototype), "dispose", this).call(this, removeEvent);
|
|
281
|
+
|
|
282
|
+
if (removeEvent) {
|
|
283
|
+
this.layer.removeEventListener('scale-property-changed', this._handlerCBEvent);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}, {
|
|
269
287
|
key: "initFromParent",
|
|
270
288
|
value: function initFromParent(parent, extents) {
|
|
271
289
|
(0, _get2["default"])((0, _getPrototypeOf2["default"])(RasterElevationTile.prototype), "initFromParent", this).call(this, parent, extents);
|
|
@@ -20,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
22
22
|
/* babel-plugin-inline-import './Chunk/color_layers_pars_fragment.glsl' */
|
|
23
|
-
var color_layers_pars_fragment = "struct Layer {\n int textureOffset;\n int crs;\n int effect_type;\n float effect_parameter;\n float opacity;\n};\n\n#include <itowns/custom_header_colorLayer>\n\nuniform sampler2D colorTextures[NUM_FS_TEXTURES];\nuniform vec4 colorOffsetScales[NUM_FS_TEXTURES];\nuniform Layer colorLayers[NUM_FS_TEXTURES];\nuniform int colorTextureCount;\n\nvec3 uvs[NUM_CRS];\n\nfloat getBorderDistance(vec2 uv) {\n vec2 p2 = min(uv, 1. -uv);\n return min(p2.x, p2.y);\n}\n\nfloat tolerance = 0.99;\n\nvec4 applyWhiteToInvisibleEffect(vec4 color, float intensity) {\n float a = dot(color.rgb, vec3(0.333333333));\n if (a >= tolerance) {\n color.a *= 1.0 - pow(abs(a), intensity);\n }\n return color;\n}\n\nvec4 applyLightColorToInvisibleEffect(vec4 color, float intensity) {\n float a = max(0.05,1. - length(color.xyz - 1.));\n color.a *= 1.0 - pow(abs(a), intensity);\n color.rgb *= color.rgb * color.rgb;\n return color;\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nuniform vec3 outlineColors[NUM_CRS];\nuniform float outlineWidth;\n\nvec4 getOutlineColor(vec3 outlineColor, vec2 uv) {\n float alpha = 1. - clamp(getBorderDistance(uv) / outlineWidth, 0., 1.);\n return vec4(outlineColor, alpha);\n}\n#endif\n\nuniform float minBorderDistance;\nvec4 getLayerColor(int textureOffset, sampler2D tex, vec4 offsetScale, Layer layer) {\n if ( textureOffset >= colorTextureCount ) return vec4(0);\n\n vec3 uv;\n // #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++ ) {\n if ( i == layer.crs ) uv = uvs[ i ];\n }\n\n float borderDistance = getBorderDistance(uv.xy);\n if (textureOffset != layer.textureOffset + int(uv.z) || borderDistance < minBorderDistance ) return vec4(0);\n vec4 color = texture2D(tex, pitUV(uv.xy, offsetScale));\n if (layer.effect_type ==
|
|
23
|
+
var color_layers_pars_fragment = "struct Layer {\n int textureOffset;\n int crs;\n int effect_type;\n float effect_parameter;\n float opacity;\n bool transparent;\n};\n\n#include <itowns/custom_header_colorLayer>\n\nuniform sampler2D colorTextures[NUM_FS_TEXTURES];\nuniform vec4 colorOffsetScales[NUM_FS_TEXTURES];\nuniform Layer colorLayers[NUM_FS_TEXTURES];\nuniform int colorTextureCount;\n\nvec3 uvs[NUM_CRS];\n\nfloat getBorderDistance(vec2 uv) {\n vec2 p2 = min(uv, 1. -uv);\n return min(p2.x, p2.y);\n}\n\nfloat tolerance = 0.99;\n\nvec4 applyWhiteToInvisibleEffect(vec4 color, float intensity) {\n float a = dot(color.rgb, vec3(0.333333333));\n if (a >= tolerance) {\n color.a *= 1.0 - pow(abs(a), intensity);\n }\n return color;\n}\n\nvec4 applyLightColorToInvisibleEffect(vec4 color, float intensity) {\n float a = max(0.05,1. - length(color.xyz - 1.));\n color.a *= 1.0 - pow(abs(a), intensity);\n color.rgb *= color.rgb * color.rgb;\n return color;\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nuniform vec3 outlineColors[NUM_CRS];\nuniform float outlineWidth;\n\nvec4 getOutlineColor(vec3 outlineColor, vec2 uv) {\n float alpha = 1. - clamp(getBorderDistance(uv) / outlineWidth, 0., 1.);\n return vec4(outlineColor, alpha);\n}\n#endif\n\nuniform float minBorderDistance;\nvec4 getLayerColor(int textureOffset, sampler2D tex, vec4 offsetScale, Layer layer) {\n if ( textureOffset >= colorTextureCount ) return vec4(0);\n\n vec3 uv;\n // #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++ ) {\n if ( i == layer.crs ) uv = uvs[ i ];\n }\n\n float borderDistance = getBorderDistance(uv.xy);\n if (textureOffset != layer.textureOffset + int(uv.z) || borderDistance < minBorderDistance ) return vec4(0);\n vec4 color = texture2D(tex, pitUV(uv.xy, offsetScale));\n if (layer.effect_type == 3) {\n #include <itowns/custom_body_colorLayer>\n } else {\n if (layer.transparent && color.a != 0.0) {\n color.rgb /= color.a;\n }\n\n if (layer.effect_type == 1) {\n color = applyLightColorToInvisibleEffect(color, layer.effect_parameter);\n } else if (layer.effect_type == 2) {\n color = applyWhiteToInvisibleEffect(color, layer.effect_parameter);\n }\n }\n color.a *= layer.opacity;\n return color;\n}\n";
|
|
24
24
|
|
|
25
25
|
/* babel-plugin-inline-import './Chunk/elevation_pars_vertex.glsl' */
|
|
26
26
|
var elevation_pars_vertex = "#if NUM_VS_TEXTURES > 0\n struct Layer {\n float scale;\n float bias;\n int mode;\n float zmin;\n float zmax;\n };\n\n uniform Layer elevationLayers[NUM_VS_TEXTURES];\n uniform sampler2D elevationTextures[NUM_VS_TEXTURES];\n uniform vec4 elevationOffsetScales[NUM_VS_TEXTURES];\n uniform int elevationTextureCount;\n\n highp float decode32(highp vec4 rgba) {\n highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;\n highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;\n highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);\n highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));\n return Result;\n }\n\n float getElevationMode(vec2 uv, sampler2D tex, int mode) {\n if (mode == ELEVATION_RGBA)\n return decode32(texture2D( tex, uv ).abgr * 255.0);\n if (mode == ELEVATION_DATA || mode == ELEVATION_COLOR)\n #if defined(WEBGL2)\n return texture2D( tex, uv ).r;\n #else\n return texture2D( tex, uv ).w;\n #endif\n return 0.;\n }\n\n float getElevation(vec2 uv, sampler2D tex, vec4 offsetScale, Layer layer) {\n uv = uv * offsetScale.zw + offsetScale.xy;\n float d = getElevationMode(uv, tex, layer.mode);\n if (d < layer.zmin || d > layer.zmax) d = 0.;\n return d * layer.scale + layer.bias;\n }\n#endif\n";
|
|
@@ -29,10 +29,10 @@ var elevation_pars_vertex = "#if NUM_VS_TEXTURES > 0\n struct Layer {\n
|
|
|
29
29
|
var elevation_vertex = "#if NUM_VS_TEXTURES > 0\n if(elevationTextureCount > 0) {\n float elevation = getElevation(uv, elevationTextures[0], elevationOffsetScales[0], elevationLayers[0]);\n transformed += elevation * normal;\n }\n#endif\n";
|
|
30
30
|
|
|
31
31
|
/* babel-plugin-inline-import './Chunk/fog_fragment.glsl' */
|
|
32
|
-
var fog_fragment = "#if defined(USE_FOG)\n float fogFactor = 1. - min( exp(-
|
|
32
|
+
var fog_fragment = "#if defined(USE_FOG)\n float fogFactor = 1. - min( exp(-vFogDepth / fogDistance), 1.);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif\n";
|
|
33
33
|
|
|
34
34
|
/* babel-plugin-inline-import './Chunk/fog_pars_fragment.glsl' */
|
|
35
|
-
var fog_pars_fragment = "#if defined(USE_FOG)\nuniform vec3 fogColor;\nuniform float fogDistance;\nvarying float
|
|
35
|
+
var fog_pars_fragment = "#if defined(USE_FOG)\nuniform vec3 fogColor;\nuniform float fogDistance;\nvarying float vFogDepth;\n#endif\n";
|
|
36
36
|
|
|
37
37
|
/* babel-plugin-inline-import './Chunk/lighting_fragment.glsl' */
|
|
38
38
|
var lighting_fragment = "if (lightingEnabled) {\n float light = min(2. * dot(vNormal, lightPosition), 1.);\n gl_FragColor.rgb *= light;\n}\n";
|
|
@@ -54,10 +54,22 @@ var c3DEngine = /*#__PURE__*/function () {
|
|
|
54
54
|
|
|
55
55
|
if (options.isWebGL2 === undefined) {
|
|
56
56
|
options.isWebGL2 = true;
|
|
57
|
+
} // If rendererOrDiv parameter is a domElement, we use it as support to display data.
|
|
58
|
+
// If it is a renderer, we check the renderer.domElement parameter which can be :
|
|
59
|
+
// - a domElement, in this case we use this domElement as a support
|
|
60
|
+
// - a canvas, in this case we use the canvas parent (which should be a domElement) as a support
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
var renderer;
|
|
64
|
+
var viewerDiv;
|
|
65
|
+
|
|
66
|
+
if (rendererOrDiv.domElement) {
|
|
67
|
+
renderer = rendererOrDiv;
|
|
68
|
+
viewerDiv = renderer.domElement instanceof HTMLDivElement ? renderer.domElement : renderer.domElement.parentElement;
|
|
69
|
+
} else {
|
|
70
|
+
viewerDiv = rendererOrDiv;
|
|
57
71
|
}
|
|
58
72
|
|
|
59
|
-
var renderer = rendererOrDiv.domElement ? rendererOrDiv : undefined;
|
|
60
|
-
var viewerDiv = renderer ? renderer.domElement : rendererOrDiv;
|
|
61
73
|
this.width = viewerDiv.clientWidth;
|
|
62
74
|
this.height = viewerDiv.clientHeight;
|
|
63
75
|
this.positionBuffer = null;
|
package/lib/Source/FileSource.js
CHANGED
|
@@ -106,13 +106,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
106
106
|
* itowns.Fetcher.json('https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson')
|
|
107
107
|
* .then(function _(geojson) {
|
|
108
108
|
* return itowns.GeoJsonParser.parse(geojson, {
|
|
109
|
-
* in: {
|
|
110
|
-
* out: {
|
|
111
|
-
* crs: view.tileLayer.extent.crs,
|
|
112
|
-
* buildExtent: true,
|
|
113
|
-
* mergeFeatures: true,
|
|
114
|
-
* structure: '2d',
|
|
115
|
-
* },
|
|
109
|
+
* in: { crs: 'EPSG:4326' },
|
|
110
|
+
* out: { crs: view.tileLayer.extent.crs },
|
|
116
111
|
* });
|
|
117
112
|
* }).then(function _(features) {
|
|
118
113
|
* ariege.source = new itowns.FileSource({
|
|
@@ -9,6 +9,10 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
+
|
|
12
16
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
17
|
|
|
14
18
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -172,6 +176,21 @@ var VectorTilesSource = /*#__PURE__*/function (_TMSSource) {
|
|
|
172
176
|
return _this;
|
|
173
177
|
}
|
|
174
178
|
|
|
179
|
+
(0, _createClass2["default"])(VectorTilesSource, [{
|
|
180
|
+
key: "onLayerAdded",
|
|
181
|
+
value: function onLayerAdded(options) {
|
|
182
|
+
var _this2 = this;
|
|
183
|
+
|
|
184
|
+
(0, _get2["default"])((0, _getPrototypeOf2["default"])(VectorTilesSource.prototype), "onLayerAdded", this).call(this, options);
|
|
185
|
+
|
|
186
|
+
if (options.out.style) {
|
|
187
|
+
var keys = Object.keys(this.styles);
|
|
188
|
+
keys.forEach(function (k) {
|
|
189
|
+
_this2.styles[k].parent = options.out.style;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}]);
|
|
175
194
|
return VectorTilesSource;
|
|
176
195
|
}(_TMSSource2["default"]);
|
|
177
196
|
|