venue-js 1.2.0 → 1.3.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,8 +46,10 @@ __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,
52
+ TextSpriteMarker: () => TextSpriteMarker,
54
53
  USER_LOCATION_ELEMENT_ID: () => USER_LOCATION_ELEMENT_ID,
55
54
  USER_LOCATION_LAYER_NAME: () => USER_LOCATION_LAYER_NAME,
56
55
  VENUE_EVENTS: () => VENUE_EVENTS,
@@ -76,6 +75,16 @@ __export(index_exports, {
76
75
  getRelatedLocationsByOccupant: () => getRelatedLocationsByOccupant,
77
76
  getSuitablyValueBetweenBearings: () => getSuitablyValueBetweenBearings,
78
77
  isClickableFeature: () => isClickableFeature,
78
+ isValidCoordinate: () => isValidCoordinate,
79
+ isValidLineString: () => isValidLineString,
80
+ isValidLineStringCoordinates: () => isValidLineStringCoordinates,
81
+ isValidMultiPolygon: () => isValidMultiPolygon,
82
+ isValidMultiPolygonCoordinates: () => isValidMultiPolygonCoordinates,
83
+ isValidPoint: () => isValidPoint,
84
+ isValidPolygon: () => isValidPolygon,
85
+ isValidPolygonCoordinates: () => isValidPolygonCoordinates,
86
+ matchFilter: () => matchFilter,
87
+ matchFilters: () => matchFilters,
79
88
  safeFetchFeature: () => safeFetchFeature,
80
89
  styledFeatureGenerator: () => styledFeatureGenerator
81
90
  });
@@ -158,7 +167,8 @@ var defaultFeatureQueryOptionsMap = {
158
167
  // refresh every 5 min
159
168
  },
160
169
  element: {},
161
- page: {}
170
+ page: {},
171
+ model3d: {}
162
172
  };
163
173
 
164
174
  // src/data/api/delivery-project.ts
@@ -174,6 +184,14 @@ async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAUL
174
184
  const items = await res.json();
175
185
  return items;
176
186
  }
187
+ case "model3d": {
188
+ const res = await fetch(
189
+ `${baseUrl}/delivery/projects/${projectId}/${featureType}.geojson?api-key=${apiKey}`
190
+ );
191
+ if (res.status !== 200) return [];
192
+ const items = await res.json();
193
+ return items.features;
194
+ }
177
195
  case "sponsored-content": {
178
196
  const res = await fetch(
179
197
  `${baseUrl}/delivery/projects/${projectId}/sponsored-content.json?api-key=${apiKey}`
@@ -274,10 +292,120 @@ var safeFetchFeature = async (featureType, params) => {
274
292
  }
275
293
  };
276
294
 
295
+ // src/data/utils/geometry-validator.ts
296
+ var isValidCoordinate = (point2) => {
297
+ return point2.length === 2 && point2.every((coord) => typeof coord === "number");
298
+ };
299
+ function isValidLinearRingCoordinates(ring) {
300
+ if (ring.length < 4) {
301
+ return false;
302
+ }
303
+ return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
304
+ }
305
+ var isValidPolygonCoordinates = (polygon2) => {
306
+ if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
307
+ return isValidLinearRingCoordinates(polygon2);
308
+ }
309
+ if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
310
+ if (!isValidLinearRingCoordinates(polygon2[0])) {
311
+ return false;
312
+ }
313
+ for (let i = 1; i < polygon2.length; i++) {
314
+ if (!isValidLinearRingCoordinates(polygon2[i])) {
315
+ return false;
316
+ }
317
+ }
318
+ return true;
319
+ }
320
+ return false;
321
+ };
322
+ var isValidMultiPolygonCoordinates = (multipolygon) => {
323
+ return multipolygon.every(isValidPolygonCoordinates);
324
+ };
325
+ var isValidLineStringCoordinates = (lineString2) => {
326
+ if (!Array.isArray(lineString2) || lineString2.length < 2) {
327
+ return false;
328
+ }
329
+ const firstPoint = lineString2[0];
330
+ const lastPoint = lineString2[lineString2.length - 1];
331
+ if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
332
+ return false;
333
+ }
334
+ return lineString2.every(isValidCoordinate);
335
+ };
336
+ var isValidMultiPolygon = (geometry) => {
337
+ const { type, coordinates } = geometry;
338
+ return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
339
+ };
340
+ var isValidPolygon = (geometry) => {
341
+ const { type, coordinates } = geometry;
342
+ return type === "Polygon" && isValidPolygonCoordinates(coordinates);
343
+ };
344
+ var isValidLineString = (geometry) => {
345
+ const { type, coordinates } = geometry;
346
+ return type === "LineString" && isValidLineStringCoordinates(coordinates);
347
+ };
348
+ var isValidPoint = (geometry) => {
349
+ const { type, coordinates } = geometry;
350
+ return type === "Point" && isValidCoordinate(coordinates);
351
+ };
352
+
353
+ // src/data/utils/match-filters.ts
354
+ function isInFilter(filter) {
355
+ return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
356
+ }
357
+ var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
358
+ function matchFilter(value, filter) {
359
+ if (Array.isArray(value)) {
360
+ if (isInFilter(filter)) return someIntersect(value, filter.$in);
361
+ return value.includes(filter);
362
+ } else {
363
+ if (isInFilter(filter)) return filter.$in.includes(value);
364
+ return value === filter;
365
+ }
366
+ }
367
+ function matchFilters(item, filters) {
368
+ return Object.entries(filters).every(([key, filter]) => {
369
+ return matchFilter(item.properties[key], filter);
370
+ });
371
+ }
372
+
373
+ // src/data/utils/occupant-helper.ts
374
+ var occupant_helper_exports = {};
375
+ __export(occupant_helper_exports, {
376
+ getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
377
+ getOccupantMainLocation: () => getOccupantMainLocation,
378
+ getOccupantMarkerLocations: () => getOccupantMarkerLocations
379
+ });
380
+ var import_lodash_es = require("lodash-es");
381
+ var getOccupantMainLocation = (occupant) => {
382
+ return occupant.properties.kiosk || occupant.properties.unit;
383
+ };
384
+ var getOccupantCorrelatedLocations = (occupant) => {
385
+ const allCorrelatedLocations = [
386
+ ...occupant.properties.units,
387
+ ...occupant.properties.kiosks
388
+ ];
389
+ return (0, import_lodash_es.compact)(allCorrelatedLocations);
390
+ };
391
+ var getOccupantMarkerLocations = (occupant, options) => {
392
+ const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
393
+ const mainLocation = getOccupantMainLocation(occupant);
394
+ const mainLocationLevel = mainLocation?.properties?.level_id;
395
+ const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
396
+ if (placementType === "ALL_LOCATIONS") {
397
+ return (0, import_lodash_es.compact)([mainLocation, ...allCorrelatedLocations]);
398
+ }
399
+ const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
400
+ const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
401
+ return (0, import_lodash_es.compact)([mainLocation, ...onePerLevelLocations]);
402
+ };
403
+
277
404
  // src/data/getDataClient.ts
278
405
  var import_query_core = require("@tanstack/query-core");
279
406
 
280
407
  // src/data/populator/index.ts
408
+ var import_lodash_es2 = require("lodash-es");
281
409
  var import_boolean_within = require("@turf/boolean-within");
