venue-js 1.2.0 → 1.3.0-next.1

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