venue-js 1.2.0-next.13 → 1.2.0-next.14

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.mjs CHANGED
@@ -207,16 +207,16 @@ function isValidLinearRingCoordinates(ring) {
207
207
  }
208
208
  return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
209
209
  }
210
- var isValidPolygonCoordinates = (polygon) => {
211
- if (Array.isArray(polygon[0]) && (polygon[0].length === 0 || typeof polygon[0][0] === "number")) {
212
- return isValidLinearRingCoordinates(polygon);
210
+ var isValidPolygonCoordinates = (polygon2) => {
211
+ if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
212
+ return isValidLinearRingCoordinates(polygon2);
213
213
  }
214
- if (Array.isArray(polygon) && polygon.length > 0 && Array.isArray(polygon[0])) {
215
- if (!isValidLinearRingCoordinates(polygon[0])) {
214
+ if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
215
+ if (!isValidLinearRingCoordinates(polygon2[0])) {
216
216
  return false;
217
217
  }
218
- for (let i = 1; i < polygon.length; i++) {
219
- if (!isValidLinearRingCoordinates(polygon[i])) {
218
+ for (let i = 1; i < polygon2.length; i++) {
219
+ if (!isValidLinearRingCoordinates(polygon2[i])) {
220
220
  return false;
221
221
  }
222
222
  }
@@ -259,7 +259,7 @@ var isValidPoint = (geometry) => {
259
259
  function isInFilter(filter) {
260
260
  return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
261
261
  }
262
- var someIntersect = (a, b) => a.some((v) => b.includes(v));
262
+ var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
263
263
  function matchFilter(value, filter) {
264
264
  if (Array.isArray(value)) {
265
265
  if (isInFilter(filter)) return someIntersect(value, filter.$in);
@@ -746,6 +746,28 @@ function point(coordinates, properties, options = {}) {
746
746
  };
747
747
  return feature(geom, properties, options);
748
748
  }
749
+ function polygon(coordinates, properties, options = {}) {
750
+ for (const ring of coordinates) {
751
+ if (ring.length < 4) {
752
+ throw new Error(
753
+ "Each LinearRing of a Polygon must have 4 or more Positions."
754
+ );
755
+ }
756
+ if (ring[ring.length - 1].length !== ring[0].length) {
757
+ throw new Error("First and last Position are not equivalent.");
758
+ }
759
+ for (let j = 0; j < ring[ring.length - 1].length; j++) {
760
+ if (ring[ring.length - 1][j] !== ring[0][j]) {
761
+ throw new Error("First and last Position are not equivalent.");
762
+ }
763
+ }
764
+ }
765
+ const geom = {
766
+ type: "Polygon",
767
+ coordinates
768
+ };
769
+ return feature(geom, properties, options);
770
+ }
749
771
  function lineString(coordinates, properties, options = {}) {
750
772
  if (coordinates.length < 2) {
751
773
  throw new Error("coordinates must be an array of two or more positions");
@@ -775,7 +797,7 @@ function isNumber(num) {
775
797
  import turfDistance from "@turf/distance";
776
798
  import turfCenter3 from "@turf/center";
777
799
  import { PerspectiveCamera } from "three";
778
- import { ThreeLayer as ThreeLayer4 } from "maptalks.three";
800
+ import { ThreeLayer as ThreeLayer5 } from "maptalks.three";
779
801
 
780
802
  // src/IndoorMap/constants.ts
781
803
  var defaultLayerOption = { enableAltitude: true };
@@ -911,7 +933,7 @@ var Billboard = class extends BaseObject {
911
933
  this._initOptions(options);
912
934
  const {
913
935
  altitude = OPTIONS.altitude,
914
- scale: scale2 = OPTIONS.scale,
936
+ scale: scale3 = OPTIONS.scale,
915
937
  alphaTest = OPTIONS.alphaTest,
916
938
  legColor = OPTIONS.legColor,
917
939
  showLeg = OPTIONS.showLeg
@@ -945,8 +967,8 @@ var Billboard = class extends BaseObject {
945
967
  const sprite = new Sprite(material);
946
968
  sprite.material.sizeAttenuation = false;
947
969
  sprite.scale.set(
948
- scale2 * naturalWidth / divider,
949
- scale2 * naturalHeight / divider,
970
+ scale3 * naturalWidth / divider,
971
+ scale3 * naturalHeight / divider,
950
972
  1
951
973
  );
952
974
  this.getObject3d().add(sprite);
@@ -955,7 +977,7 @@ var Billboard = class extends BaseObject {
955
977
  const position = layer.coordinateToVector3(coordinate, z);
956
978
  _.set(this.properties, "default.position", position);
957
979
  _.set(this.properties, "default.altitude", altitude);
958
- _.set(this.properties, "default.scale", scale2);
980
+ _.set(this.properties, "default.scale", scale3);
959
981
  this.getObject3d().position.copy(position);
960
982
  }
961
983
  setLineHeight(altitude) {
@@ -968,414 +990,120 @@ var Billboard = class extends BaseObject {
968
990
  }
969
991
  };
970
992
 
971
- // src/IndoorMap/object3d/GroundLabel.ts
972
- import * as maptalks2 from "maptalks";
993
+ // src/IndoorMap/object3d/SpriteMarker.ts
973
994
  import { BaseObject as BaseObject2 } from "maptalks.three";
974
- import {
975
- Texture,
976
- MeshPhongMaterial,
977
- PlaneGeometry
978
- } from "three";
979
- import { largestRect } from "d3plus-shape";
980
- import { max, merge, isNumber as isNumber2, isArray, range } from "lodash-es";
981
- var OPTIONS2 = {
982
- // Allowing click through and prevent interaction
983
- interactive: false,
984
- altitude: 0
985
- };
986
- var defaultFlatLabelOptions = {
987
- fontSize: 14,
988
- fontFamily: "Manrope",
989
- fontWeight: 600,
990
- margin: 0,
991
- scaleMin: 0.5,
992
- lineHeight: 1.05,
993
- scaleStep: 0.05,
994
- textAlign: "center",
995
- textBaseline: "middle",
996
- fillStyle: "#000"
995
+ import { Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
996
+ import _2 from "lodash";
997
+ var DEFAULT_SCALE = 0.05;
998
+ var DEFAULT_ALTITUDE = 0;
999
+ var DEFAULT_ALPHATEST = 0.3;
1000
+ var DEFAULT_OPTIONS = {
1001
+ scale: DEFAULT_SCALE,
1002
+ altitude: DEFAULT_ALTITUDE,
1003
+ alphaTest: DEFAULT_ALPHATEST,
1004
+ highlight: {
1005
+ options: {
1006
+ scale: DEFAULT_SCALE * 1.25
1007
+ },
1008
+ material: null
1009
+ }
997
1010
  };
998
- var defaultRectAngleToCalc = range(-90, 92, 2);
999
- var getMaterial = (text, flatLabelOptions) => {
1000
- const options = merge({}, defaultFlatLabelOptions, flatLabelOptions);
1001
- const {
1002
- fontSize: initialFontSize,
1003
- fontFamily,
1004
- fontWeight,
1005
- margin,
1006
- scaleMin,
1007
- scaleStep,
1008
- fillStyle,
1009
- lineHeight,
1010
- textAlign,
1011
- strokeStyle,
1012
- lineWidth,
1013
- textBaseline
1014
- } = options;
1015
- const pixelMultiplier = 4;
1016
- const SIZE = 100 * pixelMultiplier;
1017
- const fontSize = initialFontSize * (pixelMultiplier * 1.25);
1018
- const canvas = document.createElement("canvas");
1019
- canvas.width = canvas.height = SIZE;
1020
- const ctx = canvas.getContext("2d");
1021
- ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
1022
- ctx.textAlign = textAlign;
1023
- ctx.textBaseline = textBaseline;
1024
- ctx.fillStyle = fillStyle;
1025
- ctx.strokeStyle = strokeStyle;
1026
- ctx.lineWidth = lineWidth;
1027
- const wrapText = (ctx2, text2, maxWidth) => {
1028
- const words = text2.trim().split(/\s+/);
1029
- if (words.length <= 1) return [text2];
1030
- const lines = [];
1031
- const MAX_LINES = 3;
1032
- let currentLine = words[0];
1033
- for (let i = 1; i < words.length; i++) {
1034
- const lineToMeasure = currentLine + " " + words[i];
1035
- if (ctx2.measureText(lineToMeasure).width > maxWidth) {
1036
- lines.push(currentLine);
1037
- currentLine = words[i];
1038
- } else {
1039
- currentLine = lineToMeasure;
1040
- }
1011
+ var SpriteMarker = class extends BaseObject2 {
1012
+ #default = null;
1013
+ #highlight = null;
1014
+ constructor(coordinate, options, material, layer, properties) {
1015
+ super();
1016
+ this._initOptions(options);
1017
+ this._createGroup();
1018
+ const {
1019
+ altitude = DEFAULT_OPTIONS.altitude,
1020
+ scale: scale3 = DEFAULT_OPTIONS.scale,
1021
+ highlight = DEFAULT_OPTIONS.highlight,
1022
+ alphaTest = DEFAULT_OPTIONS.alphaTest
1023
+ } = options;
1024
+ this.properties = { ...properties };
1025
+ const modifiedAltitude = altitude + 2;
1026
+ this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
1027
+ this.#highlight = _2.merge({}, DEFAULT_OPTIONS.highlight, highlight);
1028
+ if (material && material instanceof SpriteMaterial2)
1029
+ material.alphaTest = alphaTest;
1030
+ const sprite = new Sprite2(material);
1031
+ sprite.scale.set(scale3, scale3, scale3);
1032
+ const obj3d = this.getObject3d();
1033
+ obj3d.add(sprite);
1034
+ const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
1035
+ const position = layer.coordinateToVector3(coordinate, z);
1036
+ _2.set(this.properties, "default.position", position);
1037
+ this.getObject3d().position.copy(position);
1038
+ }
1039
+ // Different objects need to implement their own methods
1040
+ setSymbol(material) {
1041
+ if (material && material instanceof SpriteMaterial2) {
1042
+ const sprite = this.getObject3d().children[0];
1043
+ if (!sprite) return this;
1044
+ sprite.material = material;
1045
+ sprite.material.needsUpdate = true;
1041
1046
  }
1042
- lines.push(currentLine);
1043
- return lines.slice(0, MAX_LINES);
1044
- };
1045
- const hasManualBreaks = text.includes("\n");
1046
- let texts;
1047
- if (hasManualBreaks) {
1048
- texts = text.split(/\n/g);
1049
- } else {
1050
- const maxWidth = SIZE - 2 * margin;
1051
- texts = wrapText(ctx, text, maxWidth);
1047
+ return this;
1052
1048
  }
1053
- let textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
1054
- let scale2 = 1;
1055
- while (scale2 > 0 && textWidth + 2 * margin > SIZE) {
1056
- scale2 -= scaleStep;
1057
- ctx.font = `${fontWeight} ${scale2 * fontSize}px "${fontFamily}", Arial`;
1058
- textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
1049
+ setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
1050
+ const sprite = this.getObject3d().children[0];
1051
+ if (!sprite) return this;
1052
+ sprite.scale.set(scaleX, scaleY, scaleZ);
1053
+ return this;
1059
1054
  }
1060
- const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
1061
- if (scale2 > scaleMin) {
1062
- const totalHeight = texts.length * (fontSize * scale2 * lineHeight);
1063
- const startY = center2.y - totalHeight / 2 + fontSize * scale2 * lineHeight * 0.5;
1064
- texts.forEach((text2, index) => {
1065
- const yOffset = startY + index * (fontSize * scale2 * lineHeight);
1066
- if (strokeStyle && lineWidth) {
1067
- ctx.strokeText(text2, center2.x, yOffset);
1068
- }
1069
- ctx.fillText(text2, center2.x, yOffset);
1070
- });
1055
+ // Different objects need to implement their own methods
1056
+ getSymbol() {
1057
+ return this.getObject3d()?.children[0]?.material;
1058
+ }
1059
+ highlight() {
1060
+ const { material, options } = this.#highlight;
1061
+ if (material) this.setSymbol(material);
1062
+ if (options.scale) this.setScale(options.scale);
1063
+ if (options.altitude) this.setAltitude(options.altitude);
1064
+ return this;
1065
+ }
1066
+ removeHighlight() {
1067
+ const { material, options } = this.#default;
1068
+ if (material) this.setSymbol(material);
1069
+ if (options.scale) this.setScale(options.scale);
1070
+ if (options.altitude) this.setAltitude(options.altitude);
1071
+ return this;
1071
1072
  }
1072
- const texture = new Texture(canvas);
1073
- texture.needsUpdate = true;
1074
- const material = new MeshPhongMaterial({
1075
- map: texture,
1076
- transparent: true,
1077
- // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
1078
- alphaTest: 0.3
1079
- });
1080
- return material;
1081
1073
  };
1082
- var GroundLabel = class extends BaseObject2 {
1083
- #angle = 0;
1084
- #bearing = 0;
1085
- #text = "";
1086
- #offsetX = 0;
1087
- #offsetY = 0;
1088
- #originalPosition = null;
1089
- #layer = null;
1090
- constructor(bound, options, layer) {
1074
+
1075
+ // src/IndoorMap/object3d/NavigationPath.ts
1076
+ import * as maptalks2 from "maptalks";
1077
+ import { BaseObject as BaseObject3 } from "maptalks.three";
1078
+ import { MeshBasicMaterial, ShaderMaterial, Color } from "three";
1079
+ var OPTIONS2 = {
1080
+ altitude: 0
1081
+ };
1082
+ var DEFAULT_LINE_OPTION = {
1083
+ color: "#000",
1084
+ opacity: 1
1085
+ };
1086
+ var DEFAULT_LINE_EFFECT_OPTION = {
1087
+ color: "#000",
1088
+ opacity: 1
1089
+ };
1090
+ var ENABLE_ANIMATED_PATH = true;
1091
+ var NavigationPath = class extends BaseObject3 {
1092
+ constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
1091
1093
  options = maptalks2.Util.extend({}, OPTIONS2, options, {
1092
- layer,
1093
- coordinate: bound
1094
+ layer
1094
1095
  });
1095
- const {
1096
- altitude,
1097
- text,
1098
- fontSize,
1099
- fillStyle,
1100
- textAlign,
1101
- fontFamily,
1102
- textBaseline,
1103
- strokeStyle,
1104
- lineWidth,
1105
- angle = defaultRectAngleToCalc,
1106
- maxFontScale,
1107
- offsetX = 0,
1108
- offsetY = 0,
1109
- ...properties
1110
- } = options;
1111
1096
  super();
1112
1097
  this._initOptions(options);
1113
- this.properties = properties;
1114
- this.#offsetX = offsetX;
1115
- this.#offsetY = offsetY;
1116
- this.#layer = layer;
1117
- const material = getMaterial(text, {
1118
- fillStyle,
1119
- fontSize,
1120
- textAlign,
1121
- textBaseline,
1122
- fontFamily,
1123
- strokeStyle,
1124
- lineWidth
1125
- });
1126
- const rectAngles = isArray(angle) ? angle : [angle];
1127
- material.needsUpdate = true;
1128
- const rect = largestRect(bound, {
1129
- cache: true,
1130
- /**
1131
- * Black magic here:
1132
- * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
1133
- * So we remove -90 and 90 from choices, and use -85 & 85 instead.
1134
- */
1135
- angle: rectAngles
1136
- });
1137
- const { cx, cy, width, angle: calculatedAngle } = rect;
1138
- this.#text = text;
1139
- this.#angle = calculatedAngle;
1140
- const geometry = new PlaneGeometry(1, 1);
1141
- this._createMesh(geometry, material);
1142
- const z = layer.altitudeToVector3(altitude, altitude).x;
1143
- const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z);
1144
- this.#originalPosition = basePosition.clone();
1145
- const finalPosition = this.#calculateFinalPosition(basePosition);
1146
- const scale2 = width / 6456122659e-13;
1147
- const finalScale = maxFontScale && scale2 > maxFontScale ? maxFontScale : scale2;
1148
- this.getObject3d().scale.set(finalScale, finalScale, finalScale);
1149
- this.getObject3d().position.copy(finalPosition);
1150
- this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
1151
- }
1152
- #calculateFinalPosition(basePosition) {
1153
- if (this.#offsetX === 0 && this.#offsetY === 0) {
1154
- return basePosition;
1155
- }
1156
- const offsetCoordinate = {
1157
- x: this.#offsetX,
1158
- y: this.#offsetY
1159
- };
1160
- const z = this.#layer.altitudeToVector3(0, 0).x;
1161
- const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
1162
- const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z);
1163
- const worldOffsetX = offsetVector.x - zeroVector.x;
1164
- const worldOffsetY = offsetVector.y - zeroVector.y;
1165
- return {
1166
- x: basePosition.x + worldOffsetX,
1167
- y: basePosition.y + worldOffsetY,
1168
- z: basePosition.z
1169
- };
1170
- }
1171
- #updatePosition() {
1172
- if (this.#originalPosition && this.#layer) {
1173
- const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
1174
- this.getObject3d().position.copy(finalPosition);
1175
- }
1176
- }
1177
- set bearing(value) {
1178
- this.#bearing = value;
1179
- const degree = this.#angle + this.#bearing;
1180
- const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
1181
- this.getObject3d().rotation.z = Math.PI / 180 * angle;
1182
- }
1183
- get angle() {
1184
- return this.#angle;
1185
- }
1186
- get currentAngle() {
1187
- return this.#angle;
1188
- }
1189
- get text() {
1190
- return this.#text;
1191
- }
1192
- get offsetX() {
1193
- return this.#offsetX;
1194
- }
1195
- get offsetY() {
1196
- return this.#offsetY;
1197
- }
1198
- get offset() {
1199
- return { x: this.#offsetX, y: this.#offsetY };
1200
- }
1201
- set offsetX(value) {
1202
- if (isNumber2(value)) {
1203
- this.#offsetX = value;
1204
- this.#updatePosition();
1205
- }
1206
- }
1207
- set offsetY(value) {
1208
- if (isNumber2(value)) {
1209
- this.#offsetY = value;
1210
- this.#updatePosition();
1211
- }
1212
- }
1213
- set angle(newAngle) {
1214
- if (isNumber2(newAngle)) {
1215
- this.#angle = newAngle;
1216
- this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
1217
- }
1218
- }
1219
- setOffset(offsetX, offsetY) {
1220
- if (isNumber2(offsetX) && isNumber2(offsetY)) {
1221
- this.#offsetX = offsetX;
1222
- this.#offsetY = offsetY;
1223
- this.#updatePosition();
1224
- }
1225
- }
1226
- addOffset(deltaX, deltaY) {
1227
- if (isNumber2(deltaX) && isNumber2(deltaY)) {
1228
- this.#offsetX += deltaX;
1229
- this.#offsetY += deltaY;
1230
- this.#updatePosition();
1231
- }
1232
- }
1233
- resetOffset() {
1234
- this.#offsetX = 0;
1235
- this.#offsetY = 0;
1236
- this.#updatePosition();
1237
- }
1238
- moveToPosition(targetX, targetY) {
1239
- if (this.#originalPosition && this.#layer) {
1240
- const currentCenter = this.#layer.vector3ToCoordinate(
1241
- this.#originalPosition
1242
- );
1243
- this.#offsetX = targetX - currentCenter.x;
1244
- this.#offsetY = targetY - currentCenter.y;
1245
- this.#updatePosition();
1246
- }
1247
- }
1248
- updateText(newText, options = {}) {
1249
- this.#text = newText;
1250
- const materialOptions = {
1251
- fillStyle: options.fillStyle || this.properties.fillStyle,
1252
- fontSize: options.fontSize || this.properties.fontSize,
1253
- textAlign: options.textAlign || this.properties.textAlign,
1254
- textBaseline: options.textBaseline || this.properties.textBaseline,
1255
- fontFamily: options.fontFamily || this.properties.fontFamily,
1256
- strokeStyle: options.strokeStyle || this.properties.strokeStyle,
1257
- lineWidth: options.lineWidth || this.properties.lineWidth
1258
- };
1259
- const newMaterial = getMaterial(newText, materialOptions);
1260
- this.getObject3d().material = newMaterial;
1261
- newMaterial.needsUpdate = true;
1262
- }
1263
- };
1264
-
1265
- // src/IndoorMap/object3d/SpriteMarker.ts
1266
- import { BaseObject as BaseObject3 } from "maptalks.three";
1267
- import { Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
1268
- import _2 from "lodash";
1269
- var DEFAULT_SCALE = 0.05;
1270
- var DEFAULT_ALTITUDE = 0;
1271
- var DEFAULT_ALPHATEST = 0.3;
1272
- var DEFAULT_OPTIONS = {
1273
- scale: DEFAULT_SCALE,
1274
- altitude: DEFAULT_ALTITUDE,
1275
- alphaTest: DEFAULT_ALPHATEST,
1276
- highlight: {
1277
- options: {
1278
- scale: DEFAULT_SCALE * 1.25
1279
- },
1280
- material: null
1281
- }
1282
- };
1283
- var SpriteMarker = class extends BaseObject3 {
1284
- #default = null;
1285
- #highlight = null;
1286
- constructor(coordinate, options, material, layer, properties) {
1287
- super();
1288
- this._initOptions(options);
1289
- this._createGroup();
1290
- const {
1291
- altitude = DEFAULT_OPTIONS.altitude,
1292
- scale: scale2 = DEFAULT_OPTIONS.scale,
1293
- highlight = DEFAULT_OPTIONS.highlight,
1294
- alphaTest = DEFAULT_OPTIONS.alphaTest
1295
- } = options;
1296
- this.properties = { ...properties };
1297
- const modifiedAltitude = altitude + 2;
1298
- this.#default = { options: { scale: scale2, altitude: modifiedAltitude }, material };
1299
- this.#highlight = _2.merge({}, DEFAULT_OPTIONS.highlight, highlight);
1300
- if (material && material instanceof SpriteMaterial2)
1301
- material.alphaTest = alphaTest;
1302
- const sprite = new Sprite2(material);
1303
- sprite.scale.set(scale2, scale2, scale2);
1304
- const obj3d = this.getObject3d();
1305
- obj3d.add(sprite);
1306
- const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
1307
- const position = layer.coordinateToVector3(coordinate, z);
1308
- _2.set(this.properties, "default.position", position);
1309
- this.getObject3d().position.copy(position);
1310
- }
1311
- // Different objects need to implement their own methods
1312
- setSymbol(material) {
1313
- if (material && material instanceof SpriteMaterial2) {
1314
- const sprite = this.getObject3d().children[0];
1315
- if (!sprite) return this;
1316
- sprite.material = material;
1317
- sprite.material.needsUpdate = true;
1318
- }
1319
- return this;
1320
- }
1321
- setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
1322
- const sprite = this.getObject3d().children[0];
1323
- if (!sprite) return this;
1324
- sprite.scale.set(scaleX, scaleY, scaleZ);
1325
- return this;
1326
- }
1327
- // Different objects need to implement their own methods
1328
- getSymbol() {
1329
- return this.getObject3d()?.children[0]?.material;
1330
- }
1331
- highlight() {
1332
- const { material, options } = this.#highlight;
1333
- if (material) this.setSymbol(material);
1334
- if (options.scale) this.setScale(options.scale);
1335
- if (options.altitude) this.setAltitude(options.altitude);
1336
- return this;
1337
- }
1338
- removeHighlight() {
1339
- const { material, options } = this.#default;
1340
- if (material) this.setSymbol(material);
1341
- if (options.scale) this.setScale(options.scale);
1342
- if (options.altitude) this.setAltitude(options.altitude);
1343
- return this;
1344
- }
1345
- };
1346
-
1347
- // src/IndoorMap/object3d/NavigationPath.ts
1348
- import * as maptalks3 from "maptalks";
1349
- import { BaseObject as BaseObject4 } from "maptalks.three";
1350
- import { MeshBasicMaterial, ShaderMaterial, Color } from "three";
1351
- var OPTIONS3 = {
1352
- altitude: 0
1353
- };
1354
- var DEFAULT_LINE_OPTION = {
1355
- color: "#000",
1356
- opacity: 1
1357
- };
1358
- var DEFAULT_LINE_EFFECT_OPTION = {
1359
- color: "#000",
1360
- opacity: 1
1361
- };
1362
- var ENABLE_ANIMATED_PATH = true;
1363
- var NavigationPath = class extends BaseObject4 {
1364
- constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
1365
- options = maptalks3.Util.extend({}, OPTIONS3, options, {
1366
- layer
1367
- });
1368
- super();
1369
- this._initOptions(options);
1370
- const { altitude = OPTIONS3.altitude } = options;
1371
- this.properties = { ...properties };
1372
- this._createGroup();
1373
- const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
1374
- const staticMaterial = new MeshBasicMaterial({
1375
- transparent: true,
1376
- color: lineColor || "#fff",
1377
- opacity: lineOpacity || 1,
1378
- depthWrite: false
1098
+ const { altitude = OPTIONS2.altitude } = options;
1099
+ this.properties = { ...properties };
1100
+ this._createGroup();
1101
+ const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
1102
+ const staticMaterial = new MeshBasicMaterial({
1103
+ transparent: true,
1104
+ color: lineColor || "#fff",
1105
+ opacity: lineOpacity || 1,
1106
+ depthWrite: false
1379
1107
  });
1380
1108
  const uniforms = {
1381
1109
  time: { value: 0 },
@@ -1407,7 +1135,7 @@ var NavigationPath = class extends BaseObject4 {
1407
1135
  }
1408
1136
  `
1409
1137
  });
1410
- const pathGeometry = maptalks3.GeoJSON.toGeometry(feature2);
1138
+ const pathGeometry = maptalks2.GeoJSON.toGeometry(feature2);
1411
1139
  const line = layer.toPath(
1412
1140
  pathGeometry,
1413
1141
  {
@@ -1465,8 +1193,8 @@ var createPolygonFromLineString = (geometry) => {
1465
1193
  const right = turfLineOffset(line, -0.3, { units: "meters" });
1466
1194
  const leftCoords = left.geometry.coordinates;
1467
1195
  const rightCoords = right.geometry.coordinates.reverse();
1468
- const polygon = [...leftCoords, ...rightCoords, leftCoords[0]];
1469
- return [polygon];
1196
+ const polygon2 = [...leftCoords, ...rightCoords, leftCoords[0]];
1197
+ return [polygon2];
1470
1198
  };
1471
1199
 
1472
1200
  // src/IndoorMap/utils/svg.ts
@@ -1500,8 +1228,8 @@ var createSVGPathFromMarkerSymbol = (style) => {
1500
1228
  markerFill,
1501
1229
  markerPath
1502
1230
  } = style;
1503
- const scale2 = markerWidth / 24;
1504
- return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${markerFill}"/>`;
1231
+ const scale3 = markerWidth / 24;
1232
+ return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
1505
1233
  };
1506
1234
 
1507
1235
  // src/IndoorMap/utils/createElements.js
@@ -1642,8 +1370,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
1642
1370
  if (allowOverride) _4.merge(symbolStyle, properties.style);
1643
1371
  if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
1644
1372
  if (geometry.type === "LineString") {
1645
- const polygon = createPolygonFromLineString(geometry);
1646
- return new GeometryType["Polygon"](polygon, {
1373
+ const polygon2 = createPolygonFromLineString(geometry);
1374
+ return new GeometryType["Polygon"](polygon2, {
1647
1375
  properties: {
1648
1376
  altitude: getAltitude(properties)
1649
1377
  },
@@ -2498,68 +2226,12 @@ var styledFeatureGenerator = (mapTheme) => {
2498
2226
  }
2499
2227
  return objects;
2500
2228
  },
2501
- create3DGroundLabel: (label, threeLayer) => {
2502
- const text = label.properties.name;
2503
- const bound = label.geometry.coordinates[0];
2504
- if (_4.isNil(bound)) throw new Error("Invalid coordinates");
2505
- const groundLabelSymbol = getElementSymbol("ground-label");
2506
- const featureSymbol = _4.get(label, "properties", {});
2507
- const groundLabelOptions = _4.merge(
2508
- {},
2509
- { text },
2510
- groundLabelSymbol,
2511
- featureSymbol
2512
- );
2513
- return new GroundLabel(bound, groundLabelOptions, threeLayer);
2514
- },
2515
- createOccupantGroundLabel: (feature2, location, mapConfig, threeLayer) => {
2516
- const text = feature2.properties.name.en;
2517
- const bound = location.geometry.coordinates[0];
2518
- if (_4.isNil(bound)) throw new Error("Invalid coordinates");
2519
- const groundLabelSymbol = getElementSymbol("occupant-flat-label");
2520
- const groundLabelOptions = getElementOptions("occupant-flat-label");
2521
- const baseAltitude = getAltitude(location.properties);
2522
- const extrudeHeight = _4.get(
2523
- mapConfig,
2524
- "extrudeConfig.unit.room.height",
2525
- 0
2526
- );
2527
- const totalAltitude = baseAltitude + extrudeHeight + 0.05;
2528
- const customAngle = _4.get(feature2, "properties.style.angle");
2529
- const offsetX = _4.get(feature2, "properties.style.offsetX", 0);
2530
- const offsetY = _4.get(feature2, "properties.style.offsetY", 0);
2531
- const featureSymbol = {
2532
- name: text,
2533
- ordinal: location.properties.ordinal,
2534
- venue_id: feature2.properties.venue_id
2535
- };
2536
- const mergedGroundLabelOptions = _4.merge(
2537
- {},
2538
- { text },
2539
- groundLabelSymbol,
2540
- groundLabelOptions,
2541
- featureSymbol,
2542
- {
2543
- altitude: totalAltitude,
2544
- offsetX,
2545
- offsetY,
2546
- // set custom angle
2547
- ...!_4.isNil(customAngle) ? { angle: customAngle } : {}
2548
- }
2549
- );
2550
- const groundLabel = new GroundLabel(
2551
- bound,
2552
- mergedGroundLabelOptions,
2553
- threeLayer
2554
- );
2555
- return groundLabel;
2556
- },
2557
2229
  create3DBillboard: (billboard, threeLayer) => {
2558
2230
  const { id, feature_type, properties } = billboard;
2559
2231
  const {
2560
2232
  logo,
2561
2233
  altitude,
2562
- scale: scale2,
2234
+ scale: scale3,
2563
2235
  alphaTest,
2564
2236
  legColor,
2565
2237
  showLeg,
@@ -2573,7 +2245,7 @@ var styledFeatureGenerator = (mapTheme) => {
2573
2245
  };
2574
2246
  const options = {
2575
2247
  altitude,
2576
- scale: scale2,
2248
+ scale: scale3,
2577
2249
  alphaTest,
2578
2250
  legColor,
2579
2251
  showLeg,
@@ -2712,10 +2384,10 @@ var styledFeatureGenerator = (mapTheme) => {
2712
2384
  transparent: true
2713
2385
  });
2714
2386
  if (unit.geometry.type === "LineString") {
2715
- const polygon = createPolygonFromLineString(unit.geometry);
2387
+ const polygon2 = createPolygonFromLineString(unit.geometry);
2716
2388
  const geometry = {
2717
2389
  type: "Polygon",
2718
- coordinates: polygon
2390
+ coordinates: polygon2
2719
2391
  };
2720
2392
  return createExtrudePolygon(
2721
2393
  geometry,
@@ -2817,9 +2489,9 @@ var getRelatedLocationsByAmenity = (feature2) => {
2817
2489
  var getRelatedLocationIdsByFeature = (feature2) => {
2818
2490
  switch (feature2?.feature_type) {
2819
2491
  case "amenity":
2820
- return getRelatedLocationsByAmenity(feature2).map((v) => v?.id);
2492
+ return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
2821
2493
  case "occupant":
2822
- return getRelatedLocationsByOccupant(feature2).map((v) => v?.id);
2494
+ return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
2823
2495
  default:
2824
2496
  return [];
2825
2497
  }
@@ -2963,108 +2635,410 @@ function coordEach(geojson, callback, excludeWrapCoord) {
2963
2635
  }
2964
2636
  }
2965
2637
  }
2966
- }
2967
-
2968
- // ../../node_modules/@turf/bbox/dist/esm/index.js
2969
- function bbox(geojson, options = {}) {
2970
- if (geojson.bbox != null && true !== options.recompute) {
2971
- return geojson.bbox;
2638
+ }
2639
+
2640
+ // ../../node_modules/@turf/bbox/dist/esm/index.js
2641
+ function bbox(geojson, options = {}) {
2642
+ if (geojson.bbox != null && true !== options.recompute) {
2643
+ return geojson.bbox;
2644
+ }
2645
+ const result = [Infinity, Infinity, -Infinity, -Infinity];
2646
+ coordEach(geojson, (coord) => {
2647
+ if (result[0] > coord[0]) {
2648
+ result[0] = coord[0];
2649
+ }
2650
+ if (result[1] > coord[1]) {
2651
+ result[1] = coord[1];
2652
+ }
2653
+ if (result[2] < coord[0]) {
2654
+ result[2] = coord[0];
2655
+ }
2656
+ if (result[3] < coord[1]) {
2657
+ result[3] = coord[1];
2658
+ }
2659
+ });
2660
+ return result;
2661
+ }
2662
+ var index_default = bbox;
2663
+
2664
+ // src/IndoorMap/camera/CameraManager.ts
2665
+ import scale from "@turf/transform-scale";
2666
+ import bboxPolygon from "@turf/bbox-polygon";
2667
+ var CameraManager = class {
2668
+ map;
2669
+ constructor(map, options) {
2670
+ this.map = map;
2671
+ if (options?.defaultView) {
2672
+ this.setView(options?.defaultView);
2673
+ }
2674
+ }
2675
+ /** Public methods */
2676
+ getView = () => {
2677
+ return this.map.getView();
2678
+ };
2679
+ setView = (value) => {
2680
+ if (this.map && Object.keys(value).length !== 0) {
2681
+ this.map.setView(value);
2682
+ }
2683
+ };
2684
+ animateTo = (view, options = {}, step) => {
2685
+ this.map.animateTo(view, options, step);
2686
+ };
2687
+ setMaxExtent(extent) {
2688
+ return this.map.setMaxExtent(extent);
2689
+ }
2690
+ getFeatureExtent = (feature2, scaleFactor = 1) => {
2691
+ const [minX, minY, maxX, maxY] = index_default(
2692
+ scale(bboxPolygon(index_default(feature2)), scaleFactor)
2693
+ );
2694
+ return new Extent(minX, minY, maxX, maxY);
2695
+ };
2696
+ getExtentZoom = (extent, options = {
2697
+ isFraction: false,
2698
+ padding: {
2699
+ paddingLeft: 0,
2700
+ paddingRight: 0,
2701
+ paddingTop: 0,
2702
+ paddingBottom: 0
2703
+ }
2704
+ }) => {
2705
+ const { isFraction = false, padding } = options;
2706
+ return this.map.getFitZoom(extent, isFraction, padding);
2707
+ };
2708
+ set maxZoom(value) {
2709
+ this.map.setMaxZoom(value);
2710
+ const spatialReference = {
2711
+ projection: "EPSG:3857",
2712
+ resolutions: (function() {
2713
+ const resolutions = [];
2714
+ const d = 2 * 6378137 * Math.PI;
2715
+ for (let i = 0; i < value; i++) {
2716
+ resolutions[i] = d / (256 * Math.pow(2, i));
2717
+ }
2718
+ return resolutions;
2719
+ })()
2720
+ };
2721
+ this.map.setSpatialReference(spatialReference);
2722
+ }
2723
+ set minZoom(value) {
2724
+ this.map.setMinZoom(value);
2725
+ }
2726
+ };
2727
+
2728
+ // src/IndoorMap/renderer/RendererManager.ts
2729
+ import _isFunction from "lodash/isFunction";
2730
+ import _min from "lodash/min";
2731
+ import { center as turfCenter2 } from "@turf/center";
2732
+ import * as THREE3 from "three";
2733
+
2734
+ // src/IndoorMap/renderer/3d/Element3DRenderer.ts
2735
+ import * as maptalks4 from "maptalks-gl";
2736
+ import * as THREE from "three";
2737
+ import { BaseObject as BaseObject5 } from "maptalks.three";
2738
+ import turfBuffer2 from "@turf/buffer";
2739
+
2740
+ // src/IndoorMap/renderer/3d/objects/GroundLabel.ts
2741
+ import * as maptalks3 from "maptalks-gl";
2742
+ import { BaseObject as BaseObject4 } from "maptalks.three";
2743
+ import {
2744
+ Texture,
2745
+ MeshPhongMaterial,
2746
+ PlaneGeometry
2747
+ } from "three";
2748
+ import { largestRect } from "d3plus-shape";
2749
+ import { max, merge, isNumber as isNumber2, isArray, range } from "lodash-es";
2750
+ var OPTIONS3 = {
2751
+ // Allowing click through and prevent interaction
2752
+ interactive: false,
2753
+ altitude: 0
2754
+ };
2755
+ var defaultFlatLabelOptions = {
2756
+ fontSize: 14,
2757
+ fontFamily: "Manrope",
2758
+ fontWeight: 600,
2759
+ margin: 0,
2760
+ scaleMin: 0.5,
2761
+ lineHeight: 1.05,
2762
+ scaleStep: 0.05,
2763
+ textAlign: "center",
2764
+ textBaseline: "middle",
2765
+ fillStyle: "#000"
2766
+ };
2767
+ var defaultRectAngleToCalc = range(-90, 92, 2);
2768
+ var getMaterial = (text, flatLabelOptions) => {
2769
+ const options = merge({}, defaultFlatLabelOptions, flatLabelOptions);
2770
+ const {
2771
+ fontSize: initialFontSize,
2772
+ fontFamily,
2773
+ fontWeight,
2774
+ margin,
2775
+ scaleMin,
2776
+ scaleStep,
2777
+ fillStyle,
2778
+ lineHeight,
2779
+ textAlign,
2780
+ strokeStyle,
2781
+ lineWidth,
2782
+ textBaseline
2783
+ } = options;
2784
+ const pixelMultiplier = 4;
2785
+ const SIZE = 100 * pixelMultiplier;
2786
+ const fontSize = initialFontSize * (pixelMultiplier * 1.25);
2787
+ const canvas = document.createElement("canvas");
2788
+ canvas.width = canvas.height = SIZE;
2789
+ const ctx = canvas.getContext("2d");
2790
+ ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
2791
+ ctx.textAlign = textAlign;
2792
+ ctx.textBaseline = textBaseline;
2793
+ ctx.fillStyle = fillStyle;
2794
+ ctx.strokeStyle = strokeStyle;
2795
+ ctx.lineWidth = lineWidth;
2796
+ const wrapText = (ctx2, text2, maxWidth) => {
2797
+ const words = text2.trim().split(/\s+/);
2798
+ if (words.length <= 1) return [text2];
2799
+ const lines = [];
2800
+ const MAX_LINES = 3;
2801
+ let currentLine = words[0];
2802
+ for (let i = 1; i < words.length; i++) {
2803
+ const lineToMeasure = currentLine + " " + words[i];
2804
+ if (ctx2.measureText(lineToMeasure).width > maxWidth) {
2805
+ lines.push(currentLine);
2806
+ currentLine = words[i];
2807
+ } else {
2808
+ currentLine = lineToMeasure;
2809
+ }
2810
+ }
2811
+ lines.push(currentLine);
2812
+ return lines.slice(0, MAX_LINES);
2813
+ };
2814
+ const hasManualBreaks = text.includes("\n");
2815
+ let texts;
2816
+ if (hasManualBreaks) {
2817
+ texts = text.split(/\n/g);
2818
+ } else {
2819
+ const maxWidth = SIZE - 2 * margin;
2820
+ texts = wrapText(ctx, text, maxWidth);
2821
+ }
2822
+ let textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
2823
+ let scale3 = 1;
2824
+ while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
2825
+ scale3 -= scaleStep;
2826
+ ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
2827
+ textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
2828
+ }
2829
+ const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
2830
+ if (scale3 > scaleMin) {
2831
+ const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
2832
+ const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
2833
+ texts.forEach((text2, index) => {
2834
+ const yOffset = startY + index * (fontSize * scale3 * lineHeight);
2835
+ if (strokeStyle && lineWidth) {
2836
+ ctx.strokeText(text2, center2.x, yOffset);
2837
+ }
2838
+ ctx.fillText(text2, center2.x, yOffset);
2839
+ });
2840
+ }
2841
+ const texture = new Texture(canvas);
2842
+ texture.needsUpdate = true;
2843
+ const material = new MeshPhongMaterial({
2844
+ map: texture,
2845
+ transparent: true,
2846
+ // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
2847
+ alphaTest: 0.3
2848
+ });
2849
+ return material;
2850
+ };
2851
+ var GroundLabel = class extends BaseObject4 {
2852
+ #angle = 0;
2853
+ #bearing = 0;
2854
+ #text = "";
2855
+ #offsetX = 0;
2856
+ #offsetY = 0;
2857
+ #originalPosition = null;
2858
+ #layer = null;
2859
+ constructor(bound, text, options, layer) {
2860
+ options = maptalks3.Util.extend({}, OPTIONS3, options, {
2861
+ layer,
2862
+ coordinate: bound
2863
+ });
2864
+ const {
2865
+ altitude = 0,
2866
+ bottomHeight = 0,
2867
+ fontSize,
2868
+ fillStyle,
2869
+ textAlign,
2870
+ fontFamily,
2871
+ textBaseline,
2872
+ strokeStyle,
2873
+ lineWidth,
2874
+ angle = defaultRectAngleToCalc,
2875
+ maxFontScale,
2876
+ offsetX = 0,
2877
+ offsetY = 0,
2878
+ ...properties
2879
+ } = options;
2880
+ super();
2881
+ this._initOptions(options);
2882
+ this.properties = properties;
2883
+ this.#offsetX = offsetX;
2884
+ this.#offsetY = offsetY;
2885
+ this.#layer = layer;
2886
+ const material = getMaterial(text, {
2887
+ fillStyle,
2888
+ fontSize,
2889
+ textAlign,
2890
+ textBaseline,
2891
+ fontFamily,
2892
+ strokeStyle,
2893
+ lineWidth
2894
+ });
2895
+ const rectAngles = isArray(angle) ? angle : [angle];
2896
+ material.needsUpdate = true;
2897
+ const rect = largestRect(bound, {
2898
+ cache: true,
2899
+ /**
2900
+ * Black magic here:
2901
+ * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
2902
+ * So we remove -90 and 90 from choices, and use -85 & 85 instead.
2903
+ */
2904
+ angle: rectAngles
2905
+ });
2906
+ const { cx, cy, width, angle: calculatedAngle } = rect;
2907
+ this.#text = text;
2908
+ this.#angle = calculatedAngle;
2909
+ const geometry = new PlaneGeometry(1, 1);
2910
+ this._createMesh(geometry, material);
2911
+ const z = layer.altitudeToVector3(altitude + bottomHeight, altitude + bottomHeight).x;
2912
+ const basePosition = layer.coordinateToVector3([cx, cy], z);
2913
+ this.#originalPosition = basePosition.clone();
2914
+ const finalPosition = this.#calculateFinalPosition(basePosition);
2915
+ const scale3 = width / 6456122659e-13;
2916
+ const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
2917
+ this.getObject3d().scale.set(finalScale, finalScale, finalScale);
2918
+ this.getObject3d().position.copy(finalPosition);
2919
+ this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
2920
+ }
2921
+ #calculateFinalPosition(basePosition) {
2922
+ if (this.#offsetX === 0 && this.#offsetY === 0) {
2923
+ return basePosition;
2924
+ }
2925
+ const offsetCoordinate = [this.#offsetX, this.#offsetY];
2926
+ const z = this.#layer.altitudeToVector3(0, 0).x;
2927
+ const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
2928
+ const zeroVector = this.#layer.coordinateToVector3([0, 0], z);
2929
+ const worldOffsetX = offsetVector.x - zeroVector.x;
2930
+ const worldOffsetY = offsetVector.y - zeroVector.y;
2931
+ return {
2932
+ x: basePosition.x + worldOffsetX,
2933
+ y: basePosition.y + worldOffsetY,
2934
+ z: basePosition.z
2935
+ };
2936
+ }
2937
+ #updatePosition() {
2938
+ if (this.#originalPosition && this.#layer) {
2939
+ const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
2940
+ this.getObject3d().position.copy(finalPosition);
2941
+ }
2942
+ }
2943
+ set bearing(value) {
2944
+ this.#bearing = value;
2945
+ const degree = this.#angle + this.#bearing;
2946
+ const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
2947
+ this.getObject3d().rotation.z = Math.PI / 180 * angle;
2972
2948
  }
2973
- const result = [Infinity, Infinity, -Infinity, -Infinity];
2974
- coordEach(geojson, (coord) => {
2975
- if (result[0] > coord[0]) {
2976
- result[0] = coord[0];
2977
- }
2978
- if (result[1] > coord[1]) {
2979
- result[1] = coord[1];
2949
+ get angle() {
2950
+ return this.#angle;
2951
+ }
2952
+ get currentAngle() {
2953
+ return this.#angle;
2954
+ }
2955
+ get text() {
2956
+ return this.#text;
2957
+ }
2958
+ get offsetX() {
2959
+ return this.#offsetX;
2960
+ }
2961
+ get offsetY() {
2962
+ return this.#offsetY;
2963
+ }
2964
+ get offset() {
2965
+ return { x: this.#offsetX, y: this.#offsetY };
2966
+ }
2967
+ set offsetX(value) {
2968
+ if (isNumber2(value)) {
2969
+ this.#offsetX = value;
2970
+ this.#updatePosition();
2980
2971
  }
2981
- if (result[2] < coord[0]) {
2982
- result[2] = coord[0];
2972
+ }
2973
+ set offsetY(value) {
2974
+ if (isNumber2(value)) {
2975
+ this.#offsetY = value;
2976
+ this.#updatePosition();
2983
2977
  }
2984
- if (result[3] < coord[1]) {
2985
- result[3] = coord[1];
2978
+ }
2979
+ set angle(newAngle) {
2980
+ if (isNumber2(newAngle)) {
2981
+ this.#angle = newAngle;
2982
+ this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
2986
2983
  }
2987
- });
2988
- return result;
2989
- }
2990
- var index_default = bbox;
2991
-
2992
- // src/IndoorMap/camera/CameraManager.ts
2993
- import scale from "@turf/transform-scale";
2994
- import bboxPolygon from "@turf/bbox-polygon";
2995
- var CameraManager = class {
2996
- map;
2997
- constructor(map, options) {
2998
- this.map = map;
2999
- if (options?.defaultView) {
3000
- this.setView(options?.defaultView);
2984
+ }
2985
+ setOffset(offsetX, offsetY) {
2986
+ if (isNumber2(offsetX) && isNumber2(offsetY)) {
2987
+ this.#offsetX = offsetX;
2988
+ this.#offsetY = offsetY;
2989
+ this.#updatePosition();
3001
2990
  }
3002
2991
  }
3003
- /** Public methods */
3004
- getView = () => {
3005
- return this.map.getView();
3006
- };
3007
- setView = (value) => {
3008
- if (this.map && Object.keys(value).length !== 0) {
3009
- this.map.setView(value);
2992
+ addOffset(deltaX, deltaY) {
2993
+ if (isNumber2(deltaX) && isNumber2(deltaY)) {
2994
+ this.#offsetX += deltaX;
2995
+ this.#offsetY += deltaY;
2996
+ this.#updatePosition();
3010
2997
  }
3011
- };
3012
- animateTo = (view, options = {}, step) => {
3013
- this.map.animateTo(view, options, step);
3014
- };
3015
- setMaxExtent(extent) {
3016
- return this.map.setMaxExtent(extent);
3017
2998
  }
3018
- getFeatureExtent = (feature2, scaleFactor = 1) => {
3019
- const [minX, minY, maxX, maxY] = index_default(
3020
- scale(bboxPolygon(index_default(feature2)), scaleFactor)
3021
- );
3022
- return new Extent(minX, minY, maxX, maxY);
3023
- };
3024
- getExtentZoom = (extent, options = {
3025
- isFraction: false,
3026
- padding: {
3027
- paddingLeft: 0,
3028
- paddingRight: 0,
3029
- paddingTop: 0,
3030
- paddingBottom: 0
2999
+ resetOffset() {
3000
+ this.#offsetX = 0;
3001
+ this.#offsetY = 0;
3002
+ this.#updatePosition();
3003
+ }
3004
+ moveToPosition(targetX, targetY) {
3005
+ if (this.#originalPosition && this.#layer) {
3006
+ const currentCenter = this.#layer.vector3ToCoordinate(
3007
+ this.#originalPosition
3008
+ );
3009
+ this.#offsetX = targetX - currentCenter.x;
3010
+ this.#offsetY = targetY - currentCenter.y;
3011
+ this.#updatePosition();
3031
3012
  }
3032
- }) => {
3033
- const { isFraction = false, padding } = options;
3034
- return this.map.getFitZoom(extent, isFraction, padding);
3035
- };
3036
- set maxZoom(value) {
3037
- this.map.setMaxZoom(value);
3038
- const spatialReference = {
3039
- projection: "EPSG:3857",
3040
- resolutions: (function() {
3041
- const resolutions = [];
3042
- const d = 2 * 6378137 * Math.PI;
3043
- for (let i = 0; i < value; i++) {
3044
- resolutions[i] = d / (256 * Math.pow(2, i));
3045
- }
3046
- return resolutions;
3047
- })()
3013
+ }
3014
+ updateText(newText, options = {}) {
3015
+ this.#text = newText;
3016
+ const materialOptions = {
3017
+ fillStyle: options.fillStyle || this.properties.fillStyle,
3018
+ fontSize: options.fontSize || this.properties.fontSize,
3019
+ textAlign: options.textAlign || this.properties.textAlign,
3020
+ textBaseline: options.textBaseline || this.properties.textBaseline,
3021
+ fontFamily: options.fontFamily || this.properties.fontFamily,
3022
+ strokeStyle: options.strokeStyle || this.properties.strokeStyle,
3023
+ lineWidth: options.lineWidth || this.properties.lineWidth
3048
3024
  };
3049
- this.map.setSpatialReference(spatialReference);
3025
+ const newMaterial = getMaterial(newText, materialOptions);
3026
+ this.getObject3d().material = newMaterial;
3027
+ newMaterial.needsUpdate = true;
3050
3028
  }
3051
- set minZoom(value) {
3052
- this.map.setMinZoom(value);
3029
+ _animation() {
3030
+ const map = this.getMap();
3031
+ if (!map) return;
3032
+ const bearing = map.getBearing();
3033
+ this.bearing = bearing;
3034
+ }
3035
+ // Add bottomHeight to altitude as final altitude position
3036
+ setAltitude(altitude) {
3037
+ const bottomHeight = this.options.bottomHeight ?? 0;
3038
+ return super.setAltitude(altitude + bottomHeight);
3053
3039
  }
3054
3040
  };
3055
3041
 
3056
- // src/IndoorMap/renderer/RendererManager.ts
3057
- import _isFunction from "lodash/isFunction";
3058
- import _min from "lodash/min";
3059
- import { center as turfCenter2 } from "@turf/center";
3060
- import * as THREE3 from "three";
3061
-
3062
- // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3063
- import * as maptalks4 from "maptalks-gl";
3064
- import * as THREE from "three";
3065
- import { BaseObject as BaseObject5 } from "maptalks.three";
3066
- import turfBuffer2 from "@turf/buffer";
3067
-
3068
3042
  // src/IndoorMap/renderer/3d/element3DRendererOptions.ts
3069
3043
  var element3DRendererOptions = {
3070
3044
  unit: {
@@ -3092,30 +3066,30 @@ var element3DRendererOptions = {
3092
3066
  }
3093
3067
  };
3094
3068
 
3095
- // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3069
+ // src/IndoorMap/renderer/3d/utils/get3DRendererOption.ts
3096
3070
  var DEFAULT_POLYGON_OPTION = {
3097
3071
  color: "#FFFFFF",
3098
3072
  offset: 0,
3099
3073
  altitude: 0
3100
3074
  };
3101
- var HEIGHT_METER = 4;
3102
- var MULTIORDINAL_HEIGHT_METER = 9;
3103
- var getGeometryOption = (feature2, options) => {
3075
+ var get3DRendererOption = (featureType, category, options) => {
3104
3076
  try {
3105
- const option = options[feature2.feature_type] ?? element3DRendererOptions[feature2.feature_type];
3106
- const category = feature2.properties.category;
3077
+ const option = options[featureType] ?? element3DRendererOptions[featureType];
3107
3078
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
3108
3079
  } catch (err) {
3109
- console.log(err.message, { options, feature: feature2 });
3080
+ console.log(err.message, { options, featureType, category });
3110
3081
  }
3111
3082
  };
3083
+
3084
+ // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3085
+ var HEIGHT_METER = 4;
3086
+ var MULTIORDINAL_HEIGHT_METER = 9;
3112
3087
  var Element3DRenderer = class extends EventTarget {
3113
3088
  options;
3114
3089
  map;
3115
3090
  gltfLayer;
3116
3091
  threeLayer;
3117
3092
  scene;
3118
- // private dracoLoader: DRACOLoader
3119
3093
  lineMaterial;
3120
3094
  materialByColorMap;
3121
3095
  // Renderer is Ready
@@ -3154,7 +3128,7 @@ var Element3DRenderer = class extends EventTarget {
3154
3128
  bottomHeight: bottomHeightOptions,
3155
3129
  color: colorOptions,
3156
3130
  ...options
3157
- } = getGeometryOption(feature2, this.options);
3131
+ } = get3DRendererOption(feature2.feature_type, feature2.properties.category, this.options);
3158
3132
  const _this = this;
3159
3133
  const createPolygon = (geometry, feature3) => {
3160
3134
  try {
@@ -3258,6 +3232,16 @@ var Element3DRenderer = class extends EventTarget {
3258
3232
  escalatorMarker.addTo(this.gltfLayer);
3259
3233
  return escalatorMarker;
3260
3234
  }
3235
+ // Note: Move to another renderer and keep this file on Geometry only?
3236
+ createGroundLabel(f, unit) {
3237
+ const text = f.properties.name;
3238
+ const bound = f.geometry.coordinates[0];
3239
+ const { height: unitHeight } = get3DRendererOption("unit", unit.properties.category, this.options);
3240
+ const options = { bottomHeight: unitHeight + 5e-3 };
3241
+ const groundLabel = new GroundLabel(bound, text, options, this.threeLayer);
3242
+ this.threeLayer.addMesh(groundLabel);
3243
+ return groundLabel;
3244
+ }
3261
3245
  async createTree(coordinate, ordinal) {
3262
3246
  const treeMarker = new maptalks4.GLTFMarker(coordinate, {
3263
3247
  symbol: {
@@ -3378,7 +3362,7 @@ var getGeometryProperties = (feature2) => ({
3378
3362
  category: feature2.properties.category,
3379
3363
  name: feature2.properties.name?.en
3380
3364
  });
3381
- var getGeometryOption2 = (feature2, options) => {
3365
+ var getGeometryOption = (feature2, options) => {
3382
3366
  try {
3383
3367
  const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
3384
3368
  const category = feature2.properties.category;
@@ -3405,7 +3389,7 @@ var Element2DRenderer = class extends EventTarget {
3405
3389
  }
3406
3390
  createGeometry = (imdfFeature) => {
3407
3391
  const feature2 = getGeometryProperties(imdfFeature);
3408
- const { symbol, ...options } = getGeometryOption2(imdfFeature, this.options);
3392
+ const { symbol, ...options } = getGeometryOption(imdfFeature, this.options);
3409
3393
  const altitude = feature2.properties.ordinal * 10;
3410
3394
  const geometry = maptalks5.Geometry.fromJSON({
3411
3395
  feature: feature2,
@@ -3427,6 +3411,11 @@ var Element2DRenderer = class extends EventTarget {
3427
3411
  async createEscalator(f, coordinates) {
3428
3412
  return Promise.resolve(null);
3429
3413
  }
3414
+ createGroundLabel(f, unit) {
3415
+ const text = f.properties.name;
3416
+ const bound = f.geometry.coordinates[0];
3417
+ return null;
3418
+ }
3430
3419
  async createTree(coordinates) {
3431
3420
  return Promise.resolve(null);
3432
3421
  }
@@ -3793,6 +3782,479 @@ var angleBetweenLineStrings = (line1, line2) => {
3793
3782
  return Math.atan2(dy, dx);
3794
3783
  };
3795
3784
 
3785
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
3786
+ var epsilon = 11102230246251565e-32;
3787
+ var splitter = 134217729;
3788
+ var resulterrbound = (3 + 8 * epsilon) * epsilon;
3789
+ function sum(elen, e, flen, f, h) {
3790
+ let Q, Qnew, hh, bvirt;
3791
+ let enow = e[0];
3792
+ let fnow = f[0];
3793
+ let eindex = 0;
3794
+ let findex = 0;
3795
+ if (fnow > enow === fnow > -enow) {
3796
+ Q = enow;
3797
+ enow = e[++eindex];
3798
+ } else {
3799
+ Q = fnow;
3800
+ fnow = f[++findex];
3801
+ }
3802
+ let hindex = 0;
3803
+ if (eindex < elen && findex < flen) {
3804
+ if (fnow > enow === fnow > -enow) {
3805
+ Qnew = enow + Q;
3806
+ hh = Q - (Qnew - enow);
3807
+ enow = e[++eindex];
3808
+ } else {
3809
+ Qnew = fnow + Q;
3810
+ hh = Q - (Qnew - fnow);
3811
+ fnow = f[++findex];
3812
+ }
3813
+ Q = Qnew;
3814
+ if (hh !== 0) {
3815
+ h[hindex++] = hh;
3816
+ }
3817
+ while (eindex < elen && findex < flen) {
3818
+ if (fnow > enow === fnow > -enow) {
3819
+ Qnew = Q + enow;
3820
+ bvirt = Qnew - Q;
3821
+ hh = Q - (Qnew - bvirt) + (enow - bvirt);
3822
+ enow = e[++eindex];
3823
+ } else {
3824
+ Qnew = Q + fnow;
3825
+ bvirt = Qnew - Q;
3826
+ hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3827
+ fnow = f[++findex];
3828
+ }
3829
+ Q = Qnew;
3830
+ if (hh !== 0) {
3831
+ h[hindex++] = hh;
3832
+ }
3833
+ }
3834
+ }
3835
+ while (eindex < elen) {
3836
+ Qnew = Q + enow;
3837
+ bvirt = Qnew - Q;
3838
+ hh = Q - (Qnew - bvirt) + (enow - bvirt);
3839
+ enow = e[++eindex];
3840
+ Q = Qnew;
3841
+ if (hh !== 0) {
3842
+ h[hindex++] = hh;
3843
+ }
3844
+ }
3845
+ while (findex < flen) {
3846
+ Qnew = Q + fnow;
3847
+ bvirt = Qnew - Q;
3848
+ hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3849
+ fnow = f[++findex];
3850
+ Q = Qnew;
3851
+ if (hh !== 0) {
3852
+ h[hindex++] = hh;
3853
+ }
3854
+ }
3855
+ if (Q !== 0 || hindex === 0) {
3856
+ h[hindex++] = Q;
3857
+ }
3858
+ return hindex;
3859
+ }
3860
+ function estimate(elen, e) {
3861
+ let Q = e[0];
3862
+ for (let i = 1; i < elen; i++) Q += e[i];
3863
+ return Q;
3864
+ }
3865
+ function vec(n) {
3866
+ return new Float64Array(n);
3867
+ }
3868
+
3869
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
3870
+ var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
3871
+ var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
3872
+ var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
3873
+ var B = vec(4);
3874
+ var C1 = vec(8);
3875
+ var C2 = vec(12);
3876
+ var D = vec(16);
3877
+ var u = vec(4);
3878
+ function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
3879
+ let acxtail, acytail, bcxtail, bcytail;
3880
+ let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
3881
+ const acx = ax - cx;
3882
+ const bcx = bx - cx;
3883
+ const acy = ay - cy;
3884
+ const bcy = by - cy;
3885
+ s1 = acx * bcy;
3886
+ c = splitter * acx;
3887
+ ahi = c - (c - acx);
3888
+ alo = acx - ahi;
3889
+ c = splitter * bcy;
3890
+ bhi = c - (c - bcy);
3891
+ blo = bcy - bhi;
3892
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
3893
+ t1 = acy * bcx;
3894
+ c = splitter * acy;
3895
+ ahi = c - (c - acy);
3896
+ alo = acy - ahi;
3897
+ c = splitter * bcx;
3898
+ bhi = c - (c - bcx);
3899
+ blo = bcx - bhi;
3900
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
3901
+ _i = s0 - t0;
3902
+ bvirt = s0 - _i;
3903
+ B[0] = s0 - (_i + bvirt) + (bvirt - t0);
3904
+ _j = s1 + _i;
3905
+ bvirt = _j - s1;
3906
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
3907
+ _i = _0 - t1;
3908
+ bvirt = _0 - _i;
3909
+ B[1] = _0 - (_i + bvirt) + (bvirt - t1);
3910
+ u32 = _j + _i;
3911
+ bvirt = u32 - _j;
3912
+ B[2] = _j - (u32 - bvirt) + (_i - bvirt);
3913
+ B[3] = u32;
3914
+ let det = estimate(4, B);
3915
+ let errbound = ccwerrboundB * detsum;
3916
+ if (det >= errbound || -det >= errbound) {
3917
+ return det;
3918
+ }
3919
+ bvirt = ax - acx;
3920
+ acxtail = ax - (acx + bvirt) + (bvirt - cx);
3921
+ bvirt = bx - bcx;
3922
+ bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
3923
+ bvirt = ay - acy;
3924
+ acytail = ay - (acy + bvirt) + (bvirt - cy);
3925
+ bvirt = by - bcy;
3926
+ bcytail = by - (bcy + bvirt) + (bvirt - cy);
3927
+ if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
3928
+ return det;
3929
+ }
3930
+ errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
3931
+ det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
3932
+ if (det >= errbound || -det >= errbound) return det;
3933
+ s1 = acxtail * bcy;
3934
+ c = splitter * acxtail;
3935
+ ahi = c - (c - acxtail);
3936
+ alo = acxtail - ahi;
3937
+ c = splitter * bcy;
3938
+ bhi = c - (c - bcy);
3939
+ blo = bcy - bhi;
3940
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
3941
+ t1 = acytail * bcx;
3942
+ c = splitter * acytail;
3943
+ ahi = c - (c - acytail);
3944
+ alo = acytail - ahi;
3945
+ c = splitter * bcx;
3946
+ bhi = c - (c - bcx);
3947
+ blo = bcx - bhi;
3948
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
3949
+ _i = s0 - t0;
3950
+ bvirt = s0 - _i;
3951
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
3952
+ _j = s1 + _i;
3953
+ bvirt = _j - s1;
3954
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
3955
+ _i = _0 - t1;
3956
+ bvirt = _0 - _i;
3957
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
3958
+ u32 = _j + _i;
3959
+ bvirt = u32 - _j;
3960
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
3961
+ u[3] = u32;
3962
+ const C1len = sum(4, B, 4, u, C1);
3963
+ s1 = acx * bcytail;
3964
+ c = splitter * acx;
3965
+ ahi = c - (c - acx);
3966
+ alo = acx - ahi;
3967
+ c = splitter * bcytail;
3968
+ bhi = c - (c - bcytail);
3969
+ blo = bcytail - bhi;
3970
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
3971
+ t1 = acy * bcxtail;
3972
+ c = splitter * acy;
3973
+ ahi = c - (c - acy);
3974
+ alo = acy - ahi;
3975
+ c = splitter * bcxtail;
3976
+ bhi = c - (c - bcxtail);
3977
+ blo = bcxtail - bhi;
3978
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
3979
+ _i = s0 - t0;
3980
+ bvirt = s0 - _i;
3981
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
3982
+ _j = s1 + _i;
3983
+ bvirt = _j - s1;
3984
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
3985
+ _i = _0 - t1;
3986
+ bvirt = _0 - _i;
3987
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
3988
+ u32 = _j + _i;
3989
+ bvirt = u32 - _j;
3990
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
3991
+ u[3] = u32;
3992
+ const C2len = sum(C1len, C1, 4, u, C2);
3993
+ s1 = acxtail * bcytail;
3994
+ c = splitter * acxtail;
3995
+ ahi = c - (c - acxtail);
3996
+ alo = acxtail - ahi;
3997
+ c = splitter * bcytail;
3998
+ bhi = c - (c - bcytail);
3999
+ blo = bcytail - bhi;
4000
+ s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4001
+ t1 = acytail * bcxtail;
4002
+ c = splitter * acytail;
4003
+ ahi = c - (c - acytail);
4004
+ alo = acytail - ahi;
4005
+ c = splitter * bcxtail;
4006
+ bhi = c - (c - bcxtail);
4007
+ blo = bcxtail - bhi;
4008
+ t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4009
+ _i = s0 - t0;
4010
+ bvirt = s0 - _i;
4011
+ u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4012
+ _j = s1 + _i;
4013
+ bvirt = _j - s1;
4014
+ _0 = s1 - (_j - bvirt) + (_i - bvirt);
4015
+ _i = _0 - t1;
4016
+ bvirt = _0 - _i;
4017
+ u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4018
+ u32 = _j + _i;
4019
+ bvirt = u32 - _j;
4020
+ u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4021
+ u[3] = u32;
4022
+ const Dlen = sum(C2len, C2, 4, u, D);
4023
+ return D[Dlen - 1];
4024
+ }
4025
+ function orient2d(ax, ay, bx, by, cx, cy) {
4026
+ const detleft = (ay - cy) * (bx - cx);
4027
+ const detright = (ax - cx) * (by - cy);
4028
+ const det = detleft - detright;
4029
+ const detsum = Math.abs(detleft + detright);
4030
+ if (Math.abs(det) >= ccwerrboundA * detsum) return det;
4031
+ return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
4032
+ }
4033
+
4034
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
4035
+ var o3derrboundA = (7 + 56 * epsilon) * epsilon;
4036
+ var o3derrboundB = (3 + 28 * epsilon) * epsilon;
4037
+ var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
4038
+ var bc = vec(4);
4039
+ var ca = vec(4);
4040
+ var ab = vec(4);
4041
+ var at_b = vec(4);
4042
+ var at_c = vec(4);
4043
+ var bt_c = vec(4);
4044
+ var bt_a = vec(4);
4045
+ var ct_a = vec(4);
4046
+ var ct_b = vec(4);
4047
+ var bct = vec(8);
4048
+ var cat = vec(8);
4049
+ var abt = vec(8);
4050
+ var u2 = vec(4);
4051
+ var _8 = vec(8);
4052
+ var _8b = vec(8);
4053
+ var _16 = vec(8);
4054
+ var _12 = vec(12);
4055
+ var fin = vec(192);
4056
+ var fin2 = vec(192);
4057
+
4058
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
4059
+ var iccerrboundA = (10 + 96 * epsilon) * epsilon;
4060
+ var iccerrboundB = (4 + 48 * epsilon) * epsilon;
4061
+ var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
4062
+ var bc2 = vec(4);
4063
+ var ca2 = vec(4);
4064
+ var ab2 = vec(4);
4065
+ var aa = vec(4);
4066
+ var bb = vec(4);
4067
+ var cc = vec(4);
4068
+ var u3 = vec(4);
4069
+ var v = vec(4);
4070
+ var axtbc = vec(8);
4071
+ var aytbc = vec(8);
4072
+ var bxtca = vec(8);
4073
+ var bytca = vec(8);
4074
+ var cxtab = vec(8);
4075
+ var cytab = vec(8);
4076
+ var abt2 = vec(8);
4077
+ var bct2 = vec(8);
4078
+ var cat2 = vec(8);
4079
+ var abtt = vec(4);
4080
+ var bctt = vec(4);
4081
+ var catt = vec(4);
4082
+ var _82 = vec(8);
4083
+ var _162 = vec(16);
4084
+ var _16b = vec(16);
4085
+ var _16c = vec(16);
4086
+ var _32 = vec(32);
4087
+ var _32b = vec(32);
4088
+ var _48 = vec(48);
4089
+ var _64 = vec(64);
4090
+ var fin3 = vec(1152);
4091
+ var fin22 = vec(1152);
4092
+
4093
+ // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
4094
+ var isperrboundA = (16 + 224 * epsilon) * epsilon;
4095
+ var isperrboundB = (5 + 72 * epsilon) * epsilon;
4096
+ var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
4097
+ var ab3 = vec(4);
4098
+ var bc3 = vec(4);
4099
+ var cd = vec(4);
4100
+ var de = vec(4);
4101
+ var ea = vec(4);
4102
+ var ac = vec(4);
4103
+ var bd = vec(4);
4104
+ var ce = vec(4);
4105
+ var da = vec(4);
4106
+ var eb = vec(4);
4107
+ var abc = vec(24);
4108
+ var bcd = vec(24);
4109
+ var cde = vec(24);
4110
+ var dea = vec(24);
4111
+ var eab = vec(24);
4112
+ var abd = vec(24);
4113
+ var bce = vec(24);
4114
+ var cda = vec(24);
4115
+ var deb = vec(24);
4116
+ var eac = vec(24);
4117
+ var adet = vec(1152);
4118
+ var bdet = vec(1152);
4119
+ var cdet = vec(1152);
4120
+ var ddet = vec(1152);
4121
+ var edet = vec(1152);
4122
+ var abdet = vec(2304);
4123
+ var cddet = vec(2304);
4124
+ var cdedet = vec(3456);
4125
+ var deter = vec(5760);
4126
+ var _83 = vec(8);
4127
+ var _8b2 = vec(8);
4128
+ var _8c = vec(8);
4129
+ var _163 = vec(16);
4130
+ var _24 = vec(24);
4131
+ var _482 = vec(48);
4132
+ var _48b = vec(48);
4133
+ var _96 = vec(96);
4134
+ var _192 = vec(192);
4135
+ var _384x = vec(384);
4136
+ var _384y = vec(384);
4137
+ var _384z = vec(384);
4138
+ var _768 = vec(768);
4139
+ var xdet = vec(96);
4140
+ var ydet = vec(96);
4141
+ var zdet = vec(96);
4142
+ var fin4 = vec(1152);
4143
+
4144
+ // ../../node_modules/point-in-polygon-hao/dist/esm/index.js
4145
+ function pointInPolygon(p, polygon2) {
4146
+ var i;
4147
+ var ii;
4148
+ var k = 0;
4149
+ var f;
4150
+ var u1;
4151
+ var v1;
4152
+ var u22;
4153
+ var v2;
4154
+ var currentP;
4155
+ var nextP;
4156
+ var x = p[0];
4157
+ var y = p[1];
4158
+ var numContours = polygon2.length;
4159
+ for (i = 0; i < numContours; i++) {
4160
+ ii = 0;
4161
+ var contour = polygon2[i];
4162
+ var contourLen = contour.length - 1;
4163
+ currentP = contour[0];
4164
+ if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
4165
+ throw new Error("First and last coordinates in a ring must be the same");
4166
+ }
4167
+ u1 = currentP[0] - x;
4168
+ v1 = currentP[1] - y;
4169
+ for (ii; ii < contourLen; ii++) {
4170
+ nextP = contour[ii + 1];
4171
+ u22 = nextP[0] - x;
4172
+ v2 = nextP[1] - y;
4173
+ if (v1 === 0 && v2 === 0) {
4174
+ if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
4175
+ return 0;
4176
+ }
4177
+ } else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
4178
+ f = orient2d(u1, u22, v1, v2, 0, 0);
4179
+ if (f === 0) {
4180
+ return 0;
4181
+ }
4182
+ if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
4183
+ k++;
4184
+ }
4185
+ }
4186
+ currentP = nextP;
4187
+ v1 = v2;
4188
+ u1 = u22;
4189
+ }
4190
+ }
4191
+ if (k % 2 === 0) {
4192
+ return false;
4193
+ }
4194
+ return true;
4195
+ }
4196
+
4197
+ // ../../node_modules/@turf/invariant/dist/esm/index.js
4198
+ function getCoord(coord) {
4199
+ if (!coord) {
4200
+ throw new Error("coord is required");
4201
+ }
4202
+ if (!Array.isArray(coord)) {
4203
+ if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
4204
+ return [...coord.geometry.coordinates];
4205
+ }
4206
+ if (coord.type === "Point") {
4207
+ return [...coord.coordinates];
4208
+ }
4209
+ }
4210
+ if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
4211
+ return [...coord];
4212
+ }
4213
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
4214
+ }
4215
+ function getGeom(geojson) {
4216
+ if (geojson.type === "Feature") {
4217
+ return geojson.geometry;
4218
+ }
4219
+ return geojson;
4220
+ }
4221
+
4222
+ // ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
4223
+ function booleanPointInPolygon(point2, polygon2, options = {}) {
4224
+ if (!point2) {
4225
+ throw new Error("point is required");
4226
+ }
4227
+ if (!polygon2) {
4228
+ throw new Error("polygon is required");
4229
+ }
4230
+ const pt = getCoord(point2);
4231
+ const geom = getGeom(polygon2);
4232
+ const type = geom.type;
4233
+ const bbox2 = polygon2.bbox;
4234
+ let polys = geom.coordinates;
4235
+ if (bbox2 && inBBox(pt, bbox2) === false) {
4236
+ return false;
4237
+ }
4238
+ if (type === "Polygon") {
4239
+ polys = [polys];
4240
+ }
4241
+ let result = false;
4242
+ for (var i = 0; i < polys.length; ++i) {
4243
+ const polyResult = pointInPolygon(pt, polys[i]);
4244
+ if (polyResult === 0) return options.ignoreBoundary ? false : true;
4245
+ else if (polyResult) result = true;
4246
+ }
4247
+ return result;
4248
+ }
4249
+ function inBBox(pt, bbox2) {
4250
+ return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
4251
+ }
4252
+
4253
+ // src/IndoorMap/renderer/utils/findUnitOnPoint.ts
4254
+ var findUnitOnPoint = (units, point2) => {
4255
+ return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
4256
+ };
4257
+
3796
4258
  // src/IndoorMap/renderer/RendererManager.ts
3797
4259
  function delay(ms) {
3798
4260
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -3896,7 +4358,7 @@ var RendererManager = class extends EventTarget {
3896
4358
  populate: true
3897
4359
  });
3898
4360
  units.filter(
3899
- (u) => !["opentobelow", "escalator"].includes(u.properties.category)
4361
+ (u4) => !["opentobelow", "escalator"].includes(u4.properties.category)
3900
4362
  ).forEach((unit) => {
3901
4363
  const element = this.elementRenderer.createGeometry(unit);
3902
4364
  if (element) {
@@ -3914,7 +4376,7 @@ var RendererManager = class extends EventTarget {
3914
4376
  this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
3915
4377
  }
3916
4378
  });
3917
- const escalators = units.filter((u) => u.properties.category === "escalator");
4379
+ const escalators = units.filter((u4) => u4.properties.category === "escalator");
3918
4380
  for (const escalator of escalators) {
3919
4381
  try {
3920
4382
  const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
@@ -3946,6 +4408,17 @@ var RendererManager = class extends EventTarget {
3946
4408
  console.warn(`cannot create escalator`, err.message);
3947
4409
  }
3948
4410
  }
4411
+ const groundLabels = await this.#dataClient.filterByType("label");
4412
+ for (const label of groundLabels) {
4413
+ const center2 = turfCenter2(polygon(label.geometry.coordinates)).geometry.coordinates;
4414
+ const unit = findUnitOnPoint(units, center2);
4415
+ const element = this.elementRenderer.createGroundLabel(label, unit);
4416
+ console.log({ element });
4417
+ if (element) {
4418
+ const _elements = Array.isArray(element) ? element : [element];
4419
+ this.addElementsToManager(label.id, _elements, label.properties.ordinal);
4420
+ }
4421
+ }
3949
4422
  this.changeLevelByOrdinal(this.currentOrdinals);
3950
4423
  this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
3951
4424
  }
@@ -4072,7 +4545,6 @@ var IndoorMap = class extends EventTarget {
4072
4545
  #billboardObjects = [];
4073
4546
  #spriteMarkerObjects = [];
4074
4547
  #mapDecorations = [];
4075
- #groundLabels = [];
4076
4548
  #groundObjects = [];
4077
4549
  #navigationGeometries = {};
4078
4550
  #venueObjects = [];
@@ -4136,7 +4608,7 @@ var IndoorMap = class extends EventTarget {
4136
4608
  layers: []
4137
4609
  });
4138
4610
  const groupLayer = new GroupGLLayer("group", [], {}).addTo(this.map);
4139
- const threeLayer = new ThreeLayer4("three", {
4611
+ const threeLayer = new ThreeLayer5("three", {
4140
4612
  forceRenderOnMoving: true,
4141
4613
  forceRenderOnRotating: true
4142
4614
  });
@@ -4237,9 +4709,6 @@ var IndoorMap = class extends EventTarget {
4237
4709
  set mapDecorations(value) {
4238
4710
  this.#mapDecorations = value;
4239
4711
  }
4240
- set groundLabels(value) {
4241
- this.#groundLabels = value;
4242
- }
4243
4712
  set pixelRatio(value) {
4244
4713
  this.map.setDevicePixelRatio(value);
4245
4714
  }
@@ -4283,13 +4752,11 @@ var IndoorMap = class extends EventTarget {
4283
4752
  createDecoration,
4284
4753
  // 3D
4285
4754
  create3DFootprint,
4286
- create3DGroundLabel,
4287
4755
  create3DBillboard,
4288
4756
  createExtrudedUnit,
4289
4757
  create3DAmenityMarker,
4290
4758
  create3DOccupantAmenityMarker,
4291
- create3DOpeningMarker,
4292
- createOccupantGroundLabel
4759
+ create3DOpeningMarker
4293
4760
  } = this.#styler;
4294
4761
  let elements = {};
4295
4762
  let object3ds = [];
@@ -4367,16 +4834,6 @@ var IndoorMap = class extends EventTarget {
4367
4834
  console.warn(`Cannot create ${feature2.id}: ${err.message}`);
4368
4835
  }
4369
4836
  }
4370
- this.#groundLabels.forEach((label) => {
4371
- const text = label.properties.name;
4372
- try {
4373
- const groundLabel = create3DGroundLabel(label, this.threeLayer);
4374
- object3ds.push(groundLabel);
4375
- this.#groundObjects.push(groundLabel);
4376
- } catch (error) {
4377
- console.log("error creating ground label for ", text);
4378
- }
4379
- });
4380
4837
  this.#mapDecorations.forEach((decoration) => {
4381
4838
  const { id, geometry, properties } = decoration;
4382
4839
  const geometryType = decoration?.geometry?.type;
@@ -4815,9 +5272,6 @@ var IndoorMap = class extends EventTarget {
4815
5272
  child.visible = this.showVenueObject && objectOpacity > 0.4;
4816
5273
  });
4817
5274
  });
4818
- this.#groundObjects.forEach((gLabel) => {
4819
- gLabel.bearing = currBearing;
4820
- });
4821
5275
  }
4822
5276
  this.#animationsToRun.forEach(({ callback }) => callback(this));
4823
5277
  TWEEN.update();