itowns 2.37.0 → 2.38.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/README.md +12 -1
- package/changelog.md +101 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.LICENSE.txt +2 -2
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.LICENSE.txt +2 -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/config.json +4 -1
- package/examples/css/example.css +21 -1
- package/examples/css/widgets.css +118 -6
- package/examples/images/code-logo.svg +43 -0
- package/examples/index.html +5 -5
- package/examples/mars.html +0 -1
- package/examples/misc_orthographic_camera.html +7 -19
- package/examples/vector_tile_3d_mesh.html +155 -0
- package/examples/vector_tile_raster_3d.html +0 -5
- package/examples/view_25d_map.html +6 -19
- package/examples/view_2d_map.html +6 -19
- package/examples/view_3d_map.html +106 -81
- package/examples/widgets_minimap.html +3 -1
- package/examples/widgets_navigation.html +6 -1
- package/examples/widgets_scale.html +96 -0
- package/examples/widgets_searchbar.html +124 -0
- package/lib/Controls/PlanarControls.js +10 -42
- package/lib/Converter/Feature2Mesh.js +225 -61
- package/lib/Converter/Feature2Texture.js +4 -3
- package/lib/Converter/convertToTile.js +10 -5
- package/lib/Core/Feature.js +57 -30
- package/lib/Core/MainLoop.js +136 -62
- package/lib/Core/TileMesh.js +21 -5
- package/lib/Core/View.js +46 -15
- package/lib/Layer/FeatureGeometryLayer.js +37 -10
- package/lib/Layer/GeoidLayer.js +17 -6
- package/lib/Layer/GeometryLayer.js +6 -54
- package/lib/Layer/OrientedImageLayer.js +1 -0
- package/lib/Layer/RasterLayer.js +3 -1
- package/lib/Layer/ReferencingLayerProperties.js +50 -0
- package/lib/Main.js +1 -1
- package/lib/Parser/B3dmParser.js +3 -2
- package/lib/Parser/GeoJsonParser.js +29 -7
- package/lib/Parser/VectorTileParser.js +5 -4
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +3 -3
- package/lib/Process/3dTilesProcessing.js +3 -3
- package/lib/Process/FeatureProcessing.js +36 -86
- package/lib/Process/LayeredMaterialNodeProcessing.js +9 -3
- package/lib/Process/ObjectRemovalHelper.js +4 -0
- package/lib/Provider/3dTilesProvider.js +2 -7
- package/lib/Provider/Fetcher.js +5 -2
- package/lib/Provider/TileProvider.js +18 -2
- package/lib/Renderer/Camera.js +33 -12
- package/lib/Renderer/ColorLayersOrdering.js +3 -1
- package/lib/Renderer/LayeredMaterial.js +32 -7
- package/lib/Renderer/OBB.js +8 -4
- package/lib/Renderer/OrientedImageMaterial.js +8 -5
- package/lib/Renderer/PointsMaterial.js +1 -0
- package/lib/Renderer/RenderMode.js +3 -1
- package/lib/Renderer/Shader/ShaderChunk.js +5 -1
- package/lib/Renderer/c3DEngine.js +9 -6
- package/lib/Source/FileSource.js +8 -1
- package/lib/Source/VectorTilesSource.js +5 -0
- package/lib/Source/WFSSource.js +9 -3
- package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
- package/lib/ThreeExtended/loaders/GLTFLoader.js +3 -4
- package/lib/Utils/DEMUtils.js +3 -1
- package/lib/Utils/gui/Main.js +39 -0
- package/lib/Utils/gui/Minimap.js +195 -0
- package/lib/Utils/gui/Navigation.js +322 -0
- package/lib/Utils/gui/Scale.js +154 -0
- package/lib/Utils/gui/Searchbar.js +299 -0
- package/lib/Utils/gui/Widget.js +119 -0
- package/package.json +27 -22
- package/examples/images/compass.svg +0 -60
- package/examples/images/widget-logo.svg +0 -66
- package/examples/js/Scale.js +0 -41
|
@@ -9,14 +9,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
|
|
27
|
+
|
|
28
|
+
var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
|
|
29
|
+
|
|
12
30
|
var THREE = _interopRequireWildcard(require("three"));
|
|
13
31
|
|
|
14
32
|
var _earcut = _interopRequireDefault(require("earcut"));
|
|
15
33
|
|
|
16
34
|
var _Feature = require("../Core/Feature");
|
|
17
35
|
|
|
36
|
+
var _ReferencingLayerProperties = _interopRequireDefault(require("../Layer/ReferencingLayerProperties"));
|
|
37
|
+
|
|
18
38
|
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
19
39
|
|
|
40
|
+
var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
|
|
41
|
+
|
|
42
|
+
var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
|
|
43
|
+
|
|
44
|
+
var _OrientationUtils = _interopRequireDefault(require("../Utils/OrientationUtils"));
|
|
45
|
+
|
|
46
|
+
var _Coordinates = _interopRequireDefault(require("../Core/Geographic/Coordinates"));
|
|
47
|
+
|
|
20
48
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
49
|
|
|
22
50
|
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; }
|
|
@@ -27,11 +55,129 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
27
55
|
|
|
28
56
|
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; }
|
|
29
57
|
|
|
58
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
59
|
+
|
|
60
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
|
+
|
|
62
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
63
|
+
|
|
64
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
65
|
+
|
|
66
|
+
var coord = new _Coordinates["default"]('EPSG:4326', 0, 0, 0);
|
|
67
|
+
var dim_ref = new THREE.Vector2();
|
|
68
|
+
var dim = new THREE.Vector2();
|
|
69
|
+
var extent = new _Extent["default"]('EPSG:4326', 0, 0, 0, 0);
|
|
70
|
+
|
|
30
71
|
var _color = new THREE.Color();
|
|
31
72
|
|
|
32
73
|
var maxValueUint8 = Math.pow(2, 8) - 1;
|
|
33
74
|
var maxValueUint16 = Math.pow(2, 16) - 1;
|
|
34
75
|
var maxValueUint32 = Math.pow(2, 32) - 1;
|
|
76
|
+
var crsWGS84 = 'EPSG:4326';
|
|
77
|
+
|
|
78
|
+
var _currentCrs = /*#__PURE__*/new WeakMap();
|
|
79
|
+
|
|
80
|
+
var _originalCrs = /*#__PURE__*/new WeakMap();
|
|
81
|
+
|
|
82
|
+
var _collection = /*#__PURE__*/new WeakMap();
|
|
83
|
+
|
|
84
|
+
var _place = /*#__PURE__*/new WeakMap();
|
|
85
|
+
|
|
86
|
+
var FeatureMesh = /*#__PURE__*/function (_THREE$Group) {
|
|
87
|
+
(0, _inherits2["default"])(FeatureMesh, _THREE$Group);
|
|
88
|
+
|
|
89
|
+
var _super = _createSuper(FeatureMesh);
|
|
90
|
+
|
|
91
|
+
function FeatureMesh(meshes, collection) {
|
|
92
|
+
var _THREE$Group2;
|
|
93
|
+
|
|
94
|
+
var _this;
|
|
95
|
+
|
|
96
|
+
(0, _classCallCheck2["default"])(this, FeatureMesh);
|
|
97
|
+
_this = _super.call(this);
|
|
98
|
+
|
|
99
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _currentCrs, {
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _originalCrs, {
|
|
105
|
+
writable: true,
|
|
106
|
+
value: void 0
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _collection, {
|
|
110
|
+
writable: true,
|
|
111
|
+
value: new THREE.Group()
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _place, {
|
|
115
|
+
writable: true,
|
|
116
|
+
value: new THREE.Group()
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
_this.meshes = (_THREE$Group2 = new THREE.Group()).add.apply(_THREE$Group2, (0, _toConsumableArray2["default"])(meshes));
|
|
120
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection, new THREE.Group().add(_this.meshes));
|
|
121
|
+
(0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection).quaternion.copy(collection.quaternion);
|
|
122
|
+
(0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection).position.copy(collection.position);
|
|
123
|
+
(0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection).scale.copy(collection.scale);
|
|
124
|
+
(0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection).updateMatrix();
|
|
125
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _originalCrs, collection.crs);
|
|
126
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _currentCrs, (0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _originalCrs));
|
|
127
|
+
_this.extent = collection.extent;
|
|
128
|
+
|
|
129
|
+
_this.add((0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _place).add((0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _collection)));
|
|
130
|
+
|
|
131
|
+
return _this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
(0, _createClass2["default"])(FeatureMesh, [{
|
|
135
|
+
key: "as",
|
|
136
|
+
value: function as(crs) {
|
|
137
|
+
if ((0, _classPrivateFieldGet2["default"])(this, _currentCrs) !== crs) {
|
|
138
|
+
(0, _classPrivateFieldSet2["default"])(this, _currentCrs, crs);
|
|
139
|
+
|
|
140
|
+
if (crs == (0, _classPrivateFieldGet2["default"])(this, _originalCrs)) {
|
|
141
|
+
// reset transformation
|
|
142
|
+
this.place.position.set(0, 0, 0);
|
|
143
|
+
this.position.set(0, 0, 0);
|
|
144
|
+
this.scale.set(1, 1, 1);
|
|
145
|
+
this.quaternion.identity();
|
|
146
|
+
} else {
|
|
147
|
+
// calculate the scale transformation to transform the feature.extent
|
|
148
|
+
// to feature.extent.as(crs)
|
|
149
|
+
coord.crs = _Crs["default"].formatToEPSG((0, _classPrivateFieldGet2["default"])(this, _originalCrs));
|
|
150
|
+
extent.copy(this.extent).applyMatrix4((0, _classPrivateFieldGet2["default"])(this, _collection).matrix);
|
|
151
|
+
extent.as(coord.crs, extent);
|
|
152
|
+
extent.spatialEuclideanDimensions(dim_ref);
|
|
153
|
+
extent.planarDimensions(dim);
|
|
154
|
+
|
|
155
|
+
if (dim.x && dim.y) {
|
|
156
|
+
this.scale.copy(dim_ref).divide(dim).setZ(1);
|
|
157
|
+
} // Position and orientation
|
|
158
|
+
// remove original position
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
(0, _classPrivateFieldGet2["default"])(this, _place).position.copy((0, _classPrivateFieldGet2["default"])(this, _collection).position).negate(); // get mesh coordinate
|
|
162
|
+
|
|
163
|
+
coord.setFromVector3((0, _classPrivateFieldGet2["default"])(this, _collection).position); // get method to calculate orientation
|
|
164
|
+
|
|
165
|
+
var crsInput = (0, _classPrivateFieldGet2["default"])(this, _originalCrs) == 'EPSG:3857' ? crsWGS84 : (0, _classPrivateFieldGet2["default"])(this, _originalCrs);
|
|
166
|
+
|
|
167
|
+
var crs2crs = _OrientationUtils["default"].quaternionFromCRSToCRS(crsInput, crs); // calculate orientation to crs
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
crs2crs(coord.as(crsWGS84), this.quaternion); // transform position to crs
|
|
171
|
+
|
|
172
|
+
coord.as(crs, coord).toVector3(this.position);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
}]);
|
|
179
|
+
return FeatureMesh;
|
|
180
|
+
}(THREE.Group);
|
|
35
181
|
|
|
36
182
|
function toColor(color) {
|
|
37
183
|
if (color) {
|
|
@@ -94,12 +240,21 @@ function coordinatesToVertices(ptsIn, normals, target, zTranslation) {
|
|
|
94
240
|
offsetOut *= 3;
|
|
95
241
|
var endIn = startIn + countIn;
|
|
96
242
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
243
|
+
if (normals) {
|
|
244
|
+
for (var i = startIn, j = offsetOut; i < endIn; i += 3, j += 3) {
|
|
245
|
+
// move the vertex following the normal, to put the point on the good altitude
|
|
246
|
+
// fill the vertices array at the offset position
|
|
247
|
+
target[j] = ptsIn[i] + normals[i] * zTranslation;
|
|
248
|
+
target[j + 1] = ptsIn[i + 1] + normals[i + 1] * zTranslation;
|
|
249
|
+
target[j + 2] = ptsIn[i + 2] + normals[i + 2] * zTranslation;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
for (var _i = startIn, _j = offsetOut; _i < endIn; _i += 3, _j += 3) {
|
|
253
|
+
// move the vertex following the z axe
|
|
254
|
+
target[_j] = ptsIn[_i];
|
|
255
|
+
target[_j + 1] = ptsIn[_i + 1];
|
|
256
|
+
target[_j + 2] = ptsIn[_i + 2] + zTranslation;
|
|
257
|
+
}
|
|
103
258
|
}
|
|
104
259
|
}
|
|
105
260
|
/*
|
|
@@ -148,8 +303,6 @@ function addExtrudedPolygonSideFaces(indices, length, offset, count, isClockWise
|
|
|
148
303
|
}
|
|
149
304
|
}
|
|
150
305
|
|
|
151
|
-
var pointMaterial = new THREE.PointsMaterial();
|
|
152
|
-
|
|
153
306
|
function featureToPoint(feature, options) {
|
|
154
307
|
var ptsIn = feature.vertices;
|
|
155
308
|
var normals = feature.normals;
|
|
@@ -174,14 +327,15 @@ function featureToPoint(feature, options) {
|
|
|
174
327
|
_step;
|
|
175
328
|
|
|
176
329
|
try {
|
|
177
|
-
var _loop = function () {
|
|
330
|
+
var _loop = function _loop() {
|
|
178
331
|
var geometry = _step.value;
|
|
179
|
-
var
|
|
332
|
+
var context = {
|
|
180
333
|
globals: globals,
|
|
181
334
|
properties: function properties() {
|
|
182
335
|
return geometry.properties;
|
|
183
336
|
}
|
|
184
|
-
}
|
|
337
|
+
};
|
|
338
|
+
var style = feature.style.drawingStylefromContext(context);
|
|
185
339
|
var start = geometry.indices[0].offset;
|
|
186
340
|
var count = geometry.indices[0].count;
|
|
187
341
|
fillColorArray(colors, count, toColor(style.point.color), start);
|
|
@@ -210,12 +364,10 @@ function featureToPoint(feature, options) {
|
|
|
210
364
|
geom.setAttribute('batchId', new THREE.BufferAttribute(batchIds, 1));
|
|
211
365
|
}
|
|
212
366
|
|
|
213
|
-
pointMaterial.size = feature.style.point.radius;
|
|
214
|
-
return new THREE.Points(geom, pointMaterial);
|
|
367
|
+
options.pointMaterial.size = feature.style.point.radius;
|
|
368
|
+
return new THREE.Points(geom, options.pointMaterial);
|
|
215
369
|
}
|
|
216
370
|
|
|
217
|
-
var lineMaterial = new THREE.LineBasicMaterial();
|
|
218
|
-
|
|
219
371
|
function featureToLine(feature, options) {
|
|
220
372
|
var ptsIn = feature.vertices;
|
|
221
373
|
var normals = feature.normals;
|
|
@@ -237,7 +389,7 @@ function featureToLine(feature, options) {
|
|
|
237
389
|
geom.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
|
238
390
|
var lines; // TODO CREATE material for each feature
|
|
239
391
|
|
|
240
|
-
lineMaterial.linewidth = feature.style.stroke.width;
|
|
392
|
+
options.lineMaterial.linewidth = feature.style.stroke.width;
|
|
241
393
|
var globals = {
|
|
242
394
|
stroke: true
|
|
243
395
|
};
|
|
@@ -251,14 +403,15 @@ function featureToLine(feature, options) {
|
|
|
251
403
|
_step2;
|
|
252
404
|
|
|
253
405
|
try {
|
|
254
|
-
var _loop2 = function () {
|
|
406
|
+
var _loop2 = function _loop2() {
|
|
255
407
|
var geometry = _step2.value;
|
|
256
|
-
var
|
|
408
|
+
var context = {
|
|
257
409
|
globals: globals,
|
|
258
410
|
properties: function properties() {
|
|
259
411
|
return geometry.properties;
|
|
260
412
|
}
|
|
261
|
-
}
|
|
413
|
+
};
|
|
414
|
+
var style = feature.style.drawingStylefromContext(context);
|
|
262
415
|
var start = geometry.indices[0].offset; // To avoid integer overflow with indice value (16 bits)
|
|
263
416
|
|
|
264
417
|
if (start > 0xffff) {
|
|
@@ -304,14 +457,15 @@ function featureToLine(feature, options) {
|
|
|
304
457
|
}
|
|
305
458
|
|
|
306
459
|
geom.setIndex(new THREE.BufferAttribute(indices, 1));
|
|
307
|
-
lines = new THREE.LineSegments(geom, lineMaterial);
|
|
460
|
+
lines = new THREE.LineSegments(geom, options.lineMaterial);
|
|
308
461
|
} else {
|
|
309
|
-
var
|
|
462
|
+
var context = {
|
|
310
463
|
globals: globals,
|
|
311
464
|
properties: function properties() {
|
|
312
465
|
return feature.geometries[0].properties;
|
|
313
466
|
}
|
|
314
|
-
}
|
|
467
|
+
};
|
|
468
|
+
var style = feature.style.drawingStylefromContext(context);
|
|
315
469
|
fillColorArray(colors, count, toColor(style.stroke.color));
|
|
316
470
|
geom.setAttribute('color', new THREE.BufferAttribute(colors, 3, true));
|
|
317
471
|
|
|
@@ -321,14 +475,12 @@ function featureToLine(feature, options) {
|
|
|
321
475
|
geom.setAttribute('batchId', new THREE.BufferAttribute(batchIds, 1));
|
|
322
476
|
}
|
|
323
477
|
|
|
324
|
-
lines = new THREE.Line(geom, lineMaterial);
|
|
478
|
+
lines = new THREE.Line(geom, options.lineMaterial);
|
|
325
479
|
}
|
|
326
480
|
|
|
327
481
|
return lines;
|
|
328
482
|
}
|
|
329
483
|
|
|
330
|
-
var material = new THREE.MeshBasicMaterial();
|
|
331
|
-
|
|
332
484
|
function featureToPolygon(feature, options) {
|
|
333
485
|
var ptsIn = feature.vertices;
|
|
334
486
|
var normals = feature.normals;
|
|
@@ -354,7 +506,7 @@ function featureToPolygon(feature, options) {
|
|
|
354
506
|
_step3;
|
|
355
507
|
|
|
356
508
|
try {
|
|
357
|
-
var _loop3 = function () {
|
|
509
|
+
var _loop3 = function _loop3() {
|
|
358
510
|
var geometry = _step3.value;
|
|
359
511
|
var start = geometry.indices[0].offset; // To avoid integer overflow with index value (32 bits)
|
|
360
512
|
|
|
@@ -363,15 +515,17 @@ function featureToPolygon(feature, options) {
|
|
|
363
515
|
return "break";
|
|
364
516
|
}
|
|
365
517
|
|
|
366
|
-
var
|
|
518
|
+
var context = {
|
|
367
519
|
globals: globals,
|
|
368
520
|
properties: function properties() {
|
|
369
521
|
return geometry.properties;
|
|
370
522
|
}
|
|
371
|
-
}
|
|
523
|
+
};
|
|
524
|
+
var style = feature.style.drawingStylefromContext(context);
|
|
372
525
|
var lastIndice = geometry.indices.slice(-1)[0];
|
|
373
526
|
var end = lastIndice.offset + lastIndice.count;
|
|
374
|
-
|
|
527
|
+
var count = end - start;
|
|
528
|
+
fillColorArray(colors, count, toColor(style.fill.color), start);
|
|
375
529
|
var geomVertices = vertices.slice(start * 3, end * 3);
|
|
376
530
|
var holesOffsets = geometry.indices.map(function (i) {
|
|
377
531
|
return i.offset - start;
|
|
@@ -411,15 +565,15 @@ function featureToPolygon(feature, options) {
|
|
|
411
565
|
}
|
|
412
566
|
|
|
413
567
|
geom.setIndex(new THREE.BufferAttribute(getIntArrayFromSize(indices, vertices.length / 3), 1));
|
|
414
|
-
return new THREE.Mesh(geom,
|
|
568
|
+
return new THREE.Mesh(geom, options.polygonMaterial);
|
|
415
569
|
}
|
|
416
570
|
|
|
417
571
|
function area(contour, offset, count) {
|
|
418
572
|
offset *= 3;
|
|
419
|
-
var n = count * 3;
|
|
573
|
+
var n = offset + count * 3;
|
|
420
574
|
var a = 0.0;
|
|
421
575
|
|
|
422
|
-
for (var p = n
|
|
576
|
+
for (var p = n - 3, q = offset; q < n; p = q, q += 3) {
|
|
423
577
|
a += contour[p] * contour[q + 1] - contour[q] * contour[p + 1];
|
|
424
578
|
}
|
|
425
579
|
|
|
@@ -430,9 +584,6 @@ var bottomColor = new THREE.Color();
|
|
|
430
584
|
|
|
431
585
|
function featureToExtrudedPolygon(feature, options) {
|
|
432
586
|
var ptsIn = feature.vertices;
|
|
433
|
-
var offset = feature.geometries[0].indices[0].offset;
|
|
434
|
-
var count = feature.geometries[0].indices[0].count;
|
|
435
|
-
var isClockWise = area(ptsIn, offset, count) < 0;
|
|
436
587
|
var normals = feature.normals;
|
|
437
588
|
var vertices = new Float32Array(ptsIn.length * 2);
|
|
438
589
|
var colors = new Uint8Array(ptsIn.length * 2);
|
|
@@ -449,14 +600,17 @@ function featureToExtrudedPolygon(feature, options) {
|
|
|
449
600
|
_step4;
|
|
450
601
|
|
|
451
602
|
try {
|
|
452
|
-
var _loop4 = function () {
|
|
603
|
+
var _loop4 = function _loop4() {
|
|
604
|
+
var _geometry$indices$0$c;
|
|
605
|
+
|
|
453
606
|
var geometry = _step4.value;
|
|
454
|
-
var
|
|
607
|
+
var context = {
|
|
455
608
|
globals: globals,
|
|
456
609
|
properties: function properties() {
|
|
457
610
|
return geometry.properties;
|
|
458
611
|
}
|
|
459
|
-
}
|
|
612
|
+
};
|
|
613
|
+
var style = feature.style.drawingStylefromContext(context); // topColor is assigned to the top of extruded polygon
|
|
460
614
|
|
|
461
615
|
var topColor = toColor(style.fill.color); // bottomColor is assigned to the bottom of extruded polygon
|
|
462
616
|
|
|
@@ -466,6 +620,7 @@ function featureToExtrudedPolygon(feature, options) {
|
|
|
466
620
|
var lastIndice = geometry.indices.slice(-1)[0];
|
|
467
621
|
var end = lastIndice.offset + lastIndice.count;
|
|
468
622
|
var count = end - start;
|
|
623
|
+
var isClockWise = (_geometry$indices$0$c = geometry.indices[0].ccw) !== null && _geometry$indices$0$c !== void 0 ? _geometry$indices$0$c : area(ptsIn, start, count) < 0;
|
|
469
624
|
coordinatesToVertices(ptsIn, normals, vertices, z, start, count);
|
|
470
625
|
fillColorArray(colors, count, bottomColor, start);
|
|
471
626
|
var startTop = start + totalVertices;
|
|
@@ -482,20 +637,16 @@ function featureToExtrudedPolygon(feature, options) {
|
|
|
482
637
|
|
|
483
638
|
for (var i = 0; i < triangles.length; i++) {
|
|
484
639
|
indices[startIndice + i] = triangles[i] + startTop;
|
|
485
|
-
}
|
|
640
|
+
} // add extruded contour
|
|
486
641
|
|
|
487
|
-
var _iterator5 = _createForOfIteratorHelper(geometry.indices),
|
|
488
|
-
_step5;
|
|
489
642
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
} finally {
|
|
498
|
-
_iterator5.f();
|
|
643
|
+
addExtrudedPolygonSideFaces(indices, totalVertices, geometry.indices[0].offset, geometry.indices[0].count, isClockWise); // add extruded holes
|
|
644
|
+
|
|
645
|
+
for (var _i2 = 1; _i2 < geometry.indices.length; _i2++) {
|
|
646
|
+
var _indice$ccw;
|
|
647
|
+
|
|
648
|
+
var indice = geometry.indices[_i2];
|
|
649
|
+
addExtrudedPolygonSideFaces(indices, totalVertices, indice.offset, indice.count, !((_indice$ccw = indice.ccw) !== null && _indice$ccw !== void 0 ? _indice$ccw : isClockWise));
|
|
499
650
|
}
|
|
500
651
|
|
|
501
652
|
if (batchIds) {
|
|
@@ -524,8 +675,7 @@ function featureToExtrudedPolygon(feature, options) {
|
|
|
524
675
|
}
|
|
525
676
|
|
|
526
677
|
geom.setIndex(new THREE.BufferAttribute(getIntArrayFromSize(indices, vertices.length / 3), 1));
|
|
527
|
-
|
|
528
|
-
return mesh;
|
|
678
|
+
return new THREE.Mesh(geom, options.polygonMaterial);
|
|
529
679
|
}
|
|
530
680
|
/**
|
|
531
681
|
* Convert a [Feature]{@link Feature} to a Mesh
|
|
@@ -569,6 +719,12 @@ function featureToMesh(feature, options) {
|
|
|
569
719
|
mesh.material.color = new THREE.Color(0xffffff);
|
|
570
720
|
mesh.feature = feature;
|
|
571
721
|
mesh.position.z = feature.altitude.min - options.GlobalZTrans;
|
|
722
|
+
|
|
723
|
+
if (options.layer) {
|
|
724
|
+
mesh.layer = options.layer;
|
|
725
|
+
mesh.layers.set(options.layer.threejsLayer);
|
|
726
|
+
}
|
|
727
|
+
|
|
572
728
|
return mesh;
|
|
573
729
|
}
|
|
574
730
|
/**
|
|
@@ -582,7 +738,9 @@ var _default = {
|
|
|
582
738
|
* a THREE.Group.
|
|
583
739
|
*
|
|
584
740
|
* @param {Object} options - options controlling the conversion
|
|
585
|
-
* @param {function} [options.batchId] - optional function to create batchId attribute.
|
|
741
|
+
* @param {function} [options.batchId] - optional function to create batchId attribute.
|
|
742
|
+
* It is passed the feature property and the feature index. As the batchId is using an unsigned int structure on 32 bits,
|
|
743
|
+
* the batchId could be between 0 and 4,294,967,295.
|
|
586
744
|
* @return {function}
|
|
587
745
|
* @example <caption>Example usage of batchId with featureId.</caption>
|
|
588
746
|
* view.addLayer({
|
|
@@ -611,26 +769,32 @@ var _default = {
|
|
|
611
769
|
convert: function convert() {
|
|
612
770
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
613
771
|
(0, _Undeprecator.deprecatedFeature2MeshOptions)(options);
|
|
614
|
-
return function (collection) {
|
|
772
|
+
return function _convert(collection) {
|
|
615
773
|
if (!collection) {
|
|
616
774
|
return;
|
|
617
775
|
}
|
|
618
776
|
|
|
777
|
+
if (!options.pointMaterial) {
|
|
778
|
+
// Opacity and wireframe refered with layer properties
|
|
779
|
+
// TODO :next step is move these properties to Style
|
|
780
|
+
options.pointMaterial = (0, _ReferencingLayerProperties["default"])(new THREE.PointsMaterial(), this);
|
|
781
|
+
options.lineMaterial = (0, _ReferencingLayerProperties["default"])(new THREE.LineBasicMaterial(), this);
|
|
782
|
+
options.polygonMaterial = (0, _ReferencingLayerProperties["default"])(new THREE.MeshBasicMaterial(), this);
|
|
783
|
+
options.layer = this;
|
|
784
|
+
}
|
|
785
|
+
|
|
619
786
|
var features = collection.features;
|
|
620
787
|
|
|
621
788
|
if (!features || features.length == 0) {
|
|
622
789
|
return;
|
|
623
790
|
}
|
|
624
791
|
|
|
625
|
-
var group = new THREE.Group();
|
|
626
792
|
options.GlobalZTrans = collection.center.z;
|
|
627
|
-
features.
|
|
628
|
-
return
|
|
793
|
+
var meshes = features.map(function (feature) {
|
|
794
|
+
return featureToMesh(feature, options);
|
|
629
795
|
});
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
group.scale.copy(collection.scale);
|
|
633
|
-
return group;
|
|
796
|
+
var featureNode = new FeatureMesh(meshes, collection);
|
|
797
|
+
return featureNode;
|
|
634
798
|
};
|
|
635
799
|
}
|
|
636
800
|
};
|
|
@@ -186,16 +186,17 @@ function drawFeature(ctx, feature, extent, style, invCtxScale) {
|
|
|
186
186
|
_step3;
|
|
187
187
|
|
|
188
188
|
try {
|
|
189
|
-
var _loop = function () {
|
|
189
|
+
var _loop = function _loop() {
|
|
190
190
|
var geometry = _step3.value;
|
|
191
191
|
|
|
192
192
|
if (geometry.extent.intersectsExtent(extent)) {
|
|
193
|
-
var
|
|
193
|
+
var context = {
|
|
194
194
|
globals: globals,
|
|
195
195
|
properties: function properties() {
|
|
196
196
|
return geometry.properties;
|
|
197
197
|
}
|
|
198
|
-
}
|
|
198
|
+
};
|
|
199
|
+
var contextStyle = (geometry.properties.style || style).drawingStylefromContext(context);
|
|
199
200
|
|
|
200
201
|
if (contextStyle) {
|
|
201
202
|
if (feature.type === _Feature.FEATURE_TYPES.POINT) {
|
|
@@ -17,6 +17,10 @@ var _LayeredMaterial = _interopRequireDefault(require("../Renderer/LayeredMateri
|
|
|
17
17
|
|
|
18
18
|
var _TileBuilder = _interopRequireDefault(require("../Core/Prefab/TileBuilder"));
|
|
19
19
|
|
|
20
|
+
var _ReferencingLayerProperties = _interopRequireDefault(require("../Layer/ReferencingLayerProperties"));
|
|
21
|
+
|
|
22
|
+
var _GeoidLayer = require("../Layer/GeoidLayer");
|
|
23
|
+
|
|
20
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
25
|
|
|
22
26
|
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; }
|
|
@@ -29,9 +33,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
29
33
|
var dimensions = new THREE.Vector2();
|
|
30
34
|
|
|
31
35
|
function setTileFromTiledLayer(tile, tileLayer) {
|
|
32
|
-
tile.material.transparent = tileLayer.opacity < 1.0;
|
|
33
|
-
tile.material.opacity = tileLayer.opacity;
|
|
34
|
-
|
|
35
36
|
if (tileLayer.diffuse) {
|
|
36
37
|
tile.material.diffuse = tileLayer.diffuse;
|
|
37
38
|
}
|
|
@@ -66,6 +67,7 @@ var _default = {
|
|
|
66
67
|
result.geometry._count++;
|
|
67
68
|
var crsCount = layer.tileMatrixSets.length;
|
|
68
69
|
var material = new _LayeredMaterial["default"](layer.materialOptions, crsCount);
|
|
70
|
+
(0, _ReferencingLayerProperties["default"])(material, layer);
|
|
69
71
|
var tile = new _TileMesh["default"](result.geometry, material, layer, extent, level); // Commented because layer.threejsLayer is undefined;
|
|
70
72
|
// Fix me: conflict with object3d added in view.scene;
|
|
71
73
|
// tile.layers.set(layer.threejsLayer);
|
|
@@ -86,11 +88,14 @@ var _default = {
|
|
|
86
88
|
setTileFromTiledLayer(tile, layer);
|
|
87
89
|
|
|
88
90
|
if (parent) {
|
|
91
|
+
tile.geoidHeight = parent.geoidHeight;
|
|
92
|
+
var geoidHeight = (0, _GeoidLayer.geoidLayerIsVisible)(layer) ? tile.geoidHeight : 0;
|
|
89
93
|
tile.setBBoxZ({
|
|
90
94
|
min: parent.obb.z.min,
|
|
91
|
-
max: parent.obb.z.max
|
|
95
|
+
max: parent.obb.z.max,
|
|
96
|
+
geoidHeight: geoidHeight
|
|
92
97
|
});
|
|
93
|
-
tile.geoidHeight =
|
|
98
|
+
tile.material.geoidHeight = geoidHeight;
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
return tile;
|