venue-js 1.2.0-next.1 → 1.2.0-next.11
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/index.d.mts +136 -90
- package/dist/index.d.ts +136 -90
- package/dist/index.js +819 -1261
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +814 -1259
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -30,12 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var index_exports = {};
|
|
31
31
|
__export(index_exports, {
|
|
32
32
|
ALL_FEATURE_TYPES: () => ALL_FEATURE_TYPES,
|
|
33
|
-
ALWAYS_VISIBLE_FEATURE_TYPES: () => ALWAYS_VISIBLE_FEATURE_TYPES,
|
|
34
33
|
BASE_LAYER_NAME: () => BASE_LAYER_NAME,
|
|
35
34
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
36
|
-
DEFAULT_HIGHLIGHT_OPTIONS: () => DEFAULT_HIGHLIGHT_OPTIONS,
|
|
37
35
|
DEFAULT_LOCALE: () => DEFAULT_LOCALE,
|
|
38
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS: () => DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
39
36
|
DESTINATION_MARKER_ID: () => DESTINATION_MARKER_ID,
|
|
40
37
|
GEOJSON_FEATURE_TYPES: () => GEOJSON_FEATURE_TYPES,
|
|
41
38
|
HIGHLIGHT_LAYER_NAME: () => HIGHLIGHT_LAYER_NAME,
|
|
@@ -49,6 +46,7 @@ __export(index_exports, {
|
|
|
49
46
|
MARKER_LAYER_NAME: () => MARKER_LAYER_NAME,
|
|
50
47
|
NONIMDF_FEATURE_TYPES: () => NONIMDF_FEATURE_TYPES,
|
|
51
48
|
ORIGIN_MARKER_ID: () => ORIGIN_MARKER_ID,
|
|
49
|
+
OccupantHelpers: () => occupant_helper_exports,
|
|
52
50
|
POI_MARKER_LAYER_NAME: () => POI_MARKER_LAYER_NAME,
|
|
53
51
|
QueryObserver: () => import_query_core2.QueryObserver,
|
|
54
52
|
USER_LOCATION_ELEMENT_ID: () => USER_LOCATION_ELEMENT_ID,
|
|
@@ -76,6 +74,16 @@ __export(index_exports, {
|
|
|
76
74
|
getRelatedLocationsByOccupant: () => getRelatedLocationsByOccupant,
|
|
77
75
|
getSuitablyValueBetweenBearings: () => getSuitablyValueBetweenBearings,
|
|
78
76
|
isClickableFeature: () => isClickableFeature,
|
|
77
|
+
isValidCoordinate: () => isValidCoordinate,
|
|
78
|
+
isValidLineString: () => isValidLineString,
|
|
79
|
+
isValidLineStringCoordinates: () => isValidLineStringCoordinates,
|
|
80
|
+
isValidMultiPolygon: () => isValidMultiPolygon,
|
|
81
|
+
isValidMultiPolygonCoordinates: () => isValidMultiPolygonCoordinates,
|
|
82
|
+
isValidPoint: () => isValidPoint,
|
|
83
|
+
isValidPolygon: () => isValidPolygon,
|
|
84
|
+
isValidPolygonCoordinates: () => isValidPolygonCoordinates,
|
|
85
|
+
matchFilter: () => matchFilter,
|
|
86
|
+
matchFilters: () => matchFilters,
|
|
79
87
|
safeFetchFeature: () => safeFetchFeature,
|
|
80
88
|
styledFeatureGenerator: () => styledFeatureGenerator
|
|
81
89
|
});
|
|
@@ -274,6 +282,115 @@ var safeFetchFeature = async (featureType, params) => {
|
|
|
274
282
|
}
|
|
275
283
|
};
|
|
276
284
|
|
|
285
|
+
// src/data/utils/geometry-validator.ts
|
|
286
|
+
var isValidCoordinate = (point2) => {
|
|
287
|
+
return point2.length === 2 && point2.every((coord) => typeof coord === "number");
|
|
288
|
+
};
|
|
289
|
+
function isValidLinearRingCoordinates(ring) {
|
|
290
|
+
if (ring.length < 4) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
294
|
+
}
|
|
295
|
+
var isValidPolygonCoordinates = (polygon) => {
|
|
296
|
+
if (Array.isArray(polygon[0]) && (polygon[0].length === 0 || typeof polygon[0][0] === "number")) {
|
|
297
|
+
return isValidLinearRingCoordinates(polygon);
|
|
298
|
+
}
|
|
299
|
+
if (Array.isArray(polygon) && polygon.length > 0 && Array.isArray(polygon[0])) {
|
|
300
|
+
if (!isValidLinearRingCoordinates(polygon[0])) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
for (let i = 1; i < polygon.length; i++) {
|
|
304
|
+
if (!isValidLinearRingCoordinates(polygon[i])) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
};
|
|
312
|
+
var isValidMultiPolygonCoordinates = (multipolygon) => {
|
|
313
|
+
return multipolygon.every(isValidPolygonCoordinates);
|
|
314
|
+
};
|
|
315
|
+
var isValidLineStringCoordinates = (lineString2) => {
|
|
316
|
+
if (!Array.isArray(lineString2) || lineString2.length < 2) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const firstPoint = lineString2[0];
|
|
320
|
+
const lastPoint = lineString2[lineString2.length - 1];
|
|
321
|
+
if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
return lineString2.every(isValidCoordinate);
|
|
325
|
+
};
|
|
326
|
+
var isValidMultiPolygon = (geometry) => {
|
|
327
|
+
const { type, coordinates } = geometry;
|
|
328
|
+
return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
|
|
329
|
+
};
|
|
330
|
+
var isValidPolygon = (geometry) => {
|
|
331
|
+
const { type, coordinates } = geometry;
|
|
332
|
+
return type === "Polygon" && isValidPolygonCoordinates(coordinates);
|
|
333
|
+
};
|
|
334
|
+
var isValidLineString = (geometry) => {
|
|
335
|
+
const { type, coordinates } = geometry;
|
|
336
|
+
return type === "LineString" && isValidLineStringCoordinates(coordinates);
|
|
337
|
+
};
|
|
338
|
+
var isValidPoint = (geometry) => {
|
|
339
|
+
const { type, coordinates } = geometry;
|
|
340
|
+
return type === "Point" && isValidCoordinate(coordinates);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// src/data/utils/match-filters.ts
|
|
344
|
+
function isInFilter(filter) {
|
|
345
|
+
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
346
|
+
}
|
|
347
|
+
var someIntersect = (a, b) => a.some((v) => b.includes(v));
|
|
348
|
+
function matchFilter(value, filter) {
|
|
349
|
+
if (Array.isArray(value)) {
|
|
350
|
+
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
351
|
+
return value.includes(filter);
|
|
352
|
+
} else {
|
|
353
|
+
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
354
|
+
return value === filter;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function matchFilters(item, filters) {
|
|
358
|
+
return Object.entries(filters).every(([key, filter]) => {
|
|
359
|
+
return matchFilter(item.properties[key], filter);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// src/data/utils/occupant-helper.ts
|
|
364
|
+
var occupant_helper_exports = {};
|
|
365
|
+
__export(occupant_helper_exports, {
|
|
366
|
+
getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
|
|
367
|
+
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
368
|
+
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
369
|
+
});
|
|
370
|
+
var import_compact = __toESM(require("lodash/compact"));
|
|
371
|
+
var getOccupantMainLocation = (occupant) => {
|
|
372
|
+
return occupant.properties.kiosk || occupant.properties.unit;
|
|
373
|
+
};
|
|
374
|
+
var getOccupantCorrelatedLocations = (occupant) => {
|
|
375
|
+
const allCorrelatedLocations = [
|
|
376
|
+
...occupant.properties.units,
|
|
377
|
+
...occupant.properties.kiosks
|
|
378
|
+
];
|
|
379
|
+
return (0, import_compact.default)(allCorrelatedLocations);
|
|
380
|
+
};
|
|
381
|
+
var getOccupantMarkerLocations = (occupant, options) => {
|
|
382
|
+
const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
|
|
383
|
+
const mainLocation = getOccupantMainLocation(occupant);
|
|
384
|
+
const mainLocationLevel = mainLocation?.properties?.level_id;
|
|
385
|
+
const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
|
|
386
|
+
if (placementType === "ALL_LOCATIONS") {
|
|
387
|
+
return (0, import_compact.default)([mainLocation, ...allCorrelatedLocations]);
|
|
388
|
+
}
|
|
389
|
+
const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
|
|
390
|
+
const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
|
|
391
|
+
return (0, import_compact.default)([mainLocation, ...onePerLevelLocations]);
|
|
392
|
+
};
|
|
393
|
+
|
|
277
394
|
// src/data/getDataClient.ts
|
|
278
395
|
var import_query_core = require("@tanstack/query-core");
|
|
279
396
|
|
|
@@ -429,8 +546,8 @@ var createPopulator = ({
|
|
|
429
546
|
venue,
|
|
430
547
|
promotions,
|
|
431
548
|
privileges,
|
|
432
|
-
kiosk,
|
|
433
|
-
unit,
|
|
549
|
+
kiosk: kiosk ? await populateKiosk(kiosk) : null,
|
|
550
|
+
unit: unit ? await populateUnit(unit) : null,
|
|
434
551
|
kiosks: await Promise.all(kiosks.map(populateKiosk)),
|
|
435
552
|
units: await Promise.all(units.map(populateUnit))
|
|
436
553
|
}
|
|
@@ -522,26 +639,6 @@ var createPopulator = ({
|
|
|
522
639
|
};
|
|
523
640
|
};
|
|
524
641
|
|
|
525
|
-
// src/data/utils/match-filters.ts
|
|
526
|
-
function isInFilter(filter) {
|
|
527
|
-
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
528
|
-
}
|
|
529
|
-
var someIntersect = (a, b) => a.some((v) => b.includes(v));
|
|
530
|
-
function matchFilter(value, filter) {
|
|
531
|
-
if (Array.isArray(value)) {
|
|
532
|
-
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
533
|
-
return value.includes(filter);
|
|
534
|
-
} else {
|
|
535
|
-
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
536
|
-
return value === filter;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function matchFilters(item, filters) {
|
|
540
|
-
return Object.entries(filters).every(([key, filter]) => {
|
|
541
|
-
return matchFilter(item.properties[key], filter);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
|
|
545
642
|
// src/data/getDataClient.ts
|
|
546
643
|
var getDataClient = (options) => {
|
|
547
644
|
const observers = /* @__PURE__ */ new Map();
|
|
@@ -670,8 +767,9 @@ var getDataClient = (options) => {
|
|
|
670
767
|
|
|
671
768
|
// src/IndoorMap/IndoorMap.ts
|
|
672
769
|
var import_maptalks_gl = require("maptalks-gl");
|
|
673
|
-
var
|
|
674
|
-
var
|
|
770
|
+
var import_transcoders = require("@maptalks/transcoders.draco");
|
|
771
|
+
var import_tween = __toESM(require("@tweenjs/tween.js"));
|
|
772
|
+
var import_lodash6 = __toESM(require("lodash"));
|
|
675
773
|
|
|
676
774
|
// ../../node_modules/@turf/helpers/dist/esm/index.js
|
|
677
775
|
var earthRadius = 63710088e-1;
|
|
@@ -751,133 +849,8 @@ function isNumber(num) {
|
|
|
751
849
|
// src/IndoorMap/IndoorMap.ts
|
|
752
850
|
var import_distance = __toESM(require("@turf/distance"));
|
|
753
851
|
var import_center4 = __toESM(require("@turf/center"));
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
757
|
-
if (geojson === null) return;
|
|
758
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
759
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
760
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
761
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
762
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
763
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
764
|
-
var multiFeatureIndex = 0;
|
|
765
|
-
var geometryIndex = 0;
|
|
766
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
767
|
-
if (geometry === null) continue;
|
|
768
|
-
coords = geometry.coordinates;
|
|
769
|
-
var geomType = geometry.type;
|
|
770
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
771
|
-
switch (geomType) {
|
|
772
|
-
case null:
|
|
773
|
-
break;
|
|
774
|
-
case "Point":
|
|
775
|
-
if (callback(
|
|
776
|
-
coords,
|
|
777
|
-
coordIndex,
|
|
778
|
-
featureIndex,
|
|
779
|
-
multiFeatureIndex,
|
|
780
|
-
geometryIndex
|
|
781
|
-
) === false)
|
|
782
|
-
return false;
|
|
783
|
-
coordIndex++;
|
|
784
|
-
multiFeatureIndex++;
|
|
785
|
-
break;
|
|
786
|
-
case "LineString":
|
|
787
|
-
case "MultiPoint":
|
|
788
|
-
for (j = 0; j < coords.length; j++) {
|
|
789
|
-
if (callback(
|
|
790
|
-
coords[j],
|
|
791
|
-
coordIndex,
|
|
792
|
-
featureIndex,
|
|
793
|
-
multiFeatureIndex,
|
|
794
|
-
geometryIndex
|
|
795
|
-
) === false)
|
|
796
|
-
return false;
|
|
797
|
-
coordIndex++;
|
|
798
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
799
|
-
}
|
|
800
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
801
|
-
break;
|
|
802
|
-
case "Polygon":
|
|
803
|
-
case "MultiLineString":
|
|
804
|
-
for (j = 0; j < coords.length; j++) {
|
|
805
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
806
|
-
if (callback(
|
|
807
|
-
coords[j][k],
|
|
808
|
-
coordIndex,
|
|
809
|
-
featureIndex,
|
|
810
|
-
multiFeatureIndex,
|
|
811
|
-
geometryIndex
|
|
812
|
-
) === false)
|
|
813
|
-
return false;
|
|
814
|
-
coordIndex++;
|
|
815
|
-
}
|
|
816
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
817
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
818
|
-
}
|
|
819
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
820
|
-
break;
|
|
821
|
-
case "MultiPolygon":
|
|
822
|
-
for (j = 0; j < coords.length; j++) {
|
|
823
|
-
geometryIndex = 0;
|
|
824
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
825
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
826
|
-
if (callback(
|
|
827
|
-
coords[j][k][l],
|
|
828
|
-
coordIndex,
|
|
829
|
-
featureIndex,
|
|
830
|
-
multiFeatureIndex,
|
|
831
|
-
geometryIndex
|
|
832
|
-
) === false)
|
|
833
|
-
return false;
|
|
834
|
-
coordIndex++;
|
|
835
|
-
}
|
|
836
|
-
geometryIndex++;
|
|
837
|
-
}
|
|
838
|
-
multiFeatureIndex++;
|
|
839
|
-
}
|
|
840
|
-
break;
|
|
841
|
-
case "GeometryCollection":
|
|
842
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
843
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
844
|
-
return false;
|
|
845
|
-
break;
|
|
846
|
-
default:
|
|
847
|
-
throw new Error("Unknown Geometry Type");
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
854
|
-
function bbox(geojson, options = {}) {
|
|
855
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
856
|
-
return geojson.bbox;
|
|
857
|
-
}
|
|
858
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
859
|
-
coordEach(geojson, (coord) => {
|
|
860
|
-
if (result[0] > coord[0]) {
|
|
861
|
-
result[0] = coord[0];
|
|
862
|
-
}
|
|
863
|
-
if (result[1] > coord[1]) {
|
|
864
|
-
result[1] = coord[1];
|
|
865
|
-
}
|
|
866
|
-
if (result[2] < coord[0]) {
|
|
867
|
-
result[2] = coord[0];
|
|
868
|
-
}
|
|
869
|
-
if (result[3] < coord[1]) {
|
|
870
|
-
result[3] = coord[1];
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
return result;
|
|
874
|
-
}
|
|
875
|
-
var index_default = bbox;
|
|
876
|
-
|
|
877
|
-
// src/IndoorMap/IndoorMap.ts
|
|
878
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
879
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
880
|
-
var import_three8 = require("three");
|
|
852
|
+
var import_three6 = require("three");
|
|
853
|
+
var import_maptalks10 = require("maptalks.three");
|
|
881
854
|
|
|
882
855
|
// src/IndoorMap/constants.ts
|
|
883
856
|
var defaultLayerOption = { enableAltitude: true };
|
|
@@ -895,7 +868,6 @@ var GEOLOCATION = "geolocation";
|
|
|
895
868
|
var ORIGIN_MARKER = "origin-marker";
|
|
896
869
|
var DESTINATION_MARKER = "destination-marker";
|
|
897
870
|
var DECORATION = "decoration";
|
|
898
|
-
var ALWAYS_VISIBLE_FEATURE_TYPES = [VENUE, FOOTPRINT];
|
|
899
871
|
var BASE_LAYER_NAME = "base";
|
|
900
872
|
var POI_MARKER_LAYER_NAME = "poi";
|
|
901
873
|
var MARKER_LAYER_NAME = "marker";
|
|
@@ -907,13 +879,6 @@ var USER_LOCATION_ELEMENT_ID = "user_location";
|
|
|
907
879
|
var LAST_USER_LOCATION_ELEMENT_ID_PREFIX = "last_user_location-";
|
|
908
880
|
var LOCALE_SYMBOL_KEY = "locale_symbol";
|
|
909
881
|
var DEFAULT_LOCALE = "en";
|
|
910
|
-
var DEFAULT_HIGHLIGHT_OPTIONS = {
|
|
911
|
-
symbolSet: null
|
|
912
|
-
};
|
|
913
|
-
var DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS = {
|
|
914
|
-
symbolSet: null,
|
|
915
|
-
defaultMarker: false
|
|
916
|
-
};
|
|
917
882
|
var LAYERS = [
|
|
918
883
|
BASE_LAYER_NAME,
|
|
919
884
|
POI_MARKER_LAYER_NAME,
|
|
@@ -1873,18 +1838,6 @@ var loadModel3d = (model3d, coordinate, threeLayer) => {
|
|
|
1873
1838
|
);
|
|
1874
1839
|
});
|
|
1875
1840
|
};
|
|
1876
|
-
var create3DModels = async (models, defaultCoordinate, properties, threeLayer) => {
|
|
1877
|
-
let modelObjs = [];
|
|
1878
|
-
for (let j = 0; j < models.length; j++) {
|
|
1879
|
-
const model = models[j];
|
|
1880
|
-
const positionCoord = import_lodash4.default.get(model, "properties.position");
|
|
1881
|
-
const coord = positionCoord || defaultCoordinate;
|
|
1882
|
-
const object = await loadModel3d(model, coord, threeLayer);
|
|
1883
|
-
object.properties = properties;
|
|
1884
|
-
modelObjs.push(object);
|
|
1885
|
-
}
|
|
1886
|
-
return modelObjs;
|
|
1887
|
-
};
|
|
1888
1841
|
var createExtrudePolygon = (geometry, threeLayer, material, height, properties = {}, options) => {
|
|
1889
1842
|
const { offset = 0, altitude = 0 } = options;
|
|
1890
1843
|
const offsetGeometry = (0, import_buffer.default)(geometry, offset, { units: "meters" });
|
|
@@ -2792,44 +2745,6 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2792
2745
|
markerProperties
|
|
2793
2746
|
);
|
|
2794
2747
|
},
|
|
2795
|
-
createVenue3DModel: async (venue, threeLayer) => {
|
|
2796
|
-
const { id, feature_type, properties } = venue;
|
|
2797
|
-
const { category, model3d } = properties;
|
|
2798
|
-
const modelProperty = {
|
|
2799
|
-
id,
|
|
2800
|
-
feature_type,
|
|
2801
|
-
category
|
|
2802
|
-
};
|
|
2803
|
-
const center2 = (0, import_center2.default)(venue);
|
|
2804
|
-
const centerCoord = import_lodash4.default.get(center2, "geometry.coordinates");
|
|
2805
|
-
const modelPosition = import_lodash4.default.get(model3d, "properties.position", centerCoord);
|
|
2806
|
-
const models = await create3DModels(
|
|
2807
|
-
model3d,
|
|
2808
|
-
modelPosition,
|
|
2809
|
-
modelProperty,
|
|
2810
|
-
threeLayer
|
|
2811
|
-
);
|
|
2812
|
-
return models;
|
|
2813
|
-
},
|
|
2814
|
-
create3DFixture: async (fixture, threeLayer) => {
|
|
2815
|
-
const { id, feature_type, properties } = fixture;
|
|
2816
|
-
const { category, ordinal, model3d } = properties;
|
|
2817
|
-
const modelProperty = {
|
|
2818
|
-
id,
|
|
2819
|
-
feature_type,
|
|
2820
|
-
category,
|
|
2821
|
-
ordinal
|
|
2822
|
-
};
|
|
2823
|
-
const center2 = (0, import_center2.default)(fixture);
|
|
2824
|
-
const coordinate = import_lodash4.default.get(center2, "geometry.coordinates");
|
|
2825
|
-
const models = await create3DModels(
|
|
2826
|
-
model3d,
|
|
2827
|
-
coordinate,
|
|
2828
|
-
modelProperty,
|
|
2829
|
-
threeLayer
|
|
2830
|
-
);
|
|
2831
|
-
return models;
|
|
2832
|
-
},
|
|
2833
2748
|
createExtrudedUnit: (unit, threeLayer, options) => {
|
|
2834
2749
|
const extrudeHeight = import_lodash4.default.get(options, "height");
|
|
2835
2750
|
if (!extrudeHeight) return;
|
|
@@ -2869,24 +2784,6 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2869
2784
|
options3d
|
|
2870
2785
|
);
|
|
2871
2786
|
return object;
|
|
2872
|
-
},
|
|
2873
|
-
createAmbientLight: (config) => {
|
|
2874
|
-
const { color: colorString = "0xffffff", intensity = 1 } = config;
|
|
2875
|
-
const color = parseInt(colorString, 16);
|
|
2876
|
-
const ambientLight = new import_three5.AmbientLight(color, intensity);
|
|
2877
|
-
return ambientLight;
|
|
2878
|
-
},
|
|
2879
|
-
createDirectionalLight: (config) => {
|
|
2880
|
-
const {
|
|
2881
|
-
color: colorString = "0xffffff",
|
|
2882
|
-
intensity = 1,
|
|
2883
|
-
position: positionString = [0, 0, 0]
|
|
2884
|
-
} = config;
|
|
2885
|
-
const color = parseInt(colorString, 16);
|
|
2886
|
-
const [x, y, z] = positionString;
|
|
2887
|
-
const light = new import_three5.DirectionalLight(color, intensity);
|
|
2888
|
-
light.position.set(x, y, z).normalize();
|
|
2889
|
-
return light;
|
|
2890
2787
|
}
|
|
2891
2788
|
};
|
|
2892
2789
|
};
|
|
@@ -3016,351 +2913,230 @@ var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
|
3016
2913
|
return newBearing;
|
|
3017
2914
|
};
|
|
3018
2915
|
|
|
3019
|
-
// src/IndoorMap/utils/createHighlightElement.ts
|
|
3020
|
-
var import_three6 = require("three");
|
|
3021
|
-
var import_lodash5 = __toESM(require("lodash"));
|
|
3022
|
-
var import_tween = __toESM(require("@tweenjs/tween.js"));
|
|
3023
|
-
var DEFAULT_ALTITUDE_FACTOR = 0.5;
|
|
3024
|
-
var createHighlighBillboardController = (obj, { altitudeFactor = DEFAULT_ALTITUDE_FACTOR } = {}) => {
|
|
3025
|
-
const controller = { start: () => {
|
|
3026
|
-
}, clear: () => {
|
|
3027
|
-
} };
|
|
3028
|
-
if (!(obj instanceof Billboard)) return controller;
|
|
3029
|
-
const altitude = obj.properties.default.altitude;
|
|
3030
|
-
const newAltitude = import_lodash5.default.clamp(altitude * altitudeFactor, 0, altitude);
|
|
3031
|
-
const tween = new import_tween.default.Tween({ altitude }).to({ altitude: newAltitude }, 800).easing(import_tween.default.Easing.Quartic.Out).onUpdate((newUpdate) => {
|
|
3032
|
-
obj.setLineHeight(newUpdate.altitude);
|
|
3033
|
-
});
|
|
3034
|
-
controller.start = () => {
|
|
3035
|
-
tween.start();
|
|
3036
|
-
};
|
|
3037
|
-
controller.clear = () => {
|
|
3038
|
-
tween.stop().to({ altitude }, 1600).startFromCurrentValues();
|
|
3039
|
-
};
|
|
3040
|
-
return controller;
|
|
3041
|
-
};
|
|
3042
|
-
var createHighlighExtrudeObjectController = (obj, { color }) => {
|
|
3043
|
-
const controller = { start: () => {
|
|
3044
|
-
}, clear: () => {
|
|
3045
|
-
} };
|
|
3046
|
-
if (obj?.type !== "ExtrudePolygon" || import_lodash5.default.isNil(obj?.object3d?.material?.color) || import_lodash5.default.isNil(color))
|
|
3047
|
-
return controller;
|
|
3048
|
-
controller.start = () => {
|
|
3049
|
-
obj.object3d.material.color = new import_three6.Color(color);
|
|
3050
|
-
};
|
|
3051
|
-
controller.clear = () => {
|
|
3052
|
-
const objectDefaultColor = import_lodash5.default.get(obj, "properties.defaultColor");
|
|
3053
|
-
obj.object3d.material.color = new import_three6.Color(objectDefaultColor);
|
|
3054
|
-
};
|
|
3055
|
-
return controller;
|
|
3056
|
-
};
|
|
3057
|
-
|
|
3058
2916
|
// src/IndoorMap/camera/CameraManager.ts
|
|
3059
|
-
var
|
|
3060
|
-
var ZOOM_IN_LEVEL = 24;
|
|
3061
|
-
var CameraManager = class {
|
|
3062
|
-
map;
|
|
3063
|
-
constructor(map, options) {
|
|
3064
|
-
this.map = map;
|
|
3065
|
-
if (options?.defaultView) {
|
|
3066
|
-
this.setView(options?.defaultView);
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
/** Private method */
|
|
3070
|
-
#animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {
|
|
3071
|
-
}) {
|
|
3072
|
-
const { start, end } = {
|
|
3073
|
-
start: (frame) => {
|
|
3074
|
-
},
|
|
3075
|
-
end: (frame) => {
|
|
3076
|
-
},
|
|
3077
|
-
...callbackOption
|
|
3078
|
-
};
|
|
3079
|
-
this.map.flyTo(viewOptions, options, (frame) => {
|
|
3080
|
-
if (frame.state.playState === "running" && frame.state.progress === 0)
|
|
3081
|
-
start(frame);
|
|
3082
|
-
if (frame.state.playState === "finished") end(frame);
|
|
3083
|
-
});
|
|
3084
|
-
}
|
|
3085
|
-
/** Public methods */
|
|
3086
|
-
getView = () => {
|
|
3087
|
-
return this.map.getView();
|
|
3088
|
-
};
|
|
3089
|
-
getZoom = () => {
|
|
3090
|
-
return this.map.getView().zoom;
|
|
3091
|
-
};
|
|
3092
|
-
setView = (value) => {
|
|
3093
|
-
this.map.setView(value);
|
|
3094
|
-
};
|
|
3095
|
-
flyTo = (center2, options = {}) => {
|
|
3096
|
-
const currentView = this.getView();
|
|
3097
|
-
const {
|
|
3098
|
-
zoom = ZOOM_OUT_LEVEL,
|
|
3099
|
-
pitch = 60,
|
|
3100
|
-
duration = 600,
|
|
3101
|
-
easing = "out",
|
|
3102
|
-
bearing = currentView.bearing
|
|
3103
|
-
} = options;
|
|
3104
|
-
this.#animateflyTo(
|
|
3105
|
-
{
|
|
3106
|
-
center: center2,
|
|
3107
|
-
zoom,
|
|
3108
|
-
pitch,
|
|
3109
|
-
bearing
|
|
3110
|
-
},
|
|
3111
|
-
{ duration, easing }
|
|
3112
|
-
);
|
|
3113
|
-
};
|
|
3114
|
-
flyToAndZoomIn = (centerPoint, options = {}) => {
|
|
3115
|
-
const {
|
|
3116
|
-
zoom = ZOOM_IN_LEVEL,
|
|
3117
|
-
pitch = 60,
|
|
3118
|
-
duration = 600,
|
|
3119
|
-
easing = "out"
|
|
3120
|
-
} = options;
|
|
3121
|
-
this.#animateflyTo(
|
|
3122
|
-
{
|
|
3123
|
-
center: centerPoint,
|
|
3124
|
-
zoom,
|
|
3125
|
-
pitch
|
|
3126
|
-
},
|
|
3127
|
-
{ duration, easing }
|
|
3128
|
-
);
|
|
3129
|
-
};
|
|
3130
|
-
};
|
|
2917
|
+
var import_maptalks6 = require("maptalks");
|
|
3131
2918
|
|
|
3132
|
-
//
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
var
|
|
3136
|
-
var
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
var
|
|
3141
|
-
var
|
|
3142
|
-
var
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
var
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
2919
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
2920
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
2921
|
+
if (geojson === null) return;
|
|
2922
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
2923
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
2924
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
2925
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
2926
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
2927
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
2928
|
+
var multiFeatureIndex = 0;
|
|
2929
|
+
var geometryIndex = 0;
|
|
2930
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
2931
|
+
if (geometry === null) continue;
|
|
2932
|
+
coords = geometry.coordinates;
|
|
2933
|
+
var geomType = geometry.type;
|
|
2934
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
2935
|
+
switch (geomType) {
|
|
2936
|
+
case null:
|
|
2937
|
+
break;
|
|
2938
|
+
case "Point":
|
|
2939
|
+
if (callback(
|
|
2940
|
+
coords,
|
|
2941
|
+
coordIndex,
|
|
2942
|
+
featureIndex,
|
|
2943
|
+
multiFeatureIndex,
|
|
2944
|
+
geometryIndex
|
|
2945
|
+
) === false)
|
|
2946
|
+
return false;
|
|
2947
|
+
coordIndex++;
|
|
2948
|
+
multiFeatureIndex++;
|
|
2949
|
+
break;
|
|
2950
|
+
case "LineString":
|
|
2951
|
+
case "MultiPoint":
|
|
2952
|
+
for (j = 0; j < coords.length; j++) {
|
|
2953
|
+
if (callback(
|
|
2954
|
+
coords[j],
|
|
2955
|
+
coordIndex,
|
|
2956
|
+
featureIndex,
|
|
2957
|
+
multiFeatureIndex,
|
|
2958
|
+
geometryIndex
|
|
2959
|
+
) === false)
|
|
2960
|
+
return false;
|
|
2961
|
+
coordIndex++;
|
|
2962
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
2963
|
+
}
|
|
2964
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
2965
|
+
break;
|
|
2966
|
+
case "Polygon":
|
|
2967
|
+
case "MultiLineString":
|
|
2968
|
+
for (j = 0; j < coords.length; j++) {
|
|
2969
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
2970
|
+
if (callback(
|
|
2971
|
+
coords[j][k],
|
|
2972
|
+
coordIndex,
|
|
2973
|
+
featureIndex,
|
|
2974
|
+
multiFeatureIndex,
|
|
2975
|
+
geometryIndex
|
|
2976
|
+
) === false)
|
|
2977
|
+
return false;
|
|
2978
|
+
coordIndex++;
|
|
2979
|
+
}
|
|
2980
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
2981
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
2982
|
+
}
|
|
2983
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
2984
|
+
break;
|
|
2985
|
+
case "MultiPolygon":
|
|
2986
|
+
for (j = 0; j < coords.length; j++) {
|
|
2987
|
+
geometryIndex = 0;
|
|
2988
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
2989
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
2990
|
+
if (callback(
|
|
2991
|
+
coords[j][k][l],
|
|
2992
|
+
coordIndex,
|
|
2993
|
+
featureIndex,
|
|
2994
|
+
multiFeatureIndex,
|
|
2995
|
+
geometryIndex
|
|
2996
|
+
) === false)
|
|
2997
|
+
return false;
|
|
2998
|
+
coordIndex++;
|
|
2999
|
+
}
|
|
3000
|
+
geometryIndex++;
|
|
3001
|
+
}
|
|
3002
|
+
multiFeatureIndex++;
|
|
3003
|
+
}
|
|
3004
|
+
break;
|
|
3005
|
+
case "GeometryCollection":
|
|
3006
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
3007
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
3008
|
+
return false;
|
|
3009
|
+
break;
|
|
3010
|
+
default:
|
|
3011
|
+
throw new Error("Unknown Geometry Type");
|
|
3012
|
+
}
|
|
3166
3013
|
}
|
|
3167
3014
|
}
|
|
3168
|
-
}
|
|
3169
|
-
|
|
3170
|
-
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3171
|
-
var import_maptalks6 = require("maptalks");
|
|
3172
|
-
var THREE = __toESM(require("three"));
|
|
3173
|
-
var import_maptalks7 = require("maptalks.three");
|
|
3174
|
-
var import_lodash6 = require("lodash");
|
|
3015
|
+
}
|
|
3175
3016
|
|
|
3176
|
-
//
|
|
3177
|
-
|
|
3178
|
-
if (
|
|
3179
|
-
|
|
3180
|
-
for (let i = 0; i < stops.length - 1; i++) {
|
|
3181
|
-
const [z1, v1] = stops[i];
|
|
3182
|
-
const [z2, v2] = stops[i + 1];
|
|
3183
|
-
if (zoom >= z1 && zoom <= z2) {
|
|
3184
|
-
const t = (zoom - z1) / (z2 - z1);
|
|
3185
|
-
return v1 + t * (v2 - v1);
|
|
3186
|
-
}
|
|
3017
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
3018
|
+
function bbox(geojson, options = {}) {
|
|
3019
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
3020
|
+
return geojson.bbox;
|
|
3187
3021
|
}
|
|
3188
|
-
|
|
3022
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
3023
|
+
coordEach(geojson, (coord) => {
|
|
3024
|
+
if (result[0] > coord[0]) {
|
|
3025
|
+
result[0] = coord[0];
|
|
3026
|
+
}
|
|
3027
|
+
if (result[1] > coord[1]) {
|
|
3028
|
+
result[1] = coord[1];
|
|
3029
|
+
}
|
|
3030
|
+
if (result[2] < coord[0]) {
|
|
3031
|
+
result[2] = coord[0];
|
|
3032
|
+
}
|
|
3033
|
+
if (result[3] < coord[1]) {
|
|
3034
|
+
result[3] = coord[1];
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
3037
|
+
return result;
|
|
3038
|
+
}
|
|
3039
|
+
var index_default = bbox;
|
|
3189
3040
|
|
|
3190
|
-
// src/IndoorMap/
|
|
3191
|
-
var
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
background: "rgba(0, 0, 0, 0.2)",
|
|
3200
|
-
lineHeight: 32,
|
|
3201
|
-
padding: 8,
|
|
3202
|
-
strokeColor: "#000000",
|
|
3203
|
-
strokeWidth: 6,
|
|
3204
|
-
strokeStyle: "round",
|
|
3205
|
-
// Sprite options
|
|
3206
|
-
/* Overall scale multiplier */
|
|
3207
|
-
scale: 1,
|
|
3208
|
-
altitude: 0,
|
|
3209
|
-
opacity: 1
|
|
3210
|
-
};
|
|
3211
|
-
var TextSpriteMarker = class extends import_maptalks7.BaseObject {
|
|
3212
|
-
#altitudeOffset = 0;
|
|
3213
|
-
constructor(coordinate, options, layer, properties = {}) {
|
|
3214
|
-
options = import_maptalks6.Util.extend({}, OPTIONS4, options, { layer });
|
|
3215
|
-
super();
|
|
3216
|
-
this._coordinate = new import_maptalks6.Coordinate(coordinate);
|
|
3217
|
-
this._initOptions(options);
|
|
3218
|
-
this._createGroup();
|
|
3219
|
-
this.properties = { ...properties };
|
|
3220
|
-
const sprite = this._createSprite();
|
|
3221
|
-
this.getObject3d().add(sprite);
|
|
3222
|
-
this._updatePosition();
|
|
3223
|
-
this.type = "TextSpriteMarker";
|
|
3224
|
-
}
|
|
3225
|
-
getOptions() {
|
|
3226
|
-
return super.getOptions();
|
|
3227
|
-
}
|
|
3228
|
-
_createSprite() {
|
|
3229
|
-
const options = this.getOptions();
|
|
3230
|
-
const texture = this._createTextTexture(options.text, options);
|
|
3231
|
-
const material = new THREE.SpriteMaterial({
|
|
3232
|
-
map: texture,
|
|
3233
|
-
transparent: true,
|
|
3234
|
-
alphaTest: 0.1
|
|
3235
|
-
});
|
|
3236
|
-
const sprite = new THREE.Sprite(material);
|
|
3237
|
-
const w = texture.image.width;
|
|
3238
|
-
const h = texture.image.height;
|
|
3239
|
-
const base = 1 / 16;
|
|
3240
|
-
const normalizedScale = options.scale / this.getMap().getGLRes();
|
|
3241
|
-
sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
|
|
3242
|
-
this.#altitudeOffset = Math.max(
|
|
3243
|
-
h * base * options.scale * 0.5,
|
|
3244
|
-
0.05
|
|
3245
|
-
// minimum lift in world units
|
|
3246
|
-
);
|
|
3247
|
-
return sprite;
|
|
3248
|
-
}
|
|
3249
|
-
_createTextTexture(text, options = {}) {
|
|
3250
|
-
const {
|
|
3251
|
-
padding,
|
|
3252
|
-
fontSize,
|
|
3253
|
-
fontFamily,
|
|
3254
|
-
fontWeight,
|
|
3255
|
-
lineHeight,
|
|
3256
|
-
background,
|
|
3257
|
-
color,
|
|
3258
|
-
textAlign,
|
|
3259
|
-
strokeColor,
|
|
3260
|
-
strokeWidth,
|
|
3261
|
-
maxWidth
|
|
3262
|
-
} = options || {};
|
|
3263
|
-
const canvas = document.createElement("canvas");
|
|
3264
|
-
const ctx = canvas.getContext("2d");
|
|
3265
|
-
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3266
|
-
const paragraphs = String(text).split("\n");
|
|
3267
|
-
const wrappedLines = [];
|
|
3268
|
-
paragraphs.forEach((paragraph) => {
|
|
3269
|
-
if ((0, import_lodash6.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
3270
|
-
wrappedLines.push(paragraph);
|
|
3271
|
-
return;
|
|
3272
|
-
}
|
|
3273
|
-
const words = paragraph.split(/\s+/);
|
|
3274
|
-
let currentLine = "";
|
|
3275
|
-
words.forEach((word) => {
|
|
3276
|
-
const testLine = currentLine ? currentLine + " " + word : word;
|
|
3277
|
-
const testWidth = ctx.measureText(testLine).width;
|
|
3278
|
-
if (testWidth > maxWidth && currentLine) {
|
|
3279
|
-
wrappedLines.push(currentLine);
|
|
3280
|
-
currentLine = word;
|
|
3281
|
-
} else {
|
|
3282
|
-
currentLine = testLine;
|
|
3283
|
-
}
|
|
3284
|
-
});
|
|
3285
|
-
if (currentLine) {
|
|
3286
|
-
wrappedLines.push(currentLine);
|
|
3287
|
-
}
|
|
3288
|
-
});
|
|
3289
|
-
const lines = wrappedLines.length ? wrappedLines : [""];
|
|
3290
|
-
const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
|
|
3291
|
-
const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
|
|
3292
|
-
const finalHeight = lineHeight * lines.length + padding * 2;
|
|
3293
|
-
canvas.width = finalWidth;
|
|
3294
|
-
canvas.height = finalHeight;
|
|
3295
|
-
const ctx2 = canvas.getContext("2d");
|
|
3296
|
-
ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3297
|
-
ctx2.textAlign = textAlign;
|
|
3298
|
-
if (background && background !== "transparent") {
|
|
3299
|
-
ctx2.fillStyle = background;
|
|
3300
|
-
ctx2.fillRect(0, 0, canvas.width, canvas.height);
|
|
3041
|
+
// src/IndoorMap/camera/CameraManager.ts
|
|
3042
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
3043
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
3044
|
+
var CameraManager = class {
|
|
3045
|
+
map;
|
|
3046
|
+
constructor(map, options) {
|
|
3047
|
+
this.map = map;
|
|
3048
|
+
if (options?.defaultView) {
|
|
3049
|
+
this.setView(options?.defaultView);
|
|
3301
3050
|
}
|
|
3302
|
-
lines.forEach((line, i) => {
|
|
3303
|
-
const y = padding + lineHeight * (i + 0.8);
|
|
3304
|
-
let x = padding;
|
|
3305
|
-
if (textAlign === "center") x = canvas.width / 2;
|
|
3306
|
-
if (textAlign === "right" || textAlign === "end")
|
|
3307
|
-
x = canvas.width - padding;
|
|
3308
|
-
if (strokeWidth > 0) {
|
|
3309
|
-
ctx2.lineWidth = strokeWidth;
|
|
3310
|
-
ctx2.lineJoin = "round";
|
|
3311
|
-
ctx2.miterLimit = 2;
|
|
3312
|
-
ctx2.strokeStyle = strokeColor;
|
|
3313
|
-
ctx2.strokeText(line, x, y);
|
|
3314
|
-
}
|
|
3315
|
-
ctx2.fillStyle = color;
|
|
3316
|
-
ctx2.fillText(line, x, y);
|
|
3317
|
-
});
|
|
3318
|
-
const texture = new THREE.CanvasTexture(canvas);
|
|
3319
|
-
texture.needsUpdate = true;
|
|
3320
|
-
texture.minFilter = THREE.LinearFilter;
|
|
3321
|
-
return texture;
|
|
3322
3051
|
}
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
(0, import_lodash6.set)(this.properties, "default.position", position);
|
|
3331
|
-
this.getObject3d().position.copy(position);
|
|
3332
|
-
}
|
|
3333
|
-
_animation() {
|
|
3334
|
-
const layer = this.getLayer();
|
|
3335
|
-
if (!this.isAdd || !layer) return;
|
|
3336
|
-
if (this._visible === true) {
|
|
3337
|
-
const zoom = layer.map.getZoom();
|
|
3338
|
-
const object3d = this.getObject3d();
|
|
3339
|
-
const { opacity } = this.getOptions();
|
|
3340
|
-
let opacityValue;
|
|
3341
|
-
if (typeof opacity === "number") {
|
|
3342
|
-
opacityValue = opacity ?? 1;
|
|
3343
|
-
} else if (Array.isArray(opacity.stops)) {
|
|
3344
|
-
opacityValue = interpolateStops(opacity, zoom);
|
|
3345
|
-
} else {
|
|
3346
|
-
throw new Error(`Unknown opacity value ${opacity}`);
|
|
3347
|
-
}
|
|
3348
|
-
const visible = opacityValue > 0.5;
|
|
3349
|
-
object3d.visible = visible;
|
|
3052
|
+
/** Public methods */
|
|
3053
|
+
getView = () => {
|
|
3054
|
+
return this.map.getView();
|
|
3055
|
+
};
|
|
3056
|
+
setView = (value) => {
|
|
3057
|
+
if (this.map && Object.keys(value).length !== 0) {
|
|
3058
|
+
this.map.setView(value);
|
|
3350
3059
|
}
|
|
3060
|
+
};
|
|
3061
|
+
animateTo = (view, options = {}, step) => {
|
|
3062
|
+
this.map.animateTo(view, options, step);
|
|
3063
|
+
};
|
|
3064
|
+
setMaxExtent(extent) {
|
|
3065
|
+
return this.map.setMaxExtent(extent);
|
|
3351
3066
|
}
|
|
3352
|
-
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3067
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
3068
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
3069
|
+
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
3070
|
+
);
|
|
3071
|
+
return new import_maptalks6.Extent(minX, minY, maxX, maxY);
|
|
3072
|
+
};
|
|
3073
|
+
getExtentZoom = (extent, options = {
|
|
3074
|
+
isFraction: false,
|
|
3075
|
+
padding: {
|
|
3076
|
+
paddingLeft: 0,
|
|
3077
|
+
paddingRight: 0,
|
|
3078
|
+
paddingTop: 0,
|
|
3079
|
+
paddingBottom: 0
|
|
3080
|
+
}
|
|
3081
|
+
}) => {
|
|
3082
|
+
const { isFraction = false, padding } = options;
|
|
3083
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
3084
|
+
};
|
|
3085
|
+
set maxZoom(value) {
|
|
3086
|
+
this.map.setMaxZoom(value);
|
|
3087
|
+
const spatialReference = {
|
|
3088
|
+
projection: "EPSG:3857",
|
|
3089
|
+
resolutions: (function() {
|
|
3090
|
+
const resolutions = [];
|
|
3091
|
+
const d = 2 * 6378137 * Math.PI;
|
|
3092
|
+
for (let i = 0; i < value; i++) {
|
|
3093
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
3094
|
+
}
|
|
3095
|
+
return resolutions;
|
|
3096
|
+
})()
|
|
3097
|
+
};
|
|
3098
|
+
this.map.setSpatialReference(spatialReference);
|
|
3360
3099
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3100
|
+
set minZoom(value) {
|
|
3101
|
+
this.map.setMinZoom(value);
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
// src/IndoorMap/renderer/RendererManager.ts
|
|
3106
|
+
var import_isFunction = __toESM(require("lodash/isFunction"));
|
|
3107
|
+
var import_min = __toESM(require("lodash/min"));
|
|
3108
|
+
var import_center3 = require("@turf/center");
|
|
3109
|
+
var THREE3 = __toESM(require("three"));
|
|
3110
|
+
|
|
3111
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3112
|
+
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3113
|
+
var THREE = __toESM(require("three"));
|
|
3114
|
+
var import_maptalks7 = require("maptalks.three");
|
|
3115
|
+
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3116
|
+
|
|
3117
|
+
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
3118
|
+
var element3DRendererOptions = {
|
|
3119
|
+
unit: {
|
|
3120
|
+
default: { color: "#ffffff", height: 4 },
|
|
3121
|
+
byCategory: {
|
|
3122
|
+
walkway: { color: "#cccccc", height: 0.1 },
|
|
3123
|
+
terrace: { color: "#cccccc", height: 0.1 },
|
|
3124
|
+
unenclosedarea: { color: "#cccccc", height: 0.2 },
|
|
3125
|
+
nonpublic: { color: "#999999", height: 0.3 },
|
|
3126
|
+
escalator: { height: 0.2 },
|
|
3127
|
+
parking: { height: 0.1 },
|
|
3128
|
+
room: { color: "#ffffff", height: 2, bottomHeight: 0.12 }
|
|
3129
|
+
}
|
|
3130
|
+
},
|
|
3131
|
+
kiosk: {
|
|
3132
|
+
default: { color: "#666666", height: 0.6, bottomHeight: 0.12 }
|
|
3133
|
+
},
|
|
3134
|
+
fixture: {
|
|
3135
|
+
default: { color: "#ffffff", height: 0.5 },
|
|
3136
|
+
byCategory: {
|
|
3137
|
+
water: { color: "#ACD7EC", height: 0.1 },
|
|
3138
|
+
vegetation: { color: "#91C499", height: 0.5 }
|
|
3139
|
+
}
|
|
3364
3140
|
}
|
|
3365
3141
|
};
|
|
3366
3142
|
|
|
@@ -3384,21 +3160,22 @@ var getGeometryOption = (feature2, options) => {
|
|
|
3384
3160
|
var Element3DRenderer = class extends EventTarget {
|
|
3385
3161
|
options;
|
|
3386
3162
|
map;
|
|
3163
|
+
gltfLayer;
|
|
3387
3164
|
threeLayer;
|
|
3388
|
-
|
|
3165
|
+
scene;
|
|
3166
|
+
// private dracoLoader: DRACOLoader
|
|
3389
3167
|
lineMaterial;
|
|
3390
3168
|
materialByColorMap;
|
|
3391
|
-
markerRenderer;
|
|
3392
3169
|
// Renderer is Ready
|
|
3393
3170
|
isReady = false;
|
|
3394
|
-
constructor(map, options
|
|
3171
|
+
constructor(map, options) {
|
|
3395
3172
|
super();
|
|
3396
3173
|
this.options = options;
|
|
3397
3174
|
this.map = map;
|
|
3398
|
-
|
|
3399
|
-
this.
|
|
3400
|
-
this.
|
|
3401
|
-
this.
|
|
3175
|
+
const groupLayer = this.map.getLayer("group");
|
|
3176
|
+
this.threeLayer = groupLayer.getLayer("three");
|
|
3177
|
+
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3178
|
+
this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
|
|
3402
3179
|
this.render();
|
|
3403
3180
|
}
|
|
3404
3181
|
animation() {
|
|
@@ -3413,7 +3190,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3413
3190
|
if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
|
|
3414
3191
|
const existingMaterial = this.materialByColorMap.get(color);
|
|
3415
3192
|
if (existingMaterial) return existingMaterial;
|
|
3416
|
-
const created = new
|
|
3193
|
+
const created = new THREE.MeshLambertMaterial({ color, transparent: true });
|
|
3417
3194
|
created.toneMapped = false;
|
|
3418
3195
|
this.materialByColorMap.set(color, created);
|
|
3419
3196
|
return created;
|
|
@@ -3428,46 +3205,48 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3428
3205
|
} = getGeometryOption(feature2, this.options);
|
|
3429
3206
|
const _this = this;
|
|
3430
3207
|
const createPolygon = (geometry, feature3) => {
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
)
|
|
3465
|
-
|
|
3208
|
+
try {
|
|
3209
|
+
const [outerRing, ...innerRings] = geometry.coordinates;
|
|
3210
|
+
const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
|
|
3211
|
+
const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
|
|
3212
|
+
if (color === "transparent") return;
|
|
3213
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3214
|
+
const altitude = 0;
|
|
3215
|
+
const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
|
|
3216
|
+
const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
|
|
3217
|
+
const extrudedPolygon = this.threeLayer.toExtrudePolygon(
|
|
3218
|
+
offsetFeature,
|
|
3219
|
+
{ asynchronous: true, ...options, height, bottomHeight, altitude },
|
|
3220
|
+
material
|
|
3221
|
+
);
|
|
3222
|
+
const topLineStrings = [
|
|
3223
|
+
new maptalks4.LineString(outerRing),
|
|
3224
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3225
|
+
];
|
|
3226
|
+
const topLines = this.threeLayer.toLines(
|
|
3227
|
+
topLineStrings,
|
|
3228
|
+
{ altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
|
|
3229
|
+
this.lineMaterial
|
|
3230
|
+
);
|
|
3231
|
+
const bottomLineStrings = [
|
|
3232
|
+
new maptalks4.LineString(outerRing),
|
|
3233
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3234
|
+
];
|
|
3235
|
+
const bottomLines = this.threeLayer.toLines(
|
|
3236
|
+
bottomLineStrings,
|
|
3237
|
+
{ altitude, bottomHeight, interactive: false },
|
|
3238
|
+
this.lineMaterial
|
|
3239
|
+
);
|
|
3240
|
+
return [extrudedPolygon, topLines, bottomLines];
|
|
3241
|
+
} catch (err) {
|
|
3242
|
+
return [];
|
|
3243
|
+
}
|
|
3466
3244
|
};
|
|
3467
3245
|
try {
|
|
3468
3246
|
switch (feature2.geometry.type) {
|
|
3469
3247
|
case "MultiPolygon": {
|
|
3470
3248
|
const { coordinates } = feature2.geometry;
|
|
3249
|
+
if (!coordinates) return [];
|
|
3471
3250
|
const multiMeshes = coordinates.flatMap((polygonCoordinates) => {
|
|
3472
3251
|
const meshes = createPolygon({ type: "Polygon", coordinates: polygonCoordinates }, feature2);
|
|
3473
3252
|
this.threeLayer.addMesh(meshes);
|
|
@@ -3476,70 +3255,47 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3476
3255
|
return multiMeshes;
|
|
3477
3256
|
}
|
|
3478
3257
|
case "Polygon": {
|
|
3258
|
+
const { coordinates } = feature2.geometry;
|
|
3259
|
+
if (!coordinates) return [];
|
|
3479
3260
|
const meshes = createPolygon(feature2.geometry, feature2);
|
|
3480
3261
|
this.threeLayer.addMesh(meshes);
|
|
3481
3262
|
return meshes;
|
|
3482
3263
|
}
|
|
3483
3264
|
}
|
|
3484
3265
|
} catch (err) {
|
|
3485
|
-
console.log(`error createGeometry`, { feature: feature2, options });
|
|
3266
|
+
console.log(`error createGeometry`, err, { feature: feature2, options });
|
|
3486
3267
|
}
|
|
3487
3268
|
};
|
|
3488
3269
|
async createEscalator(f, coordinate, options) {
|
|
3270
|
+
const model = {
|
|
3271
|
+
url: "https://cdn.venue.in.th/static/glb/escalator.glb",
|
|
3272
|
+
size: 4.4
|
|
3273
|
+
};
|
|
3489
3274
|
const { direction: dir, angle } = options;
|
|
3490
|
-
const
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
},
|
|
3499
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3500
|
-
scale: 0.01
|
|
3275
|
+
const rotationZ = dir === "up" ? 180 + angle : angle;
|
|
3276
|
+
var escalatorMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3277
|
+
symbol: {
|
|
3278
|
+
url: model.url,
|
|
3279
|
+
rotationZ,
|
|
3280
|
+
translationX: dir === "up" ? 0 : model.size * Math.cos(Math.PI * rotationZ / 180),
|
|
3281
|
+
translationY: dir === "up" ? 0 : model.size * Math.sin(Math.PI * rotationZ / 180),
|
|
3282
|
+
translationZ: dir === "up" ? -0.05 * model.size : -0.5 * model.size
|
|
3501
3283
|
}
|
|
3502
3284
|
});
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
const pivotPoint = dir === "up" ? new THREE2.Vector3(0, 0, 0) : new THREE2.Vector3(
|
|
3506
|
-
1 * (box.min.x + box.max.x),
|
|
3507
|
-
1 * (box.min.y + box.max.y),
|
|
3508
|
-
0.6 * box.max.z
|
|
3509
|
-
);
|
|
3510
|
-
const pivot = new THREE2.Group();
|
|
3511
|
-
pivot.add(model);
|
|
3512
|
-
model.position.sub(pivotPoint);
|
|
3513
|
-
model.updateMatrixWorld(true);
|
|
3514
|
-
const altitude = f.properties.ordinal * HEIGHT_METER;
|
|
3515
|
-
const baseObjectModel = this.threeLayer.toModel(pivot, {
|
|
3516
|
-
coordinate,
|
|
3517
|
-
altitude
|
|
3518
|
-
});
|
|
3519
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3520
|
-
return baseObjectModel;
|
|
3285
|
+
escalatorMarker.addTo(this.gltfLayer);
|
|
3286
|
+
return escalatorMarker;
|
|
3521
3287
|
}
|
|
3522
3288
|
async createTree(coordinate, ordinal) {
|
|
3523
|
-
const
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
rotation: {
|
|
3527
|
-
x: 0.5 * Math.PI,
|
|
3528
|
-
// Rotate the model up (new_escalator.glb)
|
|
3529
|
-
y: 0,
|
|
3530
|
-
z: 0
|
|
3531
|
-
},
|
|
3532
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3533
|
-
scale: 0.01
|
|
3289
|
+
const treeMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3290
|
+
symbol: {
|
|
3291
|
+
url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb"
|
|
3534
3292
|
}
|
|
3535
3293
|
});
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3542
|
-
return baseObjectModel;
|
|
3294
|
+
treeMarker.addTo(this.gltfLayer);
|
|
3295
|
+
return treeMarker;
|
|
3296
|
+
}
|
|
3297
|
+
async createBuilding(coordinate, ordinal) {
|
|
3298
|
+
return Promise.resolve(null);
|
|
3543
3299
|
}
|
|
3544
3300
|
createElement(f) {
|
|
3545
3301
|
switch (f.feature_type) {
|
|
@@ -3562,34 +3318,34 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3562
3318
|
}
|
|
3563
3319
|
});
|
|
3564
3320
|
}
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
}
|
|
3321
|
+
createHighlightController(element) {
|
|
3322
|
+
if (!(element instanceof import_maptalks7.BaseObject)) {
|
|
3323
|
+
return null;
|
|
3324
|
+
}
|
|
3325
|
+
switch (element.type) {
|
|
3326
|
+
case "ExtrudePolygon": {
|
|
3327
|
+
const mesh = element.getObject3d();
|
|
3328
|
+
const originalMaterial = mesh.material;
|
|
3329
|
+
const highlightMaterial = this.getOrCreateMaterialByColor("#ff0000");
|
|
3330
|
+
return {
|
|
3331
|
+
start: () => {
|
|
3332
|
+
mesh.material = highlightMaterial;
|
|
3333
|
+
},
|
|
3334
|
+
clear: () => {
|
|
3335
|
+
mesh.material = originalMaterial;
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
default: {
|
|
3340
|
+
return {
|
|
3341
|
+
start() {
|
|
3342
|
+
},
|
|
3343
|
+
clear() {
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3593
3349
|
render() {
|
|
3594
3350
|
this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
|
|
3595
3351
|
if (this.threeLayer._needsUpdate) {
|
|
@@ -3697,7 +3453,10 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3697
3453
|
async createEscalator(f, coordinates) {
|
|
3698
3454
|
return Promise.resolve(null);
|
|
3699
3455
|
}
|
|
3700
|
-
async createTree(
|
|
3456
|
+
async createTree(coordinates) {
|
|
3457
|
+
return Promise.resolve(null);
|
|
3458
|
+
}
|
|
3459
|
+
async createBuilding(coordinate, ordinal) {
|
|
3701
3460
|
return Promise.resolve(null);
|
|
3702
3461
|
}
|
|
3703
3462
|
createElement = (imdfFeature) => {
|
|
@@ -3717,6 +3476,15 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3717
3476
|
element.hide();
|
|
3718
3477
|
});
|
|
3719
3478
|
}
|
|
3479
|
+
createHighlightController(element) {
|
|
3480
|
+
if (!(element instanceof maptalks5.Geometry)) return null;
|
|
3481
|
+
return {
|
|
3482
|
+
start() {
|
|
3483
|
+
},
|
|
3484
|
+
clear() {
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
}
|
|
3720
3488
|
};
|
|
3721
3489
|
|
|
3722
3490
|
// src/IndoorMap/renderer/2d/Marker2DRenderer.ts
|
|
@@ -3727,6 +3495,7 @@ var Marker2DRenderer = class extends EventTarget {
|
|
|
3727
3495
|
markerLayer;
|
|
3728
3496
|
constructor(map) {
|
|
3729
3497
|
super();
|
|
3498
|
+
this.map = map;
|
|
3730
3499
|
}
|
|
3731
3500
|
createMarker = (coordinates, ordinal, content) => {
|
|
3732
3501
|
const marker = new maptalks6.ui.UIMarker(coordinates, {
|
|
@@ -3748,73 +3517,203 @@ var Marker2DRenderer = class extends EventTarget {
|
|
|
3748
3517
|
};
|
|
3749
3518
|
|
|
3750
3519
|
// src/IndoorMap/renderer/3d/Marker3DRenderer.ts
|
|
3751
|
-
var maptalks7 = __toESM(require("maptalks"));
|
|
3520
|
+
var maptalks7 = __toESM(require("maptalks-gl"));
|
|
3752
3521
|
|
|
3753
|
-
// src/IndoorMap/renderer/
|
|
3754
|
-
var
|
|
3755
|
-
var
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
img.onerror = function(error) {
|
|
3772
|
-
reject(error);
|
|
3773
|
-
};
|
|
3774
|
-
img.src = url;
|
|
3775
|
-
});
|
|
3522
|
+
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3523
|
+
var import_maptalks8 = require("maptalks");
|
|
3524
|
+
var THREE2 = __toESM(require("three"));
|
|
3525
|
+
var import_maptalks9 = require("maptalks.three");
|
|
3526
|
+
var import_lodash5 = require("lodash");
|
|
3527
|
+
|
|
3528
|
+
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
3529
|
+
var interpolateStops = ({ stops }, zoom) => {
|
|
3530
|
+
if (zoom <= stops[0][0]) return stops[0][1];
|
|
3531
|
+
if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
|
|
3532
|
+
for (let i = 0; i < stops.length - 1; i++) {
|
|
3533
|
+
const [z1, v1] = stops[i];
|
|
3534
|
+
const [z2, v2] = stops[i + 1];
|
|
3535
|
+
if (zoom >= z1 && zoom <= z2) {
|
|
3536
|
+
const t = (zoom - z1) / (z2 - z1);
|
|
3537
|
+
return v1 + t * (v2 - v1);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3776
3540
|
};
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3541
|
+
|
|
3542
|
+
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3543
|
+
var OPTIONS4 = {
|
|
3544
|
+
// Texture options
|
|
3545
|
+
text: "",
|
|
3546
|
+
textAlign: "center",
|
|
3547
|
+
color: "#ffffff",
|
|
3548
|
+
fontFamily: "sans-serif",
|
|
3549
|
+
fontSize: 28,
|
|
3550
|
+
fontWeight: 400,
|
|
3551
|
+
background: "transparent",
|
|
3552
|
+
lineHeight: 32,
|
|
3553
|
+
padding: 8,
|
|
3554
|
+
strokeColor: "#000000",
|
|
3555
|
+
strokeWidth: 3,
|
|
3556
|
+
strokeStyle: "round",
|
|
3557
|
+
// Sprite options
|
|
3558
|
+
/* Overall scale multiplier */
|
|
3559
|
+
scale: 1,
|
|
3560
|
+
altitude: 0,
|
|
3561
|
+
opacity: 1
|
|
3562
|
+
};
|
|
3563
|
+
var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
3564
|
+
#altitudeOffset = 0;
|
|
3565
|
+
constructor(coordinate, options, layer, properties = {}) {
|
|
3566
|
+
options = import_maptalks8.Util.extend({}, OPTIONS4, options, { layer });
|
|
3567
|
+
super();
|
|
3568
|
+
this._coordinate = new import_maptalks8.Coordinate(coordinate);
|
|
3569
|
+
this._initOptions(options);
|
|
3570
|
+
this._createGroup();
|
|
3571
|
+
this.properties = { ...properties };
|
|
3572
|
+
const sprite = this._createSprite();
|
|
3573
|
+
this.getObject3d().add(sprite);
|
|
3574
|
+
this._updatePosition();
|
|
3575
|
+
this.type = "TextSpriteMarker";
|
|
3576
|
+
}
|
|
3577
|
+
getOptions() {
|
|
3578
|
+
return super.getOptions();
|
|
3579
|
+
}
|
|
3580
|
+
_createSprite() {
|
|
3581
|
+
const options = this.getOptions();
|
|
3582
|
+
const texture = this._createTextTexture(options.text, options);
|
|
3583
|
+
const material = new THREE2.SpriteMaterial({
|
|
3584
|
+
map: texture,
|
|
3585
|
+
transparent: true,
|
|
3586
|
+
alphaTest: 0.1
|
|
3587
|
+
});
|
|
3588
|
+
const sprite = new THREE2.Sprite(material);
|
|
3589
|
+
const w = texture.image.width;
|
|
3590
|
+
const h = texture.image.height;
|
|
3591
|
+
const base = 1 / 16;
|
|
3592
|
+
const normalizedScale = options.scale / this.getMap().getGLRes();
|
|
3593
|
+
sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
|
|
3594
|
+
this.#altitudeOffset = Math.max(
|
|
3595
|
+
h * base * options.scale * 0.5,
|
|
3596
|
+
0.05
|
|
3597
|
+
// minimum lift in world units
|
|
3792
3598
|
);
|
|
3599
|
+
return sprite;
|
|
3793
3600
|
}
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3601
|
+
_createTextTexture(text, options = {}) {
|
|
3602
|
+
const {
|
|
3603
|
+
padding,
|
|
3604
|
+
fontSize,
|
|
3605
|
+
fontFamily,
|
|
3606
|
+
fontWeight,
|
|
3607
|
+
lineHeight,
|
|
3608
|
+
background,
|
|
3609
|
+
color,
|
|
3610
|
+
textAlign,
|
|
3611
|
+
strokeColor,
|
|
3612
|
+
strokeWidth,
|
|
3613
|
+
maxWidth
|
|
3614
|
+
} = options || {};
|
|
3615
|
+
const canvas = document.createElement("canvas");
|
|
3616
|
+
const ctx = canvas.getContext("2d");
|
|
3617
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3618
|
+
const paragraphs = String(text).split("\n");
|
|
3619
|
+
const wrappedLines = [];
|
|
3620
|
+
paragraphs.forEach((paragraph) => {
|
|
3621
|
+
if ((0, import_lodash5.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
3622
|
+
wrappedLines.push(paragraph);
|
|
3623
|
+
return;
|
|
3624
|
+
}
|
|
3625
|
+
const words = paragraph.split(/\s+/);
|
|
3626
|
+
let currentLine = "";
|
|
3627
|
+
words.forEach((word) => {
|
|
3628
|
+
const testLine = currentLine ? currentLine + " " + word : word;
|
|
3629
|
+
const testWidth = ctx.measureText(testLine).width;
|
|
3630
|
+
if (testWidth > maxWidth && currentLine) {
|
|
3631
|
+
wrappedLines.push(currentLine);
|
|
3632
|
+
currentLine = word;
|
|
3633
|
+
} else {
|
|
3634
|
+
currentLine = testLine;
|
|
3635
|
+
}
|
|
3812
3636
|
});
|
|
3637
|
+
if (currentLine) {
|
|
3638
|
+
wrappedLines.push(currentLine);
|
|
3639
|
+
}
|
|
3640
|
+
});
|
|
3641
|
+
const lines = wrappedLines.length ? wrappedLines : [""];
|
|
3642
|
+
const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
|
|
3643
|
+
const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
|
|
3644
|
+
const finalHeight = lineHeight * lines.length + padding * 2;
|
|
3645
|
+
canvas.width = finalWidth;
|
|
3646
|
+
canvas.height = finalHeight;
|
|
3647
|
+
const ctx2 = canvas.getContext("2d");
|
|
3648
|
+
ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3649
|
+
ctx2.textAlign = textAlign;
|
|
3650
|
+
if (background && background !== "transparent") {
|
|
3651
|
+
ctx2.fillStyle = background;
|
|
3652
|
+
ctx2.fillRect(0, 0, canvas.width, canvas.height);
|
|
3653
|
+
}
|
|
3654
|
+
lines.forEach((line, i) => {
|
|
3655
|
+
const y = padding + lineHeight * (i + 0.8);
|
|
3656
|
+
let x = padding;
|
|
3657
|
+
if (textAlign === "center") x = canvas.width / 2;
|
|
3658
|
+
if (textAlign === "right" || textAlign === "end")
|
|
3659
|
+
x = canvas.width - padding;
|
|
3660
|
+
if (strokeWidth > 0) {
|
|
3661
|
+
ctx2.lineWidth = strokeWidth;
|
|
3662
|
+
ctx2.lineJoin = "round";
|
|
3663
|
+
ctx2.miterLimit = 2;
|
|
3664
|
+
ctx2.strokeStyle = strokeColor;
|
|
3665
|
+
ctx2.strokeText(line, x, y);
|
|
3666
|
+
}
|
|
3667
|
+
ctx2.fillStyle = color;
|
|
3668
|
+
ctx2.fillText(line, x, y);
|
|
3813
3669
|
});
|
|
3814
|
-
|
|
3815
|
-
|
|
3670
|
+
const texture = new THREE2.CanvasTexture(canvas);
|
|
3671
|
+
texture.needsUpdate = true;
|
|
3672
|
+
texture.minFilter = THREE2.LinearFilter;
|
|
3673
|
+
return texture;
|
|
3674
|
+
}
|
|
3675
|
+
_updatePosition() {
|
|
3676
|
+
const options = this.getOptions();
|
|
3677
|
+
const layer = options.layer;
|
|
3678
|
+
if (!layer) return;
|
|
3679
|
+
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
3680
|
+
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
3681
|
+
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
3682
|
+
(0, import_lodash5.set)(this.properties, "default.position", position);
|
|
3683
|
+
this.getObject3d().position.copy(position);
|
|
3684
|
+
}
|
|
3685
|
+
_animation() {
|
|
3686
|
+
const layer = this.getLayer();
|
|
3687
|
+
if (!this.isAdd || !layer) return;
|
|
3688
|
+
if (this._visible === true) {
|
|
3689
|
+
const zoom = layer.map.getZoom();
|
|
3690
|
+
const object3d = this.getObject3d();
|
|
3691
|
+
const { opacity } = this.getOptions();
|
|
3692
|
+
let opacityValue;
|
|
3693
|
+
if (typeof opacity === "number") {
|
|
3694
|
+
opacityValue = opacity ?? 1;
|
|
3695
|
+
} else if (Array.isArray(opacity.stops)) {
|
|
3696
|
+
opacityValue = interpolateStops(opacity, zoom);
|
|
3697
|
+
} else {
|
|
3698
|
+
throw new Error(`Unknown opacity value ${opacity}`);
|
|
3699
|
+
}
|
|
3700
|
+
const visible = opacityValue > 0.5;
|
|
3701
|
+
object3d.visible = visible;
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
setText(text) {
|
|
3705
|
+
const options = this.getOptions();
|
|
3706
|
+
options.text = text;
|
|
3707
|
+
const newSprite = this._createSprite();
|
|
3708
|
+
const group = this.getObject3d();
|
|
3709
|
+
group.children.forEach((child) => group.remove(child));
|
|
3710
|
+
group.add(newSprite);
|
|
3711
|
+
this._updatePosition();
|
|
3712
|
+
}
|
|
3713
|
+
setAltitude(altitude) {
|
|
3714
|
+
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
3715
|
+
return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
|
|
3816
3716
|
}
|
|
3817
|
-
return material;
|
|
3818
3717
|
};
|
|
3819
3718
|
|
|
3820
3719
|
// src/IndoorMap/renderer/3d/Marker3DRenderer.ts
|
|
@@ -3865,40 +3764,41 @@ var Marker3DRenderer = class extends EventTarget {
|
|
|
3865
3764
|
});
|
|
3866
3765
|
}
|
|
3867
3766
|
/** Marker */
|
|
3868
|
-
getOrCreateIconMaterial(key) {
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3767
|
+
// getOrCreateIconMaterial(key) {
|
|
3768
|
+
// if (!this.materialByKey) this.materialByKey = new Map()
|
|
3769
|
+
// const existingMaterial = this.materialByKey.get(key)
|
|
3770
|
+
// if (existingMaterial) return existingMaterial
|
|
3771
|
+
// // Create new
|
|
3772
|
+
// const baseSymbol: maptalks.Path = {
|
|
3773
|
+
// markerType: "path",
|
|
3774
|
+
// markerPath: [
|
|
3775
|
+
// {
|
|
3776
|
+
// path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
|
|
3777
|
+
// fill: "#ff0000",
|
|
3778
|
+
// },
|
|
3779
|
+
// ],
|
|
3780
|
+
// markerPathWidth: 24,
|
|
3781
|
+
// markerPathHeight: 24
|
|
3782
|
+
// }
|
|
3783
|
+
// const markerSymbol: maptalks.PathMarkerSymbol = {
|
|
3784
|
+
// markerType: "path",
|
|
3785
|
+
// markerPath: [],
|
|
3786
|
+
// // TODO: Get Path by featureType.category
|
|
3787
|
+
// // markerPath: [{ fill: "#FFFFFF", path: "M 19 3 H 5 c -1.1 0 -2 0.9 -2 2 v 14 c 0 1.1 0.9 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 V 5 c 0 -1.1 -0.9 -2 -2 -2 Z m -2 6 h -1.7 l -5 9 H 7 c -0.83 0 -1.5 -0.67 -1.5 -1.5 S 6.17 15 7 15 h 1.7 l 5 -9 H 17 c 0.83 0 1.5 0.67 1.5 1.5 S 17.83 9 17 9 Z" }],
|
|
3788
|
+
// markerPathWidth: 24,
|
|
3789
|
+
// markerPathHeight: 24,
|
|
3790
|
+
// markerWidth: 24,
|
|
3791
|
+
// markerHeight: 24,
|
|
3792
|
+
// markerDy: 1.5,
|
|
3793
|
+
// markerDx: 1.5,
|
|
3794
|
+
// }
|
|
3795
|
+
// const created = createSpriteMaterialByLabelSymbol([
|
|
3796
|
+
// baseSymbol,
|
|
3797
|
+
// markerSymbol,
|
|
3798
|
+
// ])
|
|
3799
|
+
// this.materialByKey.set(key, created)
|
|
3800
|
+
// return created
|
|
3801
|
+
// }
|
|
3902
3802
|
};
|
|
3903
3803
|
|
|
3904
3804
|
// src/IndoorMap/renderer/utils/angleBetweenLineString.ts
|
|
@@ -3920,11 +3820,17 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3920
3820
|
};
|
|
3921
3821
|
|
|
3922
3822
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3823
|
+
function delay(ms) {
|
|
3824
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3825
|
+
}
|
|
3923
3826
|
var RendererManager = class extends EventTarget {
|
|
3924
3827
|
map;
|
|
3925
3828
|
options;
|
|
3926
3829
|
// Client for fetching data
|
|
3927
3830
|
#dataClient;
|
|
3831
|
+
#isClicked = false;
|
|
3832
|
+
#onClickElement = (e) => {
|
|
3833
|
+
};
|
|
3928
3834
|
/** Elements: Responsible for converting feature info elements and add to map */
|
|
3929
3835
|
elementRenderer;
|
|
3930
3836
|
markerRenderer;
|
|
@@ -3933,6 +3839,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3933
3839
|
currentOrdinals;
|
|
3934
3840
|
markersMap;
|
|
3935
3841
|
markersByOrdinal;
|
|
3842
|
+
highlightControllers = [];
|
|
3936
3843
|
constructor(map, dataClient, options) {
|
|
3937
3844
|
super();
|
|
3938
3845
|
this.map = map;
|
|
@@ -3942,48 +3849,52 @@ var RendererManager = class extends EventTarget {
|
|
|
3942
3849
|
this.markersMap = /* @__PURE__ */ new Map();
|
|
3943
3850
|
this.markersByOrdinal = /* @__PURE__ */ new Map();
|
|
3944
3851
|
this.#dataClient = dataClient;
|
|
3852
|
+
const _this = this;
|
|
3945
3853
|
if (options.type === "3D") {
|
|
3946
|
-
const
|
|
3947
|
-
|
|
3948
|
-
forceRenderOnRotating: true
|
|
3949
|
-
});
|
|
3950
|
-
const _this = this;
|
|
3854
|
+
const groupLayer = this.map.getLayer("group");
|
|
3855
|
+
const threeLayer = groupLayer.getLayer("three");
|
|
3951
3856
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
3952
3857
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3953
3858
|
scene.add(ambientLight);
|
|
3954
3859
|
const dirColor = 16777215;
|
|
3955
3860
|
const dllight = new THREE3.DirectionalLight(dirColor, 0.8);
|
|
3956
|
-
dllight.position.set(0, -10,
|
|
3861
|
+
dllight.position.set(0, -10, 20).normalize();
|
|
3957
3862
|
scene.add(dllight);
|
|
3958
3863
|
const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
|
|
3959
3864
|
scene.add(hemi);
|
|
3960
|
-
_this.elementRenderer = new Element3DRenderer(map, options.elements
|
|
3865
|
+
_this.elementRenderer = new Element3DRenderer(map, options.elements);
|
|
3961
3866
|
_this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
|
|
3962
3867
|
if (typeof options.onRendererReady === "function") {
|
|
3963
3868
|
options.onRendererReady();
|
|
3964
3869
|
}
|
|
3965
3870
|
_this.#createElements();
|
|
3966
3871
|
};
|
|
3967
|
-
threeLayer.addTo(this.map);
|
|
3968
3872
|
} else {
|
|
3969
3873
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
3970
3874
|
this.markerRenderer = new Marker2DRenderer(map);
|
|
3971
3875
|
this.#createElements();
|
|
3972
3876
|
}
|
|
3973
3877
|
}
|
|
3878
|
+
set onClickElement(func) {
|
|
3879
|
+
this.#onClickElement = func;
|
|
3880
|
+
}
|
|
3881
|
+
handleClickElement = (e) => {
|
|
3882
|
+
if (this.#isClicked) return;
|
|
3883
|
+
this.#isClicked = true;
|
|
3884
|
+
const onClickElement = this.#onClickElement;
|
|
3885
|
+
if (!(0, import_isFunction.default)(onClickElement)) return;
|
|
3886
|
+
this.#onClickElement(e);
|
|
3887
|
+
this.#isClicked = false;
|
|
3888
|
+
};
|
|
3974
3889
|
getElementsByOrdinal = (ordinal) => {
|
|
3975
3890
|
const exist = this.elementsByOrdinal.get(ordinal);
|
|
3976
3891
|
if (!exist) this.elementsByOrdinal.set(ordinal, []);
|
|
3977
3892
|
return this.elementsByOrdinal.get(ordinal);
|
|
3978
3893
|
};
|
|
3979
|
-
getMarkersByOrdinal = (ordinal) => {
|
|
3980
|
-
const exist = this.markersByOrdinal.get(ordinal);
|
|
3981
|
-
if (!exist) this.markersByOrdinal.set(ordinal, []);
|
|
3982
|
-
return this.markersByOrdinal.get(ordinal);
|
|
3983
|
-
};
|
|
3984
3894
|
addElementsToManager = (id, elements, ordinal) => {
|
|
3985
3895
|
this.elementsMap.set(id, elements);
|
|
3986
3896
|
elements.forEach((el) => {
|
|
3897
|
+
el.on("click", (e) => this.handleClickElement(id));
|
|
3987
3898
|
this.getElementsByOrdinal(ordinal).push(el);
|
|
3988
3899
|
});
|
|
3989
3900
|
const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals;
|
|
@@ -3993,19 +3904,8 @@ var RendererManager = class extends EventTarget {
|
|
|
3993
3904
|
this.elementRenderer.hideElements(elements, ordinal);
|
|
3994
3905
|
}
|
|
3995
3906
|
};
|
|
3996
|
-
addMarkersToManager = (id, markers, ordinal) => {
|
|
3997
|
-
this.markersMap.set(id, markers);
|
|
3998
|
-
markers.forEach((el) => {
|
|
3999
|
-
this.getMarkersByOrdinal(ordinal).push(el);
|
|
4000
|
-
});
|
|
4001
|
-
const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals;
|
|
4002
|
-
if (inOrdinal) {
|
|
4003
|
-
this.markerRenderer.showMarkers(markers, ordinal);
|
|
4004
|
-
} else {
|
|
4005
|
-
this.markerRenderer.hideMarkers(markers, ordinal);
|
|
4006
|
-
}
|
|
4007
|
-
};
|
|
4008
3907
|
async #createElements() {
|
|
3908
|
+
await delay(this.options.delayBeforeCreateElements ?? 0);
|
|
4009
3909
|
const levels = await this.#dataClient.filterByType("level", {
|
|
4010
3910
|
populate: true
|
|
4011
3911
|
});
|
|
@@ -4052,13 +3952,15 @@ var RendererManager = class extends EventTarget {
|
|
|
4052
3952
|
}
|
|
4053
3953
|
const thisOrdinal = escalator.properties.ordinal;
|
|
4054
3954
|
const relationship = escalatorRelationships[0];
|
|
3955
|
+
if (!relationship.properties.origin?.id) throw new Error(`relationship (id=${relationship.id}) - origin not exists`);
|
|
3956
|
+
if (!relationship.properties.destination?.id) throw new Error(`relationship (id=${relationship.id}) - destination not exists`);
|
|
4055
3957
|
const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
4056
3958
|
const bothOpenings = await Promise.all(
|
|
4057
3959
|
bothOpeningIds.map((id) => this.#dataClient.findById("opening", id, { populate: true }))
|
|
4058
3960
|
);
|
|
4059
3961
|
const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
|
|
4060
3962
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4061
|
-
const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
3963
|
+
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4062
3964
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4063
3965
|
const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
|
|
4064
3966
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
@@ -4067,7 +3969,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4067
3969
|
this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
|
|
4068
3970
|
}
|
|
4069
3971
|
} catch (err) {
|
|
4070
|
-
console.
|
|
3972
|
+
console.warn(`cannot create escalator`, err.message);
|
|
4071
3973
|
}
|
|
4072
3974
|
}
|
|
4073
3975
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
@@ -4103,14 +4005,48 @@ var RendererManager = class extends EventTarget {
|
|
|
4103
4005
|
}
|
|
4104
4006
|
}
|
|
4105
4007
|
}
|
|
4008
|
+
highlightElements = (elemIds, options) => {
|
|
4009
|
+
const { reset = true } = options ?? {};
|
|
4010
|
+
if (reset) {
|
|
4011
|
+
this.clearHighlightElements();
|
|
4012
|
+
}
|
|
4013
|
+
const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
|
|
4014
|
+
elements.forEach((element) => {
|
|
4015
|
+
const controller = this.elementRenderer.createHighlightController(element);
|
|
4016
|
+
controller.start();
|
|
4017
|
+
this.highlightControllers.push(controller);
|
|
4018
|
+
});
|
|
4019
|
+
};
|
|
4020
|
+
clearHighlightElements = () => {
|
|
4021
|
+
this.highlightControllers.forEach((controller) => {
|
|
4022
|
+
if ((0, import_isFunction.default)(controller?.clear)) controller.clear();
|
|
4023
|
+
});
|
|
4024
|
+
};
|
|
4106
4025
|
/**
|
|
4107
4026
|
* ========================================================================
|
|
4108
4027
|
* Markers
|
|
4109
4028
|
* ======================================================================== */
|
|
4029
|
+
_getMarkersByOrdinal = (ordinal) => {
|
|
4030
|
+
const exist = this.markersByOrdinal.get(ordinal);
|
|
4031
|
+
if (!exist) this.markersByOrdinal.set(ordinal, []);
|
|
4032
|
+
return this.markersByOrdinal.get(ordinal);
|
|
4033
|
+
};
|
|
4034
|
+
_addMarkersToManager = (id, markers, ordinal) => {
|
|
4035
|
+
this.markersMap.set(id, markers);
|
|
4036
|
+
markers.forEach((el) => {
|
|
4037
|
+
this._getMarkersByOrdinal(ordinal).push(el);
|
|
4038
|
+
});
|
|
4039
|
+
const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals;
|
|
4040
|
+
if (inOrdinal) {
|
|
4041
|
+
this.markerRenderer.showMarkers(markers, ordinal);
|
|
4042
|
+
} else {
|
|
4043
|
+
this.markerRenderer.hideMarkers(markers, ordinal);
|
|
4044
|
+
}
|
|
4045
|
+
};
|
|
4110
4046
|
createMarker(coordinate, ordinal, text, options) {
|
|
4111
4047
|
const marker = this.markerRenderer.createMarker(coordinate, ordinal, text, options);
|
|
4112
4048
|
const markerId = `${this.markersMap.size + 1}`;
|
|
4113
|
-
this.
|
|
4049
|
+
this._addMarkersToManager(markerId, [marker], ordinal);
|
|
4114
4050
|
}
|
|
4115
4051
|
clearMarkers() {
|
|
4116
4052
|
for (const [markerId, marker] of this.markersMap) {
|
|
@@ -4125,9 +4061,11 @@ var INITIAL_ZOOM = 18.5;
|
|
|
4125
4061
|
var CLICK_TOLERANCE = 20;
|
|
4126
4062
|
var defaultOptions = {
|
|
4127
4063
|
pixelRatio: 1,
|
|
4064
|
+
interactions: true,
|
|
4128
4065
|
locale: DEFAULT_LOCALE
|
|
4129
4066
|
};
|
|
4130
4067
|
var IndoorMap = class extends EventTarget {
|
|
4068
|
+
options;
|
|
4131
4069
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
4132
4070
|
/** Note: "#" means private variables */
|
|
4133
4071
|
#styler = null;
|
|
@@ -4179,18 +4117,31 @@ var IndoorMap = class extends EventTarget {
|
|
|
4179
4117
|
};
|
|
4180
4118
|
constructor(elementId, options) {
|
|
4181
4119
|
super();
|
|
4120
|
+
const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
|
|
4121
|
+
this.options = options;
|
|
4182
4122
|
const {
|
|
4183
4123
|
onMapReady,
|
|
4184
4124
|
onMapLoading,
|
|
4185
4125
|
pixelRatio,
|
|
4186
4126
|
locale
|
|
4187
|
-
} =
|
|
4127
|
+
} = combinedOptions;
|
|
4188
4128
|
this.map = new import_maptalks_gl.Map(elementId, {
|
|
4189
4129
|
attribution: false,
|
|
4130
|
+
// Temporart set, not really default view
|
|
4131
|
+
// Default view is set in camera manager
|
|
4190
4132
|
center: INITIAL_CENTER,
|
|
4191
4133
|
zoom: INITIAL_ZOOM,
|
|
4192
4134
|
clickTimeThreshold: 600,
|
|
4193
4135
|
centerCross: options.centerCross ?? false,
|
|
4136
|
+
...options.interactions === false ? {
|
|
4137
|
+
draggable: false,
|
|
4138
|
+
dragPan: false,
|
|
4139
|
+
dragRotate: false,
|
|
4140
|
+
dragPitch: false,
|
|
4141
|
+
scrollWheelZoom: false,
|
|
4142
|
+
touchZoom: false,
|
|
4143
|
+
doubleClickZoom: false
|
|
4144
|
+
} : {},
|
|
4194
4145
|
baseLayer: new import_maptalks_gl.TileLayer("base", {
|
|
4195
4146
|
urlTemplate: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
|
|
4196
4147
|
subdomains: ["a", "b", "c", "d"],
|
|
@@ -4202,8 +4153,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
4202
4153
|
}),
|
|
4203
4154
|
layers: []
|
|
4204
4155
|
});
|
|
4156
|
+
const groupLayer = new import_maptalks_gl.GroupGLLayer("group", [], {}).addTo(this.map);
|
|
4157
|
+
const threeLayer = new import_maptalks10.ThreeLayer("three", {
|
|
4158
|
+
forceRenderOnMoving: true,
|
|
4159
|
+
forceRenderOnRotating: true
|
|
4160
|
+
});
|
|
4161
|
+
groupLayer.addLayer(threeLayer);
|
|
4162
|
+
const gltfLayer = new import_maptalks_gl.GLTFLayer("gltf");
|
|
4163
|
+
groupLayer.addLayer(gltfLayer);
|
|
4205
4164
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4206
|
-
this.camera = new CameraManager(this.map);
|
|
4165
|
+
this.camera = new CameraManager(this.map, options.camera);
|
|
4207
4166
|
this.locale = locale;
|
|
4208
4167
|
this.pixelRatio = pixelRatio;
|
|
4209
4168
|
this.onMapReady = onMapReady;
|
|
@@ -4214,23 +4173,25 @@ var IndoorMap = class extends EventTarget {
|
|
|
4214
4173
|
}
|
|
4215
4174
|
set dataClient(value) {
|
|
4216
4175
|
this.#dataClient = value;
|
|
4217
|
-
this
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
this.map.on(eventName, handler);
|
|
4176
|
+
if (!this.options.camera?.defaultView?.center) {
|
|
4177
|
+
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4178
|
+
const venueCenters = (0, import_center4.default)(featureCollection(venues));
|
|
4179
|
+
const [x, y] = venueCenters.geometry.coordinates;
|
|
4180
|
+
const center2 = new import_maptalks_gl.Coordinate(x, y);
|
|
4181
|
+
this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
|
|
4182
|
+
});
|
|
4183
|
+
}
|
|
4226
4184
|
}
|
|
4227
4185
|
/**
|
|
4228
4186
|
* Events
|
|
4229
4187
|
*/
|
|
4188
|
+
on(eventName, handler) {
|
|
4189
|
+
this.map.on(eventName, handler);
|
|
4190
|
+
}
|
|
4230
4191
|
handleMapClick = ({ coordinate }) => {
|
|
4231
4192
|
const { x, y } = coordinate;
|
|
4232
4193
|
console.log(
|
|
4233
|
-
`[Coordinates]: x: ${
|
|
4194
|
+
`[Coordinates]: x: ${import_lodash6.default.round(x, 8)} y: ${import_lodash6.default.round(
|
|
4234
4195
|
y,
|
|
4235
4196
|
8
|
|
4236
4197
|
)}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
|
|
@@ -4282,40 +4243,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4282
4243
|
this.map.off("moveend", this.#findAndSetVenueInView);
|
|
4283
4244
|
}
|
|
4284
4245
|
}
|
|
4285
|
-
get ordinals() {
|
|
4286
|
-
return this.#ordinals || [];
|
|
4287
|
-
}
|
|
4288
|
-
set ordinals(value) {
|
|
4289
|
-
if (!Array.isArray(value)) throw new Error("ordinals must be Array");
|
|
4290
|
-
this.#ordinals = value;
|
|
4291
|
-
}
|
|
4292
4246
|
set billboards(value) {
|
|
4293
4247
|
this.#billboards = value;
|
|
4294
4248
|
}
|
|
4295
|
-
set mapConfig(value) {
|
|
4296
|
-
this.#mapConfig = value;
|
|
4297
|
-
}
|
|
4298
4249
|
set mapDecorations(value) {
|
|
4299
4250
|
this.#mapDecorations = value;
|
|
4300
4251
|
}
|
|
4301
|
-
set maxZoom(value) {
|
|
4302
|
-
this.map.setMaxZoom(value);
|
|
4303
|
-
const spatialReference = {
|
|
4304
|
-
projection: "EPSG:3857",
|
|
4305
|
-
resolutions: (function() {
|
|
4306
|
-
const resolutions = [];
|
|
4307
|
-
const d = 2 * 6378137 * Math.PI;
|
|
4308
|
-
for (let i = 0; i < value; i++) {
|
|
4309
|
-
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
4310
|
-
}
|
|
4311
|
-
return resolutions;
|
|
4312
|
-
})()
|
|
4313
|
-
};
|
|
4314
|
-
this.map.setSpatialReference(spatialReference);
|
|
4315
|
-
}
|
|
4316
|
-
set minZoom(value) {
|
|
4317
|
-
this.map.setMinZoom(value);
|
|
4318
|
-
}
|
|
4319
4252
|
set groundLabels(value) {
|
|
4320
4253
|
this.#groundLabels = value;
|
|
4321
4254
|
}
|
|
@@ -4323,7 +4256,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4323
4256
|
this.map.setDevicePixelRatio(value);
|
|
4324
4257
|
}
|
|
4325
4258
|
set onClickElement(func) {
|
|
4326
|
-
this
|
|
4259
|
+
this.rendererManager.onClickElement = func;
|
|
4327
4260
|
}
|
|
4328
4261
|
set locale(value) {
|
|
4329
4262
|
this.#locale = value || defaultOptions.locale;
|
|
@@ -4339,7 +4272,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4339
4272
|
const scene = this.threeLayer.getScene();
|
|
4340
4273
|
if (scene) {
|
|
4341
4274
|
scene.children = scene.children.filter(
|
|
4342
|
-
(children) => children instanceof
|
|
4275
|
+
(children) => children instanceof import_three6.PerspectiveCamera
|
|
4343
4276
|
);
|
|
4344
4277
|
}
|
|
4345
4278
|
}
|
|
@@ -4347,13 +4280,10 @@ var IndoorMap = class extends EventTarget {
|
|
|
4347
4280
|
if (this.#isClicked) return;
|
|
4348
4281
|
this.#isClicked = true;
|
|
4349
4282
|
const onClickElement = this.#onClickElement;
|
|
4350
|
-
if (!
|
|
4283
|
+
if (!import_lodash6.default.isFunction(onClickElement)) return;
|
|
4351
4284
|
this.#onClickElement(e);
|
|
4352
4285
|
this.#isClicked = false;
|
|
4353
4286
|
};
|
|
4354
|
-
setCenter(center2, padding) {
|
|
4355
|
-
this.map.setCenter(center2, padding);
|
|
4356
|
-
}
|
|
4357
4287
|
async #legacy_createElements() {
|
|
4358
4288
|
const {
|
|
4359
4289
|
// 2D
|
|
@@ -4367,46 +4297,27 @@ var IndoorMap = class extends EventTarget {
|
|
|
4367
4297
|
create3DFootprint,
|
|
4368
4298
|
create3DGroundLabel,
|
|
4369
4299
|
create3DBillboard,
|
|
4370
|
-
createVenue3DModel,
|
|
4371
4300
|
createExtrudedUnit,
|
|
4372
|
-
create3DFixture,
|
|
4373
4301
|
create3DAmenityMarker,
|
|
4374
4302
|
create3DOccupantAmenityMarker,
|
|
4375
4303
|
create3DOpeningMarker,
|
|
4376
|
-
createOccupantGroundLabel
|
|
4377
|
-
// Light
|
|
4378
|
-
createAmbientLight,
|
|
4379
|
-
createDirectionalLight
|
|
4304
|
+
createOccupantGroundLabel
|
|
4380
4305
|
} = this.#styler;
|
|
4381
4306
|
let elements = {};
|
|
4382
4307
|
let object3ds = [];
|
|
4383
|
-
const scene = this.threeLayer.getScene();
|
|
4384
|
-
if (scene) {
|
|
4385
|
-
const {
|
|
4386
|
-
ambientLight: ambientLightConfig = {},
|
|
4387
|
-
directionalLight: directionalLightConfig = {}
|
|
4388
|
-
} = import_lodash7.default.get(this.#mapConfig, "light", {
|
|
4389
|
-
ambientLight: {},
|
|
4390
|
-
directionalLight: {}
|
|
4391
|
-
});
|
|
4392
|
-
const ambientLight = createAmbientLight(ambientLightConfig);
|
|
4393
|
-
scene.add(ambientLight);
|
|
4394
|
-
const light = createDirectionalLight(directionalLightConfig);
|
|
4395
|
-
scene.add(light);
|
|
4396
|
-
}
|
|
4397
4308
|
for (const feature2 of this.#features) {
|
|
4398
4309
|
try {
|
|
4399
4310
|
const { feature_type: featureType, properties, id } = feature2;
|
|
4400
|
-
const layerName =
|
|
4311
|
+
const layerName = import_lodash6.default.get(
|
|
4401
4312
|
LAYER_FEATURE_TYPE_OBJ,
|
|
4402
4313
|
featureType,
|
|
4403
4314
|
featureType
|
|
4404
4315
|
);
|
|
4405
4316
|
const layer = this.map.getLayer(layerName);
|
|
4406
4317
|
let geometry;
|
|
4407
|
-
const category =
|
|
4408
|
-
const extrudeConfig =
|
|
4409
|
-
const textMarkerType =
|
|
4318
|
+
const category = import_lodash6.default.get(feature2, "properties.category");
|
|
4319
|
+
const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
|
|
4320
|
+
const textMarkerType = import_lodash6.default.get(
|
|
4410
4321
|
this.#mapConfig,
|
|
4411
4322
|
"text_marker_type",
|
|
4412
4323
|
"ui-marker"
|
|
@@ -4416,16 +4327,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4416
4327
|
feature2
|
|
4417
4328
|
);
|
|
4418
4329
|
switch (featureType) {
|
|
4419
|
-
case "venue": {
|
|
4420
|
-
geometry = createVenue(feature2).addTo(layer);
|
|
4421
|
-
const models = await createVenue3DModel(feature2, this.threeLayer);
|
|
4422
|
-
models.forEach((model) => {
|
|
4423
|
-
model.on("click", this.handleClickElement);
|
|
4424
|
-
object3ds.push(model);
|
|
4425
|
-
this.#venueObjects.push(model);
|
|
4426
|
-
});
|
|
4427
|
-
break;
|
|
4428
|
-
}
|
|
4429
4330
|
case "amenity": {
|
|
4430
4331
|
if (feature2.properties.is_featured) {
|
|
4431
4332
|
const billboardObj = create3DBillboard(feature2, this.threeLayer);
|
|
@@ -4469,127 +4370,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4469
4370
|
geometry = createSection(feature2)?.addTo(layer);
|
|
4470
4371
|
break;
|
|
4471
4372
|
}
|
|
4472
|
-
case "occupant": {
|
|
4473
|
-
switch (category) {
|
|
4474
|
-
// Create only marker if it is amenity occupant
|
|
4475
|
-
case "currencyexchange":
|
|
4476
|
-
case "donationcenter":
|
|
4477
|
-
case "postoffice":
|
|
4478
|
-
const markerFeature = {
|
|
4479
|
-
...feature2,
|
|
4480
|
-
geometry: feature2.properties?.anchor?.geometry
|
|
4481
|
-
};
|
|
4482
|
-
const marker3d = create3DOccupantAmenityMarker(
|
|
4483
|
-
markerFeature,
|
|
4484
|
-
this.threeLayer,
|
|
4485
|
-
extrudeConfig
|
|
4486
|
-
)?.on("click", this.handleClickElement);
|
|
4487
|
-
object3ds.push(marker3d);
|
|
4488
|
-
break;
|
|
4489
|
-
default: {
|
|
4490
|
-
const { kiosk, anchor } = feature2.properties;
|
|
4491
|
-
const { unit } = anchor.properties;
|
|
4492
|
-
let mainLocation = kiosk || unit || null;
|
|
4493
|
-
const relatedLocations = [
|
|
4494
|
-
...feature2.properties.units,
|
|
4495
|
-
...feature2.properties.kiosks
|
|
4496
|
-
].filter((f) => f.properties.ordinal !== properties.ordinal);
|
|
4497
|
-
const occupantLocations = [mainLocation, ...relatedLocations];
|
|
4498
|
-
const renderType = feature2.properties.render_type;
|
|
4499
|
-
occupantLocations.forEach((location, index) => {
|
|
4500
|
-
const isMainLocation = index === 0;
|
|
4501
|
-
if (renderType === "Label") {
|
|
4502
|
-
const occupantGroundLabel = createOccupantGroundLabel(
|
|
4503
|
-
feature2,
|
|
4504
|
-
location,
|
|
4505
|
-
{ textMarkerType, extrudeConfig },
|
|
4506
|
-
this.threeLayer
|
|
4507
|
-
);
|
|
4508
|
-
if (occupantGroundLabel instanceof GroundLabel) {
|
|
4509
|
-
occupantGroundLabel.on("click", this.handleClickElement);
|
|
4510
|
-
occupantGroundLabel.addTo(this.threeLayer);
|
|
4511
|
-
object3ds.push(occupantGroundLabel);
|
|
4512
|
-
this.#groundObjects.push(occupantGroundLabel);
|
|
4513
|
-
}
|
|
4514
|
-
} else {
|
|
4515
|
-
const occupantMarker = createOccupant(feature2, location, {
|
|
4516
|
-
textMarkerType,
|
|
4517
|
-
extrudeConfig
|
|
4518
|
-
});
|
|
4519
|
-
if (occupantMarker instanceof import_maptalks_gl.ui.UIMarker) {
|
|
4520
|
-
occupantMarker.addTo(this.map);
|
|
4521
|
-
} else {
|
|
4522
|
-
occupantMarker?.on("click", this.handleClickElement);
|
|
4523
|
-
occupantMarker?.addTo(layer);
|
|
4524
|
-
}
|
|
4525
|
-
if (isMainLocation) {
|
|
4526
|
-
geometry = occupantMarker;
|
|
4527
|
-
} else {
|
|
4528
|
-
elements[`${feature2.id}_${index}`] = {
|
|
4529
|
-
geometry: occupantMarker,
|
|
4530
|
-
properties: location.properties,
|
|
4531
|
-
featureType: "occupant",
|
|
4532
|
-
feature: feature2
|
|
4533
|
-
};
|
|
4534
|
-
}
|
|
4535
|
-
}
|
|
4536
|
-
});
|
|
4537
|
-
}
|
|
4538
|
-
}
|
|
4539
|
-
break;
|
|
4540
|
-
}
|
|
4541
|
-
case "fixture": {
|
|
4542
|
-
const models = await create3DFixture(feature2, this.threeLayer);
|
|
4543
|
-
models.forEach((model) => {
|
|
4544
|
-
model.on("click", this.handleClickElement);
|
|
4545
|
-
object3ds.push(model);
|
|
4546
|
-
this.#glbObjects.push(model);
|
|
4547
|
-
});
|
|
4548
|
-
if (!featureExtrudeConfig) {
|
|
4549
|
-
geometry = createFixture(feature2)?.addTo(layer);
|
|
4550
|
-
} else {
|
|
4551
|
-
const locatedLevel = feature2?.properties?.level;
|
|
4552
|
-
const levelExtrudeConfig = getExtrudeConfigByFeature(
|
|
4553
|
-
extrudeConfig,
|
|
4554
|
-
locatedLevel
|
|
4555
|
-
);
|
|
4556
|
-
const levelHeight = import_lodash7.default.get(levelExtrudeConfig, "height", 0);
|
|
4557
|
-
const option = { ...featureExtrudeConfig, altitude: levelHeight };
|
|
4558
|
-
const extrudedFixture = createExtrudedUnit(
|
|
4559
|
-
feature2,
|
|
4560
|
-
this.threeLayer,
|
|
4561
|
-
option
|
|
4562
|
-
);
|
|
4563
|
-
object3ds.push(extrudedFixture);
|
|
4564
|
-
}
|
|
4565
|
-
break;
|
|
4566
|
-
}
|
|
4567
|
-
case "footprint": {
|
|
4568
|
-
const objects = await create3DFootprint(
|
|
4569
|
-
feature2,
|
|
4570
|
-
this.threeLayer,
|
|
4571
|
-
featureExtrudeConfig
|
|
4572
|
-
);
|
|
4573
|
-
objects.forEach((object) => {
|
|
4574
|
-
object.on("click", () => {
|
|
4575
|
-
const {
|
|
4576
|
-
geometry: { coordinates }
|
|
4577
|
-
} = (0, import_center4.default)(feature2);
|
|
4578
|
-
this.camera.flyToAndZoomIn(coordinates, { pitch: 45 });
|
|
4579
|
-
});
|
|
4580
|
-
object3ds.push(object);
|
|
4581
|
-
this.#objects.push(object);
|
|
4582
|
-
});
|
|
4583
|
-
if (feature2.properties.logo) {
|
|
4584
|
-
const footprintMarker = create3DBillboard(
|
|
4585
|
-
feature2,
|
|
4586
|
-
this.threeLayer
|
|
4587
|
-
);
|
|
4588
|
-
object3ds.push(footprintMarker);
|
|
4589
|
-
this.#billboardObjects.push(footprintMarker);
|
|
4590
|
-
}
|
|
4591
|
-
break;
|
|
4592
|
-
}
|
|
4593
4373
|
default:
|
|
4594
4374
|
break;
|
|
4595
4375
|
}
|
|
@@ -4658,27 +4438,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4658
4438
|
changeLevelByOrdinal(ordinal) {
|
|
4659
4439
|
this.rendererManager.changeLevelByOrdinal(ordinal);
|
|
4660
4440
|
}
|
|
4661
|
-
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
4662
|
-
const [minX, minY, maxX, maxY] = index_default(
|
|
4663
|
-
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
4664
|
-
);
|
|
4665
|
-
return new import_maptalks_gl.Extent(minX, minY, maxX, maxY);
|
|
4666
|
-
};
|
|
4667
|
-
getExtentCenter = (extent) => {
|
|
4668
|
-
return extent.getCenter();
|
|
4669
|
-
};
|
|
4670
|
-
getExtentZoom = (extent, options = {
|
|
4671
|
-
isFraction: false,
|
|
4672
|
-
padding: {
|
|
4673
|
-
paddingLeft: 0,
|
|
4674
|
-
paddingRight: 0,
|
|
4675
|
-
paddingTop: 0,
|
|
4676
|
-
paddingBottom: 0
|
|
4677
|
-
}
|
|
4678
|
-
}) => {
|
|
4679
|
-
const { isFraction = false, padding } = options;
|
|
4680
|
-
return this.map.getFitZoom(extent, isFraction, padding);
|
|
4681
|
-
};
|
|
4682
4441
|
findVenueInView = () => {
|
|
4683
4442
|
const mapCenter = this.map.getCenter();
|
|
4684
4443
|
const result = this.#venues.reduce((closest, venue) => {
|
|
@@ -4691,9 +4450,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4691
4450
|
}, null);
|
|
4692
4451
|
return result;
|
|
4693
4452
|
};
|
|
4694
|
-
flyTo = (center2, options) => {
|
|
4695
|
-
this.camera.flyTo(center2, options);
|
|
4696
|
-
};
|
|
4697
4453
|
getLineStringBearing = (feature2) => {
|
|
4698
4454
|
const { geometry } = feature2;
|
|
4699
4455
|
const path = new import_maptalks_gl.LineString(geometry.coordinates);
|
|
@@ -4714,186 +4470,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4714
4470
|
clearAnimations() {
|
|
4715
4471
|
this.#animationsToRun = [];
|
|
4716
4472
|
}
|
|
4717
|
-
/**
|
|
4718
|
-
* Hilighting Elements
|
|
4719
|
-
* ========================================= */
|
|
4720
|
-
// TODO: To consider if we should use setter `set hilightElementIds` instead?
|
|
4721
|
-
setHighlightElementIds(targetElementIds, options = {}) {
|
|
4722
|
-
const highlight3DOptions = import_lodash7.default.merge(
|
|
4723
|
-
{},
|
|
4724
|
-
DEFAULT_HIGHLIGHT_OPTIONS,
|
|
4725
|
-
import_lodash7.default.get(options, "highlight3DOptions", {})
|
|
4726
|
-
);
|
|
4727
|
-
const highlight2DOptions = import_lodash7.default.merge(
|
|
4728
|
-
{},
|
|
4729
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
4730
|
-
import_lodash7.default.get(options, "highlight2DOptions", {})
|
|
4731
|
-
);
|
|
4732
|
-
this.setHighlightedObject(targetElementIds, highlight3DOptions);
|
|
4733
|
-
return this.setHighlight2DElementIds(targetElementIds, highlight2DOptions);
|
|
4734
|
-
}
|
|
4735
|
-
setHighlight2DElementIds(targetElementIds, options = {}) {
|
|
4736
|
-
const { defaultMarker, symbolSet } = import_lodash7.default.merge(
|
|
4737
|
-
{},
|
|
4738
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
4739
|
-
options
|
|
4740
|
-
);
|
|
4741
|
-
const {
|
|
4742
|
-
createMarker,
|
|
4743
|
-
createHighlightOccupantMarker,
|
|
4744
|
-
getElementSymbol,
|
|
4745
|
-
getHilighPolygonalSymbol,
|
|
4746
|
-
getHighlightMarkerSymbol
|
|
4747
|
-
} = this.#styler;
|
|
4748
|
-
const extrudeConfig = import_lodash7.default.get(this.#mapConfig, "extrude");
|
|
4749
|
-
const elementToHilights = targetElementIds.map(
|
|
4750
|
-
(elemId) => this.#elements[elemId] || this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${elemId}`]
|
|
4751
|
-
).filter((elem) => elem);
|
|
4752
|
-
elementToHilights.forEach((elem) => {
|
|
4753
|
-
const { feature: feature2, geometry } = elem;
|
|
4754
|
-
if (!geometry || !feature2) return;
|
|
4755
|
-
const hilightLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
4756
|
-
if (!hilightLayer) return;
|
|
4757
|
-
const defaultSymbol = getHilighPolygonalSymbol(geometry.type);
|
|
4758
|
-
const definedSymbol = symbolSet ? getElementSymbol(symbolSet) : null;
|
|
4759
|
-
const symbol = import_lodash7.default.isEmpty(definedSymbol) ? defaultSymbol : definedSymbol;
|
|
4760
|
-
switch (geometry.type) {
|
|
4761
|
-
case "MultiPolygon":
|
|
4762
|
-
case "Polygon": {
|
|
4763
|
-
geometry?.updateSymbol(symbol);
|
|
4764
|
-
break;
|
|
4765
|
-
}
|
|
4766
|
-
default:
|
|
4767
|
-
break;
|
|
4768
|
-
}
|
|
4769
|
-
switch (feature2.feature_type) {
|
|
4770
|
-
case "amenity":
|
|
4771
|
-
const highlightedAmenityMarker = definedSymbol || getHighlightMarkerSymbol();
|
|
4772
|
-
geometry?.updateSymbol(highlightedAmenityMarker);
|
|
4773
|
-
break;
|
|
4774
|
-
case "occupant": {
|
|
4775
|
-
switch (feature2.properties.category) {
|
|
4776
|
-
case "currencyexchange":
|
|
4777
|
-
case "donationcenter":
|
|
4778
|
-
case "postoffice":
|
|
4779
|
-
const highlightedAmenityMarker2 = definedSymbol || getHighlightMarkerSymbol();
|
|
4780
|
-
geometry?.updateSymbol(highlightedAmenityMarker2);
|
|
4781
|
-
break;
|
|
4782
|
-
default:
|
|
4783
|
-
if (feature2.properties.render_type === "Logo") {
|
|
4784
|
-
this.hideGeometryByElementId(feature2.id);
|
|
4785
|
-
}
|
|
4786
|
-
createHighlightOccupantMarker(feature2, {
|
|
4787
|
-
extrudeConfig,
|
|
4788
|
-
symbol: definedSymbol
|
|
4789
|
-
}).on("click", this.handleClickElement).addTo(hilightLayer);
|
|
4790
|
-
break;
|
|
4791
|
-
}
|
|
4792
|
-
break;
|
|
4793
|
-
}
|
|
4794
|
-
case "opening":
|
|
4795
|
-
break;
|
|
4796
|
-
default:
|
|
4797
|
-
if (defaultMarker) createMarker(feature2).addTo(hilightLayer);
|
|
4798
|
-
break;
|
|
4799
|
-
}
|
|
4800
|
-
});
|
|
4801
|
-
this.#highlightElementIds = targetElementIds;
|
|
4802
|
-
if (elementToHilights.length === 0) return;
|
|
4803
|
-
return featureCollection(
|
|
4804
|
-
elementToHilights.map(({ feature: feature2 }) => {
|
|
4805
|
-
const { geometry } = feature2;
|
|
4806
|
-
if (feature2.feature_type === "occupant")
|
|
4807
|
-
return feature(feature2?.properties?.anchor?.geometry);
|
|
4808
|
-
return feature(geometry);
|
|
4809
|
-
})
|
|
4810
|
-
);
|
|
4811
|
-
}
|
|
4812
|
-
clearHighlightElements() {
|
|
4813
|
-
this.#clearAllElementOnLayerByName(HIGHLIGHT_LAYER_NAME);
|
|
4814
|
-
(0, import_lodash7.default)(this.#highlightElementIds).map((elemId) => this.#elements[elemId]?.geometry).compact().forEach((geometry) => {
|
|
4815
|
-
if (geometry instanceof import_maptalks_gl.ui.UIMarker) return;
|
|
4816
|
-
if (geometry instanceof import_maptalks_gl.Marker) {
|
|
4817
|
-
this.showGeometryByElementId(geometry.properties.id);
|
|
4818
|
-
return;
|
|
4819
|
-
}
|
|
4820
|
-
try {
|
|
4821
|
-
const defaultSymbol = geometry.options.defaultSymbol;
|
|
4822
|
-
geometry.updateSymbol(defaultSymbol);
|
|
4823
|
-
} catch (err) {
|
|
4824
|
-
console.log(
|
|
4825
|
-
`error cannot return to defaultSymbol, check if "defaultSymbol" exists in element creation function`
|
|
4826
|
-
);
|
|
4827
|
-
}
|
|
4828
|
-
});
|
|
4829
|
-
this.#highlightElementIds = [];
|
|
4830
|
-
}
|
|
4831
|
-
setHighlightedObject(targetObjectIds, options = {}) {
|
|
4832
|
-
const { symbolSet } = import_lodash7.default.merge({}, DEFAULT_HIGHLIGHT_OPTIONS, options);
|
|
4833
|
-
const {
|
|
4834
|
-
getElementSymbol,
|
|
4835
|
-
getHilighPolygonalSymbol,
|
|
4836
|
-
createHighlight2DAmenityMarkerFrom3DMarker
|
|
4837
|
-
} = this.#styler;
|
|
4838
|
-
const objects = this.threeLayer?.getBaseObjects();
|
|
4839
|
-
const objectsToHighlight = objects.filter(
|
|
4840
|
-
({ properties }) => targetObjectIds.includes(properties?.id)
|
|
4841
|
-
);
|
|
4842
|
-
const defaultSymbol = getHilighPolygonalSymbol("Polygon");
|
|
4843
|
-
const targetSymbol = symbolSet ? getElementSymbol(symbolSet) : null;
|
|
4844
|
-
const { polygonFill: color } = import_lodash7.default.isEmpty(targetSymbol) ? defaultSymbol : targetSymbol;
|
|
4845
|
-
const amenityHighlightMode = import_lodash7.default.get(
|
|
4846
|
-
this.#mapConfig,
|
|
4847
|
-
"amenity_highlight_mode",
|
|
4848
|
-
""
|
|
4849
|
-
);
|
|
4850
|
-
objectsToHighlight.forEach((obj) => {
|
|
4851
|
-
if (obj.type === "ExtrudePolygon") {
|
|
4852
|
-
const newController = createHighlighExtrudeObjectController(obj, {
|
|
4853
|
-
color
|
|
4854
|
-
});
|
|
4855
|
-
newController.start();
|
|
4856
|
-
this.#highlightObjectControllers.push(newController);
|
|
4857
|
-
}
|
|
4858
|
-
if (obj instanceof SpriteMarker) {
|
|
4859
|
-
if (amenityHighlightMode === "2DMarker") {
|
|
4860
|
-
const hilight2DLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
4861
|
-
const extrudeConfig = import_lodash7.default.get(this.#mapConfig, "extrude");
|
|
4862
|
-
obj.hide();
|
|
4863
|
-
const { properties: featureProperties } = obj;
|
|
4864
|
-
createHighlight2DAmenityMarkerFrom3DMarker(
|
|
4865
|
-
featureProperties,
|
|
4866
|
-
extrudeConfig
|
|
4867
|
-
).on("click", this.handleClickElement).addTo(hilight2DLayer);
|
|
4868
|
-
} else {
|
|
4869
|
-
obj.highlight();
|
|
4870
|
-
}
|
|
4871
|
-
}
|
|
4872
|
-
if (obj instanceof Billboard) {
|
|
4873
|
-
const newController = createHighlighBillboardController(obj);
|
|
4874
|
-
newController.start();
|
|
4875
|
-
this.#highlightObjectControllers.push(newController);
|
|
4876
|
-
}
|
|
4877
|
-
});
|
|
4878
|
-
this.#highlightObjectIds = targetObjectIds;
|
|
4879
|
-
}
|
|
4880
|
-
clearHighlightObject() {
|
|
4881
|
-
this.#highlightObjectControllers.forEach((controller) => {
|
|
4882
|
-
if (import_lodash7.default.isFunction(controller?.clear)) controller.clear();
|
|
4883
|
-
});
|
|
4884
|
-
this.#highlightObjectIds.forEach((objIds) => {
|
|
4885
|
-
const objects = this.threeLayer?.getBaseObjects();
|
|
4886
|
-
const objectToResetHighlight = objects.find(
|
|
4887
|
-
({ properties }) => objIds.includes(properties?.id)
|
|
4888
|
-
);
|
|
4889
|
-
if (objectToResetHighlight instanceof SpriteMarker) {
|
|
4890
|
-
objectToResetHighlight.show();
|
|
4891
|
-
objectToResetHighlight.removeHighlight();
|
|
4892
|
-
}
|
|
4893
|
-
});
|
|
4894
|
-
this.#highlightObjectControllers = [];
|
|
4895
|
-
this.#highlightObjectIds = [];
|
|
4896
|
-
}
|
|
4897
4473
|
/**
|
|
4898
4474
|
* User Location
|
|
4899
4475
|
****************************/
|
|
@@ -4918,15 +4494,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
4918
4494
|
}
|
|
4919
4495
|
}
|
|
4920
4496
|
updateUserLocationSymbolByLocale(locale) {
|
|
4921
|
-
const userLocationGeometry =
|
|
4497
|
+
const userLocationGeometry = import_lodash6.default.get(
|
|
4922
4498
|
this.#elements,
|
|
4923
4499
|
`${USER_LOCATION_ELEMENT_ID}.geometry`
|
|
4924
4500
|
);
|
|
4925
4501
|
if (!userLocationGeometry) return;
|
|
4926
4502
|
const currentSymbol = userLocationGeometry.getSymbol();
|
|
4927
4503
|
const localeSymbolToUpdate = currentSymbol.map((symbol) => {
|
|
4928
|
-
const localeSymbol =
|
|
4929
|
-
if (!
|
|
4504
|
+
const localeSymbol = import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
|
|
4505
|
+
if (!import_lodash6.default.isPlainObject(localeSymbol)) return symbol;
|
|
4930
4506
|
return {
|
|
4931
4507
|
...symbol,
|
|
4932
4508
|
...localeSymbol
|
|
@@ -5000,14 +4576,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5000
4576
|
* END of User Location
|
|
5001
4577
|
****************************/
|
|
5002
4578
|
showGeometryByElementId = (elementId) => {
|
|
5003
|
-
const geometry =
|
|
4579
|
+
const geometry = import_lodash6.default.get(
|
|
5004
4580
|
this.#elements,
|
|
5005
4581
|
`${elementId}.geometry`
|
|
5006
4582
|
);
|
|
5007
4583
|
if (geometry) geometry.show();
|
|
5008
4584
|
};
|
|
5009
4585
|
hideGeometryByElementId = (elementId) => {
|
|
5010
|
-
const geometry =
|
|
4586
|
+
const geometry = import_lodash6.default.get(this.#elements, `${elementId}.geometry`);
|
|
5011
4587
|
if (geometry) geometry.hide();
|
|
5012
4588
|
};
|
|
5013
4589
|
setSpriteMarkersOpacity = (opacity = 1) => {
|
|
@@ -5054,13 +4630,13 @@ var IndoorMap = class extends EventTarget {
|
|
|
5054
4630
|
const line = lineStrings[i];
|
|
5055
4631
|
const coords = line.geometry.coordinates;
|
|
5056
4632
|
const prevLine = lineStrings[i - 1];
|
|
5057
|
-
const firstCoord =
|
|
4633
|
+
const firstCoord = import_lodash6.default.first(coords);
|
|
5058
4634
|
const isFirstLine = i === 0;
|
|
5059
4635
|
if (isFirstLine) {
|
|
5060
4636
|
accLine.push(...coords);
|
|
5061
4637
|
continue;
|
|
5062
4638
|
}
|
|
5063
|
-
const prevLastCoord =
|
|
4639
|
+
const prevLastCoord = import_lodash6.default.last(prevLine.geometry.coordinates);
|
|
5064
4640
|
const isNearby = (0, import_distance.default)(point(firstCoord), point(prevLastCoord)) < distance;
|
|
5065
4641
|
if (!isNearby) {
|
|
5066
4642
|
const remainingLines = lineStrings.slice(i);
|
|
@@ -5081,8 +4657,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5081
4657
|
create3DStepPath
|
|
5082
4658
|
} = this.#styler;
|
|
5083
4659
|
const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
5084
|
-
const linesByOrdinal = (0,
|
|
5085
|
-
const joinedLines = (0,
|
|
4660
|
+
const linesByOrdinal = (0, import_lodash6.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
|
|
4661
|
+
const joinedLines = (0, import_lodash6.default)(linesByOrdinal).reduce((acc, lines, key) => {
|
|
5086
4662
|
const joined = this.combineNearbyLineStrings(lines, {
|
|
5087
4663
|
properties: { ordinal: +key }
|
|
5088
4664
|
});
|
|
@@ -5110,14 +4686,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5110
4686
|
stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
|
|
5111
4687
|
break;
|
|
5112
4688
|
case "destination-marker":
|
|
5113
|
-
const extrudeConfig =
|
|
4689
|
+
const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
|
|
5114
4690
|
if (destinationFeature.feature_type === "occupant") {
|
|
5115
|
-
const stepId =
|
|
4691
|
+
const stepId = import_lodash6.default.get(stepGeometry, "id");
|
|
5116
4692
|
const normalizedDestinationFeature = {
|
|
5117
4693
|
...destinationFeature,
|
|
5118
4694
|
id: stepId
|
|
5119
4695
|
};
|
|
5120
|
-
const logoUrl =
|
|
4696
|
+
const logoUrl = import_lodash6.default.get(
|
|
5121
4697
|
normalizedDestinationFeature,
|
|
5122
4698
|
"properties.logo.url"
|
|
5123
4699
|
);
|
|
@@ -5162,15 +4738,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
5162
4738
|
const routeMarkerLayer = this.map.getLayer(
|
|
5163
4739
|
HIGHLIGHT_LAYER_NAME
|
|
5164
4740
|
);
|
|
5165
|
-
const originMarkerGeometry =
|
|
4741
|
+
const originMarkerGeometry = import_lodash6.default.get(
|
|
5166
4742
|
this.#elements,
|
|
5167
4743
|
`${ORIGIN_MARKER_ID}.geometry`
|
|
5168
4744
|
);
|
|
5169
|
-
const destinationMarkerGeometry =
|
|
4745
|
+
const destinationMarkerGeometry = import_lodash6.default.get(
|
|
5170
4746
|
this.#elements,
|
|
5171
4747
|
`${DESTINATION_MARKER_ID}.geometry`
|
|
5172
4748
|
);
|
|
5173
|
-
const geometriesToRemove =
|
|
4749
|
+
const geometriesToRemove = import_lodash6.default.compact([
|
|
5174
4750
|
originMarkerGeometry,
|
|
5175
4751
|
destinationMarkerGeometry
|
|
5176
4752
|
]);
|
|
@@ -5181,7 +4757,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5181
4757
|
(obj) => !(obj instanceof NavigationPath)
|
|
5182
4758
|
);
|
|
5183
4759
|
const objects = this.#navigationGeometries || {};
|
|
5184
|
-
|
|
4760
|
+
import_lodash6.default.forEach(objects, (obj) => {
|
|
5185
4761
|
if (!obj) return;
|
|
5186
4762
|
this.#navigationGeometries[obj.properties.id] = null;
|
|
5187
4763
|
obj.remove();
|
|
@@ -5209,33 +4785,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
5209
4785
|
/**
|
|
5210
4786
|
* render (frame)
|
|
5211
4787
|
*/
|
|
5212
|
-
getTargetViewCenter = (targetView, options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }) => {
|
|
5213
|
-
const map = this.map;
|
|
5214
|
-
const { offset } = options;
|
|
5215
|
-
const { top = 0, left = 0, right = 0, bottom = 0 } = offset;
|
|
5216
|
-
const originalState = {
|
|
5217
|
-
bearing: map.getBearing(),
|
|
5218
|
-
center: map.getCenter(),
|
|
5219
|
-
pitch: map.getPitch(),
|
|
5220
|
-
zoom: map.getZoom()
|
|
5221
|
-
};
|
|
5222
|
-
const finalView = {
|
|
5223
|
-
bearing: import_lodash7.default.isNil(targetView.bearing) ? map.getBearing() : targetView.bearing,
|
|
5224
|
-
center: import_lodash7.default.isNil(targetView.center) ? map.getCenter() : targetView.center,
|
|
5225
|
-
pitch: import_lodash7.default.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,
|
|
5226
|
-
zoom: import_lodash7.default.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom
|
|
5227
|
-
};
|
|
5228
|
-
map.setView(finalView);
|
|
5229
|
-
const projectedTargetCenter = map.coordinateToContainerPoint(finalView.center).add(right / 2 - left / 2, bottom / 2 - top / 2);
|
|
5230
|
-
const adjustedTargetCenter = map.containerPointToCoordinate(
|
|
5231
|
-
projectedTargetCenter
|
|
5232
|
-
);
|
|
5233
|
-
map.setView(originalState);
|
|
5234
|
-
return adjustedTargetCenter;
|
|
5235
|
-
};
|
|
5236
|
-
setMaxExtent(extent) {
|
|
5237
|
-
return this.map.setMaxExtent(extent);
|
|
5238
|
-
}
|
|
5239
4788
|
render() {
|
|
5240
4789
|
const view = this.map.getView();
|
|
5241
4790
|
const currBearing = view.bearing;
|
|
@@ -5244,7 +4793,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5244
4793
|
this.threeLayer.redraw();
|
|
5245
4794
|
}
|
|
5246
4795
|
if (this.threeLayer) {
|
|
5247
|
-
const
|
|
4796
|
+
const currentView = this.camera.getView();
|
|
4797
|
+
const objectOpacity = import_lodash6.default.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
5248
4798
|
this.#objects.forEach((object) => {
|
|
5249
4799
|
object.getObject3d().traverse((child) => {
|
|
5250
4800
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -5254,8 +4804,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5254
4804
|
});
|
|
5255
4805
|
if (this.#billboardObjects) {
|
|
5256
4806
|
this.#billboardObjects.forEach((object) => {
|
|
5257
|
-
const objectScale =
|
|
5258
|
-
20 - 1 *
|
|
4807
|
+
const objectScale = import_lodash6.default.clamp(
|
|
4808
|
+
20 - 1 * currentView.zoom,
|
|
5259
4809
|
1,
|
|
5260
4810
|
1.05
|
|
5261
4811
|
);
|
|
@@ -5263,7 +4813,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5263
4813
|
});
|
|
5264
4814
|
}
|
|
5265
4815
|
if (this.#isLayersFadingOnZoom) {
|
|
5266
|
-
const layerOpacity =
|
|
4816
|
+
const layerOpacity = import_lodash6.default.clamp(1 - objectOpacity, 0, 1);
|
|
5267
4817
|
LAYERS.forEach((layerKey) => {
|
|
5268
4818
|
const layer = this.map.getLayer(layerKey);
|
|
5269
4819
|
if (layer) layer.setOpacity(layerOpacity);
|
|
@@ -5282,19 +4832,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
5282
4832
|
});
|
|
5283
4833
|
}
|
|
5284
4834
|
this.#animationsToRun.forEach(({ callback }) => callback(this));
|
|
5285
|
-
|
|
4835
|
+
import_tween.default.update();
|
|
5286
4836
|
requestAnimationFrame(this.render.bind(this));
|
|
5287
4837
|
}
|
|
5288
4838
|
};
|
|
5289
4839
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5290
4840
|
0 && (module.exports = {
|
|
5291
4841
|
ALL_FEATURE_TYPES,
|
|
5292
|
-
ALWAYS_VISIBLE_FEATURE_TYPES,
|
|
5293
4842
|
BASE_LAYER_NAME,
|
|
5294
4843
|
DEFAULT_BASE_URL,
|
|
5295
|
-
DEFAULT_HIGHLIGHT_OPTIONS,
|
|
5296
4844
|
DEFAULT_LOCALE,
|
|
5297
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
5298
4845
|
DESTINATION_MARKER_ID,
|
|
5299
4846
|
GEOJSON_FEATURE_TYPES,
|
|
5300
4847
|
HIGHLIGHT_LAYER_NAME,
|
|
@@ -5308,6 +4855,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5308
4855
|
MARKER_LAYER_NAME,
|
|
5309
4856
|
NONIMDF_FEATURE_TYPES,
|
|
5310
4857
|
ORIGIN_MARKER_ID,
|
|
4858
|
+
OccupantHelpers,
|
|
5311
4859
|
POI_MARKER_LAYER_NAME,
|
|
5312
4860
|
QueryObserver,
|
|
5313
4861
|
USER_LOCATION_ELEMENT_ID,
|
|
@@ -5335,6 +4883,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
5335
4883
|
getRelatedLocationsByOccupant,
|
|
5336
4884
|
getSuitablyValueBetweenBearings,
|
|
5337
4885
|
isClickableFeature,
|
|
4886
|
+
isValidCoordinate,
|
|
4887
|
+
isValidLineString,
|
|
4888
|
+
isValidLineStringCoordinates,
|
|
4889
|
+
isValidMultiPolygon,
|
|
4890
|
+
isValidMultiPolygonCoordinates,
|
|
4891
|
+
isValidPoint,
|
|
4892
|
+
isValidPolygon,
|
|
4893
|
+
isValidPolygonCoordinates,
|
|
4894
|
+
matchFilter,
|
|
4895
|
+
matchFilters,
|
|
5338
4896
|
safeFetchFeature,
|
|
5339
4897
|
styledFeatureGenerator
|
|
5340
4898
|
});
|