venue-js 1.2.0-next.13 → 1.2.0-next.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +30 -38
- package/dist/index.d.ts +30 -38
- package/dist/index.js +1243 -644
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1211 -612
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -1
package/dist/index.js
CHANGED
|
@@ -168,7 +168,8 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
168
168
|
// refresh every 5 min
|
|
169
169
|
},
|
|
170
170
|
element: {},
|
|
171
|
-
page: {}
|
|
171
|
+
page: {},
|
|
172
|
+
model3d: {}
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
// src/data/api/delivery-project.ts
|
|
@@ -184,6 +185,14 @@ async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAUL
|
|
|
184
185
|
const items = await res.json();
|
|
185
186
|
return items;
|
|
186
187
|
}
|
|
188
|
+
case "model3d": {
|
|
189
|
+
const res = await fetch(
|
|
190
|
+
`${baseUrl}/delivery/projects/${projectId}/${featureType}.geojson?api-key=${apiKey}`
|
|
191
|
+
);
|
|
192
|
+
if (res.status !== 200) return [];
|
|
193
|
+
const items = await res.json();
|
|
194
|
+
return items.features;
|
|
195
|
+
}
|
|
187
196
|
case "sponsored-content": {
|
|
188
197
|
const res = await fetch(
|
|
189
198
|
`${baseUrl}/delivery/projects/${projectId}/sponsored-content.json?api-key=${apiKey}`
|
|
@@ -294,16 +303,16 @@ function isValidLinearRingCoordinates(ring) {
|
|
|
294
303
|
}
|
|
295
304
|
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
296
305
|
}
|
|
297
|
-
var isValidPolygonCoordinates = (
|
|
298
|
-
if (Array.isArray(
|
|
299
|
-
return isValidLinearRingCoordinates(
|
|
306
|
+
var isValidPolygonCoordinates = (polygon2) => {
|
|
307
|
+
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
308
|
+
return isValidLinearRingCoordinates(polygon2);
|
|
300
309
|
}
|
|
301
|
-
if (Array.isArray(
|
|
302
|
-
if (!isValidLinearRingCoordinates(
|
|
310
|
+
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
311
|
+
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
303
312
|
return false;
|
|
304
313
|
}
|
|
305
|
-
for (let i = 1; i <
|
|
306
|
-
if (!isValidLinearRingCoordinates(
|
|
314
|
+
for (let i = 1; i < polygon2.length; i++) {
|
|
315
|
+
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
307
316
|
return false;
|
|
308
317
|
}
|
|
309
318
|
}
|
|
@@ -346,7 +355,7 @@ var isValidPoint = (geometry) => {
|
|
|
346
355
|
function isInFilter(filter) {
|
|
347
356
|
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
348
357
|
}
|
|
349
|
-
var someIntersect = (a, b) => a.some((
|
|
358
|
+
var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
|
|
350
359
|
function matchFilter(value, filter) {
|
|
351
360
|
if (Array.isArray(value)) {
|
|
352
361
|
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
@@ -823,6 +832,28 @@ function point(coordinates, properties, options = {}) {
|
|
|
823
832
|
};
|
|
824
833
|
return feature(geom, properties, options);
|
|
825
834
|
}
|
|
835
|
+
function polygon(coordinates, properties, options = {}) {
|
|
836
|
+
for (const ring of coordinates) {
|
|
837
|
+
if (ring.length < 4) {
|
|
838
|
+
throw new Error(
|
|
839
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
843
|
+
throw new Error("First and last Position are not equivalent.");
|
|
844
|
+
}
|
|
845
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
846
|
+
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
847
|
+
throw new Error("First and last Position are not equivalent.");
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const geom = {
|
|
852
|
+
type: "Polygon",
|
|
853
|
+
coordinates
|
|
854
|
+
};
|
|
855
|
+
return feature(geom, properties, options);
|
|
856
|
+
}
|
|
826
857
|
function lineString(coordinates, properties, options = {}) {
|
|
827
858
|
if (coordinates.length < 2) {
|
|
828
859
|
throw new Error("coordinates must be an array of two or more positions");
|
|
@@ -844,6 +875,13 @@ function featureCollection(features, options = {}) {
|
|
|
844
875
|
fc.features = features;
|
|
845
876
|
return fc;
|
|
846
877
|
}
|
|
878
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
879
|
+
const geom = {
|
|
880
|
+
type: "MultiPoint",
|
|
881
|
+
coordinates
|
|
882
|
+
};
|
|
883
|
+
return feature(geom, properties, options);
|
|
884
|
+
}
|
|
847
885
|
function isNumber(num) {
|
|
848
886
|
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
849
887
|
}
|
|
@@ -930,10 +968,10 @@ var VENUE_EVENTS = {
|
|
|
930
968
|
|
|
931
969
|
// src/IndoorMap/utils/createElements.js
|
|
932
970
|
var import_lodash4 = __toESM(require("lodash"));
|
|
933
|
-
var
|
|
971
|
+
var import_maptalks4 = require("maptalks");
|
|
934
972
|
var import_center2 = __toESM(require("@turf/center"));
|
|
935
973
|
var import_buffer = __toESM(require("@turf/buffer"));
|
|
936
|
-
var
|
|
974
|
+
var import_three4 = require("three");
|
|
937
975
|
var import_GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader.js");
|
|
938
976
|
|
|
939
977
|
// src/IndoorMap/object3d/Billboard.js
|
|
@@ -966,7 +1004,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
966
1004
|
this._initOptions(options);
|
|
967
1005
|
const {
|
|
968
1006
|
altitude = OPTIONS.altitude,
|
|
969
|
-
scale:
|
|
1007
|
+
scale: scale3 = OPTIONS.scale,
|
|
970
1008
|
alphaTest = OPTIONS.alphaTest,
|
|
971
1009
|
legColor = OPTIONS.legColor,
|
|
972
1010
|
showLeg = OPTIONS.showLeg
|
|
@@ -1000,8 +1038,8 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1000
1038
|
const sprite = new import_three.Sprite(material);
|
|
1001
1039
|
sprite.material.sizeAttenuation = false;
|
|
1002
1040
|
sprite.scale.set(
|
|
1003
|
-
|
|
1004
|
-
|
|
1041
|
+
scale3 * naturalWidth / divider,
|
|
1042
|
+
scale3 * naturalHeight / divider,
|
|
1005
1043
|
1
|
|
1006
1044
|
);
|
|
1007
1045
|
this.getObject3d().add(sprite);
|
|
@@ -1010,7 +1048,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1010
1048
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1011
1049
|
import_lodash.default.set(this.properties, "default.position", position);
|
|
1012
1050
|
import_lodash.default.set(this.properties, "default.altitude", altitude);
|
|
1013
|
-
import_lodash.default.set(this.properties, "default.scale",
|
|
1051
|
+
import_lodash.default.set(this.properties, "default.scale", scale3);
|
|
1014
1052
|
this.getObject3d().position.copy(position);
|
|
1015
1053
|
}
|
|
1016
1054
|
setLineHeight(altitude) {
|
|
@@ -1023,419 +1061,129 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1023
1061
|
}
|
|
1024
1062
|
};
|
|
1025
1063
|
|
|
1026
|
-
// src/IndoorMap/object3d/
|
|
1027
|
-
var maptalks2 = __toESM(require("maptalks"));
|
|
1064
|
+
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1028
1065
|
var import_maptalks2 = require("maptalks.three");
|
|
1029
1066
|
var import_three2 = require("three");
|
|
1030
|
-
var
|
|
1031
|
-
var
|
|
1032
|
-
var
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
scaleStep: 0.05,
|
|
1045
|
-
textAlign: "center",
|
|
1046
|
-
textBaseline: "middle",
|
|
1047
|
-
fillStyle: "#000"
|
|
1067
|
+
var import_lodash2 = __toESM(require("lodash"));
|
|
1068
|
+
var DEFAULT_SCALE = 0.05;
|
|
1069
|
+
var DEFAULT_ALTITUDE = 0;
|
|
1070
|
+
var DEFAULT_ALPHATEST = 0.3;
|
|
1071
|
+
var DEFAULT_OPTIONS = {
|
|
1072
|
+
scale: DEFAULT_SCALE,
|
|
1073
|
+
altitude: DEFAULT_ALTITUDE,
|
|
1074
|
+
alphaTest: DEFAULT_ALPHATEST,
|
|
1075
|
+
highlight: {
|
|
1076
|
+
options: {
|
|
1077
|
+
scale: DEFAULT_SCALE * 1.25
|
|
1078
|
+
},
|
|
1079
|
+
material: null
|
|
1080
|
+
}
|
|
1048
1081
|
};
|
|
1049
|
-
var
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
for (let i = 1; i < words.length; i++) {
|
|
1085
|
-
const lineToMeasure = currentLine + " " + words[i];
|
|
1086
|
-
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
1087
|
-
lines.push(currentLine);
|
|
1088
|
-
currentLine = words[i];
|
|
1089
|
-
} else {
|
|
1090
|
-
currentLine = lineToMeasure;
|
|
1091
|
-
}
|
|
1082
|
+
var SpriteMarker = class extends import_maptalks2.BaseObject {
|
|
1083
|
+
#default = null;
|
|
1084
|
+
#highlight = null;
|
|
1085
|
+
constructor(coordinate, options, material, layer, properties) {
|
|
1086
|
+
super();
|
|
1087
|
+
this._initOptions(options);
|
|
1088
|
+
this._createGroup();
|
|
1089
|
+
const {
|
|
1090
|
+
altitude = DEFAULT_OPTIONS.altitude,
|
|
1091
|
+
scale: scale3 = DEFAULT_OPTIONS.scale,
|
|
1092
|
+
highlight = DEFAULT_OPTIONS.highlight,
|
|
1093
|
+
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1094
|
+
} = options;
|
|
1095
|
+
this.properties = { ...properties };
|
|
1096
|
+
const modifiedAltitude = altitude + 2;
|
|
1097
|
+
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
1098
|
+
this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1099
|
+
if (material && material instanceof import_three2.SpriteMaterial)
|
|
1100
|
+
material.alphaTest = alphaTest;
|
|
1101
|
+
const sprite = new import_three2.Sprite(material);
|
|
1102
|
+
sprite.scale.set(scale3, scale3, scale3);
|
|
1103
|
+
const obj3d = this.getObject3d();
|
|
1104
|
+
obj3d.add(sprite);
|
|
1105
|
+
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1106
|
+
const position = layer.coordinateToVector3(coordinate, z);
|
|
1107
|
+
import_lodash2.default.set(this.properties, "default.position", position);
|
|
1108
|
+
this.getObject3d().position.copy(position);
|
|
1109
|
+
}
|
|
1110
|
+
// Different objects need to implement their own methods
|
|
1111
|
+
setSymbol(material) {
|
|
1112
|
+
if (material && material instanceof import_three2.SpriteMaterial) {
|
|
1113
|
+
const sprite = this.getObject3d().children[0];
|
|
1114
|
+
if (!sprite) return this;
|
|
1115
|
+
sprite.material = material;
|
|
1116
|
+
sprite.material.needsUpdate = true;
|
|
1092
1117
|
}
|
|
1093
|
-
|
|
1094
|
-
return lines.slice(0, MAX_LINES);
|
|
1095
|
-
};
|
|
1096
|
-
const hasManualBreaks = text.includes("\n");
|
|
1097
|
-
let texts;
|
|
1098
|
-
if (hasManualBreaks) {
|
|
1099
|
-
texts = text.split(/\n/g);
|
|
1100
|
-
} else {
|
|
1101
|
-
const maxWidth = SIZE - 2 * margin;
|
|
1102
|
-
texts = wrapText(ctx, text, maxWidth);
|
|
1118
|
+
return this;
|
|
1103
1119
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
1120
|
+
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1121
|
+
const sprite = this.getObject3d().children[0];
|
|
1122
|
+
if (!sprite) return this;
|
|
1123
|
+
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1124
|
+
return this;
|
|
1110
1125
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1126
|
+
// Different objects need to implement their own methods
|
|
1127
|
+
getSymbol() {
|
|
1128
|
+
return this.getObject3d()?.children[0]?.material;
|
|
1129
|
+
}
|
|
1130
|
+
highlight() {
|
|
1131
|
+
const { material, options } = this.#highlight;
|
|
1132
|
+
if (material) this.setSymbol(material);
|
|
1133
|
+
if (options.scale) this.setScale(options.scale);
|
|
1134
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1135
|
+
return this;
|
|
1136
|
+
}
|
|
1137
|
+
removeHighlight() {
|
|
1138
|
+
const { material, options } = this.#default;
|
|
1139
|
+
if (material) this.setSymbol(material);
|
|
1140
|
+
if (options.scale) this.setScale(options.scale);
|
|
1141
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1142
|
+
return this;
|
|
1122
1143
|
}
|
|
1123
|
-
const texture = new import_three2.Texture(canvas);
|
|
1124
|
-
texture.needsUpdate = true;
|
|
1125
|
-
const material = new import_three2.MeshPhongMaterial({
|
|
1126
|
-
map: texture,
|
|
1127
|
-
transparent: true,
|
|
1128
|
-
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
1129
|
-
alphaTest: 0.3
|
|
1130
|
-
});
|
|
1131
|
-
return material;
|
|
1132
1144
|
};
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1145
|
+
|
|
1146
|
+
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1147
|
+
var maptalks2 = __toESM(require("maptalks"));
|
|
1148
|
+
var import_maptalks3 = require("maptalks.three");
|
|
1149
|
+
var import_three3 = require("three");
|
|
1150
|
+
var OPTIONS2 = {
|
|
1151
|
+
altitude: 0
|
|
1152
|
+
};
|
|
1153
|
+
var DEFAULT_LINE_OPTION = {
|
|
1154
|
+
color: "#000",
|
|
1155
|
+
opacity: 1
|
|
1156
|
+
};
|
|
1157
|
+
var DEFAULT_LINE_EFFECT_OPTION = {
|
|
1158
|
+
color: "#000",
|
|
1159
|
+
opacity: 1
|
|
1160
|
+
};
|
|
1161
|
+
var ENABLE_ANIMATED_PATH = true;
|
|
1162
|
+
var NavigationPath = class extends import_maptalks3.BaseObject {
|
|
1163
|
+
constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
|
|
1142
1164
|
options = maptalks2.Util.extend({}, OPTIONS2, options, {
|
|
1143
|
-
layer
|
|
1144
|
-
coordinate: bound
|
|
1165
|
+
layer
|
|
1145
1166
|
});
|
|
1146
|
-
const {
|
|
1147
|
-
altitude,
|
|
1148
|
-
text,
|
|
1149
|
-
fontSize,
|
|
1150
|
-
fillStyle,
|
|
1151
|
-
textAlign,
|
|
1152
|
-
fontFamily,
|
|
1153
|
-
textBaseline,
|
|
1154
|
-
strokeStyle,
|
|
1155
|
-
lineWidth,
|
|
1156
|
-
angle = defaultRectAngleToCalc,
|
|
1157
|
-
maxFontScale,
|
|
1158
|
-
offsetX = 0,
|
|
1159
|
-
offsetY = 0,
|
|
1160
|
-
...properties
|
|
1161
|
-
} = options;
|
|
1162
1167
|
super();
|
|
1163
1168
|
this._initOptions(options);
|
|
1164
|
-
|
|
1165
|
-
this
|
|
1166
|
-
this
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
fontFamily,
|
|
1174
|
-
strokeStyle,
|
|
1175
|
-
lineWidth
|
|
1176
|
-
});
|
|
1177
|
-
const rectAngles = (0, import_lodash_es.isArray)(angle) ? angle : [angle];
|
|
1178
|
-
material.needsUpdate = true;
|
|
1179
|
-
const rect = (0, import_d3plus_shape.largestRect)(bound, {
|
|
1180
|
-
cache: true,
|
|
1181
|
-
/**
|
|
1182
|
-
* Black magic here:
|
|
1183
|
-
* For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
|
|
1184
|
-
* So we remove -90 and 90 from choices, and use -85 & 85 instead.
|
|
1185
|
-
*/
|
|
1186
|
-
angle: rectAngles
|
|
1187
|
-
});
|
|
1188
|
-
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
1189
|
-
this.#text = text;
|
|
1190
|
-
this.#angle = calculatedAngle;
|
|
1191
|
-
const geometry = new import_three2.PlaneGeometry(1, 1);
|
|
1192
|
-
this._createMesh(geometry, material);
|
|
1193
|
-
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
1194
|
-
const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z);
|
|
1195
|
-
this.#originalPosition = basePosition.clone();
|
|
1196
|
-
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
1197
|
-
const scale2 = width / 6456122659e-13;
|
|
1198
|
-
const finalScale = maxFontScale && scale2 > maxFontScale ? maxFontScale : scale2;
|
|
1199
|
-
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
1200
|
-
this.getObject3d().position.copy(finalPosition);
|
|
1201
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1202
|
-
}
|
|
1203
|
-
#calculateFinalPosition(basePosition) {
|
|
1204
|
-
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
1205
|
-
return basePosition;
|
|
1206
|
-
}
|
|
1207
|
-
const offsetCoordinate = {
|
|
1208
|
-
x: this.#offsetX,
|
|
1209
|
-
y: this.#offsetY
|
|
1210
|
-
};
|
|
1211
|
-
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
1212
|
-
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
1213
|
-
const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z);
|
|
1214
|
-
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
1215
|
-
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
1216
|
-
return {
|
|
1217
|
-
x: basePosition.x + worldOffsetX,
|
|
1218
|
-
y: basePosition.y + worldOffsetY,
|
|
1219
|
-
z: basePosition.z
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
#updatePosition() {
|
|
1223
|
-
if (this.#originalPosition && this.#layer) {
|
|
1224
|
-
const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
|
|
1225
|
-
this.getObject3d().position.copy(finalPosition);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
set bearing(value) {
|
|
1229
|
-
this.#bearing = value;
|
|
1230
|
-
const degree = this.#angle + this.#bearing;
|
|
1231
|
-
const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
|
|
1232
|
-
this.getObject3d().rotation.z = Math.PI / 180 * angle;
|
|
1233
|
-
}
|
|
1234
|
-
get angle() {
|
|
1235
|
-
return this.#angle;
|
|
1236
|
-
}
|
|
1237
|
-
get currentAngle() {
|
|
1238
|
-
return this.#angle;
|
|
1239
|
-
}
|
|
1240
|
-
get text() {
|
|
1241
|
-
return this.#text;
|
|
1242
|
-
}
|
|
1243
|
-
get offsetX() {
|
|
1244
|
-
return this.#offsetX;
|
|
1245
|
-
}
|
|
1246
|
-
get offsetY() {
|
|
1247
|
-
return this.#offsetY;
|
|
1248
|
-
}
|
|
1249
|
-
get offset() {
|
|
1250
|
-
return { x: this.#offsetX, y: this.#offsetY };
|
|
1251
|
-
}
|
|
1252
|
-
set offsetX(value) {
|
|
1253
|
-
if ((0, import_lodash_es.isNumber)(value)) {
|
|
1254
|
-
this.#offsetX = value;
|
|
1255
|
-
this.#updatePosition();
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
set offsetY(value) {
|
|
1259
|
-
if ((0, import_lodash_es.isNumber)(value)) {
|
|
1260
|
-
this.#offsetY = value;
|
|
1261
|
-
this.#updatePosition();
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
set angle(newAngle) {
|
|
1265
|
-
if ((0, import_lodash_es.isNumber)(newAngle)) {
|
|
1266
|
-
this.#angle = newAngle;
|
|
1267
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
setOffset(offsetX, offsetY) {
|
|
1271
|
-
if ((0, import_lodash_es.isNumber)(offsetX) && (0, import_lodash_es.isNumber)(offsetY)) {
|
|
1272
|
-
this.#offsetX = offsetX;
|
|
1273
|
-
this.#offsetY = offsetY;
|
|
1274
|
-
this.#updatePosition();
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
addOffset(deltaX, deltaY) {
|
|
1278
|
-
if ((0, import_lodash_es.isNumber)(deltaX) && (0, import_lodash_es.isNumber)(deltaY)) {
|
|
1279
|
-
this.#offsetX += deltaX;
|
|
1280
|
-
this.#offsetY += deltaY;
|
|
1281
|
-
this.#updatePosition();
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
resetOffset() {
|
|
1285
|
-
this.#offsetX = 0;
|
|
1286
|
-
this.#offsetY = 0;
|
|
1287
|
-
this.#updatePosition();
|
|
1288
|
-
}
|
|
1289
|
-
moveToPosition(targetX, targetY) {
|
|
1290
|
-
if (this.#originalPosition && this.#layer) {
|
|
1291
|
-
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
1292
|
-
this.#originalPosition
|
|
1293
|
-
);
|
|
1294
|
-
this.#offsetX = targetX - currentCenter.x;
|
|
1295
|
-
this.#offsetY = targetY - currentCenter.y;
|
|
1296
|
-
this.#updatePosition();
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
updateText(newText, options = {}) {
|
|
1300
|
-
this.#text = newText;
|
|
1301
|
-
const materialOptions = {
|
|
1302
|
-
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
1303
|
-
fontSize: options.fontSize || this.properties.fontSize,
|
|
1304
|
-
textAlign: options.textAlign || this.properties.textAlign,
|
|
1305
|
-
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
1306
|
-
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
1307
|
-
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
1308
|
-
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
1309
|
-
};
|
|
1310
|
-
const newMaterial = getMaterial(newText, materialOptions);
|
|
1311
|
-
this.getObject3d().material = newMaterial;
|
|
1312
|
-
newMaterial.needsUpdate = true;
|
|
1313
|
-
}
|
|
1314
|
-
};
|
|
1315
|
-
|
|
1316
|
-
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1317
|
-
var import_maptalks3 = require("maptalks.three");
|
|
1318
|
-
var import_three3 = require("three");
|
|
1319
|
-
var import_lodash2 = __toESM(require("lodash"));
|
|
1320
|
-
var DEFAULT_SCALE = 0.05;
|
|
1321
|
-
var DEFAULT_ALTITUDE = 0;
|
|
1322
|
-
var DEFAULT_ALPHATEST = 0.3;
|
|
1323
|
-
var DEFAULT_OPTIONS = {
|
|
1324
|
-
scale: DEFAULT_SCALE,
|
|
1325
|
-
altitude: DEFAULT_ALTITUDE,
|
|
1326
|
-
alphaTest: DEFAULT_ALPHATEST,
|
|
1327
|
-
highlight: {
|
|
1328
|
-
options: {
|
|
1329
|
-
scale: DEFAULT_SCALE * 1.25
|
|
1330
|
-
},
|
|
1331
|
-
material: null
|
|
1332
|
-
}
|
|
1333
|
-
};
|
|
1334
|
-
var SpriteMarker = class extends import_maptalks3.BaseObject {
|
|
1335
|
-
#default = null;
|
|
1336
|
-
#highlight = null;
|
|
1337
|
-
constructor(coordinate, options, material, layer, properties) {
|
|
1338
|
-
super();
|
|
1339
|
-
this._initOptions(options);
|
|
1340
|
-
this._createGroup();
|
|
1341
|
-
const {
|
|
1342
|
-
altitude = DEFAULT_OPTIONS.altitude,
|
|
1343
|
-
scale: scale2 = DEFAULT_OPTIONS.scale,
|
|
1344
|
-
highlight = DEFAULT_OPTIONS.highlight,
|
|
1345
|
-
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1346
|
-
} = options;
|
|
1347
|
-
this.properties = { ...properties };
|
|
1348
|
-
const modifiedAltitude = altitude + 2;
|
|
1349
|
-
this.#default = { options: { scale: scale2, altitude: modifiedAltitude }, material };
|
|
1350
|
-
this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1351
|
-
if (material && material instanceof import_three3.SpriteMaterial)
|
|
1352
|
-
material.alphaTest = alphaTest;
|
|
1353
|
-
const sprite = new import_three3.Sprite(material);
|
|
1354
|
-
sprite.scale.set(scale2, scale2, scale2);
|
|
1355
|
-
const obj3d = this.getObject3d();
|
|
1356
|
-
obj3d.add(sprite);
|
|
1357
|
-
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1358
|
-
const position = layer.coordinateToVector3(coordinate, z);
|
|
1359
|
-
import_lodash2.default.set(this.properties, "default.position", position);
|
|
1360
|
-
this.getObject3d().position.copy(position);
|
|
1361
|
-
}
|
|
1362
|
-
// Different objects need to implement their own methods
|
|
1363
|
-
setSymbol(material) {
|
|
1364
|
-
if (material && material instanceof import_three3.SpriteMaterial) {
|
|
1365
|
-
const sprite = this.getObject3d().children[0];
|
|
1366
|
-
if (!sprite) return this;
|
|
1367
|
-
sprite.material = material;
|
|
1368
|
-
sprite.material.needsUpdate = true;
|
|
1369
|
-
}
|
|
1370
|
-
return this;
|
|
1371
|
-
}
|
|
1372
|
-
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1373
|
-
const sprite = this.getObject3d().children[0];
|
|
1374
|
-
if (!sprite) return this;
|
|
1375
|
-
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1376
|
-
return this;
|
|
1377
|
-
}
|
|
1378
|
-
// Different objects need to implement their own methods
|
|
1379
|
-
getSymbol() {
|
|
1380
|
-
return this.getObject3d()?.children[0]?.material;
|
|
1381
|
-
}
|
|
1382
|
-
highlight() {
|
|
1383
|
-
const { material, options } = this.#highlight;
|
|
1384
|
-
if (material) this.setSymbol(material);
|
|
1385
|
-
if (options.scale) this.setScale(options.scale);
|
|
1386
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1387
|
-
return this;
|
|
1388
|
-
}
|
|
1389
|
-
removeHighlight() {
|
|
1390
|
-
const { material, options } = this.#default;
|
|
1391
|
-
if (material) this.setSymbol(material);
|
|
1392
|
-
if (options.scale) this.setScale(options.scale);
|
|
1393
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1394
|
-
return this;
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
|
|
1398
|
-
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1399
|
-
var maptalks3 = __toESM(require("maptalks"));
|
|
1400
|
-
var import_maptalks4 = require("maptalks.three");
|
|
1401
|
-
var import_three4 = require("three");
|
|
1402
|
-
var OPTIONS3 = {
|
|
1403
|
-
altitude: 0
|
|
1404
|
-
};
|
|
1405
|
-
var DEFAULT_LINE_OPTION = {
|
|
1406
|
-
color: "#000",
|
|
1407
|
-
opacity: 1
|
|
1408
|
-
};
|
|
1409
|
-
var DEFAULT_LINE_EFFECT_OPTION = {
|
|
1410
|
-
color: "#000",
|
|
1411
|
-
opacity: 1
|
|
1412
|
-
};
|
|
1413
|
-
var ENABLE_ANIMATED_PATH = true;
|
|
1414
|
-
var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
1415
|
-
constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
|
|
1416
|
-
options = maptalks3.Util.extend({}, OPTIONS3, options, {
|
|
1417
|
-
layer
|
|
1418
|
-
});
|
|
1419
|
-
super();
|
|
1420
|
-
this._initOptions(options);
|
|
1421
|
-
const { altitude = OPTIONS3.altitude } = options;
|
|
1422
|
-
this.properties = { ...properties };
|
|
1423
|
-
this._createGroup();
|
|
1424
|
-
const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
|
|
1425
|
-
const staticMaterial = new import_three4.MeshBasicMaterial({
|
|
1426
|
-
transparent: true,
|
|
1427
|
-
color: lineColor || "#fff",
|
|
1428
|
-
opacity: lineOpacity || 1,
|
|
1429
|
-
depthWrite: false
|
|
1169
|
+
const { altitude = OPTIONS2.altitude } = options;
|
|
1170
|
+
this.properties = { ...properties };
|
|
1171
|
+
this._createGroup();
|
|
1172
|
+
const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
|
|
1173
|
+
const staticMaterial = new import_three3.MeshBasicMaterial({
|
|
1174
|
+
transparent: true,
|
|
1175
|
+
color: lineColor || "#fff",
|
|
1176
|
+
opacity: lineOpacity || 1,
|
|
1177
|
+
depthWrite: false
|
|
1430
1178
|
});
|
|
1431
1179
|
const uniforms = {
|
|
1432
1180
|
time: { value: 0 },
|
|
1433
|
-
color: { value: new
|
|
1181
|
+
color: { value: new import_three3.Color(lineColor || "#fff") },
|
|
1434
1182
|
opacity: { value: lineOpacity || 1 }
|
|
1435
1183
|
};
|
|
1436
1184
|
this._uniforms = uniforms;
|
|
1437
1185
|
this._t = 0;
|
|
1438
|
-
const animatedMaterial = new
|
|
1186
|
+
const animatedMaterial = new import_three3.ShaderMaterial({
|
|
1439
1187
|
uniforms,
|
|
1440
1188
|
transparent: true,
|
|
1441
1189
|
depthWrite: false,
|
|
@@ -1458,7 +1206,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
|
1458
1206
|
}
|
|
1459
1207
|
`
|
|
1460
1208
|
});
|
|
1461
|
-
const pathGeometry =
|
|
1209
|
+
const pathGeometry = maptalks2.GeoJSON.toGeometry(feature2);
|
|
1462
1210
|
const line = layer.toPath(
|
|
1463
1211
|
pathGeometry,
|
|
1464
1212
|
{
|
|
@@ -1469,7 +1217,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
|
1469
1217
|
ENABLE_ANIMATED_PATH ? animatedMaterial : staticMaterial
|
|
1470
1218
|
);
|
|
1471
1219
|
const { color: outlineColor, opacity: outlineOpacity } = outlineOption || {};
|
|
1472
|
-
const outlineMaterial = new
|
|
1220
|
+
const outlineMaterial = new import_three3.MeshBasicMaterial({
|
|
1473
1221
|
transparent: true,
|
|
1474
1222
|
color: outlineColor || "#fff",
|
|
1475
1223
|
opacity: outlineOpacity || 1
|
|
@@ -1516,8 +1264,8 @@ var createPolygonFromLineString = (geometry) => {
|
|
|
1516
1264
|
const right = (0, import_line_offset.default)(line, -0.3, { units: "meters" });
|
|
1517
1265
|
const leftCoords = left.geometry.coordinates;
|
|
1518
1266
|
const rightCoords = right.geometry.coordinates.reverse();
|
|
1519
|
-
const
|
|
1520
|
-
return [
|
|
1267
|
+
const polygon2 = [...leftCoords, ...rightCoords, leftCoords[0]];
|
|
1268
|
+
return [polygon2];
|
|
1521
1269
|
};
|
|
1522
1270
|
|
|
1523
1271
|
// src/IndoorMap/utils/svg.ts
|
|
@@ -1551,14 +1299,14 @@ var createSVGPathFromMarkerSymbol = (style) => {
|
|
|
1551
1299
|
markerFill,
|
|
1552
1300
|
markerPath
|
|
1553
1301
|
} = style;
|
|
1554
|
-
const
|
|
1555
|
-
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${
|
|
1302
|
+
const scale3 = markerWidth / 24;
|
|
1303
|
+
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
|
|
1556
1304
|
};
|
|
1557
1305
|
|
|
1558
1306
|
// src/IndoorMap/utils/createElements.js
|
|
1559
1307
|
var GeometryType = {
|
|
1560
|
-
Polygon:
|
|
1561
|
-
MultiPolygon:
|
|
1308
|
+
Polygon: import_maptalks4.Polygon,
|
|
1309
|
+
MultiPolygon: import_maptalks4.MultiPolygon
|
|
1562
1310
|
};
|
|
1563
1311
|
var ORDINAL_HEIGHT = 0;
|
|
1564
1312
|
var VENUE_Z_INDEX = 0;
|
|
@@ -1693,8 +1441,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
1693
1441
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1694
1442
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1695
1443
|
if (geometry.type === "LineString") {
|
|
1696
|
-
const
|
|
1697
|
-
return new GeometryType["Polygon"](
|
|
1444
|
+
const polygon2 = createPolygonFromLineString(geometry);
|
|
1445
|
+
return new GeometryType["Polygon"](polygon2, {
|
|
1698
1446
|
properties: {
|
|
1699
1447
|
altitude: getAltitude(properties)
|
|
1700
1448
|
},
|
|
@@ -1762,7 +1510,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
|
|
|
1762
1510
|
const symbolStyle = { ...style };
|
|
1763
1511
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1764
1512
|
try {
|
|
1765
|
-
return new
|
|
1513
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1766
1514
|
properties: {
|
|
1767
1515
|
altitude: getAltitude(properties)
|
|
1768
1516
|
},
|
|
@@ -1779,7 +1527,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
|
|
|
1779
1527
|
const symbolStyle = { ...style };
|
|
1780
1528
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1781
1529
|
try {
|
|
1782
|
-
return new
|
|
1530
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1783
1531
|
properties: {
|
|
1784
1532
|
altitude: getAltitude(properties)
|
|
1785
1533
|
},
|
|
@@ -1796,7 +1544,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
1796
1544
|
const symbolStyle = { ...style };
|
|
1797
1545
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1798
1546
|
try {
|
|
1799
|
-
return new
|
|
1547
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1800
1548
|
properties: {
|
|
1801
1549
|
id,
|
|
1802
1550
|
feature_type: "opening",
|
|
@@ -1884,7 +1632,7 @@ var getFeatureMarkerConfig = (feature2, mapConfig = {}) => {
|
|
|
1884
1632
|
};
|
|
1885
1633
|
};
|
|
1886
1634
|
var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
|
|
1887
|
-
const material = new
|
|
1635
|
+
const material = new import_three4.SpriteMaterial();
|
|
1888
1636
|
try {
|
|
1889
1637
|
const [base, icon] = labelSymbol;
|
|
1890
1638
|
const { markerWidth: baseWidth = 24 } = base;
|
|
@@ -1893,7 +1641,7 @@ var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
|
|
|
1893
1641
|
const baseSVG = createSVGPathFromMarkerSymbol(base);
|
|
1894
1642
|
const iconSVG = createSVGPathFromMarkerSymbol(icon);
|
|
1895
1643
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${viewBoxDimension}" height="${viewBoxDimension}">${baseSVG}${iconSVG}</svg>`;
|
|
1896
|
-
const textureLoader = new
|
|
1644
|
+
const textureLoader = new import_three4.TextureLoader();
|
|
1897
1645
|
const scaleFactor = 200 / 24;
|
|
1898
1646
|
svgToPng(svg, scaleFactor).then((png) => {
|
|
1899
1647
|
const texture = textureLoader.load(png, () => {
|
|
@@ -2050,7 +1798,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2050
1798
|
switch (renderType) {
|
|
2051
1799
|
case "Logo":
|
|
2052
1800
|
import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2053
|
-
return new
|
|
1801
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2054
1802
|
properties: {
|
|
2055
1803
|
altitude: getAltitude(properties) + markerHeight,
|
|
2056
1804
|
...baseProperties
|
|
@@ -2058,7 +1806,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2058
1806
|
symbol: priorityLabelSymbol
|
|
2059
1807
|
});
|
|
2060
1808
|
case "Logo + Name":
|
|
2061
|
-
return new
|
|
1809
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2062
1810
|
properties: {
|
|
2063
1811
|
name: occupantName.en,
|
|
2064
1812
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -2078,7 +1826,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2078
1826
|
}
|
|
2079
1827
|
});
|
|
2080
1828
|
case "None":
|
|
2081
|
-
return new
|
|
1829
|
+
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
2082
1830
|
properties: { ...baseProperties },
|
|
2083
1831
|
content: createStyledUIMarkerElement({
|
|
2084
1832
|
style: { display: "none" },
|
|
@@ -2089,7 +1837,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2089
1837
|
case "Name":
|
|
2090
1838
|
default:
|
|
2091
1839
|
if (textMarkerType === "marker") {
|
|
2092
|
-
return new
|
|
1840
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2093
1841
|
properties: {
|
|
2094
1842
|
name: occupantName.en,
|
|
2095
1843
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -2119,7 +1867,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2119
1867
|
`occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
|
|
2120
1868
|
);
|
|
2121
1869
|
const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
|
|
2122
|
-
return new
|
|
1870
|
+
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
2123
1871
|
properties: { ...baseProperties },
|
|
2124
1872
|
content: createStyledUIMarkerElement({
|
|
2125
1873
|
style,
|
|
@@ -2196,7 +1944,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2196
1944
|
const { geometry, properties } = feature2;
|
|
2197
1945
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2198
1946
|
const markerSymbol = getElementSymbol("pin-marker");
|
|
2199
|
-
return new
|
|
1947
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2200
1948
|
properties: {
|
|
2201
1949
|
altitude: getAltitude(properties)
|
|
2202
1950
|
},
|
|
@@ -2211,7 +1959,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2211
1959
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2212
1960
|
const markerSymbol = getElementSymbol("origin-marker");
|
|
2213
1961
|
try {
|
|
2214
|
-
return new
|
|
1962
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2215
1963
|
properties: {
|
|
2216
1964
|
altitude: getAltitude(properties)
|
|
2217
1965
|
},
|
|
@@ -2233,7 +1981,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2233
1981
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2234
1982
|
const symbol = getElementSymbol("pin-marker");
|
|
2235
1983
|
try {
|
|
2236
|
-
return new
|
|
1984
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2237
1985
|
properties: {
|
|
2238
1986
|
altitude: getAltitude(properties) + markerHeight
|
|
2239
1987
|
},
|
|
@@ -2258,7 +2006,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2258
2006
|
"highlighted-logo-marker"
|
|
2259
2007
|
);
|
|
2260
2008
|
try {
|
|
2261
|
-
return new
|
|
2009
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2262
2010
|
properties: {
|
|
2263
2011
|
altitude: getAltitude(properties) + markerHeight
|
|
2264
2012
|
},
|
|
@@ -2274,7 +2022,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2274
2022
|
const { geometry, properties } = feature2;
|
|
2275
2023
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2276
2024
|
const symbolStyle = getElementSymbol("user-location") || {};
|
|
2277
|
-
const marker = new
|
|
2025
|
+
const marker = new import_maptalks4.Marker(coordinates, {
|
|
2278
2026
|
properties: {
|
|
2279
2027
|
altitude: getAltitude(properties),
|
|
2280
2028
|
ordinal: properties.ordinal !== null ? properties.ordinal : null
|
|
@@ -2303,7 +2051,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2303
2051
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2304
2052
|
const symbolStyle = getElementSymbol("last-user-location") || {};
|
|
2305
2053
|
const options = getElementOptions("last-user-location") || {};
|
|
2306
|
-
const marker = new
|
|
2054
|
+
const marker = new import_maptalks4.Marker(coordinates, {
|
|
2307
2055
|
properties: {
|
|
2308
2056
|
...options,
|
|
2309
2057
|
altitude: getAltitude(properties),
|
|
@@ -2335,14 +2083,14 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2335
2083
|
const coordinates = import_lodash4.default.get(geometry, "coordinates");
|
|
2336
2084
|
const logoUrl = import_lodash4.default.get(properties, "logo.url");
|
|
2337
2085
|
if (markerSymbol) {
|
|
2338
|
-
return new
|
|
2086
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2339
2087
|
properties: markerProperties,
|
|
2340
2088
|
symbol: markerSymbol
|
|
2341
2089
|
});
|
|
2342
2090
|
}
|
|
2343
2091
|
if (!logoUrl) {
|
|
2344
2092
|
const symbol = getElementSymbol("pin-marker");
|
|
2345
|
-
return new
|
|
2093
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2346
2094
|
properties: markerProperties,
|
|
2347
2095
|
symbol
|
|
2348
2096
|
});
|
|
@@ -2350,7 +2098,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2350
2098
|
const labelSymbol = getLabelSymbol("highlight-occupant-logo");
|
|
2351
2099
|
const priorityMarkerSymbol = import_lodash4.default.last(labelSymbol) || {};
|
|
2352
2100
|
import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2353
|
-
return new
|
|
2101
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2354
2102
|
properties: markerProperties,
|
|
2355
2103
|
symbol: labelSymbol
|
|
2356
2104
|
});
|
|
@@ -2367,7 +2115,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2367
2115
|
const kioskHeight = import_lodash4.default.get(kioskConfig, "height", 0);
|
|
2368
2116
|
const markerHeight = unitHeight + kioskHeight;
|
|
2369
2117
|
const symbol = getElementSymbol("highlight-amenity-marker");
|
|
2370
|
-
return new
|
|
2118
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2371
2119
|
properties: {
|
|
2372
2120
|
...feature2,
|
|
2373
2121
|
altitude: markerHeight
|
|
@@ -2444,24 +2192,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2444
2192
|
switch (geometry.type) {
|
|
2445
2193
|
case "Point":
|
|
2446
2194
|
return [
|
|
2447
|
-
geometry?.getCoordinates ? geometry?.getCoordinates() : new
|
|
2195
|
+
geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.Coordinate(geometry.coordinates)
|
|
2448
2196
|
];
|
|
2449
2197
|
case "Polygon":
|
|
2450
2198
|
return [
|
|
2451
|
-
geometry?.getCenter ? geometry?.getCenter() : new
|
|
2199
|
+
geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.Polygon(geometry.coordinates).getCenter()
|
|
2452
2200
|
];
|
|
2453
2201
|
case "MultiPolygon":
|
|
2454
2202
|
return [
|
|
2455
|
-
geometry?.getCenter ? geometry?.getCenter() : new
|
|
2203
|
+
geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.MultiPolygon(geometry.coordinates).getCenter()
|
|
2456
2204
|
];
|
|
2457
2205
|
case "LineString":
|
|
2458
2206
|
default:
|
|
2459
|
-
return geometry?.getCoordinates ? geometry?.getCoordinates() : new
|
|
2207
|
+
return geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.LineString(geometry.coordinates).getCoordinates();
|
|
2460
2208
|
}
|
|
2461
2209
|
}).flatten().value();
|
|
2462
2210
|
const stepPathLineSymbol = getElementSymbol("navigation-path");
|
|
2463
2211
|
const startPathSymbolMarker = getElementSymbol("navigation-path-start");
|
|
2464
|
-
const line = new
|
|
2212
|
+
const line = new import_maptalks4.LineString(mergedCoordinates, {
|
|
2465
2213
|
smoothness: 0.5,
|
|
2466
2214
|
symbol: [...stepPathLineSymbol, startPathSymbolMarker]
|
|
2467
2215
|
});
|
|
@@ -2502,13 +2250,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2502
2250
|
};
|
|
2503
2251
|
switch (type) {
|
|
2504
2252
|
case "Polygon":
|
|
2505
|
-
return new
|
|
2253
|
+
return new import_maptalks4.Polygon(coordinates, formattedProperties);
|
|
2506
2254
|
case "MultiPolygon":
|
|
2507
|
-
return new
|
|
2255
|
+
return new import_maptalks4.MultiPolygon(coordinates, formattedProperties);
|
|
2508
2256
|
case "LineString":
|
|
2509
|
-
return new
|
|
2257
|
+
return new import_maptalks4.LineString(coordinates, formattedProperties);
|
|
2510
2258
|
case "MultiLineString":
|
|
2511
|
-
return new
|
|
2259
|
+
return new import_maptalks4.MultiLineString(coordinates, formattedProperties);
|
|
2512
2260
|
default:
|
|
2513
2261
|
return null;
|
|
2514
2262
|
}
|
|
@@ -2533,7 +2281,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2533
2281
|
} else {
|
|
2534
2282
|
const color = footprintProperties.defaultColor;
|
|
2535
2283
|
if (color === "transparent") return;
|
|
2536
|
-
const material = new
|
|
2284
|
+
const material = new import_three4.MeshLambertMaterial({
|
|
2537
2285
|
color,
|
|
2538
2286
|
transparent: true
|
|
2539
2287
|
});
|
|
@@ -2549,68 +2297,12 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2549
2297
|
}
|
|
2550
2298
|
return objects;
|
|
2551
2299
|
},
|
|
2552
|
-
create3DGroundLabel: (label, threeLayer) => {
|
|
2553
|
-
const text = label.properties.name;
|
|
2554
|
-
const bound = label.geometry.coordinates[0];
|
|
2555
|
-
if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2556
|
-
const groundLabelSymbol = getElementSymbol("ground-label");
|
|
2557
|
-
const featureSymbol = import_lodash4.default.get(label, "properties", {});
|
|
2558
|
-
const groundLabelOptions = import_lodash4.default.merge(
|
|
2559
|
-
{},
|
|
2560
|
-
{ text },
|
|
2561
|
-
groundLabelSymbol,
|
|
2562
|
-
featureSymbol
|
|
2563
|
-
);
|
|
2564
|
-
return new GroundLabel(bound, groundLabelOptions, threeLayer);
|
|
2565
|
-
},
|
|
2566
|
-
createOccupantGroundLabel: (feature2, location, mapConfig, threeLayer) => {
|
|
2567
|
-
const text = feature2.properties.name.en;
|
|
2568
|
-
const bound = location.geometry.coordinates[0];
|
|
2569
|
-
if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2570
|
-
const groundLabelSymbol = getElementSymbol("occupant-flat-label");
|
|
2571
|
-
const groundLabelOptions = getElementOptions("occupant-flat-label");
|
|
2572
|
-
const baseAltitude = getAltitude(location.properties);
|
|
2573
|
-
const extrudeHeight = import_lodash4.default.get(
|
|
2574
|
-
mapConfig,
|
|
2575
|
-
"extrudeConfig.unit.room.height",
|
|
2576
|
-
0
|
|
2577
|
-
);
|
|
2578
|
-
const totalAltitude = baseAltitude + extrudeHeight + 0.05;
|
|
2579
|
-
const customAngle = import_lodash4.default.get(feature2, "properties.style.angle");
|
|
2580
|
-
const offsetX = import_lodash4.default.get(feature2, "properties.style.offsetX", 0);
|
|
2581
|
-
const offsetY = import_lodash4.default.get(feature2, "properties.style.offsetY", 0);
|
|
2582
|
-
const featureSymbol = {
|
|
2583
|
-
name: text,
|
|
2584
|
-
ordinal: location.properties.ordinal,
|
|
2585
|
-
venue_id: feature2.properties.venue_id
|
|
2586
|
-
};
|
|
2587
|
-
const mergedGroundLabelOptions = import_lodash4.default.merge(
|
|
2588
|
-
{},
|
|
2589
|
-
{ text },
|
|
2590
|
-
groundLabelSymbol,
|
|
2591
|
-
groundLabelOptions,
|
|
2592
|
-
featureSymbol,
|
|
2593
|
-
{
|
|
2594
|
-
altitude: totalAltitude,
|
|
2595
|
-
offsetX,
|
|
2596
|
-
offsetY,
|
|
2597
|
-
// set custom angle
|
|
2598
|
-
...!import_lodash4.default.isNil(customAngle) ? { angle: customAngle } : {}
|
|
2599
|
-
}
|
|
2600
|
-
);
|
|
2601
|
-
const groundLabel = new GroundLabel(
|
|
2602
|
-
bound,
|
|
2603
|
-
mergedGroundLabelOptions,
|
|
2604
|
-
threeLayer
|
|
2605
|
-
);
|
|
2606
|
-
return groundLabel;
|
|
2607
|
-
},
|
|
2608
2300
|
create3DBillboard: (billboard, threeLayer) => {
|
|
2609
2301
|
const { id, feature_type, properties } = billboard;
|
|
2610
2302
|
const {
|
|
2611
2303
|
logo,
|
|
2612
2304
|
altitude,
|
|
2613
|
-
scale:
|
|
2305
|
+
scale: scale3,
|
|
2614
2306
|
alphaTest,
|
|
2615
2307
|
legColor,
|
|
2616
2308
|
showLeg,
|
|
@@ -2624,7 +2316,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2624
2316
|
};
|
|
2625
2317
|
const options = {
|
|
2626
2318
|
altitude,
|
|
2627
|
-
scale:
|
|
2319
|
+
scale: scale3,
|
|
2628
2320
|
alphaTest,
|
|
2629
2321
|
legColor,
|
|
2630
2322
|
showLeg,
|
|
@@ -2758,15 +2450,15 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2758
2450
|
};
|
|
2759
2451
|
const color = unitProperty.defaultColor;
|
|
2760
2452
|
if (color === "transparent") return;
|
|
2761
|
-
const material = new
|
|
2453
|
+
const material = new import_three4.MeshLambertMaterial({
|
|
2762
2454
|
color,
|
|
2763
2455
|
transparent: true
|
|
2764
2456
|
});
|
|
2765
2457
|
if (unit.geometry.type === "LineString") {
|
|
2766
|
-
const
|
|
2458
|
+
const polygon2 = createPolygonFromLineString(unit.geometry);
|
|
2767
2459
|
const geometry = {
|
|
2768
2460
|
type: "Polygon",
|
|
2769
|
-
coordinates:
|
|
2461
|
+
coordinates: polygon2
|
|
2770
2462
|
};
|
|
2771
2463
|
return createExtrudePolygon(
|
|
2772
2464
|
geometry,
|
|
@@ -2868,9 +2560,9 @@ var getRelatedLocationsByAmenity = (feature2) => {
|
|
|
2868
2560
|
var getRelatedLocationIdsByFeature = (feature2) => {
|
|
2869
2561
|
switch (feature2?.feature_type) {
|
|
2870
2562
|
case "amenity":
|
|
2871
|
-
return getRelatedLocationsByAmenity(feature2).map((
|
|
2563
|
+
return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
|
|
2872
2564
|
case "occupant":
|
|
2873
|
-
return getRelatedLocationsByOccupant(feature2).map((
|
|
2565
|
+
return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
|
|
2874
2566
|
default:
|
|
2875
2567
|
return [];
|
|
2876
2568
|
}
|
|
@@ -2916,7 +2608,7 @@ var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
|
2916
2608
|
};
|
|
2917
2609
|
|
|
2918
2610
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2919
|
-
var
|
|
2611
|
+
var import_maptalks5 = require("maptalks");
|
|
2920
2612
|
|
|
2921
2613
|
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
2922
2614
|
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
@@ -3014,120 +2706,425 @@ function coordEach(geojson, callback, excludeWrapCoord) {
|
|
|
3014
2706
|
}
|
|
3015
2707
|
}
|
|
3016
2708
|
}
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
3020
|
-
function bbox(geojson, options = {}) {
|
|
3021
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
3022
|
-
return geojson.bbox;
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
2712
|
+
function bbox(geojson, options = {}) {
|
|
2713
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
2714
|
+
return geojson.bbox;
|
|
2715
|
+
}
|
|
2716
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2717
|
+
coordEach(geojson, (coord) => {
|
|
2718
|
+
if (result[0] > coord[0]) {
|
|
2719
|
+
result[0] = coord[0];
|
|
2720
|
+
}
|
|
2721
|
+
if (result[1] > coord[1]) {
|
|
2722
|
+
result[1] = coord[1];
|
|
2723
|
+
}
|
|
2724
|
+
if (result[2] < coord[0]) {
|
|
2725
|
+
result[2] = coord[0];
|
|
2726
|
+
}
|
|
2727
|
+
if (result[3] < coord[1]) {
|
|
2728
|
+
result[3] = coord[1];
|
|
2729
|
+
}
|
|
2730
|
+
});
|
|
2731
|
+
return result;
|
|
2732
|
+
}
|
|
2733
|
+
var index_default = bbox;
|
|
2734
|
+
|
|
2735
|
+
// src/IndoorMap/camera/CameraManager.ts
|
|
2736
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
2737
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
2738
|
+
var CameraManager = class {
|
|
2739
|
+
map;
|
|
2740
|
+
constructor(map, options) {
|
|
2741
|
+
this.map = map;
|
|
2742
|
+
if (options?.defaultView) {
|
|
2743
|
+
this.setView(options?.defaultView);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
/** Public methods */
|
|
2747
|
+
getView = () => {
|
|
2748
|
+
return this.map.getView();
|
|
2749
|
+
};
|
|
2750
|
+
setView = (value) => {
|
|
2751
|
+
if (this.map && Object.keys(value).length !== 0) {
|
|
2752
|
+
this.map.setView(value);
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
animateTo = (view, options = {}, step) => {
|
|
2756
|
+
this.map.animateTo(view, options, step);
|
|
2757
|
+
};
|
|
2758
|
+
setMaxExtent(extent) {
|
|
2759
|
+
return this.map.setMaxExtent(extent);
|
|
2760
|
+
}
|
|
2761
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
2762
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
2763
|
+
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
2764
|
+
);
|
|
2765
|
+
return new import_maptalks5.Extent(minX, minY, maxX, maxY);
|
|
2766
|
+
};
|
|
2767
|
+
getExtentZoom = (extent, options = {
|
|
2768
|
+
isFraction: false,
|
|
2769
|
+
padding: {
|
|
2770
|
+
paddingLeft: 0,
|
|
2771
|
+
paddingRight: 0,
|
|
2772
|
+
paddingTop: 0,
|
|
2773
|
+
paddingBottom: 0
|
|
2774
|
+
}
|
|
2775
|
+
}) => {
|
|
2776
|
+
const { isFraction = false, padding } = options;
|
|
2777
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
2778
|
+
};
|
|
2779
|
+
set maxZoom(value) {
|
|
2780
|
+
this.map.setMaxZoom(value);
|
|
2781
|
+
const spatialReference = {
|
|
2782
|
+
projection: "EPSG:3857",
|
|
2783
|
+
resolutions: (function() {
|
|
2784
|
+
const resolutions = [];
|
|
2785
|
+
const d = 2 * 6378137 * Math.PI;
|
|
2786
|
+
for (let i = 0; i < value; i++) {
|
|
2787
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
2788
|
+
}
|
|
2789
|
+
return resolutions;
|
|
2790
|
+
})()
|
|
2791
|
+
};
|
|
2792
|
+
this.map.setSpatialReference(spatialReference);
|
|
2793
|
+
}
|
|
2794
|
+
set minZoom(value) {
|
|
2795
|
+
this.map.setMinZoom(value);
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2798
|
+
|
|
2799
|
+
// src/IndoorMap/renderer/RendererManager.ts
|
|
2800
|
+
var import_compact2 = __toESM(require("lodash/compact"));
|
|
2801
|
+
var import_isFunction = __toESM(require("lodash/isFunction"));
|
|
2802
|
+
var import_min = __toESM(require("lodash/min"));
|
|
2803
|
+
var import_center3 = require("@turf/center");
|
|
2804
|
+
var THREE3 = __toESM(require("three"));
|
|
2805
|
+
|
|
2806
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
2807
|
+
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
2808
|
+
var THREE = __toESM(require("three"));
|
|
2809
|
+
var import_maptalks7 = require("maptalks.three");
|
|
2810
|
+
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
2811
|
+
var import_clean_coords = require("@turf/clean-coords");
|
|
2812
|
+
var import_polygon_to_line = require("@turf/polygon-to-line");
|
|
2813
|
+
var import_nearest_point_on_line = require("@turf/nearest-point-on-line");
|
|
2814
|
+
var import_length = require("@turf/length");
|
|
2815
|
+
var import_along = require("@turf/along");
|
|
2816
|
+
var import_point_to_line_distance = require("@turf/point-to-line-distance");
|
|
2817
|
+
|
|
2818
|
+
// src/IndoorMap/renderer/3d/objects/GroundLabel.ts
|
|
2819
|
+
var maptalks3 = __toESM(require("maptalks-gl"));
|
|
2820
|
+
var import_maptalks6 = require("maptalks.three");
|
|
2821
|
+
var import_three5 = require("three");
|
|
2822
|
+
var import_d3plus_shape = require("d3plus-shape");
|
|
2823
|
+
var import_lodash_es = require("lodash-es");
|
|
2824
|
+
var OPTIONS3 = {
|
|
2825
|
+
// Allowing click through and prevent interaction
|
|
2826
|
+
interactive: false,
|
|
2827
|
+
altitude: 0
|
|
2828
|
+
};
|
|
2829
|
+
var defaultFlatLabelOptions = {
|
|
2830
|
+
fontSize: 14,
|
|
2831
|
+
fontFamily: "Manrope",
|
|
2832
|
+
fontWeight: 600,
|
|
2833
|
+
margin: 0,
|
|
2834
|
+
scaleMin: 0.5,
|
|
2835
|
+
lineHeight: 1.05,
|
|
2836
|
+
scaleStep: 0.05,
|
|
2837
|
+
textAlign: "center",
|
|
2838
|
+
textBaseline: "middle",
|
|
2839
|
+
fillStyle: "#000"
|
|
2840
|
+
};
|
|
2841
|
+
var defaultRectAngleToCalc = (0, import_lodash_es.range)(-90, 92, 2);
|
|
2842
|
+
var getMaterial = (text, flatLabelOptions) => {
|
|
2843
|
+
const options = (0, import_lodash_es.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
2844
|
+
const {
|
|
2845
|
+
fontSize: initialFontSize,
|
|
2846
|
+
fontFamily,
|
|
2847
|
+
fontWeight,
|
|
2848
|
+
margin,
|
|
2849
|
+
scaleMin,
|
|
2850
|
+
scaleStep,
|
|
2851
|
+
fillStyle,
|
|
2852
|
+
lineHeight,
|
|
2853
|
+
textAlign,
|
|
2854
|
+
strokeStyle,
|
|
2855
|
+
lineWidth,
|
|
2856
|
+
textBaseline
|
|
2857
|
+
} = options;
|
|
2858
|
+
const pixelMultiplier = 4;
|
|
2859
|
+
const SIZE = 100 * pixelMultiplier;
|
|
2860
|
+
const fontSize = initialFontSize * (pixelMultiplier * 1.25);
|
|
2861
|
+
const canvas = document.createElement("canvas");
|
|
2862
|
+
canvas.width = canvas.height = SIZE;
|
|
2863
|
+
const ctx = canvas.getContext("2d");
|
|
2864
|
+
ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
|
|
2865
|
+
ctx.textAlign = textAlign;
|
|
2866
|
+
ctx.textBaseline = textBaseline;
|
|
2867
|
+
ctx.fillStyle = fillStyle;
|
|
2868
|
+
ctx.strokeStyle = strokeStyle;
|
|
2869
|
+
ctx.lineWidth = lineWidth;
|
|
2870
|
+
const wrapText = (ctx2, text2, maxWidth) => {
|
|
2871
|
+
const words = text2.trim().split(/\s+/);
|
|
2872
|
+
if (words.length <= 1) return [text2];
|
|
2873
|
+
const lines = [];
|
|
2874
|
+
const MAX_LINES = 3;
|
|
2875
|
+
let currentLine = words[0];
|
|
2876
|
+
for (let i = 1; i < words.length; i++) {
|
|
2877
|
+
const lineToMeasure = currentLine + " " + words[i];
|
|
2878
|
+
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
2879
|
+
lines.push(currentLine);
|
|
2880
|
+
currentLine = words[i];
|
|
2881
|
+
} else {
|
|
2882
|
+
currentLine = lineToMeasure;
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
lines.push(currentLine);
|
|
2886
|
+
return lines.slice(0, MAX_LINES);
|
|
2887
|
+
};
|
|
2888
|
+
const hasManualBreaks = text.includes("\n");
|
|
2889
|
+
let texts;
|
|
2890
|
+
if (hasManualBreaks) {
|
|
2891
|
+
texts = text.split(/\n/g);
|
|
2892
|
+
} else {
|
|
2893
|
+
const maxWidth = SIZE - 2 * margin;
|
|
2894
|
+
texts = wrapText(ctx, text, maxWidth);
|
|
2895
|
+
}
|
|
2896
|
+
let textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2897
|
+
let scale3 = 1;
|
|
2898
|
+
while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
|
|
2899
|
+
scale3 -= scaleStep;
|
|
2900
|
+
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
2901
|
+
textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2902
|
+
}
|
|
2903
|
+
const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
2904
|
+
if (scale3 > scaleMin) {
|
|
2905
|
+
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
2906
|
+
const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
2907
|
+
texts.forEach((text2, index) => {
|
|
2908
|
+
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
2909
|
+
if (strokeStyle && lineWidth) {
|
|
2910
|
+
ctx.strokeText(text2, center2.x, yOffset);
|
|
2911
|
+
}
|
|
2912
|
+
ctx.fillText(text2, center2.x, yOffset);
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
const texture = new import_three5.Texture(canvas);
|
|
2916
|
+
texture.needsUpdate = true;
|
|
2917
|
+
const material = new import_three5.MeshPhongMaterial({
|
|
2918
|
+
map: texture,
|
|
2919
|
+
transparent: true,
|
|
2920
|
+
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
2921
|
+
alphaTest: 0.3
|
|
2922
|
+
});
|
|
2923
|
+
return material;
|
|
2924
|
+
};
|
|
2925
|
+
var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
2926
|
+
#angle = 0;
|
|
2927
|
+
#bearing = 0;
|
|
2928
|
+
#text = "";
|
|
2929
|
+
#offsetX = 0;
|
|
2930
|
+
#offsetY = 0;
|
|
2931
|
+
#originalPosition = null;
|
|
2932
|
+
#layer = null;
|
|
2933
|
+
constructor(bound, text, options, layer) {
|
|
2934
|
+
options = maptalks3.Util.extend({}, OPTIONS3, options, {
|
|
2935
|
+
layer,
|
|
2936
|
+
coordinate: bound
|
|
2937
|
+
});
|
|
2938
|
+
const {
|
|
2939
|
+
altitude = 0,
|
|
2940
|
+
bottomHeight = 0,
|
|
2941
|
+
fontSize,
|
|
2942
|
+
fillStyle,
|
|
2943
|
+
textAlign,
|
|
2944
|
+
fontFamily,
|
|
2945
|
+
textBaseline,
|
|
2946
|
+
strokeStyle,
|
|
2947
|
+
lineWidth,
|
|
2948
|
+
angle = defaultRectAngleToCalc,
|
|
2949
|
+
maxFontScale,
|
|
2950
|
+
offsetX = 0,
|
|
2951
|
+
offsetY = 0,
|
|
2952
|
+
...properties
|
|
2953
|
+
} = options;
|
|
2954
|
+
super();
|
|
2955
|
+
this._initOptions(options);
|
|
2956
|
+
this.properties = properties;
|
|
2957
|
+
this.#offsetX = offsetX;
|
|
2958
|
+
this.#offsetY = offsetY;
|
|
2959
|
+
this.#layer = layer;
|
|
2960
|
+
const material = getMaterial(text, {
|
|
2961
|
+
fillStyle,
|
|
2962
|
+
fontSize,
|
|
2963
|
+
textAlign,
|
|
2964
|
+
textBaseline,
|
|
2965
|
+
fontFamily,
|
|
2966
|
+
strokeStyle,
|
|
2967
|
+
lineWidth
|
|
2968
|
+
});
|
|
2969
|
+
const rectAngles = (0, import_lodash_es.isArray)(angle) ? angle : [angle];
|
|
2970
|
+
material.needsUpdate = true;
|
|
2971
|
+
const rect = (0, import_d3plus_shape.largestRect)(bound, {
|
|
2972
|
+
cache: true,
|
|
2973
|
+
/**
|
|
2974
|
+
* Black magic here:
|
|
2975
|
+
* For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
|
|
2976
|
+
* So we remove -90 and 90 from choices, and use -85 & 85 instead.
|
|
2977
|
+
*/
|
|
2978
|
+
angle: rectAngles
|
|
2979
|
+
});
|
|
2980
|
+
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
2981
|
+
this.#text = text;
|
|
2982
|
+
this.#angle = calculatedAngle;
|
|
2983
|
+
const geometry = new import_three5.PlaneGeometry(1, 1);
|
|
2984
|
+
this._createMesh(geometry, material);
|
|
2985
|
+
const z = layer.altitudeToVector3(altitude + bottomHeight, altitude + bottomHeight).x;
|
|
2986
|
+
const basePosition = layer.coordinateToVector3([cx, cy], z);
|
|
2987
|
+
this.#originalPosition = basePosition.clone();
|
|
2988
|
+
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
2989
|
+
const scale3 = width / 6456122659e-13;
|
|
2990
|
+
const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
|
|
2991
|
+
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
2992
|
+
this.getObject3d().position.copy(finalPosition);
|
|
2993
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
2994
|
+
}
|
|
2995
|
+
#calculateFinalPosition(basePosition) {
|
|
2996
|
+
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
2997
|
+
return basePosition;
|
|
2998
|
+
}
|
|
2999
|
+
const offsetCoordinate = [this.#offsetX, this.#offsetY];
|
|
3000
|
+
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
3001
|
+
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
3002
|
+
const zeroVector = this.#layer.coordinateToVector3([0, 0], z);
|
|
3003
|
+
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
3004
|
+
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
3005
|
+
return {
|
|
3006
|
+
x: basePosition.x + worldOffsetX,
|
|
3007
|
+
y: basePosition.y + worldOffsetY,
|
|
3008
|
+
z: basePosition.z
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
#updatePosition() {
|
|
3012
|
+
if (this.#originalPosition && this.#layer) {
|
|
3013
|
+
const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
|
|
3014
|
+
this.getObject3d().position.copy(finalPosition);
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
set bearing(value) {
|
|
3018
|
+
this.#bearing = value;
|
|
3019
|
+
const degree = this.#angle + this.#bearing;
|
|
3020
|
+
const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
|
|
3021
|
+
this.getObject3d().rotation.z = Math.PI / 180 * angle;
|
|
3022
|
+
}
|
|
3023
|
+
get angle() {
|
|
3024
|
+
return this.#angle;
|
|
3025
|
+
}
|
|
3026
|
+
get currentAngle() {
|
|
3027
|
+
return this.#angle;
|
|
3028
|
+
}
|
|
3029
|
+
get text() {
|
|
3030
|
+
return this.#text;
|
|
3031
|
+
}
|
|
3032
|
+
get offsetX() {
|
|
3033
|
+
return this.#offsetX;
|
|
3023
3034
|
}
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3035
|
+
get offsetY() {
|
|
3036
|
+
return this.#offsetY;
|
|
3037
|
+
}
|
|
3038
|
+
get offset() {
|
|
3039
|
+
return { x: this.#offsetX, y: this.#offsetY };
|
|
3040
|
+
}
|
|
3041
|
+
set offsetX(value) {
|
|
3042
|
+
if ((0, import_lodash_es.isNumber)(value)) {
|
|
3043
|
+
this.#offsetX = value;
|
|
3044
|
+
this.#updatePosition();
|
|
3031
3045
|
}
|
|
3032
|
-
|
|
3033
|
-
|
|
3046
|
+
}
|
|
3047
|
+
set offsetY(value) {
|
|
3048
|
+
if ((0, import_lodash_es.isNumber)(value)) {
|
|
3049
|
+
this.#offsetY = value;
|
|
3050
|
+
this.#updatePosition();
|
|
3034
3051
|
}
|
|
3035
|
-
|
|
3036
|
-
|
|
3052
|
+
}
|
|
3053
|
+
set angle(newAngle) {
|
|
3054
|
+
if ((0, import_lodash_es.isNumber)(newAngle)) {
|
|
3055
|
+
this.#angle = newAngle;
|
|
3056
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
3037
3057
|
}
|
|
3038
|
-
}
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
3045
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
3046
|
-
var CameraManager = class {
|
|
3047
|
-
map;
|
|
3048
|
-
constructor(map, options) {
|
|
3049
|
-
this.map = map;
|
|
3050
|
-
if (options?.defaultView) {
|
|
3051
|
-
this.setView(options?.defaultView);
|
|
3058
|
+
}
|
|
3059
|
+
setOffset(offsetX, offsetY) {
|
|
3060
|
+
if ((0, import_lodash_es.isNumber)(offsetX) && (0, import_lodash_es.isNumber)(offsetY)) {
|
|
3061
|
+
this.#offsetX = offsetX;
|
|
3062
|
+
this.#offsetY = offsetY;
|
|
3063
|
+
this.#updatePosition();
|
|
3052
3064
|
}
|
|
3053
3065
|
}
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
if (this.map && Object.keys(value).length !== 0) {
|
|
3060
|
-
this.map.setView(value);
|
|
3066
|
+
addOffset(deltaX, deltaY) {
|
|
3067
|
+
if ((0, import_lodash_es.isNumber)(deltaX) && (0, import_lodash_es.isNumber)(deltaY)) {
|
|
3068
|
+
this.#offsetX += deltaX;
|
|
3069
|
+
this.#offsetY += deltaY;
|
|
3070
|
+
this.#updatePosition();
|
|
3061
3071
|
}
|
|
3062
|
-
};
|
|
3063
|
-
animateTo = (view, options = {}, step) => {
|
|
3064
|
-
this.map.animateTo(view, options, step);
|
|
3065
|
-
};
|
|
3066
|
-
setMaxExtent(extent) {
|
|
3067
|
-
return this.map.setMaxExtent(extent);
|
|
3068
3072
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
);
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3073
|
+
resetOffset() {
|
|
3074
|
+
this.#offsetX = 0;
|
|
3075
|
+
this.#offsetY = 0;
|
|
3076
|
+
this.#updatePosition();
|
|
3077
|
+
}
|
|
3078
|
+
moveToPosition(targetX, targetY) {
|
|
3079
|
+
if (this.#originalPosition && this.#layer) {
|
|
3080
|
+
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
3081
|
+
this.#originalPosition
|
|
3082
|
+
);
|
|
3083
|
+
this.#offsetX = targetX - currentCenter.x;
|
|
3084
|
+
this.#offsetY = targetY - currentCenter.y;
|
|
3085
|
+
this.#updatePosition();
|
|
3082
3086
|
}
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
for (let i = 0; i < value; i++) {
|
|
3095
|
-
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
3096
|
-
}
|
|
3097
|
-
return resolutions;
|
|
3098
|
-
})()
|
|
3087
|
+
}
|
|
3088
|
+
updateText(newText, options = {}) {
|
|
3089
|
+
this.#text = newText;
|
|
3090
|
+
const materialOptions = {
|
|
3091
|
+
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
3092
|
+
fontSize: options.fontSize || this.properties.fontSize,
|
|
3093
|
+
textAlign: options.textAlign || this.properties.textAlign,
|
|
3094
|
+
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
3095
|
+
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
3096
|
+
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
3097
|
+
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
3099
3098
|
};
|
|
3100
|
-
|
|
3099
|
+
const newMaterial = getMaterial(newText, materialOptions);
|
|
3100
|
+
this.getObject3d().material = newMaterial;
|
|
3101
|
+
newMaterial.needsUpdate = true;
|
|
3101
3102
|
}
|
|
3102
|
-
|
|
3103
|
-
this.
|
|
3103
|
+
_animation() {
|
|
3104
|
+
const map = this.getMap();
|
|
3105
|
+
if (!map) return;
|
|
3106
|
+
const bearing = map.getBearing();
|
|
3107
|
+
this.bearing = bearing;
|
|
3108
|
+
}
|
|
3109
|
+
// Add bottomHeight to altitude as final altitude position
|
|
3110
|
+
setAltitude(altitude) {
|
|
3111
|
+
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
3112
|
+
return super.setAltitude(altitude + bottomHeight);
|
|
3104
3113
|
}
|
|
3105
3114
|
};
|
|
3106
3115
|
|
|
3107
|
-
// src/IndoorMap/renderer/RendererManager.ts
|
|
3108
|
-
var import_isFunction = __toESM(require("lodash/isFunction"));
|
|
3109
|
-
var import_min = __toESM(require("lodash/min"));
|
|
3110
|
-
var import_center3 = require("@turf/center");
|
|
3111
|
-
var THREE3 = __toESM(require("three"));
|
|
3112
|
-
|
|
3113
|
-
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3114
|
-
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3115
|
-
var THREE = __toESM(require("three"));
|
|
3116
|
-
var import_maptalks7 = require("maptalks.three");
|
|
3117
|
-
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3118
|
-
|
|
3119
3116
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
3120
3117
|
var element3DRendererOptions = {
|
|
3121
3118
|
unit: {
|
|
3122
|
-
default: { color: "#ffffff", height:
|
|
3119
|
+
default: { color: "#ffffff", height: 0.2 },
|
|
3123
3120
|
byCategory: {
|
|
3124
3121
|
walkway: { color: "#cccccc", height: 0.1 },
|
|
3125
3122
|
terrace: { color: "#cccccc", height: 0.1 },
|
|
3126
3123
|
unenclosedarea: { color: "#cccccc", height: 0.2 },
|
|
3127
3124
|
nonpublic: { color: "#999999", height: 0.3 },
|
|
3128
3125
|
escalator: { height: 0.2 },
|
|
3129
|
-
parking: { height: 0.1 },
|
|
3130
|
-
room: { color: "#ffffff", height:
|
|
3126
|
+
parking: { color: "#999999", height: 0.1 },
|
|
3127
|
+
room: { color: "#ffffff", height: 0.5, bottomHeight: 0.12 }
|
|
3131
3128
|
}
|
|
3132
3129
|
},
|
|
3133
3130
|
kiosk: {
|
|
@@ -3143,30 +3140,31 @@ var element3DRendererOptions = {
|
|
|
3143
3140
|
}
|
|
3144
3141
|
};
|
|
3145
3142
|
|
|
3146
|
-
// src/IndoorMap/renderer/3d/
|
|
3143
|
+
// src/IndoorMap/renderer/3d/utils/get3DRendererOption.ts
|
|
3147
3144
|
var DEFAULT_POLYGON_OPTION = {
|
|
3148
3145
|
color: "#FFFFFF",
|
|
3149
3146
|
offset: 0,
|
|
3150
3147
|
altitude: 0
|
|
3151
3148
|
};
|
|
3152
|
-
var
|
|
3153
|
-
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3154
|
-
var getGeometryOption = (feature2, options) => {
|
|
3149
|
+
var get3DRendererOption = (featureType, category, options) => {
|
|
3155
3150
|
try {
|
|
3156
|
-
const option = options[
|
|
3157
|
-
const category = feature2.properties.category;
|
|
3151
|
+
const option = options[featureType] ?? element3DRendererOptions[featureType];
|
|
3158
3152
|
return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
|
|
3159
3153
|
} catch (err) {
|
|
3160
|
-
console.log(err.message, { options,
|
|
3154
|
+
console.log(err.message, { options, featureType, category });
|
|
3161
3155
|
}
|
|
3162
3156
|
};
|
|
3157
|
+
|
|
3158
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3159
|
+
var import_line_split = __toESM(require("@turf/line-split"));
|
|
3160
|
+
var HEIGHT_METER = 4;
|
|
3161
|
+
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3163
3162
|
var Element3DRenderer = class extends EventTarget {
|
|
3164
3163
|
options;
|
|
3165
3164
|
map;
|
|
3166
3165
|
gltfLayer;
|
|
3167
3166
|
threeLayer;
|
|
3168
3167
|
scene;
|
|
3169
|
-
// private dracoLoader: DRACOLoader
|
|
3170
3168
|
lineMaterial;
|
|
3171
3169
|
materialByColorMap;
|
|
3172
3170
|
// Renderer is Ready
|
|
@@ -3205,7 +3203,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3205
3203
|
bottomHeight: bottomHeightOptions,
|
|
3206
3204
|
color: colorOptions,
|
|
3207
3205
|
...options
|
|
3208
|
-
} =
|
|
3206
|
+
} = get3DRendererOption(feature2.feature_type, feature2.properties.category, this.options);
|
|
3209
3207
|
const _this = this;
|
|
3210
3208
|
const createPolygon = (geometry, feature3) => {
|
|
3211
3209
|
try {
|
|
@@ -3290,6 +3288,68 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3290
3288
|
console.log(`error createGeometry`, err, { feature: feature2, options });
|
|
3291
3289
|
}
|
|
3292
3290
|
};
|
|
3291
|
+
createRoomWall(unit, openings = []) {
|
|
3292
|
+
const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
|
|
3293
|
+
return polygons.map((plg) => {
|
|
3294
|
+
return plg.map((ring) => {
|
|
3295
|
+
const roomWall = (0, import_clean_coords.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
|
|
3296
|
+
if (openings.length === 0) {
|
|
3297
|
+
const color = "#ababab";
|
|
3298
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3299
|
+
const extrudedWall = this.threeLayer.toExtrudeLine(
|
|
3300
|
+
new maptalks4.LineString(roomWall.geometry.coordinates),
|
|
3301
|
+
{ height: 4, width: 1 },
|
|
3302
|
+
material
|
|
3303
|
+
);
|
|
3304
|
+
return extrudedWall;
|
|
3305
|
+
}
|
|
3306
|
+
let openingPoints = [];
|
|
3307
|
+
openings.forEach((opening) => {
|
|
3308
|
+
const doorCoords = opening?.geometry?.coordinates;
|
|
3309
|
+
const p0 = point(doorCoords[0]);
|
|
3310
|
+
const p1 = point(doorCoords[doorCoords.length - 1]);
|
|
3311
|
+
const s0 = (0, import_nearest_point_on_line.nearestPointOnLine)(roomWall, p0, { units: "meters" });
|
|
3312
|
+
const s1 = (0, import_nearest_point_on_line.nearestPointOnLine)(roomWall, p1, { units: "meters" });
|
|
3313
|
+
const d0 = s0.properties.dist;
|
|
3314
|
+
const d1 = s1.properties.dist;
|
|
3315
|
+
if (d0 > 1 || d1 > 1) {
|
|
3316
|
+
} else {
|
|
3317
|
+
openingPoints = openingPoints.concat([s0.geometry.coordinates, s1.geometry.coordinates]);
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
try {
|
|
3321
|
+
const split = (0, import_line_split.default)(roomWall, multiPoint(openingPoints));
|
|
3322
|
+
const wallsOnly = split.features.filter((seg) => {
|
|
3323
|
+
const mid = (0, import_along.along)(seg, (0, import_length.length)(seg, { units: "meters" }) / 2, { units: "meters" });
|
|
3324
|
+
for (const opening of openings) {
|
|
3325
|
+
const dist = (0, import_point_to_line_distance.pointToLineDistance)(mid, opening, { units: "meters" });
|
|
3326
|
+
if (dist < 0.05) return false;
|
|
3327
|
+
}
|
|
3328
|
+
return true;
|
|
3329
|
+
});
|
|
3330
|
+
const wallMeshes = wallsOnly.map((feature2, i) => {
|
|
3331
|
+
const color = "#ababab";
|
|
3332
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3333
|
+
const extrudedLine = this.threeLayer.toExtrudeLine(
|
|
3334
|
+
new maptalks4.LineString(feature2.geometry.coordinates),
|
|
3335
|
+
{ height: 3, width: 0.4, id: unit.id },
|
|
3336
|
+
material
|
|
3337
|
+
);
|
|
3338
|
+
extrudedLine.getObject3d().userData = {
|
|
3339
|
+
unitId: unit.id,
|
|
3340
|
+
coords: feature2.geometry.coordinates
|
|
3341
|
+
};
|
|
3342
|
+
return extrudedLine;
|
|
3343
|
+
}).flat();
|
|
3344
|
+
this.threeLayer.addMesh(wallMeshes);
|
|
3345
|
+
return wallMeshes;
|
|
3346
|
+
} catch (e) {
|
|
3347
|
+
console.log(e.message, { unit, roomWall });
|
|
3348
|
+
return [];
|
|
3349
|
+
}
|
|
3350
|
+
}).flat();
|
|
3351
|
+
}).flat();
|
|
3352
|
+
}
|
|
3293
3353
|
async createEscalator(f, coordinate, options) {
|
|
3294
3354
|
const model = {
|
|
3295
3355
|
url: "https://cdn.venue.in.th/static/glb/escalator.glb",
|
|
@@ -3309,14 +3369,24 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3309
3369
|
escalatorMarker.addTo(this.gltfLayer);
|
|
3310
3370
|
return escalatorMarker;
|
|
3311
3371
|
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3372
|
+
// Note: Move to another renderer and keep this file on Geometry only?
|
|
3373
|
+
createGroundLabel(f, unit) {
|
|
3374
|
+
const text = f.properties.name;
|
|
3375
|
+
const bound = f.geometry.coordinates[0];
|
|
3376
|
+
const { height: unitHeight } = get3DRendererOption("unit", unit.properties.category, this.options);
|
|
3377
|
+
const options = { bottomHeight: unitHeight + 5e-3 };
|
|
3378
|
+
const groundLabel = new GroundLabel(bound, text, options, this.threeLayer);
|
|
3379
|
+
this.threeLayer.addMesh(groundLabel);
|
|
3380
|
+
return groundLabel;
|
|
3381
|
+
}
|
|
3382
|
+
async createModel3d(f) {
|
|
3383
|
+
const marker = new maptalks4.GLTFMarker(f.properties.center, {
|
|
3314
3384
|
symbol: {
|
|
3315
|
-
url:
|
|
3385
|
+
url: f.properties.model
|
|
3316
3386
|
}
|
|
3317
3387
|
});
|
|
3318
|
-
|
|
3319
|
-
return
|
|
3388
|
+
marker.addTo(this.gltfLayer);
|
|
3389
|
+
return marker;
|
|
3320
3390
|
}
|
|
3321
3391
|
async createBuilding(coordinate, ordinal) {
|
|
3322
3392
|
return Promise.resolve(null);
|
|
@@ -3429,7 +3499,7 @@ var getGeometryProperties = (feature2) => ({
|
|
|
3429
3499
|
category: feature2.properties.category,
|
|
3430
3500
|
name: feature2.properties.name?.en
|
|
3431
3501
|
});
|
|
3432
|
-
var
|
|
3502
|
+
var getGeometryOption = (feature2, options) => {
|
|
3433
3503
|
try {
|
|
3434
3504
|
const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
|
|
3435
3505
|
const category = feature2.properties.category;
|
|
@@ -3456,7 +3526,7 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3456
3526
|
}
|
|
3457
3527
|
createGeometry = (imdfFeature) => {
|
|
3458
3528
|
const feature2 = getGeometryProperties(imdfFeature);
|
|
3459
|
-
const { symbol, ...options } =
|
|
3529
|
+
const { symbol, ...options } = getGeometryOption(imdfFeature, this.options);
|
|
3460
3530
|
const altitude = feature2.properties.ordinal * 10;
|
|
3461
3531
|
const geometry = maptalks5.Geometry.fromJSON({
|
|
3462
3532
|
feature: feature2,
|
|
@@ -3475,11 +3545,16 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3475
3545
|
return geometry;
|
|
3476
3546
|
}
|
|
3477
3547
|
};
|
|
3548
|
+
createRoomWall(unit, openings) {
|
|
3549
|
+
return null;
|
|
3550
|
+
}
|
|
3478
3551
|
async createEscalator(f, coordinates) {
|
|
3479
3552
|
return Promise.resolve(null);
|
|
3480
3553
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3554
|
+
createGroundLabel(f, unit) {
|
|
3555
|
+
const text = f.properties.name;
|
|
3556
|
+
const bound = f.geometry.coordinates[0];
|
|
3557
|
+
return null;
|
|
3483
3558
|
}
|
|
3484
3559
|
async createBuilding(coordinate, ordinal) {
|
|
3485
3560
|
return Promise.resolve(null);
|
|
@@ -3844,6 +3919,479 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3844
3919
|
return Math.atan2(dy, dx);
|
|
3845
3920
|
};
|
|
3846
3921
|
|
|
3922
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
|
|
3923
|
+
var epsilon = 11102230246251565e-32;
|
|
3924
|
+
var splitter = 134217729;
|
|
3925
|
+
var resulterrbound = (3 + 8 * epsilon) * epsilon;
|
|
3926
|
+
function sum(elen, e, flen, f, h) {
|
|
3927
|
+
let Q, Qnew, hh, bvirt;
|
|
3928
|
+
let enow = e[0];
|
|
3929
|
+
let fnow = f[0];
|
|
3930
|
+
let eindex = 0;
|
|
3931
|
+
let findex = 0;
|
|
3932
|
+
if (fnow > enow === fnow > -enow) {
|
|
3933
|
+
Q = enow;
|
|
3934
|
+
enow = e[++eindex];
|
|
3935
|
+
} else {
|
|
3936
|
+
Q = fnow;
|
|
3937
|
+
fnow = f[++findex];
|
|
3938
|
+
}
|
|
3939
|
+
let hindex = 0;
|
|
3940
|
+
if (eindex < elen && findex < flen) {
|
|
3941
|
+
if (fnow > enow === fnow > -enow) {
|
|
3942
|
+
Qnew = enow + Q;
|
|
3943
|
+
hh = Q - (Qnew - enow);
|
|
3944
|
+
enow = e[++eindex];
|
|
3945
|
+
} else {
|
|
3946
|
+
Qnew = fnow + Q;
|
|
3947
|
+
hh = Q - (Qnew - fnow);
|
|
3948
|
+
fnow = f[++findex];
|
|
3949
|
+
}
|
|
3950
|
+
Q = Qnew;
|
|
3951
|
+
if (hh !== 0) {
|
|
3952
|
+
h[hindex++] = hh;
|
|
3953
|
+
}
|
|
3954
|
+
while (eindex < elen && findex < flen) {
|
|
3955
|
+
if (fnow > enow === fnow > -enow) {
|
|
3956
|
+
Qnew = Q + enow;
|
|
3957
|
+
bvirt = Qnew - Q;
|
|
3958
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3959
|
+
enow = e[++eindex];
|
|
3960
|
+
} else {
|
|
3961
|
+
Qnew = Q + fnow;
|
|
3962
|
+
bvirt = Qnew - Q;
|
|
3963
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3964
|
+
fnow = f[++findex];
|
|
3965
|
+
}
|
|
3966
|
+
Q = Qnew;
|
|
3967
|
+
if (hh !== 0) {
|
|
3968
|
+
h[hindex++] = hh;
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
while (eindex < elen) {
|
|
3973
|
+
Qnew = Q + enow;
|
|
3974
|
+
bvirt = Qnew - Q;
|
|
3975
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3976
|
+
enow = e[++eindex];
|
|
3977
|
+
Q = Qnew;
|
|
3978
|
+
if (hh !== 0) {
|
|
3979
|
+
h[hindex++] = hh;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
while (findex < flen) {
|
|
3983
|
+
Qnew = Q + fnow;
|
|
3984
|
+
bvirt = Qnew - Q;
|
|
3985
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3986
|
+
fnow = f[++findex];
|
|
3987
|
+
Q = Qnew;
|
|
3988
|
+
if (hh !== 0) {
|
|
3989
|
+
h[hindex++] = hh;
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
if (Q !== 0 || hindex === 0) {
|
|
3993
|
+
h[hindex++] = Q;
|
|
3994
|
+
}
|
|
3995
|
+
return hindex;
|
|
3996
|
+
}
|
|
3997
|
+
function estimate(elen, e) {
|
|
3998
|
+
let Q = e[0];
|
|
3999
|
+
for (let i = 1; i < elen; i++) Q += e[i];
|
|
4000
|
+
return Q;
|
|
4001
|
+
}
|
|
4002
|
+
function vec(n) {
|
|
4003
|
+
return new Float64Array(n);
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
|
|
4007
|
+
var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
|
|
4008
|
+
var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
|
|
4009
|
+
var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
|
|
4010
|
+
var B = vec(4);
|
|
4011
|
+
var C1 = vec(8);
|
|
4012
|
+
var C2 = vec(12);
|
|
4013
|
+
var D = vec(16);
|
|
4014
|
+
var u = vec(4);
|
|
4015
|
+
function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
|
|
4016
|
+
let acxtail, acytail, bcxtail, bcytail;
|
|
4017
|
+
let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
|
|
4018
|
+
const acx = ax - cx;
|
|
4019
|
+
const bcx = bx - cx;
|
|
4020
|
+
const acy = ay - cy;
|
|
4021
|
+
const bcy = by - cy;
|
|
4022
|
+
s1 = acx * bcy;
|
|
4023
|
+
c = splitter * acx;
|
|
4024
|
+
ahi = c - (c - acx);
|
|
4025
|
+
alo = acx - ahi;
|
|
4026
|
+
c = splitter * bcy;
|
|
4027
|
+
bhi = c - (c - bcy);
|
|
4028
|
+
blo = bcy - bhi;
|
|
4029
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4030
|
+
t1 = acy * bcx;
|
|
4031
|
+
c = splitter * acy;
|
|
4032
|
+
ahi = c - (c - acy);
|
|
4033
|
+
alo = acy - ahi;
|
|
4034
|
+
c = splitter * bcx;
|
|
4035
|
+
bhi = c - (c - bcx);
|
|
4036
|
+
blo = bcx - bhi;
|
|
4037
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4038
|
+
_i = s0 - t0;
|
|
4039
|
+
bvirt = s0 - _i;
|
|
4040
|
+
B[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4041
|
+
_j = s1 + _i;
|
|
4042
|
+
bvirt = _j - s1;
|
|
4043
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4044
|
+
_i = _0 - t1;
|
|
4045
|
+
bvirt = _0 - _i;
|
|
4046
|
+
B[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4047
|
+
u32 = _j + _i;
|
|
4048
|
+
bvirt = u32 - _j;
|
|
4049
|
+
B[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4050
|
+
B[3] = u32;
|
|
4051
|
+
let det = estimate(4, B);
|
|
4052
|
+
let errbound = ccwerrboundB * detsum;
|
|
4053
|
+
if (det >= errbound || -det >= errbound) {
|
|
4054
|
+
return det;
|
|
4055
|
+
}
|
|
4056
|
+
bvirt = ax - acx;
|
|
4057
|
+
acxtail = ax - (acx + bvirt) + (bvirt - cx);
|
|
4058
|
+
bvirt = bx - bcx;
|
|
4059
|
+
bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
|
|
4060
|
+
bvirt = ay - acy;
|
|
4061
|
+
acytail = ay - (acy + bvirt) + (bvirt - cy);
|
|
4062
|
+
bvirt = by - bcy;
|
|
4063
|
+
bcytail = by - (bcy + bvirt) + (bvirt - cy);
|
|
4064
|
+
if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
|
|
4065
|
+
return det;
|
|
4066
|
+
}
|
|
4067
|
+
errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
|
|
4068
|
+
det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
|
|
4069
|
+
if (det >= errbound || -det >= errbound) return det;
|
|
4070
|
+
s1 = acxtail * bcy;
|
|
4071
|
+
c = splitter * acxtail;
|
|
4072
|
+
ahi = c - (c - acxtail);
|
|
4073
|
+
alo = acxtail - ahi;
|
|
4074
|
+
c = splitter * bcy;
|
|
4075
|
+
bhi = c - (c - bcy);
|
|
4076
|
+
blo = bcy - bhi;
|
|
4077
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4078
|
+
t1 = acytail * bcx;
|
|
4079
|
+
c = splitter * acytail;
|
|
4080
|
+
ahi = c - (c - acytail);
|
|
4081
|
+
alo = acytail - ahi;
|
|
4082
|
+
c = splitter * bcx;
|
|
4083
|
+
bhi = c - (c - bcx);
|
|
4084
|
+
blo = bcx - bhi;
|
|
4085
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4086
|
+
_i = s0 - t0;
|
|
4087
|
+
bvirt = s0 - _i;
|
|
4088
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4089
|
+
_j = s1 + _i;
|
|
4090
|
+
bvirt = _j - s1;
|
|
4091
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4092
|
+
_i = _0 - t1;
|
|
4093
|
+
bvirt = _0 - _i;
|
|
4094
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4095
|
+
u32 = _j + _i;
|
|
4096
|
+
bvirt = u32 - _j;
|
|
4097
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4098
|
+
u[3] = u32;
|
|
4099
|
+
const C1len = sum(4, B, 4, u, C1);
|
|
4100
|
+
s1 = acx * bcytail;
|
|
4101
|
+
c = splitter * acx;
|
|
4102
|
+
ahi = c - (c - acx);
|
|
4103
|
+
alo = acx - ahi;
|
|
4104
|
+
c = splitter * bcytail;
|
|
4105
|
+
bhi = c - (c - bcytail);
|
|
4106
|
+
blo = bcytail - bhi;
|
|
4107
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4108
|
+
t1 = acy * bcxtail;
|
|
4109
|
+
c = splitter * acy;
|
|
4110
|
+
ahi = c - (c - acy);
|
|
4111
|
+
alo = acy - ahi;
|
|
4112
|
+
c = splitter * bcxtail;
|
|
4113
|
+
bhi = c - (c - bcxtail);
|
|
4114
|
+
blo = bcxtail - bhi;
|
|
4115
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4116
|
+
_i = s0 - t0;
|
|
4117
|
+
bvirt = s0 - _i;
|
|
4118
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4119
|
+
_j = s1 + _i;
|
|
4120
|
+
bvirt = _j - s1;
|
|
4121
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4122
|
+
_i = _0 - t1;
|
|
4123
|
+
bvirt = _0 - _i;
|
|
4124
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4125
|
+
u32 = _j + _i;
|
|
4126
|
+
bvirt = u32 - _j;
|
|
4127
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4128
|
+
u[3] = u32;
|
|
4129
|
+
const C2len = sum(C1len, C1, 4, u, C2);
|
|
4130
|
+
s1 = acxtail * bcytail;
|
|
4131
|
+
c = splitter * acxtail;
|
|
4132
|
+
ahi = c - (c - acxtail);
|
|
4133
|
+
alo = acxtail - ahi;
|
|
4134
|
+
c = splitter * bcytail;
|
|
4135
|
+
bhi = c - (c - bcytail);
|
|
4136
|
+
blo = bcytail - bhi;
|
|
4137
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4138
|
+
t1 = acytail * bcxtail;
|
|
4139
|
+
c = splitter * acytail;
|
|
4140
|
+
ahi = c - (c - acytail);
|
|
4141
|
+
alo = acytail - ahi;
|
|
4142
|
+
c = splitter * bcxtail;
|
|
4143
|
+
bhi = c - (c - bcxtail);
|
|
4144
|
+
blo = bcxtail - bhi;
|
|
4145
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4146
|
+
_i = s0 - t0;
|
|
4147
|
+
bvirt = s0 - _i;
|
|
4148
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4149
|
+
_j = s1 + _i;
|
|
4150
|
+
bvirt = _j - s1;
|
|
4151
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4152
|
+
_i = _0 - t1;
|
|
4153
|
+
bvirt = _0 - _i;
|
|
4154
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4155
|
+
u32 = _j + _i;
|
|
4156
|
+
bvirt = u32 - _j;
|
|
4157
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4158
|
+
u[3] = u32;
|
|
4159
|
+
const Dlen = sum(C2len, C2, 4, u, D);
|
|
4160
|
+
return D[Dlen - 1];
|
|
4161
|
+
}
|
|
4162
|
+
function orient2d(ax, ay, bx, by, cx, cy) {
|
|
4163
|
+
const detleft = (ay - cy) * (bx - cx);
|
|
4164
|
+
const detright = (ax - cx) * (by - cy);
|
|
4165
|
+
const det = detleft - detright;
|
|
4166
|
+
const detsum = Math.abs(detleft + detright);
|
|
4167
|
+
if (Math.abs(det) >= ccwerrboundA * detsum) return det;
|
|
4168
|
+
return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
|
|
4172
|
+
var o3derrboundA = (7 + 56 * epsilon) * epsilon;
|
|
4173
|
+
var o3derrboundB = (3 + 28 * epsilon) * epsilon;
|
|
4174
|
+
var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
|
|
4175
|
+
var bc = vec(4);
|
|
4176
|
+
var ca = vec(4);
|
|
4177
|
+
var ab = vec(4);
|
|
4178
|
+
var at_b = vec(4);
|
|
4179
|
+
var at_c = vec(4);
|
|
4180
|
+
var bt_c = vec(4);
|
|
4181
|
+
var bt_a = vec(4);
|
|
4182
|
+
var ct_a = vec(4);
|
|
4183
|
+
var ct_b = vec(4);
|
|
4184
|
+
var bct = vec(8);
|
|
4185
|
+
var cat = vec(8);
|
|
4186
|
+
var abt = vec(8);
|
|
4187
|
+
var u2 = vec(4);
|
|
4188
|
+
var _8 = vec(8);
|
|
4189
|
+
var _8b = vec(8);
|
|
4190
|
+
var _16 = vec(8);
|
|
4191
|
+
var _12 = vec(12);
|
|
4192
|
+
var fin = vec(192);
|
|
4193
|
+
var fin2 = vec(192);
|
|
4194
|
+
|
|
4195
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
|
|
4196
|
+
var iccerrboundA = (10 + 96 * epsilon) * epsilon;
|
|
4197
|
+
var iccerrboundB = (4 + 48 * epsilon) * epsilon;
|
|
4198
|
+
var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
|
|
4199
|
+
var bc2 = vec(4);
|
|
4200
|
+
var ca2 = vec(4);
|
|
4201
|
+
var ab2 = vec(4);
|
|
4202
|
+
var aa = vec(4);
|
|
4203
|
+
var bb = vec(4);
|
|
4204
|
+
var cc = vec(4);
|
|
4205
|
+
var u3 = vec(4);
|
|
4206
|
+
var v = vec(4);
|
|
4207
|
+
var axtbc = vec(8);
|
|
4208
|
+
var aytbc = vec(8);
|
|
4209
|
+
var bxtca = vec(8);
|
|
4210
|
+
var bytca = vec(8);
|
|
4211
|
+
var cxtab = vec(8);
|
|
4212
|
+
var cytab = vec(8);
|
|
4213
|
+
var abt2 = vec(8);
|
|
4214
|
+
var bct2 = vec(8);
|
|
4215
|
+
var cat2 = vec(8);
|
|
4216
|
+
var abtt = vec(4);
|
|
4217
|
+
var bctt = vec(4);
|
|
4218
|
+
var catt = vec(4);
|
|
4219
|
+
var _82 = vec(8);
|
|
4220
|
+
var _162 = vec(16);
|
|
4221
|
+
var _16b = vec(16);
|
|
4222
|
+
var _16c = vec(16);
|
|
4223
|
+
var _32 = vec(32);
|
|
4224
|
+
var _32b = vec(32);
|
|
4225
|
+
var _48 = vec(48);
|
|
4226
|
+
var _64 = vec(64);
|
|
4227
|
+
var fin3 = vec(1152);
|
|
4228
|
+
var fin22 = vec(1152);
|
|
4229
|
+
|
|
4230
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
|
|
4231
|
+
var isperrboundA = (16 + 224 * epsilon) * epsilon;
|
|
4232
|
+
var isperrboundB = (5 + 72 * epsilon) * epsilon;
|
|
4233
|
+
var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
|
|
4234
|
+
var ab3 = vec(4);
|
|
4235
|
+
var bc3 = vec(4);
|
|
4236
|
+
var cd = vec(4);
|
|
4237
|
+
var de = vec(4);
|
|
4238
|
+
var ea = vec(4);
|
|
4239
|
+
var ac = vec(4);
|
|
4240
|
+
var bd = vec(4);
|
|
4241
|
+
var ce = vec(4);
|
|
4242
|
+
var da = vec(4);
|
|
4243
|
+
var eb = vec(4);
|
|
4244
|
+
var abc = vec(24);
|
|
4245
|
+
var bcd = vec(24);
|
|
4246
|
+
var cde = vec(24);
|
|
4247
|
+
var dea = vec(24);
|
|
4248
|
+
var eab = vec(24);
|
|
4249
|
+
var abd = vec(24);
|
|
4250
|
+
var bce = vec(24);
|
|
4251
|
+
var cda = vec(24);
|
|
4252
|
+
var deb = vec(24);
|
|
4253
|
+
var eac = vec(24);
|
|
4254
|
+
var adet = vec(1152);
|
|
4255
|
+
var bdet = vec(1152);
|
|
4256
|
+
var cdet = vec(1152);
|
|
4257
|
+
var ddet = vec(1152);
|
|
4258
|
+
var edet = vec(1152);
|
|
4259
|
+
var abdet = vec(2304);
|
|
4260
|
+
var cddet = vec(2304);
|
|
4261
|
+
var cdedet = vec(3456);
|
|
4262
|
+
var deter = vec(5760);
|
|
4263
|
+
var _83 = vec(8);
|
|
4264
|
+
var _8b2 = vec(8);
|
|
4265
|
+
var _8c = vec(8);
|
|
4266
|
+
var _163 = vec(16);
|
|
4267
|
+
var _24 = vec(24);
|
|
4268
|
+
var _482 = vec(48);
|
|
4269
|
+
var _48b = vec(48);
|
|
4270
|
+
var _96 = vec(96);
|
|
4271
|
+
var _192 = vec(192);
|
|
4272
|
+
var _384x = vec(384);
|
|
4273
|
+
var _384y = vec(384);
|
|
4274
|
+
var _384z = vec(384);
|
|
4275
|
+
var _768 = vec(768);
|
|
4276
|
+
var xdet = vec(96);
|
|
4277
|
+
var ydet = vec(96);
|
|
4278
|
+
var zdet = vec(96);
|
|
4279
|
+
var fin4 = vec(1152);
|
|
4280
|
+
|
|
4281
|
+
// ../../node_modules/point-in-polygon-hao/dist/esm/index.js
|
|
4282
|
+
function pointInPolygon(p, polygon2) {
|
|
4283
|
+
var i;
|
|
4284
|
+
var ii;
|
|
4285
|
+
var k = 0;
|
|
4286
|
+
var f;
|
|
4287
|
+
var u1;
|
|
4288
|
+
var v1;
|
|
4289
|
+
var u22;
|
|
4290
|
+
var v2;
|
|
4291
|
+
var currentP;
|
|
4292
|
+
var nextP;
|
|
4293
|
+
var x = p[0];
|
|
4294
|
+
var y = p[1];
|
|
4295
|
+
var numContours = polygon2.length;
|
|
4296
|
+
for (i = 0; i < numContours; i++) {
|
|
4297
|
+
ii = 0;
|
|
4298
|
+
var contour = polygon2[i];
|
|
4299
|
+
var contourLen = contour.length - 1;
|
|
4300
|
+
currentP = contour[0];
|
|
4301
|
+
if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
|
|
4302
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
4303
|
+
}
|
|
4304
|
+
u1 = currentP[0] - x;
|
|
4305
|
+
v1 = currentP[1] - y;
|
|
4306
|
+
for (ii; ii < contourLen; ii++) {
|
|
4307
|
+
nextP = contour[ii + 1];
|
|
4308
|
+
u22 = nextP[0] - x;
|
|
4309
|
+
v2 = nextP[1] - y;
|
|
4310
|
+
if (v1 === 0 && v2 === 0) {
|
|
4311
|
+
if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
|
|
4312
|
+
return 0;
|
|
4313
|
+
}
|
|
4314
|
+
} else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
|
|
4315
|
+
f = orient2d(u1, u22, v1, v2, 0, 0);
|
|
4316
|
+
if (f === 0) {
|
|
4317
|
+
return 0;
|
|
4318
|
+
}
|
|
4319
|
+
if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
|
|
4320
|
+
k++;
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
currentP = nextP;
|
|
4324
|
+
v1 = v2;
|
|
4325
|
+
u1 = u22;
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
if (k % 2 === 0) {
|
|
4329
|
+
return false;
|
|
4330
|
+
}
|
|
4331
|
+
return true;
|
|
4332
|
+
}
|
|
4333
|
+
|
|
4334
|
+
// ../../node_modules/@turf/invariant/dist/esm/index.js
|
|
4335
|
+
function getCoord(coord) {
|
|
4336
|
+
if (!coord) {
|
|
4337
|
+
throw new Error("coord is required");
|
|
4338
|
+
}
|
|
4339
|
+
if (!Array.isArray(coord)) {
|
|
4340
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
4341
|
+
return [...coord.geometry.coordinates];
|
|
4342
|
+
}
|
|
4343
|
+
if (coord.type === "Point") {
|
|
4344
|
+
return [...coord.coordinates];
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
4348
|
+
return [...coord];
|
|
4349
|
+
}
|
|
4350
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4351
|
+
}
|
|
4352
|
+
function getGeom(geojson) {
|
|
4353
|
+
if (geojson.type === "Feature") {
|
|
4354
|
+
return geojson.geometry;
|
|
4355
|
+
}
|
|
4356
|
+
return geojson;
|
|
4357
|
+
}
|
|
4358
|
+
|
|
4359
|
+
// ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
|
|
4360
|
+
function booleanPointInPolygon(point2, polygon2, options = {}) {
|
|
4361
|
+
if (!point2) {
|
|
4362
|
+
throw new Error("point is required");
|
|
4363
|
+
}
|
|
4364
|
+
if (!polygon2) {
|
|
4365
|
+
throw new Error("polygon is required");
|
|
4366
|
+
}
|
|
4367
|
+
const pt = getCoord(point2);
|
|
4368
|
+
const geom = getGeom(polygon2);
|
|
4369
|
+
const type = geom.type;
|
|
4370
|
+
const bbox2 = polygon2.bbox;
|
|
4371
|
+
let polys = geom.coordinates;
|
|
4372
|
+
if (bbox2 && inBBox(pt, bbox2) === false) {
|
|
4373
|
+
return false;
|
|
4374
|
+
}
|
|
4375
|
+
if (type === "Polygon") {
|
|
4376
|
+
polys = [polys];
|
|
4377
|
+
}
|
|
4378
|
+
let result = false;
|
|
4379
|
+
for (var i = 0; i < polys.length; ++i) {
|
|
4380
|
+
const polyResult = pointInPolygon(pt, polys[i]);
|
|
4381
|
+
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
4382
|
+
else if (polyResult) result = true;
|
|
4383
|
+
}
|
|
4384
|
+
return result;
|
|
4385
|
+
}
|
|
4386
|
+
function inBBox(pt, bbox2) {
|
|
4387
|
+
return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
4391
|
+
var findUnitOnPoint = (units, point2) => {
|
|
4392
|
+
return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
|
|
4393
|
+
};
|
|
4394
|
+
|
|
3847
4395
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3848
4396
|
function delay(ms) {
|
|
3849
4397
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -3879,6 +4427,38 @@ var RendererManager = class extends EventTarget {
|
|
|
3879
4427
|
const groupLayer = this.map.getLayer("group");
|
|
3880
4428
|
const threeLayer = groupLayer.getLayer("three");
|
|
3881
4429
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
4430
|
+
function findBadMeshes(scene2) {
|
|
4431
|
+
const bad = [];
|
|
4432
|
+
scene2.traverse((obj) => {
|
|
4433
|
+
if (!obj?.isMesh) return;
|
|
4434
|
+
const geom = obj.geometry;
|
|
4435
|
+
const pos = geom?.attributes?.position?.array;
|
|
4436
|
+
if (!pos || pos.length === 0) return;
|
|
4437
|
+
for (let i = 0; i < pos.length; i++) {
|
|
4438
|
+
const v2 = pos[i];
|
|
4439
|
+
if (!Number.isFinite(v2)) {
|
|
4440
|
+
bad.push({ mesh: obj, index: i, value: v2 });
|
|
4441
|
+
break;
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
4444
|
+
});
|
|
4445
|
+
if (bad.length) {
|
|
4446
|
+
console.group(`\u274C Found ${bad.length} meshes with invalid positions`);
|
|
4447
|
+
for (const b of bad) {
|
|
4448
|
+
console.log({
|
|
4449
|
+
name: b.mesh.name,
|
|
4450
|
+
userData: b.mesh.userData,
|
|
4451
|
+
uuid: b.mesh.uuid,
|
|
4452
|
+
badIndex: b.index,
|
|
4453
|
+
badValue: b.value
|
|
4454
|
+
});
|
|
4455
|
+
}
|
|
4456
|
+
console.groupEnd();
|
|
4457
|
+
} else {
|
|
4458
|
+
console.log("\u2705 No invalid meshes found");
|
|
4459
|
+
}
|
|
4460
|
+
return bad;
|
|
4461
|
+
}
|
|
3882
4462
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3883
4463
|
scene.add(ambientLight);
|
|
3884
4464
|
const dirColor = 16777215;
|
|
@@ -3893,6 +4473,9 @@ var RendererManager = class extends EventTarget {
|
|
|
3893
4473
|
options.onRendererReady();
|
|
3894
4474
|
}
|
|
3895
4475
|
_this.#createElements();
|
|
4476
|
+
setTimeout(() => {
|
|
4477
|
+
findBadMeshes(scene);
|
|
4478
|
+
}, 3e3);
|
|
3896
4479
|
};
|
|
3897
4480
|
} else {
|
|
3898
4481
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
@@ -3934,6 +4517,9 @@ var RendererManager = class extends EventTarget {
|
|
|
3934
4517
|
const levels = await this.#dataClient.filterByType("level", {
|
|
3935
4518
|
populate: true
|
|
3936
4519
|
});
|
|
4520
|
+
const openings = await this.#dataClient.filterByType("opening", {
|
|
4521
|
+
populate: true
|
|
4522
|
+
});
|
|
3937
4523
|
const relationships = await this.#dataClient.filterByType("relationship");
|
|
3938
4524
|
const fixtures = await this.#dataClient.filterByType("fixture", { populate: true });
|
|
3939
4525
|
fixtures.forEach((fixture) => {
|
|
@@ -3947,7 +4533,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3947
4533
|
populate: true
|
|
3948
4534
|
});
|
|
3949
4535
|
units.filter(
|
|
3950
|
-
(
|
|
4536
|
+
(u4) => !["opentobelow", "escalator", "room"].includes(u4.properties.category)
|
|
3951
4537
|
).forEach((unit) => {
|
|
3952
4538
|
const element = this.elementRenderer.createGeometry(unit);
|
|
3953
4539
|
if (element) {
|
|
@@ -3955,6 +4541,22 @@ var RendererManager = class extends EventTarget {
|
|
|
3955
4541
|
this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
|
|
3956
4542
|
}
|
|
3957
4543
|
});
|
|
4544
|
+
units.filter((u4) => u4.properties.category === "room").forEach((unit) => {
|
|
4545
|
+
const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
|
|
4546
|
+
const roomOpenings = (0, import_compact2.default)(openingRelationships.map((rel) => {
|
|
4547
|
+
const openingId = rel?.properties.intermediary[0].id;
|
|
4548
|
+
return openings.find((o) => o.id === openingId);
|
|
4549
|
+
}));
|
|
4550
|
+
const innerElements = this.elementRenderer.createGeometry(unit);
|
|
4551
|
+
const wallElements = this.elementRenderer.createRoomWall(unit, roomOpenings);
|
|
4552
|
+
if (innerElements || wallElements) {
|
|
4553
|
+
const _innerElements = Array.isArray(innerElements) ? innerElements : [innerElements];
|
|
4554
|
+
const _wallElements = Array.isArray(wallElements) ? wallElements : [wallElements];
|
|
4555
|
+
const _elements = [..._innerElements, ..._wallElements];
|
|
4556
|
+
const ordinal = unit.properties.level.properties.ordinal;
|
|
4557
|
+
this.addElementsToManager(unit.id, _elements, ordinal);
|
|
4558
|
+
}
|
|
4559
|
+
});
|
|
3958
4560
|
const kiosks = await this.#dataClient.filterByType("kiosk", {
|
|
3959
4561
|
populate: true
|
|
3960
4562
|
});
|
|
@@ -3965,7 +4567,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3965
4567
|
this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
|
|
3966
4568
|
}
|
|
3967
4569
|
});
|
|
3968
|
-
const escalators = units.filter((
|
|
4570
|
+
const escalators = units.filter((u4) => u4.properties.category === "escalator");
|
|
3969
4571
|
for (const escalator of escalators) {
|
|
3970
4572
|
try {
|
|
3971
4573
|
const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
|
|
@@ -3997,6 +4599,22 @@ var RendererManager = class extends EventTarget {
|
|
|
3997
4599
|
console.warn(`cannot create escalator`, err.message);
|
|
3998
4600
|
}
|
|
3999
4601
|
}
|
|
4602
|
+
const groundLabels = await this.#dataClient.filterByType("label");
|
|
4603
|
+
for (const label of groundLabels) {
|
|
4604
|
+
const center2 = (0, import_center3.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
4605
|
+
const unit = findUnitOnPoint(units, center2);
|
|
4606
|
+
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4607
|
+
if (element) {
|
|
4608
|
+
const _elements = Array.isArray(element) ? element : [element];
|
|
4609
|
+
this.addElementsToManager(label.id, _elements, label.properties.ordinal);
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
if (this.options.type === "3D") {
|
|
4613
|
+
const model3ds = await this.#dataClient.filterByType("model3d");
|
|
4614
|
+
for (const model3d of model3ds) {
|
|
4615
|
+
this.elementRenderer.createModel3d(model3d);
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4000
4618
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
4001
4619
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
4002
4620
|
}
|
|
@@ -4123,7 +4741,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4123
4741
|
#billboardObjects = [];
|
|
4124
4742
|
#spriteMarkerObjects = [];
|
|
4125
4743
|
#mapDecorations = [];
|
|
4126
|
-
#groundLabels = [];
|
|
4127
4744
|
#groundObjects = [];
|
|
4128
4745
|
#navigationGeometries = {};
|
|
4129
4746
|
#venueObjects = [];
|
|
@@ -4288,9 +4905,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4288
4905
|
set mapDecorations(value) {
|
|
4289
4906
|
this.#mapDecorations = value;
|
|
4290
4907
|
}
|
|
4291
|
-
set groundLabels(value) {
|
|
4292
|
-
this.#groundLabels = value;
|
|
4293
|
-
}
|
|
4294
4908
|
set pixelRatio(value) {
|
|
4295
4909
|
this.map.setDevicePixelRatio(value);
|
|
4296
4910
|
}
|
|
@@ -4334,13 +4948,11 @@ var IndoorMap = class extends EventTarget {
|
|
|
4334
4948
|
createDecoration,
|
|
4335
4949
|
// 3D
|
|
4336
4950
|
create3DFootprint,
|
|
4337
|
-
create3DGroundLabel,
|
|
4338
4951
|
create3DBillboard,
|
|
4339
4952
|
createExtrudedUnit,
|
|
4340
4953
|
create3DAmenityMarker,
|
|
4341
4954
|
create3DOccupantAmenityMarker,
|
|
4342
|
-
create3DOpeningMarker
|
|
4343
|
-
createOccupantGroundLabel
|
|
4955
|
+
create3DOpeningMarker
|
|
4344
4956
|
} = this.#styler;
|
|
4345
4957
|
let elements = {};
|
|
4346
4958
|
let object3ds = [];
|
|
@@ -4418,16 +5030,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4418
5030
|
console.warn(`Cannot create ${feature2.id}: ${err.message}`);
|
|
4419
5031
|
}
|
|
4420
5032
|
}
|
|
4421
|
-
this.#groundLabels.forEach((label) => {
|
|
4422
|
-
const text = label.properties.name;
|
|
4423
|
-
try {
|
|
4424
|
-
const groundLabel = create3DGroundLabel(label, this.threeLayer);
|
|
4425
|
-
object3ds.push(groundLabel);
|
|
4426
|
-
this.#groundObjects.push(groundLabel);
|
|
4427
|
-
} catch (error) {
|
|
4428
|
-
console.log("error creating ground label for ", text);
|
|
4429
|
-
}
|
|
4430
|
-
});
|
|
4431
5033
|
this.#mapDecorations.forEach((decoration) => {
|
|
4432
5034
|
const { id, geometry, properties } = decoration;
|
|
4433
5035
|
const geometryType = decoration?.geometry?.type;
|
|
@@ -4866,9 +5468,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4866
5468
|
child.visible = this.showVenueObject && objectOpacity > 0.4;
|
|
4867
5469
|
});
|
|
4868
5470
|
});
|
|
4869
|
-
this.#groundObjects.forEach((gLabel) => {
|
|
4870
|
-
gLabel.bearing = currBearing;
|
|
4871
|
-
});
|
|
4872
5471
|
}
|
|
4873
5472
|
this.#animationsToRun.forEach(({ callback }) => callback(this));
|
|
4874
5473
|
import_tween.default.update();
|