282
410
  var createPopulator = ({
283
411
  internalFindById,
@@ -424,13 +552,13 @@ var createPopulator = ({
424
552
  ...occupant.properties,
425
553
  anchor: anchor ? await populateAnchor(anchor) : null,
426
554
  local_categories: await Promise.all(
427
- localCategories.map(populateTaxonomy)
555
+ (0, import_lodash_es2.compact)(localCategories).map(populateTaxonomy)
428
556
  ),
429
557
  venue,
430
558
  promotions,
431
559
  privileges,
432
- kiosk,
433
- unit,
560
+ kiosk: kiosk ? await populateKiosk(kiosk) : null,
561
+ unit: unit ? await populateUnit(unit) : null,
434
562
  kiosks: await Promise.all(kiosks.map(populateKiosk)),
435
563
  units: await Promise.all(units.map(populateUnit))
436
564
  }
@@ -522,26 +650,6 @@ var createPopulator = ({
522
650
  };
523
651
  };
524
652
 
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
653
  // src/data/getDataClient.ts
546
654
  var getDataClient = (options) => {
547
655
  const observers = /* @__PURE__ */ new Map();
@@ -670,8 +778,9 @@ var getDataClient = (options) => {
670
778
 
671
779
  // src/IndoorMap/IndoorMap.ts
672
780
  var import_maptalks_gl = require("maptalks-gl");
673
- var import_tween2 = __toESM(require("@tweenjs/tween.js"));
674
- var import_lodash7 = __toESM(require("lodash"));
781
+ var import_transcoders = require("@maptalks/transcoders.draco");
782
+ var import_tween = __toESM(require("@tweenjs/tween.js"));
783
+ var import_lodash6 = __toESM(require("lodash"));
675
784
 
676
785
  // ../../node_modules/@turf/helpers/dist/esm/index.js
677
786
  var earthRadius = 63710088e-1;
@@ -723,6 +832,28 @@ function point(coordinates, properties, options = {}) {
723
832
  };
724
833
  return feature(geom, properties, options);
725
834
  }
835
+ function polygon(coordinates, properties, options = {}) {
836
+ for (const ring of coordinates) {
837
+ if (ring.length < 4) {
838
+ throw new Error(
839
+ "Each LinearRing of a Polygon must have 4 or more Positions."
840
+ );
841
+ }
842
+ if (ring[ring.length - 1].length !== ring[0].length) {
843
+ throw new Error("First and last Position are not equivalent.");
844
+ }
845
+ for (let j = 0; j < ring[ring.length - 1].length; j++) {
846
+ if (ring[ring.length - 1][j] !== ring[0][j]) {
847
+ throw new Error("First and last Position are not equivalent.");
848
+ }
849
+ }
850
+ }
851
+ const geom = {
852
+ type: "Polygon",
853
+ coordinates
854
+ };
855
+ return feature(geom, properties, options);
856
+ }
726
857
  function lineString(coordinates, properties, options = {}) {
727
858
  if (coordinates.length < 2) {
728
859
  throw new Error("coordinates must be an array of two or more positions");
@@ -744,6 +875,13 @@ function featureCollection(features, options = {}) {
744
875
  fc.features = features;
745
876
  return fc;
746
877
  }
878
+ function multiPoint(coordinates, properties, options = {}) {
879
+ const geom = {
880
+ type: "MultiPoint",
881
+ coordinates
882
+ };
883
+ return feature(geom, properties, options);
884
+ }
747
885
  function isNumber(num) {
748
886
  return !isNaN(num) && num !== null && !Array.isArray(num);
749
887
  }
@@ -751,133 +889,8 @@ function isNumber(num) {
751
889
  // src/IndoorMap/IndoorMap.ts
752
890
  var import_distance = __toESM(require("@turf/distance"));
753
891
  var import_center4 = __toESM(require("@turf/center"));
754
-
755
- // ../../node_modules/@turf/meta/dist/esm/index.js
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");
892
+ var import_three6 = require("three");
893
+ var import_maptalks10 = require("maptalks.three");
881
894
 
882
895
  // src/IndoorMap/constants.ts
883
896
  var defaultLayerOption = { enableAltitude: true };
@@ -895,7 +908,6 @@ var GEOLOCATION = "geolocation";
895
908
  var ORIGIN_MARKER = "origin-marker";
896
909
  var DESTINATION_MARKER = "destination-marker";
897
910
  var DECORATION = "decoration";
898
- var ALWAYS_VISIBLE_FEATURE_TYPES = [VENUE, FOOTPRINT];
899
911
  var BASE_LAYER_NAME = "base";
900
912
  var POI_MARKER_LAYER_NAME = "poi";
901
913
  var MARKER_LAYER_NAME = "marker";
@@ -907,13 +919,6 @@ var USER_LOCATION_ELEMENT_ID = "user_location";
907
919
  var LAST_USER_LOCATION_ELEMENT_ID_PREFIX = "last_user_location-";
908
920
  var LOCALE_SYMBOL_KEY = "locale_symbol";
909
921
  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
922
  var LAYERS = [
918
923
  BASE_LAYER_NAME,
919
924
  POI_MARKER_LAYER_NAME,
@@ -963,11 +968,10 @@ var VENUE_EVENTS = {
963
968
 
964
969
  // src/IndoorMap/utils/createElements.js
965
970
  var import_lodash4 = __toESM(require("lodash"));
966
- var import_maptalks5 = require("maptalks");
971
+ var import_maptalks4 = require("maptalks");
967
972
  var import_center2 = __toESM(require("@turf/center"));
968
973
  var import_buffer = __toESM(require("@turf/buffer"));
969
- var import_three5 = require("three");
970
- var import_GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader.js");
974
+ var import_three4 = require("three");
971
975
 
972
976
  // src/IndoorMap/object3d/Billboard.js
973
977
  var maptalks = __toESM(require("maptalks"));
@@ -999,7 +1003,7 @@ var Billboard = class extends import_maptalks.BaseObject {
999
1003
  this._initOptions(options);
1000
1004
  const {
1001
1005
  altitude = OPTIONS.altitude,
1002
- scale: scale2 = OPTIONS.scale,
1006
+ scale: scale3 = OPTIONS.scale,
1003
1007
  alphaTest = OPTIONS.alphaTest,
1004
1008
  legColor = OPTIONS.legColor,
1005
1009
  showLeg = OPTIONS.showLeg
@@ -1033,8 +1037,8 @@ var Billboard = class extends import_maptalks.BaseObject {
1033
1037
  const sprite = new import_three.Sprite(material);
1034
1038
  sprite.material.sizeAttenuation = false;
1035
1039
  sprite.scale.set(
1036
- scale2 * naturalWidth / divider,
1037
- scale2 * naturalHeight / divider,
1040
+ scale3 * naturalWidth / divider,
1041
+ scale3 * naturalHeight / divider,
1038
1042
  1
1039
1043
  );
1040
1044
  this.getObject3d().add(sprite);
@@ -1043,7 +1047,7 @@ var Billboard = class extends import_maptalks.BaseObject {
1043
1047
  const position = layer.coordinateToVector3(coordinate, z);
1044
1048
  import_lodash.default.set(this.properties, "default.position", position);
1045
1049
  import_lodash.default.set(this.properties, "default.altitude", altitude);
1046
- import_lodash.default.set(this.properties, "default.scale", scale2);
1050
+ import_lodash.default.set(this.properties, "default.scale", scale3);
1047
1051
  this.getObject3d().position.copy(position);
1048
1052
  }
1049
1053
  setLineHeight(altitude) {
@@ -1056,315 +1060,25 @@ var Billboard = class extends import_maptalks.BaseObject {
1056
1060
  }
1057
1061
  };
1058
1062
 
1059
- // src/IndoorMap/object3d/GroundLabel.ts
1060
- var maptalks2 = __toESM(require("maptalks"));
1063
+ // src/IndoorMap/object3d/SpriteMarker.ts
1061
1064
  var import_maptalks2 = require("maptalks.three");
1062
1065
  var import_three2 = require("three");
1063
- var import_d3plus_shape = require("d3plus-shape");
1064
- var import_lodash_es = require("lodash-es");
1065
- var OPTIONS2 = {
1066
- // Allowing click through and prevent interaction
1067
- interactive: false,
1068
- altitude: 0
1069
- };
1070
- var defaultFlatLabelOptions = {
1071
- fontSize: 14,
1072
- fontFamily: "Manrope",
1073
- fontWeight: 600,
1074
- margin: 0,
1075
- scaleMin: 0.5,
1076
- lineHeight: 1.05,
1077
- scaleStep: 0.05,
1078
- textAlign: "center",
1079
- textBaseline: "middle",
1080
- fillStyle: "#000"
1066
+ var import_lodash2 = __toESM(require("lodash"));
1067
+ var DEFAULT_SCALE = 0.05;
1068
+ var DEFAULT_ALTITUDE = 0;
1069
+ var DEFAULT_ALPHATEST = 0.3;
1070
+ var DEFAULT_OPTIONS = {
1071
+ scale: DEFAULT_SCALE,
1072
+ altitude: DEFAULT_ALTITUDE,
1073
+ alphaTest: DEFAULT_ALPHATEST,
1074
+ highlight: {
1075
+ options: {
1076
+ scale: DEFAULT_SCALE * 1.25
1077
+ },
1078
+ material: null
1079
+ }
1081
1080
  };
1082
- var defaultRectAngleToCalc = (0, import_lodash_es.range)(-90, 92, 2);
1083
- var getMaterial = (text, flatLabelOptions) => {
1084
- const options = (0, import_lodash_es.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
1085
- const {
1086
- fontSize: initialFontSize,
1087
- fontFamily,
1088
- fontWeight,
1089
- margin,
1090
- scaleMin,
1091
- scaleStep,
1092
- fillStyle,
1093
- lineHeight,
1094
- textAlign,
1095
- strokeStyle,
1096
- lineWidth,
1097
- textBaseline
1098
- } = options;
1099
- const pixelMultiplier = 4;
1100
- const SIZE = 100 * pixelMultiplier;
1101
- const fontSize = initialFontSize * (pixelMultiplier * 1.25);
1102
- const canvas = document.createElement("canvas");
1103
- canvas.width = canvas.height = SIZE;
1104
- const ctx = canvas.getContext("2d");
1105
- ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
1106
- ctx.textAlign = textAlign;
1107
- ctx.textBaseline = textBaseline;
1108
- ctx.fillStyle = fillStyle;
1109
- ctx.strokeStyle = strokeStyle;
1110
- ctx.lineWidth = lineWidth;
1111
- const wrapText = (ctx2, text2, maxWidth) => {
1112
- const words = text2.trim().split(/\s+/);
1113
- if (words.length <= 1) return [text2];
1114
- const lines = [];
1115
- const MAX_LINES = 3;
1116
- let currentLine = words[0];
1117
- for (let i = 1; i < words.length; i++) {
1118
- const lineToMeasure = currentLine + " " + words[i];
1119
- if (ctx2.measureText(lineToMeasure).width > maxWidth) {
1120
- lines.push(currentLine);
1121
- currentLine = words[i];
1122
- } else {
1123
- currentLine = lineToMeasure;
1124
- }
1125
- }
1126
- lines.push(currentLine);
1127
- return lines.slice(0, MAX_LINES);
1128
- };
1129
- const hasManualBreaks = text.includes("\n");
1130
- let texts;
1131
- if (hasManualBreaks) {
1132
- texts = text.split(/\n/g);
1133
- } else {
1134
- const maxWidth = SIZE - 2 * margin;
1135
- texts = wrapText(ctx, text, maxWidth);
1136
- }
1137
- let textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
1138
- let scale2 = 1;
1139
- while (scale2 > 0 && textWidth + 2 * margin > SIZE) {
1140
- scale2 -= scaleStep;
1141
- ctx.font = `${fontWeight} ${scale2 * fontSize}px "${fontFamily}", Arial`;
1142
- textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
1143
- }
1144
- const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
1145
- if (scale2 > scaleMin) {
1146
- const totalHeight = texts.length * (fontSize * scale2 * lineHeight);
1147
- const startY = center2.y - totalHeight / 2 + fontSize * scale2 * lineHeight * 0.5;
1148
- texts.forEach((text2, index) => {
1149
- const yOffset = startY + index * (fontSize * scale2 * lineHeight);
1150
- if (strokeStyle && lineWidth) {
1151
- ctx.strokeText(text2, center2.x, yOffset);
1152
- }
1153
- ctx.fillText(text2, center2.x, yOffset);
1154
- });
1155
- }
1156
- const texture = new import_three2.Texture(canvas);
1157
- texture.needsUpdate = true;
1158
- const material = new import_three2.MeshPhongMaterial({
1159
- map: texture,
1160
- transparent: true,
1161
- // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
1162
- alphaTest: 0.3
1163
- });
1164
- return material;
1165
- };
1166
- var GroundLabel = class extends import_maptalks2.BaseObject {
1167
- #angle = 0;
1168
- #bearing = 0;
1169
- #text = "";
1170
- #offsetX = 0;
1171
- #offsetY = 0;
1172
- #originalPosition = null;
1173
- #layer = null;
1174
- constructor(bound, options, layer) {
1175
- options = maptalks2.Util.extend({}, OPTIONS2, options, {
1176
- layer,
1177
- coordinate: bound
1178
- });
1179
- const {
1180
- altitude,
1181
- text,
1182
- fontSize,
1183
- fillStyle,
1184
- textAlign,
1185
- fontFamily,
1186
- textBaseline,
1187
- strokeStyle,
1188
- lineWidth,
1189
- angle = defaultRectAngleToCalc,
1190
- maxFontScale,
1191
- offsetX = 0,
1192
- offsetY = 0,
1193
- ...properties
1194
- } = options;
1195
- super();
1196
- this._initOptions(options);
1197
- this.properties = properties;
1198
- this.#offsetX = offsetX;
1199
- this.#offsetY = offsetY;
1200
- this.#layer = layer;
1201
- const material = getMaterial(text, {
1202
- fillStyle,
1203
- fontSize,
1204
- textAlign,
1205
- textBaseline,
1206
- fontFamily,
1207
- strokeStyle,
1208
- lineWidth
1209
- });
1210
- const rectAngles = (0, import_lodash_es.isArray)(angle) ? angle : [angle];
1211
- material.needsUpdate = true;
1212
- const rect = (0, import_d3plus_shape.largestRect)(bound, {
1213
- cache: true,
1214
- /**
1215
- * Black magic here:
1216
- * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
1217
- * So we remove -90 and 90 from choices, and use -85 & 85 instead.
1218
- */
1219
- angle: rectAngles
1220
- });
1221
- const { cx, cy, width, angle: calculatedAngle } = rect;
1222
- this.#text = text;
1223
- this.#angle = calculatedAngle;
1224
- const geometry = new import_three2.PlaneGeometry(1, 1);
1225
- this._createMesh(geometry, material);
1226
- const z = layer.altitudeToVector3(altitude, altitude).x;
1227
- const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z);
1228
- this.#originalPosition = basePosition.clone();
1229
- const finalPosition = this.#calculateFinalPosition(basePosition);
1230
- const scale2 = width / 6456122659e-13;
1231
- const finalScale = maxFontScale && scale2 > maxFontScale ? maxFontScale : scale2;
1232
- this.getObject3d().scale.set(finalScale, finalScale, finalScale);
1233
- this.getObject3d().position.copy(finalPosition);
1234
- this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
1235
- }
1236
- #calculateFinalPosition(basePosition) {
1237
- if (this.#offsetX === 0 && this.#offsetY === 0) {
1238
- return basePosition;
1239
- }
1240
- const offsetCoordinate = {
1241
- x: this.#offsetX,
1242
- y: this.#offsetY
1243
- };
1244
- const z = this.#layer.altitudeToVector3(0, 0).x;
1245
- const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
1246
- const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z);
1247
- const worldOffsetX = offsetVector.x - zeroVector.x;
1248
- const worldOffsetY = offsetVector.y - zeroVector.y;
1249
- return {
1250
- x: basePosition.x + worldOffsetX,
1251
- y: basePosition.y + worldOffsetY,
1252
- z: basePosition.z
1253
- };
1254
- }
1255
- #updatePosition() {
1256
- if (this.#originalPosition && this.#layer) {
1257
- const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
1258
- this.getObject3d().position.copy(finalPosition);
1259
- }
1260
- }
1261
- set bearing(value) {
1262
- this.#bearing = value;
1263
- const degree = this.#angle + this.#bearing;
1264
- const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
1265
- this.getObject3d().rotation.z = Math.PI / 180 * angle;
1266
- }
1267
- get angle() {
1268
- return this.#angle;
1269
- }
1270
- get currentAngle() {
1271
- return this.#angle;
1272
- }
1273
- get text() {
1274
- return this.#text;
1275
- }
1276
- get offsetX() {
1277
- return this.#offsetX;
1278
- }
1279
- get offsetY() {
1280
- return this.#offsetY;
1281
- }
1282
- get offset() {
1283
- return { x: this.#offsetX, y: this.#offsetY };
1284
- }
1285
- set offsetX(value) {
1286
- if ((0, import_lodash_es.isNumber)(value)) {
1287
- this.#offsetX = value;
1288
- this.#updatePosition();
1289
- }
1290
- }
1291
- set offsetY(value) {
1292
- if ((0, import_lodash_es.isNumber)(value)) {
1293
- this.#offsetY = value;
1294
- this.#updatePosition();
1295
- }
1296
- }
1297
- set angle(newAngle) {
1298
- if ((0, import_lodash_es.isNumber)(newAngle)) {
1299
- this.#angle = newAngle;
1300
- this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
1301
- }
1302
- }
1303
- setOffset(offsetX, offsetY) {
1304
- if ((0, import_lodash_es.isNumber)(offsetX) && (0, import_lodash_es.isNumber)(offsetY)) {
1305
- this.#offsetX = offsetX;
1306
- this.#offsetY = offsetY;
1307
- this.#updatePosition();
1308
- }
1309
- }
1310
- addOffset(deltaX, deltaY) {
1311
- if ((0, import_lodash_es.isNumber)(deltaX) && (0, import_lodash_es.isNumber)(deltaY)) {
1312
- this.#offsetX += deltaX;
1313
- this.#offsetY += deltaY;
1314
- this.#updatePosition();
1315
- }
1316
- }
1317
- resetOffset() {
1318
- this.#offsetX = 0;
1319
- this.#offsetY = 0;
1320
- this.#updatePosition();
1321
- }
1322
- moveToPosition(targetX, targetY) {
1323
- if (this.#originalPosition && this.#layer) {
1324
- const currentCenter = this.#layer.vector3ToCoordinate(
1325
- this.#originalPosition
1326
- );
1327
- this.#offsetX = targetX - currentCenter.x;
1328
- this.#offsetY = targetY - currentCenter.y;
1329
- this.#updatePosition();
1330
- }
1331
- }
1332
- updateText(newText, options = {}) {
1333
- this.#text = newText;
1334
- const materialOptions = {
1335
- fillStyle: options.fillStyle || this.properties.fillStyle,
1336
- fontSize: options.fontSize || this.properties.fontSize,
1337
- textAlign: options.textAlign || this.properties.textAlign,
1338
- textBaseline: options.textBaseline || this.properties.textBaseline,
1339
- fontFamily: options.fontFamily || this.properties.fontFamily,
1340
- strokeStyle: options.strokeStyle || this.properties.strokeStyle,
1341
- lineWidth: options.lineWidth || this.properties.lineWidth
1342
- };
1343
- const newMaterial = getMaterial(newText, materialOptions);
1344
- this.getObject3d().material = newMaterial;
1345
- newMaterial.needsUpdate = true;
1346
- }
1347
- };
1348
-
1349
- // src/IndoorMap/object3d/SpriteMarker.ts
1350
- var import_maptalks3 = require("maptalks.three");
1351
- var import_three3 = require("three");
1352
- var import_lodash2 = __toESM(require("lodash"));
1353
- var DEFAULT_SCALE = 0.05;
1354
- var DEFAULT_ALTITUDE = 0;
1355
- var DEFAULT_ALPHATEST = 0.3;
1356
- var DEFAULT_OPTIONS = {
1357
- scale: DEFAULT_SCALE,
1358
- altitude: DEFAULT_ALTITUDE,
1359
- alphaTest: DEFAULT_ALPHATEST,
1360
- highlight: {
1361
- options: {
1362
- scale: DEFAULT_SCALE * 1.25
1363
- },
1364
- material: null
1365
- }
1366
- };
1367
- var SpriteMarker = class extends import_maptalks3.BaseObject {
1081
+ var SpriteMarker = class extends import_maptalks2.BaseObject {
1368
1082
  #default = null;
1369
1083
  #highlight = null;
1370
1084
  constructor(coordinate, options, material, layer, properties) {
@@ -1373,18 +1087,18 @@ var SpriteMarker = class extends import_maptalks3.BaseObject {
1373
1087
  this._createGroup();
1374
1088
  const {
1375
1089
  altitude = DEFAULT_OPTIONS.altitude,
1376
- scale: scale2 = DEFAULT_OPTIONS.scale,
1090
+ scale: scale3 = DEFAULT_OPTIONS.scale,
1377
1091
  highlight = DEFAULT_OPTIONS.highlight,
1378
1092
  alphaTest = DEFAULT_OPTIONS.alphaTest
1379
1093
  } = options;
1380
1094
  this.properties = { ...properties };
1381
1095
  const modifiedAltitude = altitude + 2;
1382
- this.#default = { options: { scale: scale2, altitude: modifiedAltitude }, material };
1096
+ this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
1383
1097
  this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
1384
- if (material && material instanceof import_three3.SpriteMaterial)
1098
+ if (material && material instanceof import_three2.SpriteMaterial)
1385
1099
  material.alphaTest = alphaTest;
1386
- const sprite = new import_three3.Sprite(material);
1387
- sprite.scale.set(scale2, scale2, scale2);
1100
+ const sprite = new import_three2.Sprite(material);
1101
+ sprite.scale.set(scale3, scale3, scale3);
1388
1102
  const obj3d = this.getObject3d();
1389
1103
  obj3d.add(sprite);
1390
1104
  const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
@@ -1394,7 +1108,7 @@ var SpriteMarker = class extends import_maptalks3.BaseObject {
1394
1108
  }
1395
1109
  // Different objects need to implement their own methods
1396
1110
  setSymbol(material) {
1397
- if (material && material instanceof import_three3.SpriteMaterial) {
1111
+ if (material && material instanceof import_three2.SpriteMaterial) {
1398
1112
  const sprite = this.getObject3d().children[0];
1399
1113
  if (!sprite) return this;
1400
1114
  sprite.material = material;
@@ -1429,10 +1143,10 @@ var SpriteMarker = class extends import_maptalks3.BaseObject {
1429
1143
  };
1430
1144
 
1431
1145
  // src/IndoorMap/object3d/NavigationPath.ts
1432
- var maptalks3 = __toESM(require("maptalks"));
1433
- var import_maptalks4 = require("maptalks.three");
1434
- var import_three4 = require("three");
1435
- var OPTIONS3 = {
1146
+ var maptalks2 = __toESM(require("maptalks"));
1147
+ var import_maptalks3 = require("maptalks.three");
1148
+ var import_three3 = require("three");
1149
+ var OPTIONS2 = {
1436
1150
  altitude: 0
1437
1151
  };
1438
1152
  var DEFAULT_LINE_OPTION = {
@@ -1444,18 +1158,18 @@ var DEFAULT_LINE_EFFECT_OPTION = {
1444
1158
  opacity: 1
1445
1159
  };
1446
1160
  var ENABLE_ANIMATED_PATH = true;
1447
- var NavigationPath = class extends import_maptalks4.BaseObject {
1161
+ var NavigationPath = class extends import_maptalks3.BaseObject {
1448
1162
  constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
1449
- options = maptalks3.Util.extend({}, OPTIONS3, options, {
1163
+ options = maptalks2.Util.extend({}, OPTIONS2, options, {
1450
1164
  layer
1451
1165
  });
1452
1166
  super();
1453
1167
  this._initOptions(options);
1454
- const { altitude = OPTIONS3.altitude } = options;
1168
+ const { altitude = OPTIONS2.altitude } = options;
1455
1169
  this.properties = { ...properties };
1456
1170
  this._createGroup();
1457
1171
  const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
1458
- const staticMaterial = new import_three4.MeshBasicMaterial({
1172
+ const staticMaterial = new import_three3.MeshBasicMaterial({
1459
1173
  transparent: true,
1460
1174
  color: lineColor || "#fff",
1461
1175
  opacity: lineOpacity || 1,
@@ -1463,12 +1177,12 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
1463
1177
  });
1464
1178
  const uniforms = {
1465
1179
  time: { value: 0 },
1466
- color: { value: new import_three4.Color(lineColor || "#fff") },
1180
+ color: { value: new import_three3.Color(lineColor || "#fff") },
1467
1181
  opacity: { value: lineOpacity || 1 }
1468
1182
  };
1469
1183
  this._uniforms = uniforms;
1470
1184
  this._t = 0;
1471
- const animatedMaterial = new import_three4.ShaderMaterial({
1185
+ const animatedMaterial = new import_three3.ShaderMaterial({
1472
1186
  uniforms,
1473
1187
  transparent: true,
1474
1188
  depthWrite: false,
@@ -1491,7 +1205,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
1491
1205
  }
1492
1206
  `
1493
1207
  });
1494
- const pathGeometry = maptalks3.GeoJSON.toGeometry(feature2);
1208
+ const pathGeometry = maptalks2.GeoJSON.toGeometry(feature2);
1495
1209
  const line = layer.toPath(
1496
1210
  pathGeometry,
1497
1211
  {
@@ -1502,7 +1216,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
1502
1216
  ENABLE_ANIMATED_PATH ? animatedMaterial : staticMaterial
1503
1217
  );
1504
1218
  const { color: outlineColor, opacity: outlineOpacity } = outlineOption || {};
1505
- const outlineMaterial = new import_three4.MeshBasicMaterial({
1219
+ const outlineMaterial = new import_three3.MeshBasicMaterial({
1506
1220
  transparent: true,
1507
1221
  color: outlineColor || "#fff",
1508
1222
  opacity: outlineOpacity || 1
@@ -1549,8 +1263,8 @@ var createPolygonFromLineString = (geometry) => {
1549
1263
  const right = (0, import_line_offset.default)(line, -0.3, { units: "meters" });
1550
1264
  const leftCoords = left.geometry.coordinates;
1551
1265
  const rightCoords = right.geometry.coordinates.reverse();
1552
- const polygon = [...leftCoords, ...rightCoords, leftCoords[0]];
1553
- return [polygon];
1266
+ const polygon2 = [...leftCoords, ...rightCoords, leftCoords[0]];
1267
+ return [polygon2];
1554
1268
  };
1555
1269
 
1556
1270
  // src/IndoorMap/utils/svg.ts
@@ -1584,14 +1298,14 @@ var createSVGPathFromMarkerSymbol = (style) => {
1584
1298
  markerFill,
1585
1299
  markerPath
1586
1300
  } = style;
1587
- const scale2 = markerWidth / 24;
1588
- return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${markerFill}"/>`;
1301
+ const scale3 = markerWidth / 24;
1302
+ return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
1589
1303
  };
1590
1304
 
1591
1305
  // src/IndoorMap/utils/createElements.js
1592
1306
  var GeometryType = {
1593
- Polygon: import_maptalks5.Polygon,
1594
- MultiPolygon: import_maptalks5.MultiPolygon
1307
+ Polygon: import_maptalks4.Polygon,
1308
+ MultiPolygon: import_maptalks4.MultiPolygon
1595
1309
  };
1596
1310
  var ORDINAL_HEIGHT = 0;
1597
1311
  var VENUE_Z_INDEX = 0;
@@ -1726,8 +1440,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
1726
1440
  if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
1727
1441
  if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
1728
1442
  if (geometry.type === "LineString") {
1729
- const polygon = createPolygonFromLineString(geometry);
1730
- return new GeometryType["Polygon"](polygon, {
1443
+ const polygon2 = createPolygonFromLineString(geometry);
1444
+ return new GeometryType["Polygon"](polygon2, {
1731
1445
  properties: {
1732
1446
  altitude: getAltitude(properties)
1733
1447
  },
@@ -1795,7 +1509,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
1795
1509
  const symbolStyle = { ...style };
1796
1510
  if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
1797
1511
  try {
1798
- return new import_maptalks5.LineString(geometry.coordinates, {
1512
+ return new import_maptalks4.LineString(geometry.coordinates, {
1799
1513
  properties: {
1800
1514
  altitude: getAltitude(properties)
1801
1515
  },
@@ -1812,7 +1526,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
1812
1526
  const symbolStyle = { ...style };
1813
1527
  if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
1814
1528
  try {
1815
- return new import_maptalks5.LineString(geometry.coordinates, {
1529
+ return new import_maptalks4.LineString(geometry.coordinates, {
1816
1530
  properties: {
1817
1531
  altitude: getAltitude(properties)
1818
1532
  },
@@ -1829,7 +1543,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
1829
1543
  const symbolStyle = { ...style };
1830
1544
  if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
1831
1545
  try {
1832
- return new import_maptalks5.LineString(geometry.coordinates, {
1546
+ return new import_maptalks4.LineString(geometry.coordinates, {
1833
1547
  properties: {
1834
1548
  id,
1835
1549
  feature_type: "opening",
@@ -1843,48 +1557,6 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
1843
1557
  console.log(`error creating pedestrian opening:`, feature2);
1844
1558
  }
1845
1559
  };
1846
- var loadModel3d = (model3d, coordinate, threeLayer) => {
1847
- return new Promise((resolve, reject) => {
1848
- const loader = new import_GLTFLoader.GLTFLoader();
1849
- const { url, properties: modelProperties } = model3d;
1850
- loader.load(
1851
- url,
1852
- (gltf) => {
1853
- const object3d = gltf.scene;
1854
- object3d.rotation.x = import_lodash4.default.get(modelProperties, "rotation.x");
1855
- object3d.rotation.y = import_lodash4.default.get(modelProperties, "rotation.y");
1856
- object3d.scale.set(...import_lodash4.default.get(modelProperties, "scale") || []);
1857
- const object = threeLayer.toModel(object3d, {
1858
- coordinate
1859
- });
1860
- object.getObject3d().traverse((child) => {
1861
- if (child.isMesh === true) {
1862
- child.material.transparent = true;
1863
- child.material.metalness = 0.1;
1864
- }
1865
- });
1866
- resolve(object);
1867
- },
1868
- (xhr) => {
1869
- },
1870
- (error) => {
1871
- reject(error);
1872
- }
1873
- );
1874
- });
1875
- };
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
1560
  var createExtrudePolygon = (geometry, threeLayer, material, height, properties = {}, options) => {
1889
1561
  const { offset = 0, altitude = 0 } = options;
1890
1562
  const offsetGeometry = (0, import_buffer.default)(geometry, offset, { units: "meters" });
@@ -1929,7 +1601,7 @@ var getFeatureMarkerConfig = (feature2, mapConfig = {}) => {
1929
1601
  };
1930
1602
  };
1931
1603
  var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
1932
- const material = new import_three5.SpriteMaterial();
1604
+ const material = new import_three4.SpriteMaterial();
1933
1605
  try {
1934
1606
  const [base, icon] = labelSymbol;
1935
1607
  const { markerWidth: baseWidth = 24 } = base;
@@ -1938,7 +1610,7 @@ var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
1938
1610
  const baseSVG = createSVGPathFromMarkerSymbol(base);
1939
1611
  const iconSVG = createSVGPathFromMarkerSymbol(icon);
1940
1612
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${viewBoxDimension}" height="${viewBoxDimension}">${baseSVG}${iconSVG}</svg>`;
1941
- const textureLoader = new import_three5.TextureLoader();
1613
+ const textureLoader = new import_three4.TextureLoader();
1942
1614
  const scaleFactor = 200 / 24;
1943
1615
  svgToPng(svg, scaleFactor).then((png) => {
1944
1616
  const texture = textureLoader.load(png, () => {
@@ -2095,7 +1767,7 @@ var styledFeatureGenerator = (mapTheme) => {
2095
1767
  switch (renderType) {
2096
1768
  case "Logo":
2097
1769
  import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
2098
- return new import_maptalks5.Marker(coordinates, {
1770
+ return new import_maptalks4.Marker(coordinates, {
2099
1771
  properties: {
2100
1772
  altitude: getAltitude(properties) + markerHeight,
2101
1773
  ...baseProperties
@@ -2103,7 +1775,7 @@ var styledFeatureGenerator = (mapTheme) => {
2103
1775
  symbol: priorityLabelSymbol
2104
1776
  });
2105
1777
  case "Logo + Name":
2106
- return new import_maptalks5.Marker(coordinates, {
1778
+ return new import_maptalks4.Marker(coordinates, {
2107
1779
  properties: {
2108
1780
  name: occupantName.en,
2109
1781
  altitude: getAltitude(properties) + markerHeight,
@@ -2123,7 +1795,7 @@ var styledFeatureGenerator = (mapTheme) => {
2123
1795
  }
2124
1796
  });
2125
1797
  case "None":
2126
- return new import_maptalks5.ui.UIMarker(coordinates, {
1798
+ return new import_maptalks4.ui.UIMarker(coordinates, {
2127
1799
  properties: { ...baseProperties },
2128
1800
  content: createStyledUIMarkerElement({
2129
1801
  style: { display: "none" },
@@ -2134,7 +1806,7 @@ var styledFeatureGenerator = (mapTheme) => {
2134
1806
  case "Name":
2135
1807
  default:
2136
1808
  if (textMarkerType === "marker") {
2137
- return new import_maptalks5.Marker(coordinates, {
1809
+ return new import_maptalks4.Marker(coordinates, {
2138
1810
  properties: {
2139
1811
  name: occupantName.en,
2140
1812
  altitude: getAltitude(properties) + markerHeight,
@@ -2164,7 +1836,7 @@ var styledFeatureGenerator = (mapTheme) => {
2164
1836
  `occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
2165
1837
  );
2166
1838
  const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
2167
- return new import_maptalks5.ui.UIMarker(coordinates, {
1839
+ return new import_maptalks4.ui.UIMarker(coordinates, {
2168
1840
  properties: { ...baseProperties },
2169
1841
  content: createStyledUIMarkerElement({
2170
1842
  style,
@@ -2241,7 +1913,7 @@ var styledFeatureGenerator = (mapTheme) => {
2241
1913
  const { geometry, properties } = feature2;
2242
1914
  const coordinates = getCenterFromGeometry(geometry);
2243
1915
  const markerSymbol = getElementSymbol("pin-marker");
2244
- return new import_maptalks5.Marker(coordinates, {
1916
+ return new import_maptalks4.Marker(coordinates, {
2245
1917
  properties: {
2246
1918
  altitude: getAltitude(properties)
2247
1919
  },
@@ -2256,7 +1928,7 @@ var styledFeatureGenerator = (mapTheme) => {
2256
1928
  const coordinates = getCenterFromGeometry(geometry);
2257
1929
  const markerSymbol = getElementSymbol("origin-marker");
2258
1930
  try {
2259
- return new import_maptalks5.Marker(coordinates, {
1931
+ return new import_maptalks4.Marker(coordinates, {
2260
1932
  properties: {
2261
1933
  altitude: getAltitude(properties)
2262
1934
  },
@@ -2278,7 +1950,7 @@ var styledFeatureGenerator = (mapTheme) => {
2278
1950
  const coordinates = getCenterFromGeometry(geometry);
2279
1951
  const symbol = getElementSymbol("pin-marker");
2280
1952
  try {
2281
- return new import_maptalks5.Marker(coordinates, {
1953
+ return new import_maptalks4.Marker(coordinates, {
2282
1954
  properties: {
2283
1955
  altitude: getAltitude(properties) + markerHeight
2284
1956
  },
@@ -2303,7 +1975,7 @@ var styledFeatureGenerator = (mapTheme) => {
2303
1975
  "highlighted-logo-marker"
2304
1976
  );
2305
1977
  try {
2306
- return new import_maptalks5.Marker(coordinates, {
1978
+ return new import_maptalks4.Marker(coordinates, {
2307
1979
  properties: {
2308
1980
  altitude: getAltitude(properties) + markerHeight
2309
1981
  },
@@ -2319,7 +1991,7 @@ var styledFeatureGenerator = (mapTheme) => {
2319
1991
  const { geometry, properties } = feature2;
2320
1992
  const coordinates = getCenterFromGeometry(geometry);
2321
1993
  const symbolStyle = getElementSymbol("user-location") || {};
2322
- const marker = new import_maptalks5.Marker(coordinates, {
1994
+ const marker = new import_maptalks4.Marker(coordinates, {
2323
1995
  properties: {
2324
1996
  altitude: getAltitude(properties),
2325
1997
  ordinal: properties.ordinal !== null ? properties.ordinal : null
@@ -2348,7 +2020,7 @@ var styledFeatureGenerator = (mapTheme) => {
2348
2020
  const coordinates = getCenterFromGeometry(geometry);
2349
2021
  const symbolStyle = getElementSymbol("last-user-location") || {};
2350
2022
  const options = getElementOptions("last-user-location") || {};
2351
- const marker = new import_maptalks5.Marker(coordinates, {
2023
+ const marker = new import_maptalks4.Marker(coordinates, {
2352
2024
  properties: {
2353
2025
  ...options,
2354
2026
  altitude: getAltitude(properties),
@@ -2380,14 +2052,14 @@ var styledFeatureGenerator = (mapTheme) => {
2380
2052
  const coordinates = import_lodash4.default.get(geometry, "coordinates");
2381
2053
  const logoUrl = import_lodash4.default.get(properties, "logo.url");
2382
2054
  if (markerSymbol) {
2383
- return new import_maptalks5.Marker(coordinates, {
2055
+ return new import_maptalks4.Marker(coordinates, {
2384
2056
  properties: markerProperties,
2385
2057
  symbol: markerSymbol
2386
2058
  });
2387
2059
  }
2388
2060
  if (!logoUrl) {
2389
2061
  const symbol = getElementSymbol("pin-marker");
2390
- return new import_maptalks5.Marker(coordinates, {
2062
+ return new import_maptalks4.Marker(coordinates, {
2391
2063
  properties: markerProperties,
2392
2064
  symbol
2393
2065
  });
@@ -2395,7 +2067,7 @@ var styledFeatureGenerator = (mapTheme) => {
2395
2067
  const labelSymbol = getLabelSymbol("highlight-occupant-logo");
2396
2068
  const priorityMarkerSymbol = import_lodash4.default.last(labelSymbol) || {};
2397
2069
  import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
2398
- return new import_maptalks5.Marker(coordinates, {
2070
+ return new import_maptalks4.Marker(coordinates, {
2399
2071
  properties: markerProperties,
2400
2072
  symbol: labelSymbol
2401
2073
  });
@@ -2412,7 +2084,7 @@ var styledFeatureGenerator = (mapTheme) => {
2412
2084
  const kioskHeight = import_lodash4.default.get(kioskConfig, "height", 0);
2413
2085
  const markerHeight = unitHeight + kioskHeight;
2414
2086
  const symbol = getElementSymbol("highlight-amenity-marker");
2415
- return new import_maptalks5.Marker(coordinates, {
2087
+ return new import_maptalks4.Marker(coordinates, {
2416
2088
  properties: {
2417
2089
  ...feature2,
2418
2090
  altitude: markerHeight
@@ -2489,24 +2161,24 @@ var styledFeatureGenerator = (mapTheme) => {
2489
2161
  switch (geometry.type) {
2490
2162
  case "Point":
2491
2163
  return [
2492
- geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks5.Coordinate(geometry.coordinates)
2164
+ geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.Coordinate(geometry.coordinates)
2493
2165
  ];
2494
2166
  case "Polygon":
2495
2167
  return [
2496
- geometry?.getCenter ? geometry?.getCenter() : new import_maptalks5.Polygon(geometry.coordinates).getCenter()
2168
+ geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.Polygon(geometry.coordinates).getCenter()
2497
2169
  ];
2498
2170
  case "MultiPolygon":
2499
2171
  return [
2500
- geometry?.getCenter ? geometry?.getCenter() : new import_maptalks5.MultiPolygon(geometry.coordinates).getCenter()
2172
+ geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.MultiPolygon(geometry.coordinates).getCenter()
2501
2173
  ];
2502
2174
  case "LineString":
2503
2175
  default:
2504
- return geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks5.LineString(geometry.coordinates).getCoordinates();
2176
+ return geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.LineString(geometry.coordinates).getCoordinates();
2505
2177
  }
2506
2178
  }).flatten().value();
2507
2179
  const stepPathLineSymbol = getElementSymbol("navigation-path");
2508
2180
  const startPathSymbolMarker = getElementSymbol("navigation-path-start");
2509
- const line = new import_maptalks5.LineString(mergedCoordinates, {
2181
+ const line = new import_maptalks4.LineString(mergedCoordinates, {
2510
2182
  smoothness: 0.5,
2511
2183
  symbol: [...stepPathLineSymbol, startPathSymbolMarker]
2512
2184
  });
@@ -2547,115 +2219,23 @@ var styledFeatureGenerator = (mapTheme) => {
2547
2219
  };
2548
2220
  switch (type) {
2549
2221
  case "Polygon":
2550
- return new import_maptalks5.Polygon(coordinates, formattedProperties);
2222
+ return new import_maptalks4.Polygon(coordinates, formattedProperties);
2551
2223
  case "MultiPolygon":
2552
- return new import_maptalks5.MultiPolygon(coordinates, formattedProperties);
2224
+ return new import_maptalks4.MultiPolygon(coordinates, formattedProperties);
2553
2225
  case "LineString":
2554
- return new import_maptalks5.LineString(coordinates, formattedProperties);
2226
+ return new import_maptalks4.LineString(coordinates, formattedProperties);
2555
2227
  case "MultiLineString":
2556
- return new import_maptalks5.MultiLineString(coordinates, formattedProperties);
2228
+ return new import_maptalks4.MultiLineString(coordinates, formattedProperties);
2557
2229
  default:
2558
2230
  return null;
2559
2231
  }
2560
2232
  },
2561
- /** Three JS */
2562
- create3DFootprint: async (feature2, threeLayer, options) => {
2563
- const objects = [];
2564
- const extrudeHeight = import_lodash4.default.get(options, "height");
2565
- if (!extrudeHeight) return objects;
2566
- const { properties } = feature2;
2567
- const footprintProperties = getFeatureProperties(feature2);
2568
- const hasModel3ds = Array.isArray(properties.model3d) && properties.model3d.length > 0;
2569
- if (hasModel3ds) {
2570
- const models = properties.model3d;
2571
- const center2 = (0, import_center2.default)(feature2);
2572
- const coordinate = import_lodash4.default.get(center2, "geometry.coordinates");
2573
- for (const model of models) {
2574
- const object = await loadModel3d(model, coordinate, threeLayer);
2575
- object.properties = footprintProperties;
2576
- objects.push(object);
2577
- }
2578
- } else {
2579
- const color = footprintProperties.defaultColor;
2580
- if (color === "transparent") return;
2581
- const material = new import_three5.MeshLambertMaterial({
2582
- color,
2583
- transparent: true
2584
- });
2585
- const object = createExtrudePolygon(
2586
- feature2.geometry,
2587
- threeLayer,
2588
- material,
2589
- extrudeHeight,
2590
- footprintProperties,
2591
- {}
2592
- );
2593
- objects.push(object);
2594
- }
2595
- return objects;
2596
- },
2597
- create3DGroundLabel: (label, threeLayer) => {
2598
- const text = label.properties.name;
2599
- const bound = label.geometry.coordinates[0];
2600
- if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
2601
- const groundLabelSymbol = getElementSymbol("ground-label");
2602
- const featureSymbol = import_lodash4.default.get(label, "properties", {});
2603
- const groundLabelOptions = import_lodash4.default.merge(
2604
- {},
2605
- { text },
2606
- groundLabelSymbol,
2607
- featureSymbol
2608
- );
2609
- return new GroundLabel(bound, groundLabelOptions, threeLayer);
2610
- },
2611
- createOccupantGroundLabel: (feature2, location, mapConfig, threeLayer) => {
2612
- const text = feature2.properties.name.en;
2613
- const bound = location.geometry.coordinates[0];
2614
- if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
2615
- const groundLabelSymbol = getElementSymbol("occupant-flat-label");
2616
- const groundLabelOptions = getElementOptions("occupant-flat-label");
2617
- const baseAltitude = getAltitude(location.properties);
2618
- const extrudeHeight = import_lodash4.default.get(
2619
- mapConfig,
2620
- "extrudeConfig.unit.room.height",
2621
- 0
2622
- );
2623
- const totalAltitude = baseAltitude + extrudeHeight + 0.05;
2624
- const customAngle = import_lodash4.default.get(feature2, "properties.style.angle");
2625
- const offsetX = import_lodash4.default.get(feature2, "properties.style.offsetX", 0);
2626
- const offsetY = import_lodash4.default.get(feature2, "properties.style.offsetY", 0);
2627
- const featureSymbol = {
2628
- name: text,
2629
- ordinal: location.properties.ordinal,
2630
- venue_id: feature2.properties.venue_id
2631
- };
2632
- const mergedGroundLabelOptions = import_lodash4.default.merge(
2633
- {},
2634
- { text },
2635
- groundLabelSymbol,
2636
- groundLabelOptions,
2637
- featureSymbol,
2638
- {
2639
- altitude: totalAltitude,
2640
- offsetX,
2641
- offsetY,
2642
- // set custom angle
2643
- ...!import_lodash4.default.isNil(customAngle) ? { angle: customAngle } : {}
2644
- }
2645
- );
2646
- const groundLabel = new GroundLabel(
2647
- bound,
2648
- mergedGroundLabelOptions,
2649
- threeLayer
2650
- );
2651
- return groundLabel;
2652
- },
2653
2233
  create3DBillboard: (billboard, threeLayer) => {
2654
2234
  const { id, feature_type, properties } = billboard;
2655
2235
  const {
2656
2236
  logo,
2657
2237
  altitude,
2658
- scale: scale2,
2238
+ scale: scale3,
2659
2239
  alphaTest,
2660
2240
  legColor,
2661
2241
  showLeg,
@@ -2669,7 +2249,7 @@ var styledFeatureGenerator = (mapTheme) => {
2669
2249
  };
2670
2250
  const options = {
2671
2251
  altitude,
2672
- scale: scale2,
2252
+ scale: scale3,
2673
2253
  alphaTest,
2674
2254
  legColor,
2675
2255
  showLeg,
@@ -2792,44 +2372,6 @@ var styledFeatureGenerator = (mapTheme) => {
2792
2372
  markerProperties
2793
2373
  );
2794
2374
  },
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
2375
  createExtrudedUnit: (unit, threeLayer, options) => {
2834
2376
  const extrudeHeight = import_lodash4.default.get(options, "height");
2835
2377
  if (!extrudeHeight) return;
@@ -2841,15 +2383,15 @@ var styledFeatureGenerator = (mapTheme) => {
2841
2383
  };
2842
2384
  const color = unitProperty.defaultColor;
2843
2385
  if (color === "transparent") return;
2844
- const material = new import_three5.MeshLambertMaterial({
2386
+ const material = new import_three4.MeshLambertMaterial({
2845
2387
  color,
2846
2388
  transparent: true
2847
2389
  });
2848
2390
  if (unit.geometry.type === "LineString") {
2849
- const polygon = createPolygonFromLineString(unit.geometry);
2391
+ const polygon2 = createPolygonFromLineString(unit.geometry);
2850
2392
  const geometry = {
2851
2393
  type: "Polygon",
2852
- coordinates: polygon
2394
+ coordinates: polygon2
2853
2395
  };
2854
2396
  return createExtrudePolygon(
2855
2397
  geometry,
@@ -2869,24 +2411,6 @@ var styledFeatureGenerator = (mapTheme) => {
2869
2411
  options3d
2870
2412
  );
2871
2413
  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
2414
  }
2891
2415
  };
2892
2416
  };
@@ -2969,9 +2493,9 @@ var getRelatedLocationsByAmenity = (feature2) => {
2969
2493
  var getRelatedLocationIdsByFeature = (feature2) => {
2970
2494
  switch (feature2?.feature_type) {
2971
2495
  case "amenity":
2972
- return getRelatedLocationsByAmenity(feature2).map((v) => v?.id);
2496
+ return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
2973
2497
  case "occupant":
2974
- return getRelatedLocationsByOccupant(feature2).map((v) => v?.id);
2498
+ return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
2975
2499
  default:
2976
2500
  return [];
2977
2501
  }
@@ -3016,48 +2540,134 @@ var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
3016
2540
  return newBearing;
3017
2541
  };
3018
2542
 
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);
2543
+ // src/IndoorMap/camera/CameraManager.ts
2544
+ var import_maptalks5 = require("maptalks");
2545
+
2546
+ // ../../node_modules/@turf/meta/dist/esm/index.js
2547
+ function coordEach(geojson, callback, excludeWrapCoord) {
2548
+ if (geojson === null) return;
2549
+ 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;
2550
+ for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
2551
+ geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
2552
+ isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
2553
+ stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
2554
+ for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
2555
+ var multiFeatureIndex = 0;
2556
+ var geometryIndex = 0;
2557
+ geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
2558
+ if (geometry === null) continue;
2559
+ coords = geometry.coordinates;
2560
+ var geomType = geometry.type;
2561
+ wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
2562
+ switch (geomType) {
2563
+ case null:
2564
+ break;
2565
+ case "Point":
2566
+ if (callback(
2567
+ coords,
2568
+ coordIndex,
2569
+ featureIndex,
2570
+ multiFeatureIndex,
2571
+ geometryIndex
2572
+ ) === false)
2573
+ return false;
2574
+ coordIndex++;
2575
+ multiFeatureIndex++;
2576
+ break;
2577
+ case "LineString":
2578
+ case "MultiPoint":
2579
+ for (j = 0; j < coords.length; j++) {
2580
+ if (callback(
2581
+ coords[j],
2582
+ coordIndex,
2583
+ featureIndex,
2584
+ multiFeatureIndex,
2585
+ geometryIndex
2586
+ ) === false)
2587
+ return false;
2588
+ coordIndex++;
2589
+ if (geomType === "MultiPoint") multiFeatureIndex++;
2590
+ }
2591
+ if (geomType === "LineString") multiFeatureIndex++;
2592
+ break;
2593
+ case "Polygon":
2594
+ case "MultiLineString":
2595
+ for (j = 0; j < coords.length; j++) {
2596
+ for (k = 0; k < coords[j].length - wrapShrink; k++) {
2597
+ if (callback(
2598
+ coords[j][k],
2599
+ coordIndex,
2600
+ featureIndex,
2601
+ multiFeatureIndex,
2602
+ geometryIndex
2603
+ ) === false)
2604
+ return false;
2605
+ coordIndex++;
2606
+ }
2607
+ if (geomType === "MultiLineString") multiFeatureIndex++;
2608
+ if (geomType === "Polygon") geometryIndex++;
2609
+ }
2610
+ if (geomType === "Polygon") multiFeatureIndex++;
2611
+ break;
2612
+ case "MultiPolygon":
2613
+ for (j = 0; j < coords.length; j++) {
2614
+ geometryIndex = 0;
2615
+ for (k = 0; k < coords[j].length; k++) {
2616
+ for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
2617
+ if (callback(
2618
+ coords[j][k][l],
2619
+ coordIndex,
2620
+ featureIndex,
2621
+ multiFeatureIndex,
2622
+ geometryIndex
2623
+ ) === false)
2624
+ return false;
2625
+ coordIndex++;
2626
+ }
2627
+ geometryIndex++;
2628
+ }
2629
+ multiFeatureIndex++;
2630
+ }
2631
+ break;
2632
+ case "GeometryCollection":
2633
+ for (j = 0; j < geometry.geometries.length; j++)
2634
+ if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
2635
+ return false;
2636
+ break;
2637
+ default:
2638
+ throw new Error("Unknown Geometry Type");
2639
+ }
2640
+ }
2641
+ }
2642
+ }
2643
+
2644
+ // ../../node_modules/@turf/bbox/dist/esm/index.js
2645
+ function bbox(geojson, options = {}) {
2646
+ if (geojson.bbox != null && true !== options.recompute) {
2647
+ return geojson.bbox;
2648
+ }
2649
+ const result = [Infinity, Infinity, -Infinity, -Infinity];
2650
+ coordEach(geojson, (coord) => {
2651
+ if (result[0] > coord[0]) {
2652
+ result[0] = coord[0];
2653
+ }
2654
+ if (result[1] > coord[1]) {
2655
+ result[1] = coord[1];
2656
+ }
2657
+ if (result[2] < coord[0]) {
2658
+ result[2] = coord[0];
2659
+ }
2660
+ if (result[3] < coord[1]) {
2661
+ result[3] = coord[1];
2662
+ }
3033
2663
  });
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
- };
2664
+ return result;
2665
+ }
2666
+ var index_default = bbox;
3057
2667
 
3058
2668
  // src/IndoorMap/camera/CameraManager.ts
3059
- var ZOOM_OUT_LEVEL = 21;
3060
- var ZOOM_IN_LEVEL = 24;
2669
+ var import_transform_scale = __toESM(require("@turf/transform-scale"));
2670
+ var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
3061
2671
  var CameraManager = class {
3062
2672
  map;
3063
2673
  constructor(map, options) {
@@ -3066,339 +2676,438 @@ var CameraManager = class {
3066
2676
  this.setView(options?.defaultView);
3067
2677
  }
3068
2678
  }
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
2679
  /** Public methods */
3086
2680
  getView = () => {
3087
2681
  return this.map.getView();
3088
2682
  };
3089
- getZoom = () => {
3090
- return this.map.getView().zoom;
3091
- };
3092
2683
  setView = (value) => {
3093
- this.map.setView(value);
2684
+ if (this.map && Object.keys(value).length !== 0) {
2685
+ this.map.setView(value);
2686
+ }
3094
2687
  };
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
- );
2688
+ animateTo = (view, options = {}, step) => {
2689
+ this.map.animateTo(view, options, step);
3113
2690
  };
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 }
2691
+ setMaxExtent(extent) {
2692
+ return this.map.setMaxExtent(extent);
2693
+ }
2694
+ getFeatureExtent = (feature2, scaleFactor = 1) => {
2695
+ const [minX, minY, maxX, maxY] = index_default(
2696
+ (0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
3128
2697
  );
2698
+ return new import_maptalks5.Extent(minX, minY, maxX, maxY);
2699
+ };
2700
+ getExtentZoom = (extent, options = {
2701
+ isFraction: false,
2702
+ padding: {
2703
+ paddingLeft: 0,
2704
+ paddingRight: 0,
2705
+ paddingTop: 0,
2706
+ paddingBottom: 0
2707
+ }
2708
+ }) => {
2709
+ const { isFraction = false, padding } = options;
2710
+ return this.map.getFitZoom(extent, isFraction, padding);
3129
2711
  };
2712
+ set maxZoom(value) {
2713
+ this.map.setMaxZoom(value);
2714
+ const spatialReference = {
2715
+ projection: "EPSG:3857",
2716
+ resolutions: (function() {
2717
+ const resolutions = [];
2718
+ const d = 2 * 6378137 * Math.PI;
2719
+ for (let i = 0; i < value; i++) {
2720
+ resolutions[i] = d / (256 * Math.pow(2, i));
2721
+ }
2722
+ return resolutions;
2723
+ })()
2724
+ };
2725
+ this.map.setSpatialReference(spatialReference);
2726
+ }
2727
+ set minZoom(value) {
2728
+ this.map.setMinZoom(value);
2729
+ }
3130
2730
  };
3131
2731
 
3132
2732
  // src/IndoorMap/renderer/RendererManager.ts
3133
- var import_min = __toESM(require("lodash/min"));
2733
+ var import_lodash_es4 = require("lodash-es");
3134
2734
  var import_center3 = require("@turf/center");
3135
- var import_maptalks8 = require("maptalks.three");
3136
2735
  var THREE3 = __toESM(require("three"));
3137
2736
 
3138
2737
  // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3139
- var maptalks4 = __toESM(require("maptalks"));
3140
- var THREE2 = __toESM(require("three"));
3141
- var import_GLTFLoader2 = require("three/examples/jsm/loaders/GLTFLoader");
3142
- var import_DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
2738
+ var maptalks4 = __toESM(require("maptalks-gl"));
2739
+ var THREE = __toESM(require("three"));
2740
+ var import_maptalks7 = require("maptalks.three");
3143
2741
  var import_buffer2 = __toESM(require("@turf/buffer"));
2742
+ var import_clean_coords = require("@turf/clean-coords");
2743
+ var import_polygon_to_line = require("@turf/polygon-to-line");
2744
+ var import_nearest_point_on_line = require("@turf/nearest-point-on-line");
2745
+ var import_length = require("@turf/length");
2746
+ var import_along = require("@turf/along");
2747
+ var import_point_to_line_distance = require("@turf/point-to-line-distance");
3144
2748
 
3145
- // src/IndoorMap/renderer/3d/element3DRendererOptions.ts
3146
- var element3DRendererOptions = {
3147
- unit: {
3148
- default: { color: "#ffffff", height: 4 },
3149
- byCategory: {
3150
- walkway: { color: "#cccccc", height: 0.1 },
3151
- terrace: { color: "#cccccc", height: 0.1 },
3152
- unenclosedarea: { color: "#cccccc", height: 0.2 },
3153
- nonpublic: { color: "#999999", height: 0.3 },
3154
- escalator: { height: 0.2 },
3155
- room: { color: "#ffffff", height: 2, bottomHeight: 0.12 }
3156
- }
3157
- },
3158
- kiosk: {
3159
- default: { color: "#666666", height: 0.6, bottomHeight: 0.12 }
3160
- },
3161
- fixture: {
3162
- default: { color: "#ffffff", height: 0.5 },
3163
- byCategory: {
3164
- water: { color: "#ACD7EC", height: 0.1 },
3165
- vegetation: { color: "#91C499", height: 0.5 }
3166
- }
3167
- }
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");
3175
-
3176
- // src/IndoorMap/renderer/utils/interpolateStops.ts
3177
- var interpolateStops = ({ stops }, zoom) => {
3178
- if (zoom <= stops[0][0]) return stops[0][1];
3179
- if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
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
- }
3187
- }
2749
+ // src/IndoorMap/renderer/3d/objects/GroundLabel.ts
2750
+ var maptalks3 = __toESM(require("maptalks-gl"));
2751
+ var import_maptalks6 = require("maptalks.three");
2752
+ var import_three5 = require("three");
2753
+ var import_d3plus_shape = require("d3plus-shape");
2754
+ var import_lodash_es3 = require("lodash-es");
2755
+ var OPTIONS3 = {
2756
+ // Allowing click through and prevent interaction
2757
+ interactive: false,
2758
+ altitude: 0
3188
2759
  };
3189
-
3190
- // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3191
- var OPTIONS4 = {
3192
- // Texture options
3193
- text: "",
2760
+ var defaultFlatLabelOptions = {
2761
+ fontSize: 14,
2762
+ fontFamily: "Manrope",
2763
+ fontWeight: 600,
2764
+ margin: 0,
2765
+ scaleMin: 0.5,
2766
+ lineHeight: 1.05,
2767
+ scaleStep: 0.05,
3194
2768
  textAlign: "center",
3195
- color: "#ffffff",
3196
- fontFamily: "sans-serif",
3197
- fontSize: 28,
3198
- fontWeight: 400,
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
2769
+ textBaseline: "middle",
2770
+ fillStyle: "#000"
3210
2771
  };
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";
2772
+ var defaultRectAngleToCalc = (0, import_lodash_es3.range)(-90, 92, 2);
2773
+ var getMaterial = (text, flatLabelOptions) => {
2774
+ const options = (0, import_lodash_es3.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
2775
+ const {
2776
+ fontSize: initialFontSize,
2777
+ fontFamily,
2778
+ fontWeight,
2779
+ margin,
2780
+ scaleMin,
2781
+ scaleStep,
2782
+ fillStyle,
2783
+ lineHeight,
2784
+ textAlign,
2785
+ strokeStyle,
2786
+ lineWidth,
2787
+ textBaseline
2788
+ } = options;
2789
+ const pixelMultiplier = 4;
2790
+ const SIZE = 100 * pixelMultiplier;
2791
+ const fontSize = initialFontSize * (pixelMultiplier * 1.25);
2792
+ const canvas = document.createElement("canvas");
2793
+ canvas.width = canvas.height = SIZE;
2794
+ const ctx = canvas.getContext("2d");
2795
+ ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
2796
+ ctx.textAlign = textAlign;
2797
+ ctx.textBaseline = textBaseline;
2798
+ ctx.fillStyle = fillStyle;
2799
+ ctx.strokeStyle = strokeStyle;
2800
+ ctx.lineWidth = lineWidth;
2801
+ const wrapText = (ctx2, text2, maxWidth) => {
2802
+ const words = text2.trim().split(/\s+/);
2803
+ if (words.length <= 1) return [text2];
2804
+ const lines = [];
2805
+ const MAX_LINES = 3;
2806
+ let currentLine = words[0];
2807
+ for (let i = 1; i < words.length; i++) {
2808
+ const lineToMeasure = currentLine + " " + words[i];
2809
+ if (ctx2.measureText(lineToMeasure).width > maxWidth) {
2810
+ lines.push(currentLine);
2811
+ currentLine = words[i];
2812
+ } else {
2813
+ currentLine = lineToMeasure;
2814
+ }
2815
+ }
2816
+ lines.push(currentLine);
2817
+ return lines.slice(0, MAX_LINES);
2818
+ };
2819
+ const hasManualBreaks = text.includes("\n");
2820
+ let texts;
2821
+ if (hasManualBreaks) {
2822
+ texts = text.split(/\n/g);
2823
+ } else {
2824
+ const maxWidth = SIZE - 2 * margin;
2825
+ texts = wrapText(ctx, text, maxWidth);
3224
2826
  }
3225
- getOptions() {
3226
- return super.getOptions();
2827
+ let textWidth = (0, import_lodash_es3.max)(texts.map((text2) => ctx.measureText(text2).width));
2828
+ let scale3 = 1;
2829
+ while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
2830
+ scale3 -= scaleStep;
2831
+ ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
2832
+ textWidth = (0, import_lodash_es3.max)(texts.map((text2) => ctx.measureText(text2).width));
3227
2833
  }
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
2834
+ const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
2835
+ if (scale3 > scaleMin) {
2836
+ const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
2837
+ const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
2838
+ texts.forEach((text2, index) => {
2839
+ const yOffset = startY + index * (fontSize * scale3 * lineHeight);
2840
+ if (strokeStyle && lineWidth) {
2841
+ ctx.strokeText(text2, center2.x, yOffset);
2842
+ }
2843
+ ctx.fillText(text2, center2.x, yOffset);
3235
2844
  });
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
2845
  }
3249
- _createTextTexture(text, options = {}) {
2846
+ const texture = new import_three5.Texture(canvas);
2847
+ texture.needsUpdate = true;
2848
+ const material = new import_three5.MeshPhongMaterial({
2849
+ map: texture,
2850
+ transparent: true,
2851
+ // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
2852
+ alphaTest: 0.3
2853
+ });
2854
+ return material;
2855
+ };
2856
+ var GroundLabel = class extends import_maptalks6.BaseObject {
2857
+ #angle = 0;
2858
+ #bearing = 0;
2859
+ #text = "";
2860
+ #offsetX = 0;
2861
+ #offsetY = 0;
2862
+ #originalPosition = null;
2863
+ #layer = null;
2864
+ constructor(bound, text, options, layer) {
2865
+ options = maptalks3.Util.extend({}, OPTIONS3, options, {
2866
+ layer,
2867
+ coordinate: bound
2868
+ });
3250
2869
  const {
3251
- padding,
2870
+ altitude = 0,
2871
+ bottomHeight = 0,
3252
2872
  fontSize,
2873
+ fillStyle,
2874
+ textAlign,
3253
2875
  fontFamily,
3254
- fontWeight,
3255
- lineHeight,
3256
- background,
3257
- color,
2876
+ textBaseline,
2877
+ strokeStyle,
2878
+ lineWidth,
2879
+ angle = defaultRectAngleToCalc,
2880
+ maxFontScale,
2881
+ offsetX = 0,
2882
+ offsetY = 0,
2883
+ ...properties
2884
+ } = options;
2885
+ super();
2886
+ this._initOptions(options);
2887
+ this.properties = properties;
2888
+ this.#offsetX = offsetX;
2889
+ this.#offsetY = offsetY;
2890
+ this.#layer = layer;
2891
+ const material = getMaterial(text, {
2892
+ fillStyle,
2893
+ fontSize,
3258
2894
  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
- }
2895
+ textBaseline,
2896
+ fontFamily,
2897
+ strokeStyle,
2898
+ lineWidth
3288
2899
  });
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);
2900
+ const rectAngles = (0, import_lodash_es3.isArray)(angle) ? angle : [angle];
2901
+ material.needsUpdate = true;
2902
+ const rect = (0, import_d3plus_shape.largestRect)(bound, {
2903
+ cache: true,
2904
+ /**
2905
+ * Black magic here:
2906
+ * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
2907
+ * So we remove -90 and 90 from choices, and use -85 & 85 instead.
2908
+ */
2909
+ angle: rectAngles
2910
+ });
2911
+ const { cx, cy, width, angle: calculatedAngle } = rect;
2912
+ this.#text = text;
2913
+ this.#angle = calculatedAngle;
2914
+ const geometry = new import_three5.PlaneGeometry(1, 1);
2915
+ this._createMesh(geometry, material);
2916
+ const z = layer.altitudeToVector3(altitude + bottomHeight, altitude + bottomHeight).x;
2917
+ const basePosition = layer.coordinateToVector3([cx, cy], z);
2918
+ this.#originalPosition = basePosition.clone();
2919
+ const finalPosition = this.#calculateFinalPosition(basePosition);
2920
+ const scale3 = width / 6456122659e-13;
2921
+ const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
2922
+ this.getObject3d().scale.set(finalScale, finalScale, finalScale);
2923
+ this.getObject3d().position.copy(finalPosition);
2924
+ this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
2925
+ }
2926
+ #calculateFinalPosition(basePosition) {
2927
+ if (this.#offsetX === 0 && this.#offsetY === 0) {
2928
+ return basePosition;
2929
+ }
2930
+ const offsetCoordinate = [this.#offsetX, this.#offsetY];
2931
+ const z = this.#layer.altitudeToVector3(0, 0).x;
2932
+ const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
2933
+ const zeroVector = this.#layer.coordinateToVector3([0, 0], z);
2934
+ const worldOffsetX = offsetVector.x - zeroVector.x;
2935
+ const worldOffsetY = offsetVector.y - zeroVector.y;
2936
+ return {
2937
+ x: basePosition.x + worldOffsetX,
2938
+ y: basePosition.y + worldOffsetY,
2939
+ z: basePosition.z
2940
+ };
2941
+ }
2942
+ #updatePosition() {
2943
+ if (this.#originalPosition && this.#layer) {
2944
+ const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
2945
+ this.getObject3d().position.copy(finalPosition);
3301
2946
  }
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
2947
  }
3323
- _updatePosition() {
3324
- const options = this.getOptions();
3325
- const layer = options.layer;
3326
- if (!layer) return;
3327
- const altitude = (options.altitude || 0) + this.#altitudeOffset;
3328
- const z = layer.altitudeToVector3(altitude, altitude).x;
3329
- const position = layer.coordinateToVector3(this._coordinate, z);
3330
- (0, import_lodash6.set)(this.properties, "default.position", position);
3331
- this.getObject3d().position.copy(position);
2948
+ set bearing(value) {
2949
+ this.#bearing = value;
2950
+ const degree = this.#angle + this.#bearing;
2951
+ const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
2952
+ this.getObject3d().rotation.z = Math.PI / 180 * angle;
3332
2953
  }
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;
2954
+ get angle() {
2955
+ return this.#angle;
2956
+ }
2957
+ get currentAngle() {
2958
+ return this.#angle;
2959
+ }
2960
+ get text() {
2961
+ return this.#text;
2962
+ }
2963
+ get offsetX() {
2964
+ return this.#offsetX;
2965
+ }
2966
+ get offsetY() {
2967
+ return this.#offsetY;
2968
+ }
2969
+ get offset() {
2970
+ return { x: this.#offsetX, y: this.#offsetY };
2971
+ }
2972
+ set offsetX(value) {
2973
+ if ((0, import_lodash_es3.isNumber)(value)) {
2974
+ this.#offsetX = value;
2975
+ this.#updatePosition();
3350
2976
  }
3351
2977
  }
3352
- setText(text) {
3353
- const options = this.getOptions();
3354
- options.text = text;
3355
- const newSprite = this._createSprite();
3356
- const group = this.getObject3d();
3357
- group.children.forEach((child) => group.remove(child));
3358
- group.add(newSprite);
3359
- this._updatePosition();
2978
+ set offsetY(value) {
2979
+ if ((0, import_lodash_es3.isNumber)(value)) {
2980
+ this.#offsetY = value;
2981
+ this.#updatePosition();
2982
+ }
2983
+ }
2984
+ set angle(newAngle) {
2985
+ if ((0, import_lodash_es3.isNumber)(newAngle)) {
2986
+ this.#angle = newAngle;
2987
+ this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
2988
+ }
2989
+ }
2990
+ setOffset(offsetX, offsetY) {
2991
+ if ((0, import_lodash_es3.isNumber)(offsetX) && (0, import_lodash_es3.isNumber)(offsetY)) {
2992
+ this.#offsetX = offsetX;
2993
+ this.#offsetY = offsetY;
2994
+ this.#updatePosition();
2995
+ }
2996
+ }
2997
+ addOffset(deltaX, deltaY) {
2998
+ if ((0, import_lodash_es3.isNumber)(deltaX) && (0, import_lodash_es3.isNumber)(deltaY)) {
2999
+ this.#offsetX += deltaX;
3000
+ this.#offsetY += deltaY;
3001
+ this.#updatePosition();
3002
+ }
3003
+ }
3004
+ resetOffset() {
3005
+ this.#offsetX = 0;
3006
+ this.#offsetY = 0;
3007
+ this.#updatePosition();
3008
+ }
3009
+ moveToPosition(targetX, targetY) {
3010
+ if (this.#originalPosition && this.#layer) {
3011
+ const currentCenter = this.#layer.vector3ToCoordinate(
3012
+ this.#originalPosition
3013
+ );
3014
+ this.#offsetX = targetX - currentCenter.x;
3015
+ this.#offsetY = targetY - currentCenter.y;
3016
+ this.#updatePosition();
3017
+ }
3018
+ }
3019
+ updateText(newText, options = {}) {
3020
+ this.#text = newText;
3021
+ const materialOptions = {
3022
+ fillStyle: options.fillStyle || this.properties.fillStyle,
3023
+ fontSize: options.fontSize || this.properties.fontSize,
3024
+ textAlign: options.textAlign || this.properties.textAlign,
3025
+ textBaseline: options.textBaseline || this.properties.textBaseline,
3026
+ fontFamily: options.fontFamily || this.properties.fontFamily,
3027
+ strokeStyle: options.strokeStyle || this.properties.strokeStyle,
3028
+ lineWidth: options.lineWidth || this.properties.lineWidth
3029
+ };
3030
+ const newMaterial = getMaterial(newText, materialOptions);
3031
+ this.getObject3d().material = newMaterial;
3032
+ newMaterial.needsUpdate = true;
3360
3033
  }
3034
+ _animation() {
3035
+ const map = this.getMap();
3036
+ if (!map) return;
3037
+ const bearing = map.getBearing();
3038
+ this.bearing = bearing;
3039
+ }
3040
+ // Add bottomHeight to altitude as final altitude position
3361
3041
  setAltitude(altitude) {
3362
3042
  const bottomHeight = this.options.bottomHeight ?? 0;
3363
- return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
3043
+ return super.setAltitude(altitude + bottomHeight);
3364
3044
  }
3365
3045
  };
3366
3046
 
3367
- // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3047
+ // src/IndoorMap/renderer/3d/element3DRendererOptions.ts
3048
+ var element3DRendererOptions = {
3049
+ unit: {
3050
+ default: { color: "#ffffff", height: 0.2 },
3051
+ byCategory: {
3052
+ walkway: { color: "#cccccc", height: 0.1 },
3053
+ terrace: { color: "#cccccc", height: 0.1 },
3054
+ unenclosedarea: { color: "#cccccc", height: 0.2 },
3055
+ nonpublic: { color: "#999999", height: 0.3 },
3056
+ escalator: { height: 0.2 },
3057
+ parking: { color: "#999999", height: 0.1 },
3058
+ room: { color: "#ffffff", height: 0.5, bottomHeight: 0.12 }
3059
+ }
3060
+ },
3061
+ kiosk: {
3062
+ default: { color: "#666666", height: 0.6, bottomHeight: 0.12 }
3063
+ },
3064
+ fixture: {
3065
+ default: { color: "#ffffff", height: 0.5 },
3066
+ byCategory: {
3067
+ water: { color: "#ACD7EC", height: 0.1 },
3068
+ vegetation: { color: "#91C499", height: 0.5 },
3069
+ wall: { color: "#787878", topColor: "#ffffff", height: 4.2, width: 1 }
3070
+ }
3071
+ }
3072
+ };
3073
+
3074
+ // src/IndoorMap/renderer/3d/utils/get3DRendererOption.ts
3368
3075
  var DEFAULT_POLYGON_OPTION = {
3369
3076
  color: "#FFFFFF",
3370
3077
  offset: 0,
3371
3078
  altitude: 0
3372
3079
  };
3373
- var HEIGHT_METER = 4;
3374
- var MULTIORDINAL_HEIGHT_METER = 9;
3375
- var getGeometryOption = (feature2, options) => {
3080
+ var get3DRendererOption = (featureType, category, options) => {
3376
3081
  try {
3377
- const option = options[feature2.feature_type] ?? element3DRendererOptions[feature2.feature_type];
3378
- const category = feature2.properties.category;
3082
+ const option = options[featureType] ?? element3DRendererOptions[featureType];
3379
3083
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
3380
3084
  } catch (err) {
3381
- console.log(err.message, { options, feature: feature2 });
3085
+ console.log(err.message, { options, featureType, category });
3382
3086
  }
3383
3087
  };
3088
+
3089
+ // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3090
+ var import_line_split = __toESM(require("@turf/line-split"));
3091
+ var HEIGHT_METER = 4;
3092
+ var MULTIORDINAL_HEIGHT_METER = 9;
3384
3093
  var Element3DRenderer = class extends EventTarget {
3385
3094
  options;
3386
3095
  map;
3096
+ gltfLayer;
3387
3097
  threeLayer;
3388
- dracoLoader;
3098
+ scene;
3389
3099
  lineMaterial;
3390
3100
  materialByColorMap;
3391
- markerRenderer;
3392
3101
  // Renderer is Ready
3393
3102
  isReady = false;
3394
- constructor(map, options, layer) {
3103
+ constructor(map, options) {
3395
3104
  super();
3396
3105
  this.options = options;
3397
3106
  this.map = map;
3398
- this.dracoLoader = new import_DRACOLoader.DRACOLoader();
3399
- this.dracoLoader.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/");
3400
- this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
3401
- this.threeLayer = layer;
3107
+ const groupLayer = this.map.getLayer("group");
3108
+ this.threeLayer = groupLayer.getLayer("three");
3109
+ this.gltfLayer = groupLayer.getLayer("gltf");
3110
+ this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
3402
3111
  this.render();
3403
3112
  }
3404
3113
  animation() {
@@ -3413,7 +3122,7 @@ var Element3DRenderer = class extends EventTarget {
3413
3122
  if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
3414
3123
  const existingMaterial = this.materialByColorMap.get(color);
3415
3124
  if (existingMaterial) return existingMaterial;
3416
- const created = new THREE2.MeshLambertMaterial({ color, transparent: true });
3125
+ const created = new THREE.MeshLambertMaterial({ color, transparent: true });
3417
3126
  created.toneMapped = false;
3418
3127
  this.materialByColorMap.set(color, created);
3419
3128
  return created;
@@ -3425,49 +3134,65 @@ var Element3DRenderer = class extends EventTarget {
3425
3134
  bottomHeight: bottomHeightOptions,
3426
3135
  color: colorOptions,
3427
3136
  ...options
3428
- } = getGeometryOption(feature2, this.options);
3137
+ } = get3DRendererOption(feature2.feature_type, feature2.properties.category, this.options);
3429
3138
  const _this = this;
3430
3139
  const createPolygon = (geometry, feature3) => {
3431
- const [outerRing, ...innerRings] = geometry.coordinates;
3432
- const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
3433
- const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
3434
- if (color === "transparent") return;
3435
- const material = this.getOrCreateMaterialByColor(color);
3436
- const altitude = feature3.properties.ordinal * HEIGHT_METER;
3437
- const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
3438
- const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
3439
- const extrudedPolygon = this.threeLayer.toExtrudePolygon(
3440
- offsetFeature,
3441
- { asynchronous: true, ...options, height, bottomHeight, altitude },
3442
- material
3443
- );
3444
- extrudedPolygon.on("click", (e) => {
3445
- console.log(e.target.options.polygon.id);
3446
- });
3447
- const topLineStrings = [
3448
- new maptalks4.LineString(outerRing),
3449
- ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3450
- ];
3451
- const topLines = this.threeLayer.toLines(
3452
- topLineStrings,
3453
- { altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
3454
- this.lineMaterial
3455
- );
3456
- const bottomLineStrings = [
3457
- new maptalks4.LineString(outerRing),
3458
- ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3459
- ];
3460
- const bottomLines = this.threeLayer.toLines(
3461
- bottomLineStrings,
3462
- { altitude, bottomHeight, interactive: false },
3463
- this.lineMaterial
3464
- );
3465
- return [extrudedPolygon, topLines, bottomLines];
3140
+ try {
3141
+ const [outerRing, ...innerRings] = geometry.coordinates;
3142
+ const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
3143
+ const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
3144
+ if (color === "transparent") return;
3145
+ const material = this.getOrCreateMaterialByColor(color);
3146
+ const altitude = 0;
3147
+ const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
3148
+ const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
3149
+ const extrudedPolygon = this.threeLayer.toExtrudePolygon(
3150
+ offsetFeature,
3151
+ { asynchronous: true, ...options, height, bottomHeight, altitude },
3152
+ material
3153
+ );
3154
+ const topLineStrings = [
3155
+ new maptalks4.LineString(outerRing),
3156
+ ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3157
+ ];
3158
+ const topLines = this.threeLayer.toLines(
3159
+ topLineStrings,
3160
+ { altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
3161
+ this.lineMaterial
3162
+ );
3163
+ const bottomLineStrings = [
3164
+ new maptalks4.LineString(outerRing),
3165
+ ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3166
+ ];
3167
+ const bottomLines = this.threeLayer.toLines(
3168
+ bottomLineStrings,
3169
+ { altitude, bottomHeight, interactive: false },
3170
+ this.lineMaterial
3171
+ );
3172
+ return [extrudedPolygon, topLines, bottomLines];
3173
+ } catch (err) {
3174
+ return [];
3175
+ }
3176
+ };
3177
+ const createLineString = (geometry, feature3) => {
3178
+ try {
3179
+ const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#000000";
3180
+ const material = this.getOrCreateMaterialByColor(color);
3181
+ const extrudedLine = this.threeLayer.toExtrudeLine(
3182
+ new maptalks4.LineString(geometry.coordinates),
3183
+ { height: heightOptions, ...options },
3184
+ material
3185
+ );
3186
+ return [extrudedLine];
3187
+ } catch (err) {
3188
+ return [];
3189
+ }
3466
3190
  };
3467
3191
  try {
3468
3192
  switch (feature2.geometry.type) {
3469
3193
  case "MultiPolygon": {
3470
3194
  const { coordinates } = feature2.geometry;
3195
+ if (!coordinates) return [];
3471
3196
  const multiMeshes = coordinates.flatMap((polygonCoordinates) => {
3472
3197
  const meshes = createPolygon({ type: "Polygon", coordinates: polygonCoordinates }, feature2);
3473
3198
  this.threeLayer.addMesh(meshes);
@@ -3476,70 +3201,126 @@ var Element3DRenderer = class extends EventTarget {
3476
3201
  return multiMeshes;
3477
3202
  }
3478
3203
  case "Polygon": {
3204
+ const { coordinates } = feature2.geometry;
3205
+ if (!coordinates) return [];
3479
3206
  const meshes = createPolygon(feature2.geometry, feature2);
3480
3207
  this.threeLayer.addMesh(meshes);
3481
3208
  return meshes;
3482
3209
  }
3210
+ case "LineString": {
3211
+ const { coordinates } = feature2.geometry;
3212
+ if (!coordinates) return [];
3213
+ const meshes = createLineString(feature2.geometry, feature2);
3214
+ this.threeLayer.addMesh(meshes);
3215
+ return meshes;
3216
+ }
3483
3217
  }
3484
3218
  } catch (err) {
3485
- console.log(`error createGeometry`, { feature: feature2, options });
3219
+ console.log(`error createGeometry`, err, { feature: feature2, options });
3486
3220
  }
3487
3221
  };
3222
+ createRoomWall(unit, openings = []) {
3223
+ const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
3224
+ return polygons.map((plg) => {
3225
+ return plg.map((ring) => {
3226
+ const roomWall = (0, import_clean_coords.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
3227
+ if (openings.length === 0) {
3228
+ const color = "#ababab";
3229
+ const material = this.getOrCreateMaterialByColor(color);
3230
+ const extrudedWall = this.threeLayer.toExtrudeLine(
3231
+ new maptalks4.LineString(roomWall.geometry.coordinates),
3232
+ { height: 4, width: 1 },
3233
+ material
3234
+ );
3235
+ return extrudedWall;
3236
+ }
3237
+ let openingPoints = [];
3238
+ openings.forEach((opening) => {
3239
+ const doorCoords = opening?.geometry?.coordinates;
3240
+ const p0 = point(doorCoords[0]);
3241
+ const p1 = point(doorCoords[doorCoords.length - 1]);
3242
+ const s0 = (0, import_nearest_point_on_line.nearestPointOnLine)(roomWall, p0, { units: "meters" });
3243
+ const s1 = (0, import_nearest_point_on_line.nearestPointOnLine)(roomWall, p1, { units: "meters" });
3244
+ const d0 = s0.properties.dist;
3245
+ const d1 = s1.properties.dist;
3246
+ if (d0 > 1 || d1 > 1) {
3247
+ } else {
3248
+ openingPoints = openingPoints.concat([s0.geometry.coordinates, s1.geometry.coordinates]);
3249
+ }
3250
+ });
3251
+ try {
3252
+ const split = (0, import_line_split.default)(roomWall, multiPoint(openingPoints));
3253
+ const wallsOnly = split.features.filter((seg) => {
3254
+ const mid = (0, import_along.along)(seg, (0, import_length.length)(seg, { units: "meters" }) / 2, { units: "meters" });
3255
+ for (const opening of openings) {
3256
+ const dist = (0, import_point_to_line_distance.pointToLineDistance)(mid, opening, { units: "meters" });
3257
+ if (dist < 0.05) return false;
3258
+ }
3259
+ return true;
3260
+ });
3261
+ const wallMeshes = wallsOnly.map((feature2, i) => {
3262
+ const color = "#ababab";
3263
+ const material = this.getOrCreateMaterialByColor(color);
3264
+ const extrudedLine = this.threeLayer.toExtrudeLine(
3265
+ new maptalks4.LineString(feature2.geometry.coordinates),
3266
+ { height: 3, width: 0.4, id: unit.id },
3267
+ material
3268
+ );
3269
+ extrudedLine.getObject3d().userData = {
3270
+ unitId: unit.id,
3271
+ coords: feature2.geometry.coordinates
3272
+ };
3273
+ return extrudedLine;
3274
+ }).flat();
3275
+ this.threeLayer.addMesh(wallMeshes);
3276
+ return wallMeshes;
3277
+ } catch (e) {
3278
+ console.log(e.message, { unit, roomWall });
3279
+ return [];
3280
+ }
3281
+ }).flat();
3282
+ }).flat();
3283
+ }
3488
3284
  async createEscalator(f, coordinate, options) {
3285
+ const model = {
3286
+ url: "https://cdn.venue.in.th/static/glb/escalator.glb",
3287
+ size: 4.4
3288
+ };
3489
3289
  const { direction: dir, angle } = options;
3490
- const model = await this.loadModel3d({
3491
- url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb",
3492
- properties: {
3493
- rotation: {
3494
- x: 0.5 * Math.PI,
3495
- // Rotate the model up (new_escalator.glb)
3496
- y: 0,
3497
- z: 0
3498
- },
3499
- position: { x: 0, y: 0, z: 0 },
3500
- scale: 0.01
3290
+ const rotationZ = dir === "up" ? 180 + angle : angle;
3291
+ var escalatorMarker = new maptalks4.GLTFMarker(coordinate, {
3292
+ symbol: {
3293
+ url: model.url,
3294
+ rotationZ,
3295
+ translationX: dir === "up" ? 0 : model.size * Math.cos(Math.PI * rotationZ / 180),
3296
+ translationY: dir === "up" ? 0 : model.size * Math.sin(Math.PI * rotationZ / 180),
3297
+ translationZ: dir === "up" ? -0.05 * model.size : -0.5 * model.size
3501
3298
  }
3502
3299
  });
3503
- model.rotation.y += dir === "up" ? Math.PI + angle : angle;
3504
- const box = new THREE2.Box3().setFromObject(model);
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;
3521
- }
3522
- async createTree(coordinate, ordinal) {
3523
- const model = await this.loadModel3d({
3524
- url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/arbol.glb",
3525
- properties: {
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
3300
+ escalatorMarker.addTo(this.gltfLayer);
3301
+ return escalatorMarker;
3302
+ }
3303
+ // Note: Move to another renderer and keep this file on Geometry only?
3304
+ createGroundLabel(f, unit) {
3305
+ const text = f.properties.name;
3306
+ const bound = f.geometry.coordinates[0];
3307
+ const { height: unitHeight } = get3DRendererOption("unit", unit.properties.category, this.options);
3308
+ const options = { bottomHeight: unitHeight + 5e-3 };
3309
+ const groundLabel = new GroundLabel(bound, text, options, this.threeLayer);
3310
+ this.threeLayer.addMesh(groundLabel);
3311
+ return groundLabel;
3312
+ }
3313
+ async createModel3d(f) {
3314
+ const marker = new maptalks4.GLTFMarker(f.properties.center, {
3315
+ symbol: {
3316
+ url: f.properties.model
3534
3317
  }
3535
3318
  });
3536
- const altitude = ordinal * HEIGHT_METER;
3537
- const baseObjectModel = this.threeLayer.toModel(model, {
3538
- coordinate,
3539
- altitude
3540
- });
3541
- this.threeLayer.addMesh(baseObjectModel);
3542
- return baseObjectModel;
3319
+ marker.addTo(this.gltfLayer);
3320
+ return marker;
3321
+ }
3322
+ async createBuilding(coordinate, ordinal) {
3323
+ return Promise.resolve(null);
3543
3324
  }
3544
3325
  createElement(f) {
3545
3326
  switch (f.feature_type) {
@@ -3562,34 +3343,35 @@ var Element3DRenderer = class extends EventTarget {
3562
3343
  }
3563
3344
  });
3564
3345
  }
3565
- async loadModel3d(model3d) {
3566
- const loader = new import_GLTFLoader2.GLTFLoader();
3567
- loader.setDRACOLoader(this.dracoLoader);
3568
- const { url, properties: modelProperties } = model3d;
3569
- const gltf = await loader.loadAsync(url);
3570
- const model = gltf.scene;
3571
- model.rotation.x = modelProperties.rotation.x;
3572
- model.rotation.y = modelProperties.rotation.y;
3573
- model.position.x = modelProperties.position.x;
3574
- model.position.y = modelProperties.position.y;
3575
- model.position.z = modelProperties.position.z;
3576
- const scale2 = modelProperties.scale;
3577
- model.scale.set(scale2, scale2, scale2);
3578
- return model;
3579
- }
3580
- createMarker = (coordinates, ordinal, text) => {
3581
- const options = {
3582
- // scale: 0.05,
3583
- // altitude: ordinal * HEIGHT_METER,
3584
- text
3585
- // interactive: true,
3586
- };
3587
- const marker = new TextSpriteMarker(coordinates, options, this.threeLayer);
3588
- this.threeLayer.addMesh([marker]);
3589
- return marker;
3590
- };
3591
- removeMarker = () => {
3592
- };
3346
+ createHighlightController(element) {
3347
+ if (!(element instanceof import_maptalks7.BaseObject)) {
3348
+ return null;
3349
+ }
3350
+ switch (element.type) {
3351
+ case "ExtrudePolygon":
3352
+ case "ExtrudeLine": {
3353
+ const mesh = element.getObject3d();
3354
+ const originalMaterial = mesh.material;
3355
+ const highlightMaterial = this.getOrCreateMaterialByColor("#ff0000");
3356
+ return {
3357
+ start: () => {
3358
+ mesh.material = highlightMaterial;
3359
+ },
3360
+ clear: () => {
3361
+ mesh.material = originalMaterial;
3362
+ }
3363
+ };
3364
+ }
3365
+ default: {
3366
+ return {
3367
+ start() {
3368
+ },
3369
+ clear() {
3370
+ }
3371
+ };
3372
+ }
3373
+ }
3374
+ }
3593
3375
  render() {
3594
3376
  this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
3595
3377
  if (this.threeLayer._needsUpdate) {
@@ -3648,7 +3430,7 @@ var getGeometryProperties = (feature2) => ({
3648
3430
  category: feature2.properties.category,
3649
3431
  name: feature2.properties.name?.en
3650
3432
  });
3651
- var getGeometryOption2 = (feature2, options) => {
3433
+ var getGeometryOption = (feature2, options) => {
3652
3434
  try {
3653
3435
  const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
3654
3436
  const category = feature2.properties.category;
@@ -3675,7 +3457,7 @@ var Element2DRenderer = class extends EventTarget {
3675
3457
  }
3676
3458
  createGeometry = (imdfFeature) => {
3677
3459
  const feature2 = getGeometryProperties(imdfFeature);
3678
- const { symbol, ...options } = getGeometryOption2(imdfFeature, this.options);
3460
+ const { symbol, ...options } = getGeometryOption(imdfFeature, this.options);
3679
3461
  const altitude = feature2.properties.ordinal * 10;
3680
3462
  const geometry = maptalks5.Geometry.fromJSON({
3681
3463
  feature: feature2,
@@ -3694,10 +3476,18 @@ var Element2DRenderer = class extends EventTarget {
3694
3476
  return geometry;
3695
3477
  }
3696
3478
  };
3479
+ createRoomWall(unit, openings) {
3480
+ return null;
3481
+ }
3697
3482
  async createEscalator(f, coordinates) {
3698
3483
  return Promise.resolve(null);
3699
3484
  }
3700
- async createTree(f, coordinates) {
3485
+ createGroundLabel(f, unit) {
3486
+ const text = f.properties.name;
3487
+ const bound = f.geometry.coordinates[0];
3488
+ return null;
3489
+ }
3490
+ async createBuilding(coordinate, ordinal) {
3701
3491
  return Promise.resolve(null);
3702
3492
  }
3703
3493
  createElement = (imdfFeature) => {
@@ -3717,6 +3507,15 @@ var Element2DRenderer = class extends EventTarget {
3717
3507
  element.hide();
3718
3508
  });
3719
3509
  }
3510
+ createHighlightController(element) {
3511
+ if (!(element instanceof maptalks5.Geometry)) return null;
3512
+ return {
3513
+ start() {
3514
+ },
3515
+ clear() {
3516
+ }
3517
+ };
3518
+ }
3720
3519
  };
3721
3520
 
3722
3521
  // src/IndoorMap/renderer/2d/Marker2DRenderer.ts
@@ -3727,6 +3526,7 @@ var Marker2DRenderer = class extends EventTarget {
3727
3526
  markerLayer;
3728
3527
  constructor(map) {
3729
3528
  super();
3529
+ this.map = map;
3730
3530
  }
3731
3531
  createMarker = (coordinates, ordinal, content) => {
3732
3532
  const marker = new maptalks6.ui.UIMarker(coordinates, {
@@ -3747,74 +3547,204 @@ var Marker2DRenderer = class extends EventTarget {
3747
3547
  }
3748
3548
  };
3749
3549
 
3750
- // src/IndoorMap/renderer/3d/Marker3DRenderer.ts
3751
- var maptalks7 = __toESM(require("maptalks"));
3752
-
3753
- // src/IndoorMap/renderer/utils/svg2material.ts
3754
- var import_three7 = require("three");
3755
- var svgToDataURL = (svgString, scaleFactor = 1) => {
3756
- const svgBlob = new Blob([svgString], { type: "image/svg+xml" });
3757
- const url = URL.createObjectURL(svgBlob);
3758
- const img = new Image();
3759
- return new Promise((resolve, reject) => {
3760
- img.onload = function() {
3761
- const newWidth = img.width * scaleFactor;
3762
- const newHeight = img.height * scaleFactor;
3763
- const canvas = document.createElement("canvas");
3764
- canvas.width = newWidth;
3765
- canvas.height = newHeight;
3766
- const ctx = canvas.getContext("2d");
3767
- ctx.drawImage(img, 0, 0, newWidth, newHeight);
3768
- const pngDataUrl = canvas.toDataURL("image/png");
3769
- resolve(pngDataUrl);
3770
- };
3771
- img.onerror = function(error) {
3772
- reject(error);
3773
- };
3774
- img.src = url;
3775
- });
3550
+ // src/IndoorMap/renderer/3d/Marker3DRenderer.ts
3551
+ var maptalks7 = __toESM(require("maptalks-gl"));
3552
+
3553
+ // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3554
+ var import_maptalks8 = require("maptalks");
3555
+ var THREE2 = __toESM(require("three"));
3556
+ var import_maptalks9 = require("maptalks.three");
3557
+ var import_lodash5 = require("lodash");
3558
+
3559
+ // src/IndoorMap/renderer/utils/interpolateStops.ts
3560
+ var interpolateStops = ({ stops }, zoom) => {
3561
+ if (zoom <= stops[0][0]) return stops[0][1];
3562
+ if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
3563
+ for (let i = 0; i < stops.length - 1; i++) {
3564
+ const [z1, v1] = stops[i];
3565
+ const [z2, v2] = stops[i + 1];
3566
+ if (zoom >= z1 && zoom <= z2) {
3567
+ const t = (zoom - z1) / (z2 - z1);
3568
+ return v1 + t * (v2 - v1);
3569
+ }
3570
+ }
3571
+ };
3572
+
3573
+ // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3574
+ var OPTIONS4 = {
3575
+ // Texture options
3576
+ text: "",
3577
+ textAlign: "center",
3578
+ color: "#ffffff",
3579
+ fontFamily: "sans-serif",
3580
+ fontSize: 28,
3581
+ fontWeight: 400,
3582
+ background: "transparent",
3583
+ lineHeight: 32,
3584
+ padding: 8,
3585
+ strokeColor: "#000000",
3586
+ strokeWidth: 3,
3587
+ strokeStyle: "round",
3588
+ // Sprite options
3589
+ /* Overall scale multiplier */
3590
+ scale: 1,
3591
+ altitude: 0,
3592
+ opacity: 1
3776
3593
  };
3777
- var createSVGPathFromMarkerSymbol2 = (style) => {
3778
- const {
3779
- markerWidth = 24,
3780
- markerDx = 0,
3781
- markerDy = 0,
3782
- // markerFill,
3783
- markerPath,
3784
- fill = "#000000"
3785
- } = style;
3786
- const scale2 = markerWidth / 24;
3787
- const strokeWidth = 2;
3788
- const halfStrokeWidth = 0.5 * strokeWidth;
3789
- if (Array.isArray(markerPath)) {
3790
- return markerPath.map(
3791
- ({ path, fill: fill2 }) => `<path d="${path}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill2}" stroke="#ffffff" stroke-width="${strokeWidth}" />`
3594
+ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
3595
+ #altitudeOffset = 0;
3596
+ constructor(coordinate, options, layer, properties = {}) {
3597
+ options = import_maptalks8.Util.extend({}, OPTIONS4, options, { layer });
3598
+ super();
3599
+ this._coordinate = new import_maptalks8.Coordinate(coordinate);
3600
+ this._initOptions(options);
3601
+ this._createGroup();
3602
+ this.properties = { ...properties };
3603
+ const sprite = this._createSprite();
3604
+ this.getObject3d().add(sprite);
3605
+ this._updatePosition();
3606
+ this.type = "TextSpriteMarker";
3607
+ }
3608
+ getOptions() {
3609
+ return super.getOptions();
3610
+ }
3611
+ _createSprite() {
3612
+ const options = this.getOptions();
3613
+ const texture = this._createTextTexture(options.text, options);
3614
+ const material = new THREE2.SpriteMaterial({
3615
+ map: texture,
3616
+ transparent: true,
3617
+ alphaTest: 0.1
3618
+ });
3619
+ const sprite = new THREE2.Sprite(material);
3620
+ const w = texture.image.width;
3621
+ const h = texture.image.height;
3622
+ const base = 1 / 16;
3623
+ const normalizedScale = options.scale / this.getMap().getGLRes();
3624
+ sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
3625
+ this.#altitudeOffset = Math.max(
3626
+ h * base * options.scale * 0.5,
3627
+ 0.05
3628
+ // minimum lift in world units
3792
3629
  );
3630
+ return sprite;
3793
3631
  }
3794
- return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill}" />`;
3795
- };
3796
- var createSpriteMaterialByLabelSymbol2 = (labelSymbol) => {
3797
- const material = new import_three7.SpriteMaterial();
3798
- try {
3799
- const [base, icon] = labelSymbol ?? [{}, {}];
3800
- const { markerWidth: baseWidth = 24 } = base;
3801
- const { markerWidth: iconWidth = 24 } = icon;
3802
- const viewBoxDimension = Math.max(baseWidth, iconWidth);
3803
- const baseSVG = createSVGPathFromMarkerSymbol2(base);
3804
- const iconSVG = icon ? createSVGPathFromMarkerSymbol2(icon) : "";
3805
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${viewBoxDimension}" height="${viewBoxDimension}">${baseSVG}${iconSVG}</svg>`;
3806
- const textureLoader = new import_three7.TextureLoader();
3807
- const scaleFactor = 200 / 24;
3808
- svgToDataURL(svg, scaleFactor).then((png) => {
3809
- const texture = textureLoader.load(png, () => {
3810
- material.map = texture;
3811
- material.needsUpdate = true;
3632
+ _createTextTexture(text, options = {}) {
3633
+ const {
3634
+ padding,
3635
+ fontSize,
3636
+ fontFamily,
3637
+ fontWeight,
3638
+ lineHeight,
3639
+ background,
3640
+ color,
3641
+ textAlign,
3642
+ strokeColor,
3643
+ strokeWidth,
3644
+ maxWidth
3645
+ } = options || {};
3646
+ const canvas = document.createElement("canvas");
3647
+ const ctx = canvas.getContext("2d");
3648
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3649
+ const paragraphs = String(text).split("\n");
3650
+ const wrappedLines = [];
3651
+ paragraphs.forEach((paragraph) => {
3652
+ if ((0, import_lodash5.isNil)(maxWidth) || isNaN(maxWidth)) {
3653
+ wrappedLines.push(paragraph);
3654
+ return;
3655
+ }
3656
+ const words = paragraph.split(/\s+/);
3657
+ let currentLine = "";
3658
+ words.forEach((word) => {
3659
+ const testLine = currentLine ? currentLine + " " + word : word;
3660
+ const testWidth = ctx.measureText(testLine).width;
3661
+ if (testWidth > maxWidth && currentLine) {
3662
+ wrappedLines.push(currentLine);
3663
+ currentLine = word;
3664
+ } else {
3665
+ currentLine = testLine;
3666
+ }
3812
3667
  });
3668
+ if (currentLine) {
3669
+ wrappedLines.push(currentLine);
3670
+ }
3813
3671
  });
3814
- } catch (error) {
3815
- console.warn(`Error createSpriteMaterialByLabelSymbol: `, labelSymbol);
3672
+ const lines = wrappedLines.length ? wrappedLines : [""];
3673
+ const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
3674
+ const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
3675
+ const finalHeight = lineHeight * lines.length + padding * 2;
3676
+ canvas.width = finalWidth;
3677
+ canvas.height = finalHeight;
3678
+ const ctx2 = canvas.getContext("2d");
3679
+ ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3680
+ ctx2.textAlign = textAlign;
3681
+ if (background && background !== "transparent") {
3682
+ ctx2.fillStyle = background;
3683
+ ctx2.fillRect(0, 0, canvas.width, canvas.height);
3684
+ }
3685
+ lines.forEach((line, i) => {
3686
+ const y = padding + lineHeight * (i + 0.8);
3687
+ let x = padding;
3688
+ if (textAlign === "center") x = canvas.width / 2;
3689
+ if (textAlign === "right" || textAlign === "end")
3690
+ x = canvas.width - padding;
3691
+ if (strokeWidth > 0) {
3692
+ ctx2.lineWidth = strokeWidth;
3693
+ ctx2.lineJoin = "round";
3694
+ ctx2.miterLimit = 2;
3695
+ ctx2.strokeStyle = strokeColor;
3696
+ ctx2.strokeText(line, x, y);
3697
+ }
3698
+ ctx2.fillStyle = color;
3699
+ ctx2.fillText(line, x, y);
3700
+ });
3701
+ const texture = new THREE2.CanvasTexture(canvas);
3702
+ texture.needsUpdate = true;
3703
+ texture.minFilter = THREE2.LinearFilter;
3704
+ return texture;
3705
+ }
3706
+ _updatePosition() {
3707
+ const options = this.getOptions();
3708
+ const layer = options.layer;
3709
+ if (!layer) return;
3710
+ const altitude = (options.altitude || 0) + this.#altitudeOffset;
3711
+ const z = layer.altitudeToVector3(altitude, altitude).x;
3712
+ const position = layer.coordinateToVector3(this._coordinate, z);
3713
+ (0, import_lodash5.set)(this.properties, "default.position", position);
3714
+ this.getObject3d().position.copy(position);
3715
+ }
3716
+ _animation() {
3717
+ const layer = this.getLayer();
3718
+ if (!this.isAdd || !layer) return;
3719
+ if (this._visible === true) {
3720
+ const zoom = layer.map.getZoom();
3721
+ const object3d = this.getObject3d();
3722
+ const { opacity } = this.getOptions();
3723
+ let opacityValue;
3724
+ if (typeof opacity === "number") {
3725
+ opacityValue = opacity ?? 1;
3726
+ } else if (Array.isArray(opacity.stops)) {
3727
+ opacityValue = interpolateStops(opacity, zoom);
3728
+ } else {
3729
+ throw new Error(`Unknown opacity value ${opacity}`);
3730
+ }
3731
+ const visible = opacityValue > 0.5;
3732
+ object3d.visible = visible;
3733
+ }
3734
+ }
3735
+ setText(text) {
3736
+ const options = this.getOptions();
3737
+ options.text = text;
3738
+ const newSprite = this._createSprite();
3739
+ const group = this.getObject3d();
3740
+ group.children.forEach((child) => group.remove(child));
3741
+ group.add(newSprite);
3742
+ this._updatePosition();
3743
+ }
3744
+ setAltitude(altitude) {
3745
+ const bottomHeight = this.options.bottomHeight ?? 0;
3746
+ return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
3816
3747
  }
3817
- return material;
3818
3748
  };
3819
3749
 
3820
3750
  // src/IndoorMap/renderer/3d/Marker3DRenderer.ts
@@ -3864,67 +3794,547 @@ var Marker3DRenderer = class extends EventTarget {
3864
3794
  }
3865
3795
  });
3866
3796
  }
3867
- /** Marker */
3868
- getOrCreateIconMaterial(key) {
3869
- if (!this.materialByKey) this.materialByKey = /* @__PURE__ */ new Map();
3870
- const existingMaterial = this.materialByKey.get(key);
3871
- if (existingMaterial) return existingMaterial;
3872
- const baseSymbol = {
3873
- markerType: "path",
3874
- markerPath: [
3875
- {
3876
- path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3877
- fill: "#ff0000"
3878
- }
3879
- ],
3880
- markerPathWidth: 24,
3881
- markerPathHeight: 24
3882
- };
3883
- const markerSymbol = {
3884
- markerType: "path",
3885
- markerPath: [],
3886
- // TODO: Get Path by featureType.category
3887
- // 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" }],
3888
- markerPathWidth: 24,
3889
- markerPathHeight: 24,
3890
- markerWidth: 24,
3891
- markerHeight: 24,
3892
- markerDy: 1.5,
3893
- markerDx: 1.5
3894
- };
3895
- const created = createSpriteMaterialByLabelSymbol2([
3896
- baseSymbol,
3897
- markerSymbol
3898
- ]);
3899
- this.materialByKey.set(key, created);
3900
- return created;
3797
+ /** Marker */
3798
+ // getOrCreateIconMaterial(key) {
3799
+ // if (!this.materialByKey) this.materialByKey = new Map()
3800
+ // const existingMaterial = this.materialByKey.get(key)
3801
+ // if (existingMaterial) return existingMaterial
3802
+ // // Create new
3803
+ // const baseSymbol: maptalks.Path = {
3804
+ // markerType: "path",
3805
+ // markerPath: [
3806
+ // {
3807
+ // path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3808
+ // fill: "#ff0000",
3809
+ // },
3810
+ // ],
3811
+ // markerPathWidth: 24,
3812
+ // markerPathHeight: 24
3813
+ // }
3814
+ // const markerSymbol: maptalks.PathMarkerSymbol = {
3815
+ // markerType: "path",
3816
+ // markerPath: [],
3817
+ // // TODO: Get Path by featureType.category
3818
+ // // 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" }],
3819
+ // markerPathWidth: 24,
3820
+ // markerPathHeight: 24,
3821
+ // markerWidth: 24,
3822
+ // markerHeight: 24,
3823
+ // markerDy: 1.5,
3824
+ // markerDx: 1.5,
3825
+ // }
3826
+ // const created = createSpriteMaterialByLabelSymbol([
3827
+ // baseSymbol,
3828
+ // markerSymbol,
3829
+ // ])
3830
+ // this.materialByKey.set(key, created)
3831
+ // return created
3832
+ // }
3833
+ };
3834
+
3835
+ // src/IndoorMap/renderer/utils/angleBetweenLineString.ts
3836
+ var getLineCenter = (line) => {
3837
+ let x = 0, y = 0;
3838
+ for (const [lx, ly] of line) {
3839
+ x += lx;
3840
+ y += ly;
3841
+ }
3842
+ const len = line.length;
3843
+ return [x / len, y / len];
3844
+ };
3845
+ var angleBetweenLineStrings = (line1, line2) => {
3846
+ const [x1, y1] = getLineCenter(line1);
3847
+ const [x2, y2] = getLineCenter(line2);
3848
+ const dx = x2 - x1;
3849
+ const dy = y2 - y1;
3850
+ return Math.atan2(dy, dx);
3851
+ };
3852
+
3853
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
3854
+ var epsilon = 11102230246251565e-32;
3855
+ var splitter = 134217729;
3856
+ var resulterrbound = (3 + 8 * epsilon) * epsilon;
3857
+ function sum(elen, e, flen, f, h) {
3858
+ let Q, Qnew, hh, bvirt;
3859
+ let enow = e[0];
3860
+ let fnow = f[0];
3861
+ let eindex = 0;
3862
+ let findex = 0;
3863
+ if (fnow > enow === fnow > -enow) {
3864
+ Q = enow;
3865
+ enow = e[++eindex];
3866
+ } else {
3867
+ Q = fnow;
3868
+ fnow = f[++findex];
3869
+ }
3870
+ let hindex = 0;
3871
+ if (eindex < elen && findex < flen) {
3872
+ if (fnow > enow === fnow > -enow) {
3873
+ Qnew = enow + Q;
3874
+ hh = Q - (Qnew - enow);
3875
+ enow = e[++eindex];
3876
+ } else {
3877
+ Qnew = fnow + Q;
3878
+ hh = Q - (Qnew - fnow);
3879
+ fnow = f[++findex];
3880
+ }
3881
+ Q = Qnew;
3882
+ if (hh !== 0) {
3883
+ h[hindex++] = hh;
3884
+ }
3885
+ while (eindex < elen && findex < flen) {
3886
+ if (fnow > enow === fnow > -enow) {
3887
+ Qnew = Q + enow;
3888
+ bvirt = Qnew - Q;
3889
+ hh = Q - (Qnew - bvirt) + (enow - bvirt);
3890
+ enow = e[++eindex];
3891
+ } else {
3892
+ Qnew = Q + fnow;
3893
+ bvirt = Qnew - Q;
3894
+ hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3895
+ fnow = f[++findex];
3896
+ }
3897
+ Q = Qnew;
3898
+ if (hh !== 0) {
3899
+ h[hindex++] = hh;
3900
+ }
3901
+ }
3902
+ }
3903
+ while (eindex < elen) {
3904
+ Qnew = Q + enow;
3905
+ bvirt = Qnew - Q;
3906
+ hh = Q - (Qnew - bvirt) + (enow - bvirt);
3907
+ enow = e[++eindex];
3908
+ Q = Qnew;
3909
+ if (hh !== 0) {
3910
+ h[hindex++] = hh;
3911
+ }
3912
+ }
3913
+ while (findex < flen) {
3914
+ Qnew = Q + fnow;
3915
+ bvirt = Qnew - Q;
3916
+ hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3917
+ fnow = f[++findex];
3918
+ Q = Qnew;
3919
+ if (hh !== 0) {
3920
+ h[hindex++] = hh;
3921
+ }
3922
+ }
3923
+ if (Q !== 0 || hindex === 0) {
3924
+ h[hindex++] = Q;
3925
+ }
3926
+ return hindex;
3927
+ }
3928
+ function estimate(elen, e) {
3929
+ let Q = e[0];
3930
+ for (let i = 1; i < elen; i++) Q += e[i];
3931
+ return Q;
3932
+ }
3933
+ function vec(n) {
3934
+ return new Float64Array(n);
3935
+ }
3936
+
3937
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
3938
+ var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
3939
+ var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
3940
+ var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
3941
+ var B = vec(4);
3942
+ var C1 = vec(8);
3943
+ var C2 = vec(12);
3944
+ var D = vec(16);
3945
+ var u = vec(4);
3946
+ function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
3947
+ let acxtail, acytail, bcxtail, bcytail;
3948
+ let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
3949
+ const acx = ax - cx;
3950
+ const bcx = bx - cx;
3951
+ const acy = ay - cy;
3952
+ const bcy = by - cy;
3953
+ s1 = acx * bcy;
3954
+ c = splitter * acx;
3955
+ ahi = c - (c - acx);
3956
+ alo = acx - ahi;
3957
+ c = splitter * bcy;
3958
+ bhi = c - (c - bcy);
3959
+ blo = bcy - bhi;
3960
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
3961
+ t1 = acy * bcx;
3962
+ c = splitter * acy;
3963
+ ahi = c - (c - acy);
3964
+ alo = acy - ahi;
3965
+ c = splitter * bcx;
3966
+ bhi = c - (c - bcx);
3967
+ blo = bcx - bhi;
3968
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
3969
+ _i = s0 - t0;
3970
+ bvirt = s0 - _i;
3971
+ B[0] = s0 - (_i + bvirt) + (bvirt - t0);
3972
+ _j = s1 + _i;
3973
+ bvirt = _j - s1;
3974
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
3975
+ _i = _0 - t1;
3976
+ bvirt = _0 - _i;
3977
+ B[1] = _0 - (_i + bvirt) + (bvirt - t1);
3978
+ u32 = _j + _i;
3979
+ bvirt = u32 - _j;
3980
+ B[2] = _j - (u32 - bvirt) + (_i - bvirt);
3981
+ B[3] = u32;
3982
+ let det = estimate(4, B);
3983
+ let errbound = ccwerrboundB * detsum;
3984
+ if (det >= errbound || -det >= errbound) {
3985
+ return det;
3986
+ }
3987
+ bvirt = ax - acx;
3988
+ acxtail = ax - (acx + bvirt) + (bvirt - cx);
3989
+ bvirt = bx - bcx;
3990
+ bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
3991
+ bvirt = ay - acy;
3992
+ acytail = ay - (acy + bvirt) + (bvirt - cy);
3993
+ bvirt = by - bcy;
3994
+ bcytail = by - (bcy + bvirt) + (bvirt - cy);
3995
+ if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
3996
+ return det;
3997
+ }
3998
+ errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
3999
+ det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
4000
+ if (det >= errbound || -det >= errbound) return det;
4001
+ s1 = acxtail * bcy;
4002
+ c = splitter * acxtail;
4003
+ ahi = c - (c - acxtail);
4004
+ alo = acxtail - ahi;
4005
+ c = splitter * bcy;
4006
+ bhi = c - (c - bcy);
4007
+ blo = bcy - bhi;
4008
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4009
+ t1 = acytail * bcx;
4010
+ c = splitter * acytail;
4011
+ ahi = c - (c - acytail);
4012
+ alo = acytail - ahi;
4013
+ c = splitter * bcx;
4014
+ bhi = c - (c - bcx);
4015
+ blo = bcx - bhi;
4016
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4017
+ _i = s0 - t0;
4018
+ bvirt = s0 - _i;
4019
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4020
+ _j = s1 + _i;
4021
+ bvirt = _j - s1;
4022
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
4023
+ _i = _0 - t1;
4024
+ bvirt = _0 - _i;
4025
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4026
+ u32 = _j + _i;
4027
+ bvirt = u32 - _j;
4028
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4029
+ u[3] = u32;
4030
+ const C1len = sum(4, B, 4, u, C1);
4031
+ s1 = acx * bcytail;
4032
+ c = splitter * acx;
4033
+ ahi = c - (c - acx);
4034
+ alo = acx - ahi;
4035
+ c = splitter * bcytail;
4036
+ bhi = c - (c - bcytail);
4037
+ blo = bcytail - bhi;
4038
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4039
+ t1 = acy * bcxtail;
4040
+ c = splitter * acy;
4041
+ ahi = c - (c - acy);
4042
+ alo = acy - ahi;
4043
+ c = splitter * bcxtail;
4044
+ bhi = c - (c - bcxtail);
4045
+ blo = bcxtail - bhi;
4046
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4047
+ _i = s0 - t0;
4048
+ bvirt = s0 - _i;
4049
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4050
+ _j = s1 + _i;
4051
+ bvirt = _j - s1;
4052
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
4053
+ _i = _0 - t1;
4054
+ bvirt = _0 - _i;
4055
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4056
+ u32 = _j + _i;
4057
+ bvirt = u32 - _j;
4058
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4059
+ u[3] = u32;
4060
+ const C2len = sum(C1len, C1, 4, u, C2);
4061
+ s1 = acxtail * bcytail;
4062
+ c = splitter * acxtail;
4063
+ ahi = c - (c - acxtail);
4064
+ alo = acxtail - ahi;
4065
+ c = splitter * bcytail;
4066
+ bhi = c - (c - bcytail);
4067
+ blo = bcytail - bhi;
4068
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4069
+ t1 = acytail * bcxtail;
4070
+ c = splitter * acytail;
4071
+ ahi = c - (c - acytail);
4072
+ alo = acytail - ahi;
4073
+ c = splitter * bcxtail;
4074
+ bhi = c - (c - bcxtail);
4075
+ blo = bcxtail - bhi;
4076
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4077
+ _i = s0 - t0;
4078
+ bvirt = s0 - _i;
4079
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4080
+ _j = s1 + _i;
4081
+ bvirt = _j - s1;
4082
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
4083
+ _i = _0 - t1;
4084
+ bvirt = _0 - _i;
4085
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4086
+ u32 = _j + _i;
4087
+ bvirt = u32 - _j;
4088
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4089
+ u[3] = u32;
4090
+ const Dlen = sum(C2len, C2, 4, u, D);
4091
+ return D[Dlen - 1];
4092
+ }
4093
+ function orient2d(ax, ay, bx, by, cx, cy) {
4094
+ const detleft = (ay - cy) * (bx - cx);
4095
+ const detright = (ax - cx) * (by - cy);
4096
+ const det = detleft - detright;
4097
+ const detsum = Math.abs(detleft + detright);
4098
+ if (Math.abs(det) >= ccwerrboundA * detsum) return det;
4099
+ return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
4100
+ }
4101
+
4102
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
4103
+ var o3derrboundA = (7 + 56 * epsilon) * epsilon;
4104
+ var o3derrboundB = (3 + 28 * epsilon) * epsilon;
4105
+ var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
4106
+ var bc = vec(4);
4107
+ var ca = vec(4);
4108
+ var ab = vec(4);
4109
+ var at_b = vec(4);
4110
+ var at_c = vec(4);
4111
+ var bt_c = vec(4);
4112
+ var bt_a = vec(4);
4113
+ var ct_a = vec(4);
4114
+ var ct_b = vec(4);
4115
+ var bct = vec(8);
4116
+ var cat = vec(8);
4117
+ var abt = vec(8);
4118
+ var u2 = vec(4);
4119
+ var _8 = vec(8);
4120
+ var _8b = vec(8);
4121
+ var _16 = vec(8);
4122
+ var _12 = vec(12);
4123
+ var fin = vec(192);
4124
+ var fin2 = vec(192);
4125
+
4126
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
4127
+ var iccerrboundA = (10 + 96 * epsilon) * epsilon;
4128
+ var iccerrboundB = (4 + 48 * epsilon) * epsilon;
4129
+ var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
4130
+ var bc2 = vec(4);
4131
+ var ca2 = vec(4);
4132
+ var ab2 = vec(4);
4133
+ var aa = vec(4);
4134
+ var bb = vec(4);
4135
+ var cc = vec(4);
4136
+ var u3 = vec(4);
4137
+ var v = vec(4);
4138
+ var axtbc = vec(8);
4139
+ var aytbc = vec(8);
4140
+ var bxtca = vec(8);
4141
+ var bytca = vec(8);
4142
+ var cxtab = vec(8);
4143
+ var cytab = vec(8);
4144
+ var abt2 = vec(8);
4145
+ var bct2 = vec(8);
4146
+ var cat2 = vec(8);
4147
+ var abtt = vec(4);
4148
+ var bctt = vec(4);
4149
+ var catt = vec(4);
4150
+ var _82 = vec(8);
4151
+ var _162 = vec(16);
4152
+ var _16b = vec(16);
4153
+ var _16c = vec(16);
4154
+ var _32 = vec(32);
4155
+ var _32b = vec(32);
4156
+ var _48 = vec(48);
4157
+ var _64 = vec(64);
4158
+ var fin3 = vec(1152);
4159
+ var fin22 = vec(1152);
4160
+
4161
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
4162
+ var isperrboundA = (16 + 224 * epsilon) * epsilon;
4163
+ var isperrboundB = (5 + 72 * epsilon) * epsilon;
4164
+ var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
4165
+ var ab3 = vec(4);
4166
+ var bc3 = vec(4);
4167
+ var cd = vec(4);
4168
+ var de = vec(4);
4169
+ var ea = vec(4);
4170
+ var ac = vec(4);
4171
+ var bd = vec(4);
4172
+ var ce = vec(4);
4173
+ var da = vec(4);
4174
+ var eb = vec(4);
4175
+ var abc = vec(24);
4176
+ var bcd = vec(24);
4177
+ var cde = vec(24);
4178
+ var dea = vec(24);
4179
+ var eab = vec(24);
4180
+ var abd = vec(24);
4181
+ var bce = vec(24);
4182
+ var cda = vec(24);
4183
+ var deb = vec(24);
4184
+ var eac = vec(24);
4185
+ var adet = vec(1152);
4186
+ var bdet = vec(1152);
4187
+ var cdet = vec(1152);
4188
+ var ddet = vec(1152);
4189
+ var edet = vec(1152);
4190
+ var abdet = vec(2304);
4191
+ var cddet = vec(2304);
4192
+ var cdedet = vec(3456);
4193
+ var deter = vec(5760);
4194
+ var _83 = vec(8);
4195
+ var _8b2 = vec(8);
4196
+ var _8c = vec(8);
4197
+ var _163 = vec(16);
4198
+ var _24 = vec(24);
4199
+ var _482 = vec(48);
4200
+ var _48b = vec(48);
4201
+ var _96 = vec(96);
4202
+ var _192 = vec(192);
4203
+ var _384x = vec(384);
4204
+ var _384y = vec(384);
4205
+ var _384z = vec(384);
4206
+ var _768 = vec(768);
4207
+ var xdet = vec(96);
4208
+ var ydet = vec(96);
4209
+ var zdet = vec(96);
4210
+ var fin4 = vec(1152);
4211
+
4212
+ // ../../node_modules/point-in-polygon-hao/dist/esm/index.js
4213
+ function pointInPolygon(p, polygon2) {
4214
+ var i;
4215
+ var ii;
4216
+ var k = 0;
4217
+ var f;
4218
+ var u1;
4219
+ var v1;
4220
+ var u22;
4221
+ var v2;
4222
+ var currentP;
4223
+ var nextP;
4224
+ var x = p[0];
4225
+ var y = p[1];
4226
+ var numContours = polygon2.length;
4227
+ for (i = 0; i < numContours; i++) {
4228
+ ii = 0;
4229
+ var contour = polygon2[i];
4230
+ var contourLen = contour.length - 1;
4231
+ currentP = contour[0];
4232
+ if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
4233
+ throw new Error("First and last coordinates in a ring must be the same");
4234
+ }
4235
+ u1 = currentP[0] - x;
4236
+ v1 = currentP[1] - y;
4237
+ for (ii; ii < contourLen; ii++) {
4238
+ nextP = contour[ii + 1];
4239
+ u22 = nextP[0] - x;
4240
+ v2 = nextP[1] - y;
4241
+ if (v1 === 0 && v2 === 0) {
4242
+ if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
4243
+ return 0;
4244
+ }
4245
+ } else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
4246
+ f = orient2d(u1, u22, v1, v2, 0, 0);
4247
+ if (f === 0) {
4248
+ return 0;
4249
+ }
4250
+ if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
4251
+ k++;
4252
+ }
4253
+ }
4254
+ currentP = nextP;
4255
+ v1 = v2;
4256
+ u1 = u22;
4257
+ }
4258
+ }
4259
+ if (k % 2 === 0) {
4260
+ return false;
4261
+ }
4262
+ return true;
4263
+ }
4264
+
4265
+ // ../../node_modules/@turf/invariant/dist/esm/index.js
4266
+ function getCoord(coord) {
4267
+ if (!coord) {
4268
+ throw new Error("coord is required");
4269
+ }
4270
+ if (!Array.isArray(coord)) {
4271
+ if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
4272
+ return [...coord.geometry.coordinates];
4273
+ }
4274
+ if (coord.type === "Point") {
4275
+ return [...coord.coordinates];
4276
+ }
4277
+ }
4278
+ if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
4279
+ return [...coord];
3901
4280
  }
3902
- };
4281
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
4282
+ }
4283
+ function getGeom(geojson) {
4284
+ if (geojson.type === "Feature") {
4285
+ return geojson.geometry;
4286
+ }
4287
+ return geojson;
4288
+ }
3903
4289
 
3904
- // src/IndoorMap/renderer/utils/angleBetweenLineString.ts
3905
- var getLineCenter = (line) => {
3906
- let x = 0, y = 0;
3907
- for (const [lx, ly] of line) {
3908
- x += lx;
3909
- y += ly;
4290
+ // ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
4291
+ function booleanPointInPolygon(point2, polygon2, options = {}) {
4292
+ if (!point2) {
4293
+ throw new Error("point is required");
4294
+ }
4295
+ if (!polygon2) {
4296
+ throw new Error("polygon is required");
4297
+ }
4298
+ const pt = getCoord(point2);
4299
+ const geom = getGeom(polygon2);
4300
+ const type = geom.type;
4301
+ const bbox2 = polygon2.bbox;
4302
+ let polys = geom.coordinates;
4303
+ if (bbox2 && inBBox(pt, bbox2) === false) {
4304
+ return false;
4305
+ }
4306
+ if (type === "Polygon") {
4307
+ polys = [polys];
4308
+ }
4309
+ let result = false;
4310
+ for (var i = 0; i < polys.length; ++i) {
4311
+ const polyResult = pointInPolygon(pt, polys[i]);
4312
+ if (polyResult === 0) return options.ignoreBoundary ? false : true;
4313
+ else if (polyResult) result = true;
3910
4314
  }
3911
- const len = line.length;
3912
- return [x / len, y / len];
3913
- };
3914
- var angleBetweenLineStrings = (line1, line2) => {
3915
- const [x1, y1] = getLineCenter(line1);
3916
- const [x2, y2] = getLineCenter(line2);
3917
- const dx = x2 - x1;
3918
- const dy = y2 - y1;
3919
- return Math.atan2(dy, dx);
4315
+ return result;
4316
+ }
4317
+ function inBBox(pt, bbox2) {
4318
+ return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
4319
+ }
4320
+
4321
+ // src/IndoorMap/renderer/utils/findUnitOnPoint.ts
4322
+ var findUnitOnPoint = (units, point2) => {
4323
+ return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
3920
4324
  };
3921
4325
 
3922
4326
  // src/IndoorMap/renderer/RendererManager.ts
4327
+ function delay(ms) {
4328
+ return new Promise((resolve) => setTimeout(resolve, ms));
4329
+ }
3923
4330
  var RendererManager = class extends EventTarget {
3924
4331
  map;
3925
4332
  options;
3926
4333
  // Client for fetching data
3927
4334
  #dataClient;
4335
+ #isClicked = false;
4336
+ #onClickElement = (e) => {
4337
+ };
3928
4338
  /** Elements: Responsible for converting feature info elements and add to map */
3929
4339
  elementRenderer;
3930
4340
  markerRenderer;
@@ -3933,6 +4343,7 @@ var RendererManager = class extends EventTarget {
3933
4343
  currentOrdinals;
3934
4344
  markersMap;
3935
4345
  markersByOrdinal;
4346
+ highlightControllers = [];
3936
4347
  constructor(map, dataClient, options) {
3937
4348
  super();
3938
4349
  this.map = map;
@@ -3942,48 +4353,87 @@ var RendererManager = class extends EventTarget {
3942
4353
  this.markersMap = /* @__PURE__ */ new Map();
3943
4354
  this.markersByOrdinal = /* @__PURE__ */ new Map();
3944
4355
  this.#dataClient = dataClient;
4356
+ const _this = this;
3945
4357
  if (options.type === "3D") {
3946
- const threeLayer = new import_maptalks8.ThreeLayer("elements", {
3947
- forceRenderOnMoving: true,
3948
- forceRenderOnRotating: true
3949
- });
3950
- const _this = this;
4358
+ const groupLayer = this.map.getLayer("group");
4359
+ const threeLayer = groupLayer.getLayer("three");
3951
4360
  threeLayer.prepareToDraw = function(gl, scene, camera) {
4361
+ function findBadMeshes(scene2) {
4362
+ const bad = [];
4363
+ scene2.traverse((obj) => {
4364
+ if (!obj?.isMesh) return;
4365
+ const geom = obj.geometry;
4366
+ const pos = geom?.attributes?.position?.array;
4367
+ if (!pos || pos.length === 0) return;
4368
+ for (let i = 0; i < pos.length; i++) {
4369
+ const v2 = pos[i];
4370
+ if (!Number.isFinite(v2)) {
4371
+ bad.push({ mesh: obj, index: i, value: v2 });
4372
+ break;
4373
+ }
4374
+ }
4375
+ });
4376
+ if (bad.length) {
4377
+ console.group(`\u274C Found ${bad.length} meshes with invalid positions`);
4378
+ for (const b of bad) {
4379
+ console.log({
4380
+ name: b.mesh.name,
4381
+ userData: b.mesh.userData,
4382
+ uuid: b.mesh.uuid,
4383
+ badIndex: b.index,
4384
+ badValue: b.value
4385
+ });
4386
+ }
4387
+ console.groupEnd();
4388
+ } else {
4389
+ console.log("\u2705 No invalid meshes found");
4390
+ }
4391
+ return bad;
4392
+ }
3952
4393
  const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
3953
4394
  scene.add(ambientLight);
3954
4395
  const dirColor = 16777215;
3955
4396
  const dllight = new THREE3.DirectionalLight(dirColor, 0.8);
3956
- dllight.position.set(0, -10, 10).normalize();
4397
+ dllight.position.set(0, -10, 20).normalize();
3957
4398
  scene.add(dllight);
3958
4399
  const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
3959
4400
  scene.add(hemi);
3960
- _this.elementRenderer = new Element3DRenderer(map, options.elements, threeLayer);
4401
+ _this.elementRenderer = new Element3DRenderer(map, options.elements);
3961
4402
  _this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
3962
4403
  if (typeof options.onRendererReady === "function") {
3963
4404
  options.onRendererReady();
3964
4405
  }
3965
4406
  _this.#createElements();
4407
+ setTimeout(() => {
4408
+ findBadMeshes(scene);
4409
+ }, 3e3);
3966
4410
  };
3967
- threeLayer.addTo(this.map);
3968
4411
  } else {
3969
4412
  this.elementRenderer = new Element2DRenderer(map, options.elements);
3970
4413
  this.markerRenderer = new Marker2DRenderer(map);
3971
4414
  this.#createElements();
3972
4415
  }
3973
4416
  }
4417
+ set onClickElement(func) {
4418
+ this.#onClickElement = func;
4419
+ }
4420
+ handleClickElement = (e) => {
4421
+ if (this.#isClicked) return;
4422
+ this.#isClicked = true;
4423
+ const onClickElement = this.#onClickElement;
4424
+ if (!(0, import_lodash_es4.isFunction)(onClickElement)) return;
4425
+ this.#onClickElement(e);
4426
+ this.#isClicked = false;
4427
+ };
3974
4428
  getElementsByOrdinal = (ordinal) => {
3975
4429
  const exist = this.elementsByOrdinal.get(ordinal);
3976
4430
  if (!exist) this.elementsByOrdinal.set(ordinal, []);
3977
4431
  return this.elementsByOrdinal.get(ordinal);
3978
4432
  };
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
4433
  addElementsToManager = (id, elements, ordinal) => {
3985
4434
  this.elementsMap.set(id, elements);
3986
4435
  elements.forEach((el) => {
4436
+ el.on("click", (e) => this.handleClickElement(id));
3987
4437
  this.getElementsByOrdinal(ordinal).push(el);
3988
4438
  });
3989
4439
  const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals;
@@ -3993,22 +4443,14 @@ var RendererManager = class extends EventTarget {
3993
4443
  this.elementRenderer.hideElements(elements, ordinal);
3994
4444
  }
3995
4445
  };
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
4446
  async #createElements() {
4447
+ await delay(this.options.delayBeforeCreateElements ?? 0);
4009
4448
  const levels = await this.#dataClient.filterByType("level", {
4010
4449
  populate: true
4011
4450
  });
4451
+ const openings = await this.#dataClient.filterByType("opening", {
4452
+ populate: true
4453
+ });
4012
4454
  const relationships = await this.#dataClient.filterByType("relationship");
4013
4455
  const fixtures = await this.#dataClient.filterByType("fixture", { populate: true });
4014
4456
  fixtures.forEach((fixture) => {
@@ -4022,7 +4464,7 @@ var RendererManager = class extends EventTarget {
4022
4464
  populate: true
4023
4465
  });
4024
4466
  units.filter(
4025
- (u) => !["opentobelow", "escalator"].includes(u.properties.category)
4467
+ (u4) => !["opentobelow", "escalator", "room"].includes(u4.properties.category)
4026
4468
  ).forEach((unit) => {
4027
4469
  const element = this.elementRenderer.createGeometry(unit);
4028
4470
  if (element) {
@@ -4030,6 +4472,22 @@ var RendererManager = class extends EventTarget {
4030
4472
  this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
4031
4473
  }
4032
4474
  });
4475
+ units.filter((u4) => u4.properties.category === "room").forEach((unit) => {
4476
+ const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
4477
+ const roomOpenings = (0, import_lodash_es4.compact)(openingRelationships.map((rel) => {
4478
+ const openingId = rel?.properties.intermediary[0].id;
4479
+ return openings.find((o) => o.id === openingId);
4480
+ }));
4481
+ const innerElements = this.elementRenderer.createGeometry(unit);
4482
+ const wallElements = this.elementRenderer.createRoomWall(unit, roomOpenings);
4483
+ if (innerElements || wallElements) {
4484
+ const _innerElements = Array.isArray(innerElements) ? innerElements : [innerElements];
4485
+ const _wallElements = Array.isArray(wallElements) ? wallElements : [wallElements];
4486
+ const _elements = [..._innerElements, ..._wallElements];
4487
+ const ordinal = unit.properties.level.properties.ordinal;
4488
+ this.addElementsToManager(unit.id, _elements, ordinal);
4489
+ }
4490
+ });
4033
4491
  const kiosks = await this.#dataClient.filterByType("kiosk", {
4034
4492
  populate: true
4035
4493
  });
@@ -4040,7 +4498,7 @@ var RendererManager = class extends EventTarget {
4040
4498
  this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
4041
4499
  }
4042
4500
  });
4043
- const escalators = units.filter((u) => u.properties.category === "escalator");
4501
+ const escalators = units.filter((u4) => u4.properties.category === "escalator");
4044
4502
  for (const escalator of escalators) {
4045
4503
  try {
4046
4504
  const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
@@ -4052,13 +4510,15 @@ var RendererManager = class extends EventTarget {
4052
4510
  }
4053
4511
  const thisOrdinal = escalator.properties.ordinal;
4054
4512
  const relationship = escalatorRelationships[0];
4513
+ if (!relationship.properties.origin?.id) throw new Error(`relationship (id=${relationship.id}) - origin not exists`);
4514
+ if (!relationship.properties.destination?.id) throw new Error(`relationship (id=${relationship.id}) - destination not exists`);
4055
4515
  const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id];
4056
4516
  const bothOpenings = await Promise.all(
4057
4517
  bothOpeningIds.map((id) => this.#dataClient.findById("opening", id, { populate: true }))
4058
4518
  );
4059
4519
  const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
4060
4520
  const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
4061
- const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
4521
+ const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
4062
4522
  const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
4063
4523
  const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
4064
4524
  const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
@@ -4067,7 +4527,23 @@ var RendererManager = class extends EventTarget {
4067
4527
  this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
4068
4528
  }
4069
4529
  } catch (err) {
4070
- console.log(`cannot create escalator`, err);
4530
+ console.warn(`cannot create escalator`, err.message);
4531
+ }
4532
+ }
4533
+ const groundLabels = await this.#dataClient.filterByType("label");
4534
+ for (const label of groundLabels) {
4535
+ const center2 = (0, import_center3.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
4536
+ const unit = findUnitOnPoint(units, center2);
4537
+ const element = this.elementRenderer.createGroundLabel(label, unit);
4538
+ if (element) {
4539
+ const _elements = Array.isArray(element) ? element : [element];
4540
+ this.addElementsToManager(label.id, _elements, label.properties.ordinal);
4541
+ }
4542
+ }
4543
+ if (this.options.type === "3D") {
4544
+ const model3ds = await this.#dataClient.filterByType("model3d");
4545
+ for (const model3d of model3ds) {
4546
+ this.elementRenderer.createModel3d(model3d);
4071
4547
  }
4072
4548
  }
4073
4549
  this.changeLevelByOrdinal(this.currentOrdinals);
@@ -4084,7 +4560,7 @@ var RendererManager = class extends EventTarget {
4084
4560
  this.markerRenderer.showMarkers(markers, ordinal - baseOrdinal);
4085
4561
  }
4086
4562
  } else {
4087
- const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_min.default)(targetOrdinal) : targetOrdinal;
4563
+ const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_lodash_es4.min)(targetOrdinal) : targetOrdinal;
4088
4564
  for (const [ordinal, elements] of this.elementsByOrdinal) {
4089
4565
  const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
4090
4566
  if (inOrdinal) {
@@ -4103,14 +4579,50 @@ var RendererManager = class extends EventTarget {
4103
4579
  }
4104
4580
  }
4105
4581
  }
4582
+ highlightElements = (elemIds, options) => {
4583
+ const { reset = true } = options ?? {};
4584
+ if (reset) {
4585
+ this.clearHighlightElements();
4586
+ }
4587
+ const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
4588
+ elements.forEach((element) => {
4589
+ const controller = this.elementRenderer.createHighlightController(element);
4590
+ if (controller && (0, import_lodash_es4.isFunction)(controller.start)) {
4591
+ controller.start();
4592
+ this.highlightControllers.push(controller);
4593
+ }
4594
+ });
4595
+ };
4596
+ clearHighlightElements = () => {
4597
+ this.highlightControllers.forEach((controller) => {
4598
+ if ((0, import_lodash_es4.isFunction)(controller?.clear)) controller.clear();
4599
+ });
4600
+ };
4106
4601
  /**
4107
4602
  * ========================================================================
4108
4603
  * Markers
4109
4604
  * ======================================================================== */
4605
+ _getMarkersByOrdinal = (ordinal) => {
4606
+ const exist = this.markersByOrdinal.get(ordinal);
4607
+ if (!exist) this.markersByOrdinal.set(ordinal, []);
4608
+ return this.markersByOrdinal.get(ordinal);
4609
+ };
4610
+ _addMarkersToManager = (id, markers, ordinal) => {
4611
+ this.markersMap.set(id, markers);
4612
+ markers.forEach((el) => {
4613
+ this._getMarkersByOrdinal(ordinal).push(el);
4614
+ });
4615
+ const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals;
4616
+ if (inOrdinal) {
4617
+ this.markerRenderer.showMarkers(markers, ordinal);
4618
+ } else {
4619
+ this.markerRenderer.hideMarkers(markers, ordinal);
4620
+ }
4621
+ };
4110
4622
  createMarker(coordinate, ordinal, text, options) {
4111
4623
  const marker = this.markerRenderer.createMarker(coordinate, ordinal, text, options);
4112
4624
  const markerId = `${this.markersMap.size + 1}`;
4113
- this.addMarkersToManager(markerId, [marker], ordinal);
4625
+ this._addMarkersToManager(markerId, [marker], ordinal);
4114
4626
  }
4115
4627
  clearMarkers() {
4116
4628
  for (const [markerId, marker] of this.markersMap) {
@@ -4125,9 +4637,25 @@ var INITIAL_ZOOM = 18.5;
4125
4637
  var CLICK_TOLERANCE = 20;
4126
4638
  var defaultOptions = {
4127
4639
  pixelRatio: 1,
4640
+ interactions: true,
4128
4641
  locale: DEFAULT_LOCALE
4129
4642
  };
4643
+ var parseMaptalksOptions = (options) => {
4644
+ return {
4645
+ centerCross: options.centerCross ?? false,
4646
+ ...options.interactions === false ? {
4647
+ draggable: false,
4648
+ dragPan: false,
4649
+ dragRotate: false,
4650
+ dragPitch: false,
4651
+ scrollWheelZoom: false,
4652
+ touchZoom: false,
4653
+ doubleClickZoom: false
4654
+ } : {}
4655
+ };
4656
+ };
4130
4657
  var IndoorMap = class extends EventTarget {
4658
+ options;
4131
4659
  //TODO: refac functions; let them do only 1 thing in a function
4132
4660
  /** Note: "#" means private variables */
4133
4661
  #styler = null;
@@ -4144,7 +4672,6 @@ var IndoorMap = class extends EventTarget {
4144
4672
  #billboardObjects = [];
4145
4673
  #spriteMarkerObjects = [];
4146
4674
  #mapDecorations = [];
4147
- #groundLabels = [];
4148
4675
  #groundObjects = [];
4149
4676
  #navigationGeometries = {};
4150
4677
  #venueObjects = [];
@@ -4179,18 +4706,23 @@ var IndoorMap = class extends EventTarget {
4179
4706
  };
4180
4707
  constructor(elementId, options) {
4181
4708
  super();
4709
+ const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
4710
+ this.options = combinedOptions;
4182
4711
  const {
4183
4712
  onMapReady,
4184
4713
  onMapLoading,
4185
4714
  pixelRatio,
4186
4715
  locale
4187
- } = import_lodash7.default.merge({}, defaultOptions, options);
4716
+ } = combinedOptions;
4717
+ const maptalksOptions = parseMaptalksOptions(combinedOptions);
4188
4718
  this.map = new import_maptalks_gl.Map(elementId, {
4189
4719
  attribution: false,
4720
+ // Temporart set, not really default view
4721
+ // Default view is set in camera manager
4190
4722
  center: INITIAL_CENTER,
4191
4723
  zoom: INITIAL_ZOOM,
4192
4724
  clickTimeThreshold: 600,
4193
- centerCross: options.centerCross ?? false,
4725
+ ...maptalksOptions,
4194
4726
  baseLayer: new import_maptalks_gl.TileLayer("base", {
4195
4727
  urlTemplate: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
4196
4728
  subdomains: ["a", "b", "c", "d"],
@@ -4202,8 +4734,16 @@ var IndoorMap = class extends EventTarget {
4202
4734
  }),
4203
4735
  layers: []
4204
4736
  });
4737
+ const groupLayer = new import_maptalks_gl.GroupGLLayer("group", [], {}).addTo(this.map);
4738
+ const threeLayer = new import_maptalks10.ThreeLayer("three", {
4739
+ forceRenderOnMoving: true,
4740
+ forceRenderOnRotating: true
4741
+ });
4742
+ groupLayer.addLayer(threeLayer);
4743
+ const gltfLayer = new import_maptalks_gl.GLTFLayer("gltf");
4744
+ groupLayer.addLayer(gltfLayer);
4205
4745
  this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
4206
- this.camera = new CameraManager(this.map);
4746
+ this.camera = new CameraManager(this.map, options.camera);
4207
4747
  this.locale = locale;
4208
4748
  this.pixelRatio = pixelRatio;
4209
4749
  this.onMapReady = onMapReady;
@@ -4212,25 +4752,33 @@ var IndoorMap = class extends EventTarget {
4212
4752
  this.map.on("click", this.handleMapClick);
4213
4753
  this.dataClient = options.dataClient;
4214
4754
  }
4755
+ setOptions(options) {
4756
+ const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
4757
+ this.options = combinedOptions;
4758
+ const maptalksOptions = parseMaptalksOptions(combinedOptions);
4759
+ this.map.setOptions(maptalksOptions);
4760
+ }
4215
4761
  set dataClient(value) {
4216
4762
  this.#dataClient = value;
4217
- this.#dataClient.filterByType("venue").then((venues) => {
4218
- const venueCenters = (0, import_center4.default)(featureCollection(venues));
4219
- const [x, y] = venueCenters.geometry.coordinates;
4220
- const center2 = new import_maptalks_gl.Coordinate(x, y);
4221
- this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
4222
- });
4223
- }
4224
- on(eventName, handler) {
4225
- this.map.on(eventName, handler);
4763
+ if (!this.options.camera?.defaultView?.center) {
4764
+ this.#dataClient.filterByType("venue").then((venues) => {
4765
+ const venueCenters = (0, import_center4.default)(featureCollection(venues));
4766
+ const [x, y] = venueCenters.geometry.coordinates;
4767
+ const center2 = new import_maptalks_gl.Coordinate(x, y);
4768
+ this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
4769
+ });
4770
+ }
4226
4771
  }
4227
4772
  /**
4228
4773
  * Events
4229
4774
  */
4775
+ on(eventName, handler) {
4776
+ this.map.on(eventName, handler);
4777
+ }
4230
4778
  handleMapClick = ({ coordinate }) => {
4231
4779
  const { x, y } = coordinate;
4232
4780
  console.log(
4233
- `[Coordinates]: x: ${import_lodash7.default.round(x, 8)} y: ${import_lodash7.default.round(
4781
+ `[Coordinates]: x: ${import_lodash6.default.round(x, 8)} y: ${import_lodash6.default.round(
4234
4782
  y,
4235
4783
  8
4236
4784
  )}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
@@ -4282,48 +4830,17 @@ var IndoorMap = class extends EventTarget {
4282
4830
  this.map.off("moveend", this.#findAndSetVenueInView);
4283
4831
  }
4284
4832
  }
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
4833
  set billboards(value) {
4293
4834
  this.#billboards = value;
4294
4835
  }
4295
- set mapConfig(value) {
4296
- this.#mapConfig = value;
4297
- }
4298
4836
  set mapDecorations(value) {
4299
4837
  this.#mapDecorations = value;
4300
4838
  }
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
- set groundLabels(value) {
4320
- this.#groundLabels = value;
4321
- }
4322
4839
  set pixelRatio(value) {
4323
4840
  this.map.setDevicePixelRatio(value);
4324
4841
  }
4325
4842
  set onClickElement(func) {
4326
- this.#onClickElement = func;
4843
+ this.rendererManager.onClickElement = func;
4327
4844
  }
4328
4845
  set locale(value) {
4329
4846
  this.#locale = value || defaultOptions.locale;
@@ -4339,7 +4856,7 @@ var IndoorMap = class extends EventTarget {
4339
4856
  const scene = this.threeLayer.getScene();
4340
4857
  if (scene) {
4341
4858
  scene.children = scene.children.filter(
4342
- (children) => children instanceof import_three8.PerspectiveCamera
4859
+ (children) => children instanceof import_three6.PerspectiveCamera
4343
4860
  );
4344
4861
  }
4345
4862
  }
@@ -4347,66 +4864,36 @@ var IndoorMap = class extends EventTarget {
4347
4864
  if (this.#isClicked) return;
4348
4865
  this.#isClicked = true;
4349
4866
  const onClickElement = this.#onClickElement;
4350
- if (!import_lodash7.default.isFunction(onClickElement)) return;
4867
+ if (!import_lodash6.default.isFunction(onClickElement)) return;
4351
4868
  this.#onClickElement(e);
4352
4869
  this.#isClicked = false;
4353
4870
  };
4354
- setCenter(center2, padding) {
4355
- this.map.setCenter(center2, padding);
4356
- }
4357
4871
  async #legacy_createElements() {
4358
4872
  const {
4359
4873
  // 2D
4360
- createVenue,
4361
4874
  createOpening,
4362
4875
  createSection,
4363
- createFixture,
4364
- createOccupant,
4365
4876
  createDecoration,
4366
4877
  // 3D
4367
- create3DFootprint,
4368
- create3DGroundLabel,
4369
4878
  create3DBillboard,
4370
- createVenue3DModel,
4371
- createExtrudedUnit,
4372
- create3DFixture,
4373
4879
  create3DAmenityMarker,
4374
- create3DOccupantAmenityMarker,
4375
- create3DOpeningMarker,
4376
- createOccupantGroundLabel,
4377
- // Light
4378
- createAmbientLight,
4379
- createDirectionalLight
4880
+ create3DOpeningMarker
4380
4881
  } = this.#styler;
4381
4882
  let elements = {};
4382
4883
  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
4884
  for (const feature2 of this.#features) {
4398
4885
  try {
4399
4886
  const { feature_type: featureType, properties, id } = feature2;
4400
- const layerName = import_lodash7.default.get(
4887
+ const layerName = import_lodash6.default.get(
4401
4888
  LAYER_FEATURE_TYPE_OBJ,
4402
4889
  featureType,
4403
4890
  featureType
4404
4891
  );
4405
4892
  const layer = this.map.getLayer(layerName);
4406
4893
  let geometry;
4407
- const category = import_lodash7.default.get(feature2, "properties.category");
4408
- const extrudeConfig = import_lodash7.default.get(this.#mapConfig, "extrude");
4409
- const textMarkerType = import_lodash7.default.get(
4894
+ const category = import_lodash6.default.get(feature2, "properties.category");
4895
+ const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
4896
+ const textMarkerType = import_lodash6.default.get(
4410
4897
  this.#mapConfig,
4411
4898
  "text_marker_type",
4412
4899
  "ui-marker"
@@ -4416,16 +4903,6 @@ var IndoorMap = class extends EventTarget {
4416
4903
  feature2
4417
4904
  );
4418
4905
  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
4906
  case "amenity": {
4430
4907
  if (feature2.properties.is_featured) {
4431
4908
  const billboardObj = create3DBillboard(feature2, this.threeLayer);
@@ -4469,127 +4946,6 @@ var IndoorMap = class extends EventTarget {
4469
4946
  geometry = createSection(feature2)?.addTo(layer);
4470
4947
  break;
4471
4948
  }
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
4949
  default:
4594
4950
  break;
4595
4951
  }
@@ -4599,16 +4955,6 @@ var IndoorMap = class extends EventTarget {
4599
4955
  console.warn(`Cannot create ${feature2.id}: ${err.message}`);
4600
4956
  }
4601
4957
  }
4602
- this.#groundLabels.forEach((label) => {
4603
- const text = label.properties.name;
4604
- try {
4605
- const groundLabel = create3DGroundLabel(label, this.threeLayer);
4606
- object3ds.push(groundLabel);
4607
- this.#groundObjects.push(groundLabel);
4608
- } catch (error) {
4609
- console.log("error creating ground label for ", text);
4610
- }
4611
- });
4612
4958
  this.#mapDecorations.forEach((decoration) => {
4613
4959
  const { id, geometry, properties } = decoration;
4614
4960
  const geometryType = decoration?.geometry?.type;
@@ -4658,27 +5004,6 @@ var IndoorMap = class extends EventTarget {
4658
5004
  changeLevelByOrdinal(ordinal) {
4659
5005
  this.rendererManager.changeLevelByOrdinal(ordinal);
4660
5006
  }
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
5007
  findVenueInView = () => {
4683
5008
  const mapCenter = this.map.getCenter();
4684
5009
  const result = this.#venues.reduce((closest, venue) => {
@@ -4691,9 +5016,6 @@ var IndoorMap = class extends EventTarget {
4691
5016
  }, null);
4692
5017
  return result;
4693
5018
  };
4694
- flyTo = (center2, options) => {
4695
- this.camera.flyTo(center2, options);
4696
- };
4697
5019
  getLineStringBearing = (feature2) => {
4698
5020
  const { geometry } = feature2;
4699
5021
  const path = new import_maptalks_gl.LineString(geometry.coordinates);
@@ -4714,186 +5036,6 @@ var IndoorMap = class extends EventTarget {
4714
5036
  clearAnimations() {
4715
5037
  this.#animationsToRun = [];
4716
5038
  }
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
5039
  /**
4898
5040
  * User Location
4899
5041
  ****************************/
@@ -4918,15 +5060,15 @@ var IndoorMap = class extends EventTarget {
4918
5060
  }
4919
5061
  }
4920
5062
  updateUserLocationSymbolByLocale(locale) {
4921
- const userLocationGeometry = import_lodash7.default.get(
5063
+ const userLocationGeometry = import_lodash6.default.get(
4922
5064
  this.#elements,
4923
5065
  `${USER_LOCATION_ELEMENT_ID}.geometry`
4924
5066
  );
4925
5067
  if (!userLocationGeometry) return;
4926
5068
  const currentSymbol = userLocationGeometry.getSymbol();
4927
5069
  const localeSymbolToUpdate = currentSymbol.map((symbol) => {
4928
- const localeSymbol = import_lodash7.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash7.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
4929
- if (!import_lodash7.default.isPlainObject(localeSymbol)) return symbol;
5070
+ const localeSymbol = import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
5071
+ if (!import_lodash6.default.isPlainObject(localeSymbol)) return symbol;
4930
5072
  return {
4931
5073
  ...symbol,
4932
5074
  ...localeSymbol
@@ -5000,14 +5142,14 @@ var IndoorMap = class extends EventTarget {
5000
5142
  * END of User Location
5001
5143
  ****************************/
5002
5144
  showGeometryByElementId = (elementId) => {
5003
- const geometry = import_lodash7.default.get(
5145
+ const geometry = import_lodash6.default.get(
5004
5146
  this.#elements,
5005
5147
  `${elementId}.geometry`
5006
5148
  );
5007
5149
  if (geometry) geometry.show();
5008
5150
  };
5009
5151
  hideGeometryByElementId = (elementId) => {
5010
- const geometry = import_lodash7.default.get(this.#elements, `${elementId}.geometry`);
5152
+ const geometry = import_lodash6.default.get(this.#elements, `${elementId}.geometry`);
5011
5153
  if (geometry) geometry.hide();
5012
5154
  };
5013
5155
  setSpriteMarkersOpacity = (opacity = 1) => {
@@ -5054,13 +5196,13 @@ var IndoorMap = class extends EventTarget {
5054
5196
  const line = lineStrings[i];
5055
5197
  const coords = line.geometry.coordinates;
5056
5198
  const prevLine = lineStrings[i - 1];
5057
- const firstCoord = import_lodash7.default.first(coords);
5199
+ const firstCoord = import_lodash6.default.first(coords);
5058
5200
  const isFirstLine = i === 0;
5059
5201
  if (isFirstLine) {
5060
5202
  accLine.push(...coords);
5061
5203
  continue;
5062
5204
  }
5063
- const prevLastCoord = import_lodash7.default.last(prevLine.geometry.coordinates);
5205
+ const prevLastCoord = import_lodash6.default.last(prevLine.geometry.coordinates);
5064
5206
  const isNearby = (0, import_distance.default)(point(firstCoord), point(prevLastCoord)) < distance;
5065
5207
  if (!isNearby) {
5066
5208
  const remainingLines = lineStrings.slice(i);
@@ -5081,8 +5223,8 @@ var IndoorMap = class extends EventTarget {
5081
5223
  create3DStepPath
5082
5224
  } = this.#styler;
5083
5225
  const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
5084
- const linesByOrdinal = (0, import_lodash7.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
5085
- const joinedLines = (0, import_lodash7.default)(linesByOrdinal).reduce((acc, lines, key) => {
5226
+ const linesByOrdinal = (0, import_lodash6.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
5227
+ const joinedLines = (0, import_lodash6.default)(linesByOrdinal).reduce((acc, lines, key) => {
5086
5228
  const joined = this.combineNearbyLineStrings(lines, {
5087
5229
  properties: { ordinal: +key }
5088
5230
  });
@@ -5110,14 +5252,14 @@ var IndoorMap = class extends EventTarget {
5110
5252
  stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
5111
5253
  break;
5112
5254
  case "destination-marker":
5113
- const extrudeConfig = import_lodash7.default.get(this.#mapConfig, "extrude");
5255
+ const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
5114
5256
  if (destinationFeature.feature_type === "occupant") {
5115
- const stepId = import_lodash7.default.get(stepGeometry, "id");
5257
+ const stepId = import_lodash6.default.get(stepGeometry, "id");
5116
5258
  const normalizedDestinationFeature = {
5117
5259
  ...destinationFeature,
5118
5260
  id: stepId
5119
5261
  };
5120
- const logoUrl = import_lodash7.default.get(
5262
+ const logoUrl = import_lodash6.default.get(
5121
5263
  normalizedDestinationFeature,
5122
5264
  "properties.logo.url"
5123
5265
  );
@@ -5162,15 +5304,15 @@ var IndoorMap = class extends EventTarget {
5162
5304
  const routeMarkerLayer = this.map.getLayer(
5163
5305
  HIGHLIGHT_LAYER_NAME
5164
5306
  );
5165
- const originMarkerGeometry = import_lodash7.default.get(
5307
+ const originMarkerGeometry = import_lodash6.default.get(
5166
5308
  this.#elements,
5167
5309
  `${ORIGIN_MARKER_ID}.geometry`
5168
5310
  );
5169
- const destinationMarkerGeometry = import_lodash7.default.get(
5311
+ const destinationMarkerGeometry = import_lodash6.default.get(
5170
5312
  this.#elements,
5171
5313
  `${DESTINATION_MARKER_ID}.geometry`
5172
5314
  );
5173
- const geometriesToRemove = import_lodash7.default.compact([
5315
+ const geometriesToRemove = import_lodash6.default.compact([
5174
5316
  originMarkerGeometry,
5175
5317
  destinationMarkerGeometry
5176
5318
  ]);
@@ -5181,7 +5323,7 @@ var IndoorMap = class extends EventTarget {
5181
5323
  (obj) => !(obj instanceof NavigationPath)
5182
5324
  );
5183
5325
  const objects = this.#navigationGeometries || {};
5184
- import_lodash7.default.forEach(objects, (obj) => {
5326
+ import_lodash6.default.forEach(objects, (obj) => {
5185
5327
  if (!obj) return;
5186
5328
  this.#navigationGeometries[obj.properties.id] = null;
5187
5329
  obj.remove();
@@ -5209,33 +5351,6 @@ var IndoorMap = class extends EventTarget {
5209
5351
  /**
5210
5352
  * render (frame)
5211
5353
  */
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
5354
  render() {
5240
5355
  const view = this.map.getView();
5241
5356
  const currBearing = view.bearing;
@@ -5244,7 +5359,8 @@ var IndoorMap = class extends EventTarget {
5244
5359
  this.threeLayer.redraw();
5245
5360
  }
5246
5361
  if (this.threeLayer) {
5247
- const objectOpacity = import_lodash7.default.clamp(38 - 2 * this.camera.getZoom(), 0, 1);
5362
+ const currentView = this.camera.getView();
5363
+ const objectOpacity = import_lodash6.default.clamp(38 - 2 * currentView.zoom, 0, 1);
5248
5364
  this.#objects.forEach((object) => {
5249
5365
  object.getObject3d().traverse((child) => {
5250
5366
  if (child.isMesh) child.material.opacity = objectOpacity;
@@ -5254,8 +5370,8 @@ var IndoorMap = class extends EventTarget {
5254
5370
  });
5255
5371
  if (this.#billboardObjects) {
5256
5372
  this.#billboardObjects.forEach((object) => {
5257
- const objectScale = import_lodash7.default.clamp(
5258
- 20 - 1 * this.camera.getZoom(),
5373
+ const objectScale = import_lodash6.default.clamp(
5374
+ 20 - 1 * currentView.zoom,
5259
5375
  1,
5260
5376
  1.05
5261
5377
  );
@@ -5263,7 +5379,7 @@ var IndoorMap = class extends EventTarget {
5263
5379
  });
5264
5380
  }
5265
5381
  if (this.#isLayersFadingOnZoom) {
5266
- const layerOpacity = import_lodash7.default.clamp(1 - objectOpacity, 0, 1);
5382
+ const layerOpacity = import_lodash6.default.clamp(1 - objectOpacity, 0, 1);
5267
5383
  LAYERS.forEach((layerKey) => {
5268
5384
  const layer = this.map.getLayer(layerKey);
5269
5385
  if (layer) layer.setOpacity(layerOpacity);
@@ -5277,24 +5393,18 @@ var IndoorMap = class extends EventTarget {
5277
5393
  child.visible = this.showVenueObject && objectOpacity > 0.4;
5278
5394
  });
5279
5395
  });
5280
- this.#groundObjects.forEach((gLabel) => {
5281
- gLabel.bearing = currBearing;
5282
- });
5283
5396
  }
5284
5397
  this.#animationsToRun.forEach(({ callback }) => callback(this));
5285
- import_tween2.default.update();
5398
+ import_tween.default.update();
5286
5399
  requestAnimationFrame(this.render.bind(this));
5287
5400
  }
5288
5401
  };
5289
5402
  // Annotate the CommonJS export names for ESM import in node:
5290
5403
  0 && (module.exports = {
5291
5404
  ALL_FEATURE_TYPES,
5292
- ALWAYS_VISIBLE_FEATURE_TYPES,
5293
5405
  BASE_LAYER_NAME,
5294
5406
  DEFAULT_BASE_URL,
5295
- DEFAULT_HIGHLIGHT_OPTIONS,
5296
5407
  DEFAULT_LOCALE,
5297
- DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
5298
5408
  DESTINATION_MARKER_ID,
5299
5409
  GEOJSON_FEATURE_TYPES,
5300
5410
  HIGHLIGHT_LAYER_NAME,
@@ -5308,8 +5418,10 @@ var IndoorMap = class extends EventTarget {
5308
5418
  MARKER_LAYER_NAME,
5309
5419
  NONIMDF_FEATURE_TYPES,
5310
5420
  ORIGIN_MARKER_ID,
5421
+ OccupantHelpers,
5311
5422
  POI_MARKER_LAYER_NAME,
5312
5423
  QueryObserver,
5424
+ TextSpriteMarker,
5313
5425
  USER_LOCATION_ELEMENT_ID,
5314
5426
  USER_LOCATION_LAYER_NAME,
5315
5427
  VENUE_EVENTS,
@@ -5335,6 +5447,16 @@ var IndoorMap = class extends EventTarget {
5335
5447
  getRelatedLocationsByOccupant,
5336
5448
  getSuitablyValueBetweenBearings,
5337
5449
  isClickableFeature,
5450
+ isValidCoordinate,
5451
+ isValidLineString,
5452
+ isValidLineStringCoordinates,
5453
+ isValidMultiPolygon,
5454
+ isValidMultiPolygonCoordinates,
5455
+ isValidPoint,
5456
+ isValidPolygon,
5457
+ isValidPolygonCoordinates,
5458
+ matchFilter,
5459
+ matchFilters,
5338
5460
  safeFetchFeature,
5339
5461
  styledFeatureGenerator
5340
5462
  });