architwin 1.10.21 → 1.10.23
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/lib/architwin.d.ts +65 -6
- package/lib/architwin.js +1 -1
- package/lib/atwinui/components/toolbar/card.js +3 -1
- package/lib/atwinui/components/toolbar/generalSettingsMenuPane.d.ts +4 -0
- package/lib/atwinui/components/toolbar/generalSettingsMenuPane.js +92 -0
- package/lib/atwinui/components/toolbar/i18n.js +10 -2
- package/lib/atwinui/components/toolbar/index.js +5 -1
- package/lib/atwinui/components/toolbar/menuBar.d.ts +1 -0
- package/lib/atwinui/components/toolbar/menuBar.js +16 -0
- package/lib/atwinui/components/toolbar/modelControlsPane.js +3 -3
- package/lib/atwinui/components/toolbar/tagListPane.d.ts +4 -0
- package/lib/atwinui/components/toolbar/tagListPane.js +98 -4
- package/lib/atwinui/events.d.ts +6 -1
- package/lib/atwinui/events.js +381 -5
- package/lib/atwinui/index.js +7 -1
- package/lib/minimap.d.ts +63 -3
- package/lib/minimap.js +491 -60
- package/lib/types.d.ts +92 -1
- package/lib/types.js +22 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +20 -1
- package/lib/worldConversion.d.ts +15 -0
- package/lib/worldConversion.js +45 -0
- package/package.json +1 -1
- package/static/atwinui.css +38 -1
- package/static/icons/mapleftrighticon.svg +17 -0
- package/static/icons/mapscaleheighticon.svg +18 -0
- package/static/icons/mapscalewidthicon.svg +16 -0
- package/static/icons/mapupdownicon.svg +17 -0
- package/static/images/377.png +0 -0
- package/static/images/pinkoriginmarker.png +0 -0
- package/static/map.css +212 -0
- package/static/utility.css +157 -1
package/lib/minimap.js
CHANGED
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import * as superviz from './superviz';
|
|
11
|
-
import { _mpConfig, getCurrentCameraPose, getCurrentSweep, getMapConfig, dispatchSpaceEvent, isCdnMapDataAvailable } from "./architwin";
|
|
12
|
-
import { SPACE_EVENTS } from "./types";
|
|
11
|
+
import { _mpConfig, getCurrentCameraPose, getCurrentSweep, getMapConfig, dispatchSpaceEvent, isCdnMapDataAvailable, getCurrentFloor } from "./architwin";
|
|
12
|
+
import { SPACE_EVENTS, DEGREE, MAP_OPTIONS } from "./types";
|
|
13
13
|
import { isValidCSSColor } from "./color";
|
|
14
14
|
import { _participants } from "./participant";
|
|
15
15
|
import { getAtwinSdk } from "./architwin";
|
|
@@ -17,6 +17,8 @@ import log from 'loglevel';
|
|
|
17
17
|
import { Notyf } from 'notyf';
|
|
18
18
|
import i18n from './atwinui/components/toolbar/i18n';
|
|
19
19
|
import 'notyf/notyf.min.css';
|
|
20
|
+
import { getAssetUrl } from "./utils";
|
|
21
|
+
import { isCustomMapControlsVisible } from "./atwinui/events";
|
|
20
22
|
let _miniMapData;
|
|
21
23
|
let _mapContainer;
|
|
22
24
|
let _mapBox;
|
|
@@ -32,6 +34,14 @@ let _currentFloor;
|
|
|
32
34
|
let _mapImgEl;
|
|
33
35
|
let _floorsInSpace;
|
|
34
36
|
const _minimapId = 'minimapCanvas';
|
|
37
|
+
let _minimapRotation = DEGREE.DEG_0;
|
|
38
|
+
let _customMapScale = 30;
|
|
39
|
+
let _customMapTranslate = 1;
|
|
40
|
+
let _customMapXOffset = 0;
|
|
41
|
+
let _customMapYOffset = 0;
|
|
42
|
+
let minX = 0, minY = 0, maxX = 0, maxY = 0;
|
|
43
|
+
let _customMapContainer;
|
|
44
|
+
let _customMapFloorData = [];
|
|
35
45
|
let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500, types: [
|
|
36
46
|
{
|
|
37
47
|
type: 'info',
|
|
@@ -269,7 +279,7 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
|
|
|
269
279
|
}
|
|
270
280
|
},
|
|
271
281
|
onCollectionUpdated: function (collection) {
|
|
272
|
-
log.info('the entire up-to-date collection', collection);
|
|
282
|
+
log.info('JOCHE default the entire up-to-date collection', collection);
|
|
273
283
|
_minimapSweepCollection = collection;
|
|
274
284
|
if (_currentFloor) {
|
|
275
285
|
toggleSweepMarkerFloors(_currentFloor);
|
|
@@ -479,36 +489,63 @@ function setImg(minimap, floorSequence, isStandAlone = false) {
|
|
|
479
489
|
_mapContainer.appendChild(isCurrentFloorOnlyEnabled ? _mapImgEl : map);
|
|
480
490
|
});
|
|
481
491
|
}
|
|
482
|
-
function showDirection() {
|
|
483
|
-
//log.info('showDirection')
|
|
492
|
+
function showDirection(mapType = MAP_OPTIONS.CUSTOM_MAP) {
|
|
493
|
+
// log.info('showDirection')
|
|
484
494
|
let btnX = 0;
|
|
485
495
|
let btnY = 0;
|
|
486
496
|
const thisSweep = getCurrentSweep();
|
|
487
497
|
const thisCameraPose = getCurrentCameraPose();
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
ctx
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
498
|
+
// Check current minimap type from general settings
|
|
499
|
+
// FOR NOW USE CUSTOM MAP; BUT SHOULD CHECK BASED ON ACTUAL SETTINGS STATE
|
|
500
|
+
if (mapType === MAP_OPTIONS.DEFAULT_MAP) {
|
|
501
|
+
if (!thisSweep && !thisCameraPose)
|
|
502
|
+
return;
|
|
503
|
+
if (!thisCameraPose.rotation || !thisCameraPose.rotation.y)
|
|
504
|
+
return;
|
|
505
|
+
const angle = thisCameraPose.rotation.y;
|
|
506
|
+
const sweepBtn = document.getElementById('p' + thisSweep.id);
|
|
507
|
+
const canvas = document.getElementById(_minimapId);
|
|
508
|
+
if (!sweepBtn || !canvas)
|
|
509
|
+
return;
|
|
510
|
+
const ctx = canvas.getContext("2d");
|
|
511
|
+
if (ctx && sweepBtn && angle) {
|
|
512
|
+
ctx.globalAlpha = 0.7;
|
|
513
|
+
btnX = (sweepBtn.getBoundingClientRect().x - canvas.getBoundingClientRect().x) + (sweepBtn.offsetWidth / 2);
|
|
514
|
+
btnY = (sweepBtn.getBoundingClientRect().y - canvas.getBoundingClientRect().y) + (sweepBtn.offsetHeight / 2);
|
|
515
|
+
const startA = (Math.sign(angle) == -1 || Math.sign(angle) == 1) ? 230 - angle : angle;
|
|
516
|
+
const sA = ((startA + 20.5) * (Math.PI * 2)) / 360;
|
|
517
|
+
const eA = sA + (Math.PI / 4);
|
|
518
|
+
ctx.clearRect(0, 0, canvas.offsetWidth, canvas.offsetHeight);
|
|
519
|
+
ctx.beginPath();
|
|
520
|
+
ctx.moveTo(btnX, btnY);
|
|
521
|
+
ctx.arc(btnX, btnY, 40, sA, eA);
|
|
522
|
+
ctx.fillStyle = '#00a2e8';
|
|
523
|
+
ctx.fill();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
if (!thisSweep && !thisCameraPose)
|
|
528
|
+
return;
|
|
529
|
+
const angle = thisCameraPose.rotation.y;
|
|
530
|
+
const sweepBtn = document.getElementById('p' + thisSweep.id);
|
|
531
|
+
const canvas = document.getElementById("at-custom-map-canvas");
|
|
532
|
+
if (!sweepBtn || !canvas)
|
|
533
|
+
return;
|
|
534
|
+
const ctx = canvas.getContext("2d");
|
|
535
|
+
if (ctx && sweepBtn) {
|
|
536
|
+
ctx.globalAlpha = 0.7;
|
|
537
|
+
btnX = (sweepBtn.getBoundingClientRect().x - canvas.getBoundingClientRect().x) + (sweepBtn.offsetWidth / 2);
|
|
538
|
+
btnY = (sweepBtn.getBoundingClientRect().y - canvas.getBoundingClientRect().y) + (sweepBtn.offsetHeight / 2);
|
|
539
|
+
const startA = (Math.sign(angle) == -1 || Math.sign(angle) == 1) ? 230 - angle : angle;
|
|
540
|
+
const sA = ((startA + 20.5) * (Math.PI * 2)) / 360;
|
|
541
|
+
const eA = sA + (Math.PI / 4);
|
|
542
|
+
ctx.clearRect(0, 0, canvas.offsetWidth, canvas.offsetHeight);
|
|
543
|
+
ctx.beginPath();
|
|
544
|
+
ctx.moveTo(btnX, btnY);
|
|
545
|
+
ctx.arc(btnX, btnY, 40, sA, eA);
|
|
546
|
+
ctx.fillStyle = '#00a2e8';
|
|
547
|
+
ctx.fill();
|
|
548
|
+
}
|
|
512
549
|
}
|
|
513
550
|
}
|
|
514
551
|
/**
|
|
@@ -866,29 +903,6 @@ function setStandaloneMap(modelId, appKey, mapId) {
|
|
|
866
903
|
toggleSweepMarkerFloors(0);
|
|
867
904
|
});
|
|
868
905
|
}
|
|
869
|
-
// async function createDropdown(options: string[]) {
|
|
870
|
-
// const element = document.createElement('div')
|
|
871
|
-
// element.classList.add('at_flex', 'at_justify_end')
|
|
872
|
-
// log.info('createDropdown')
|
|
873
|
-
// const dropdown = document.createElement('select');
|
|
874
|
-
// dropdown.classList.add('at_dropdown')
|
|
875
|
-
// dropdown.setAttribute('id', 'at-map-dropdown')
|
|
876
|
-
// options.forEach(optionText => {
|
|
877
|
-
// const option = document.createElement('option');
|
|
878
|
-
// option.value = optionText;
|
|
879
|
-
// option.textContent = optionText.replace(/([A-Z])/g, ' $1').trim().toUpperCase()
|
|
880
|
-
// dropdown.appendChild(option);
|
|
881
|
-
// });
|
|
882
|
-
// dropdown.value = _mpConfig.mapConfig.position ?? 'bottomRight'
|
|
883
|
-
// dropdown.addEventListener('change', () => {
|
|
884
|
-
// const selectedValue = dropdown.value;
|
|
885
|
-
// log.info('addEvent: ', selectedValue)
|
|
886
|
-
// mapPositions.forEach(position => _mapBox.classList.remove(position));
|
|
887
|
-
// setMinimapPosition(selectedValue)
|
|
888
|
-
// });
|
|
889
|
-
// element.appendChild(dropdown)
|
|
890
|
-
// return element;
|
|
891
|
-
// }
|
|
892
906
|
/**
|
|
893
907
|
* This function creates the dropdown (HTLMElement) for available positions that Minimap can be set
|
|
894
908
|
* @param mapPositions An array of strings representing the minimap positions (e.g., 'topLeft','bottomRight').
|
|
@@ -899,13 +913,6 @@ function createDropdown(mapPositions) {
|
|
|
899
913
|
log.info('createDropdown');
|
|
900
914
|
const element = document.createElement('div');
|
|
901
915
|
element.setAttribute('id', 'at-map-dropdown');
|
|
902
|
-
// const formattedPositions = mapPositions.map(position => {
|
|
903
|
-
// return position
|
|
904
|
-
// .replace('top', 'Upper ')
|
|
905
|
-
// .replace('bottom', 'Bottom ')
|
|
906
|
-
// .replace('Left', 'left')
|
|
907
|
-
// .replace('Right', 'right');
|
|
908
|
-
// });
|
|
909
916
|
element.innerHTML = `
|
|
910
917
|
<div style="height: 20px; padding-left: 3px" class="at_flex at_items_center">
|
|
911
918
|
<span class="mdi mdi-overscan" style="color: white; cursor: pointer;" id="at-map-position-dropdown" data-cy="at-map-position-dropdown"></span>
|
|
@@ -1028,6 +1035,430 @@ function handleMapResize() {
|
|
|
1028
1035
|
marker.style.borderWidth = `${parseFloat(markerSize) * 0.125}rem`;
|
|
1029
1036
|
});
|
|
1030
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Creates and returns a custom minimap DOM element containing a canvas.
|
|
1040
|
+
* @returns {HTMLDivElement} The custom minimap element.
|
|
1041
|
+
*/
|
|
1042
|
+
function setupCustomMinimapPane() {
|
|
1043
|
+
log.info('setupCustomMinimap');
|
|
1044
|
+
return `
|
|
1045
|
+
<div id="at-custom-minimap-pane" class="at_overlay_left_minimap">
|
|
1046
|
+
<div id="at-custom-map-close-btn" class="at_close_minimap">
|
|
1047
|
+
<span class="mdi mdi-window-close" id="at-close-minimap-btn" data-cy="at-close-minimap-btn"></span>
|
|
1048
|
+
</div>
|
|
1049
|
+
<div id="at-custom-map-settings-btn" class="at_setting_icon">
|
|
1050
|
+
<span class="mdi mdi-cog" id="at-map-setting-btn" data-cy="at-map-setting-btn"></span>
|
|
1051
|
+
</div>
|
|
1052
|
+
|
|
1053
|
+
<div id="at-spinner" class="at_spinner"></div>
|
|
1054
|
+
<canvas id="at-custom-map-canvas" class="at_custom_map_canvas" width="379" height="379"></canvas>
|
|
1055
|
+
<div id="at-custom-map" class="at_custom_map">
|
|
1056
|
+
<img id="at-custom-map-img" src="${getAssetUrl('images/377.png')}" alt="Minimap">
|
|
1057
|
+
</div>
|
|
1058
|
+
|
|
1059
|
+
${setupCustomMinimapSettingUI()}
|
|
1060
|
+
</div>
|
|
1061
|
+
|
|
1062
|
+
`;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Sets up and returns the HTML for the custom minimap settings panel.
|
|
1066
|
+
* @returns {HTMLElement} The minimap controls element.
|
|
1067
|
+
*/
|
|
1068
|
+
function setupCustomMinimapSettingUI() {
|
|
1069
|
+
return `
|
|
1070
|
+
<div id="at-custom-minimap-settings" class="at_custom_minimap_settings ${isCustomMapControlsVisible ? 'show' : ''}">
|
|
1071
|
+
<!-- Buttons Row -->
|
|
1072
|
+
<div class="at_custom_button_row">
|
|
1073
|
+
<div id="at-custom-screenshot-btn" class="at_custom_button_settings">
|
|
1074
|
+
<span class="mdi mdi-camera-outline"></span>
|
|
1075
|
+
<span>${i18n.t('Screenshot')}</span>
|
|
1076
|
+
</div>
|
|
1077
|
+
<div id="at-custom-rotate-btn" class="at_custom_button_settings">
|
|
1078
|
+
<span class="mdi mdi-rotate-right"></span>
|
|
1079
|
+
<span>${i18n.t('RotateMinimap')}</span>
|
|
1080
|
+
</div>
|
|
1081
|
+
</div>
|
|
1082
|
+
|
|
1083
|
+
<!-- Sliders -->
|
|
1084
|
+
<div class="at_custom_slider_group">
|
|
1085
|
+
<div class="at_custom_slider_row">
|
|
1086
|
+
<div class="at_svg_icon_container">
|
|
1087
|
+
<img src="${getAssetUrl('icons/mapscalewidthicon.svg')}" alt="map_scale_width">
|
|
1088
|
+
</div>
|
|
1089
|
+
<input id="at-slider-scale" type="range" id="slider-scale" min="0" max="100" step="1" />
|
|
1090
|
+
</div>
|
|
1091
|
+
<div class="at_custom_slider_row">
|
|
1092
|
+
<div class="at_svg_icon_container">
|
|
1093
|
+
<img src="${getAssetUrl('icons/mapscaleheighticon.svg')}" alt="map_scale_height">
|
|
1094
|
+
</div>
|
|
1095
|
+
<input id="at-slider-translate" type="range" id="slider-translate" min="0.1" max="20" step="0.1" />
|
|
1096
|
+
</div>
|
|
1097
|
+
<div class="at_custom_slider_row">
|
|
1098
|
+
<div class="at_svg_icon_container">
|
|
1099
|
+
<img src="${getAssetUrl('icons/mapleftrighticon.svg')}" alt="map_left_right">
|
|
1100
|
+
</div>
|
|
1101
|
+
<input id="at-slider-xOffset" type="range" id="slider-xoffset" min="-50" max="100" step="1" />
|
|
1102
|
+
</div>
|
|
1103
|
+
<div class="at_custom_slider_row">
|
|
1104
|
+
<div class="at_svg_icon_container">
|
|
1105
|
+
<img src="${getAssetUrl('icons/mapupdownicon.svg')}" alt="map_up_down">
|
|
1106
|
+
</div>
|
|
1107
|
+
<input id="at-slider-yOffset" type="range" id="slider-yoffset" min="-15" max="100" step="1" />
|
|
1108
|
+
</div>
|
|
1109
|
+
</div>
|
|
1110
|
+
</div>
|
|
1111
|
+
`;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Initializes and renders the custom minimap UI.
|
|
1115
|
+
* @param mpSdk - The Matterport SDK instance
|
|
1116
|
+
*/
|
|
1117
|
+
function setCustomMap(mpSdk) {
|
|
1118
|
+
const minimapElement = setupCustomMinimapPane();
|
|
1119
|
+
const showcase = document.getElementById('showcase-container');
|
|
1120
|
+
const mapContainer = document.createElement('div');
|
|
1121
|
+
mapContainer.innerHTML = minimapElement;
|
|
1122
|
+
showcase.prepend(mapContainer);
|
|
1123
|
+
console.log("Successfully rendered.");
|
|
1124
|
+
subscribeToFloorChanges(mpSdk);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Sets the current rotation value of the custom minimap.
|
|
1128
|
+
* @param {DEGREE} rotation
|
|
1129
|
+
*/
|
|
1130
|
+
function setCustomMinimapRotation(rotation) {
|
|
1131
|
+
_minimapRotation = rotation;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Gets the current rotation value of the custom minimap.
|
|
1135
|
+
* @returns {_minimapRotation} Minimap rotation in degrees.
|
|
1136
|
+
*/
|
|
1137
|
+
function getCustomMinimapRotation() {
|
|
1138
|
+
return _minimapRotation;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Subscribes to floor change events in the Matterport model.
|
|
1142
|
+
* @param mpSdk
|
|
1143
|
+
*/
|
|
1144
|
+
function subscribeToFloorChanges(mpSdk) {
|
|
1145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1146
|
+
mpSdk.Floor.current.subscribe(function (currentFloor) {
|
|
1147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1148
|
+
if (currentFloor.sequence !== undefined && currentFloor.sequence !== -1) {
|
|
1149
|
+
log.info("handleModelFloorChange: ", currentFloor.sequence);
|
|
1150
|
+
const mapConfig = getMapConfig();
|
|
1151
|
+
if (mapConfig === null || mapConfig === void 0 ? void 0 : mapConfig.enableCustomMap) {
|
|
1152
|
+
populateCurrentCustomFloor(currentFloor.sequence);
|
|
1153
|
+
yield generateCustomMinimap(mpSdk);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Generates a custom minimap and transformation parameters.
|
|
1162
|
+
* @param mpSdk - The Matterport SDK instance used to access and manipulate the space data.
|
|
1163
|
+
* @param scaling - Scale factor to resize the minimap (default is 10)
|
|
1164
|
+
* @param translate - Translation factor applied to the minimap (default is 1)
|
|
1165
|
+
* @param xOffset - Horizontal offset applied to shift the minimap along the X-axis (default is 0).
|
|
1166
|
+
* @param yOffset - Vertical offset applied to shift the minimap along the Y-axis (default is 0).
|
|
1167
|
+
*/
|
|
1168
|
+
function generateCustomMinimap(mpSdk) {
|
|
1169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1170
|
+
log.info("generateCustomMinimap()");
|
|
1171
|
+
try {
|
|
1172
|
+
// Clean up custom map container
|
|
1173
|
+
resetCustomMapContainer();
|
|
1174
|
+
// Get current floor data
|
|
1175
|
+
const currentFloor = getCurrentFloor();
|
|
1176
|
+
minX = maxX = minY = maxY = 0;
|
|
1177
|
+
// Render Sweeps
|
|
1178
|
+
mpSdk.Sweep.data.subscribe({
|
|
1179
|
+
onCollectionUpdated: function (collection) {
|
|
1180
|
+
log.info('the entire up-to-date collection', collection);
|
|
1181
|
+
// Convert object to array
|
|
1182
|
+
const sweeps = Object.values(collection);
|
|
1183
|
+
const alignedSweeps = sweeps.filter(item => item.alignmentType === 'aligned' &&
|
|
1184
|
+
item.position &&
|
|
1185
|
+
item.floorInfo.sequence === currentFloor.sequence);
|
|
1186
|
+
const sweepPoints = alignedSweeps.map(item => {
|
|
1187
|
+
const x = item.position.x;
|
|
1188
|
+
const y = item.position.z; // Z is treated as Y (2D)
|
|
1189
|
+
// Update min/max
|
|
1190
|
+
setMinAndMax(x, y);
|
|
1191
|
+
return {
|
|
1192
|
+
id: item.id,
|
|
1193
|
+
x: x,
|
|
1194
|
+
y: y,
|
|
1195
|
+
floorIndex: item.floorInfo.sequence
|
|
1196
|
+
};
|
|
1197
|
+
});
|
|
1198
|
+
// Display sweeps to custom map
|
|
1199
|
+
sweepPoints.map(item => displaySweepToCustomMap(item, mpSdk));
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
catch (error) {
|
|
1204
|
+
log.error("Error generate custom minimap.");
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Renders a sweep button on the custom minimap based on the given sweep item.
|
|
1210
|
+
* @param sweepItem
|
|
1211
|
+
* @param mpSdk - The Matterport SDK instance
|
|
1212
|
+
*/
|
|
1213
|
+
function displaySweepToCustomMap(sweepItem, mpSdk) {
|
|
1214
|
+
log.info("displaySweepToMap");
|
|
1215
|
+
const posX = sweepItem.x;
|
|
1216
|
+
const posY = sweepItem.y;
|
|
1217
|
+
let thisSweep = document.createElement('button');
|
|
1218
|
+
const cList = getCurrentSweep().id === sweepItem.id ? 'at_custom_sweep active' : 'at_custom_sweep';
|
|
1219
|
+
const scaleX = _customMapScale;
|
|
1220
|
+
const scaleY = (_customMapScale * 21 / 9) / _customMapTranslate;
|
|
1221
|
+
const scaledX = scaleToContainer(posX, minX, maxX, scaleX, 0);
|
|
1222
|
+
const scaledY = scaleToContainer(posY, minY, maxY, scaleY, 0);
|
|
1223
|
+
thisSweep.setAttribute('id', 'p' + sweepItem.id);
|
|
1224
|
+
thisSweep.setAttribute('value', sweepItem.id);
|
|
1225
|
+
thisSweep.setAttribute('data-cy', 'p' + sweepItem.id);
|
|
1226
|
+
thisSweep.style.left = (scaledX + parseInt(_customMapXOffset.toString())) + '%';
|
|
1227
|
+
thisSweep.style.top = (scaledY + parseInt(_customMapYOffset.toString())) + '%';
|
|
1228
|
+
thisSweep.style.position = 'absolute';
|
|
1229
|
+
thisSweep.style.zIndex = '2';
|
|
1230
|
+
thisSweep.setAttribute('class', cList);
|
|
1231
|
+
thisSweep.setAttribute('title', 'x:' + scaledX + _customMapXOffset +
|
|
1232
|
+
' y:' + scaledY + _customMapYOffset +
|
|
1233
|
+
' f:' + sweepItem.floorIndex);
|
|
1234
|
+
thisSweep.setAttribute('floor-level', `${sweepItem.floorIndex}`);
|
|
1235
|
+
thisSweep.addEventListener('click', (event) => onSweepMoveCustomMap(event, mpSdk));
|
|
1236
|
+
_customMapContainer.appendChild(thisSweep);
|
|
1237
|
+
showDirection();
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Handles custom minimap sweep navigation when a sweep button is clicked.
|
|
1241
|
+
* @param event - The DOM event triggered by clicking the sweep button
|
|
1242
|
+
* @param mpSdk - The Matterport SDK instance
|
|
1243
|
+
* @returns A promise that will return the destination sweep.
|
|
1244
|
+
*/
|
|
1245
|
+
function onSweepMoveCustomMap(event, mpSdk) {
|
|
1246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1247
|
+
isMinimapNavigation = true;
|
|
1248
|
+
return mpSdk.Sweep.moveTo(event.target.value, {
|
|
1249
|
+
transition: mpSdk.Sweep.Transition.FADEOUT
|
|
1250
|
+
})
|
|
1251
|
+
.then(function (handleMessage) {
|
|
1252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1253
|
+
log.info(handleMessage);
|
|
1254
|
+
isMinimapNavigation = false;
|
|
1255
|
+
showDirection();
|
|
1256
|
+
if (superviz.isMeetingInitialized) {
|
|
1257
|
+
yield locateAvatar();
|
|
1258
|
+
}
|
|
1259
|
+
let clickedSweep;
|
|
1260
|
+
clickedSweep = _minimapSweepCollection[event.target.value];
|
|
1261
|
+
dispatchSpaceEvent(SPACE_EVENTS.MINIMAP_SWEEP_CLICK, clickedSweep);
|
|
1262
|
+
});
|
|
1263
|
+
})
|
|
1264
|
+
.catch(function (handleError) {
|
|
1265
|
+
log.info("Sweep move error", handleError);
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Resets the custom map container by clearing its contents and re-adding the custom map image.
|
|
1271
|
+
*/
|
|
1272
|
+
function resetCustomMapContainer() {
|
|
1273
|
+
log.info("resetCustomMapContainer()");
|
|
1274
|
+
// Set custom map container
|
|
1275
|
+
_customMapContainer = document.getElementById('at-custom-map');
|
|
1276
|
+
const customMapImage = document.getElementById('at-custom-map-img');
|
|
1277
|
+
if (customMapImage) {
|
|
1278
|
+
_customMapContainer.innerHTML = '';
|
|
1279
|
+
_customMapContainer.appendChild(customMapImage);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Scales a number within a range (min to max) to a normalized percentage-based value.
|
|
1284
|
+
* @param num - The value to scale (e.g., position.x or position.z)
|
|
1285
|
+
* @param min - The minimum value in the original coordinate range
|
|
1286
|
+
* @param max - The maximum value in the original coordinate range
|
|
1287
|
+
* @param scale - The scale factor to apply to the normalized result
|
|
1288
|
+
* @param offset - An optional offset to shift the scaled value
|
|
1289
|
+
* @returns - A scaled and offset percentage-based value
|
|
1290
|
+
*/
|
|
1291
|
+
function scaleToContainer(num, min, max, scale, offset) {
|
|
1292
|
+
if (max === min)
|
|
1293
|
+
return 0; // avoid divide-by-zero
|
|
1294
|
+
// calculate position as percentage with left and top offset
|
|
1295
|
+
return (((num - min) / (max - min)) * scale) + offset;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Updates the global minimum and maximum X and Y values
|
|
1299
|
+
* based on the given coordinates. Used for determining
|
|
1300
|
+
* bounding box extents of all sweep positions.
|
|
1301
|
+
* @param x - The X coordinate (typically item.position.x)
|
|
1302
|
+
* @param y - The Y coordinate (typically item.position.z mapped to Y)
|
|
1303
|
+
*/
|
|
1304
|
+
function setMinAndMax(x, y) {
|
|
1305
|
+
// Compare a set of coordinates to update min and max
|
|
1306
|
+
minX = Math.min(minX, x);
|
|
1307
|
+
maxX = Math.max(maxX, x);
|
|
1308
|
+
minY = Math.min(minY, y);
|
|
1309
|
+
maxY = Math.max(maxY, y);
|
|
1310
|
+
}
|
|
1311
|
+
// SETTERS AND GETTERS (Scaling, Translate, xOffset, yOffset)
|
|
1312
|
+
// SET GET: Scale value
|
|
1313
|
+
function setCustomMapScale(scale) {
|
|
1314
|
+
_customMapScale = scale;
|
|
1315
|
+
}
|
|
1316
|
+
function getCustomMapScale() {
|
|
1317
|
+
return _customMapScale;
|
|
1318
|
+
}
|
|
1319
|
+
// SET GET: Translate value
|
|
1320
|
+
function setCustomMapTranslate(translate) {
|
|
1321
|
+
_customMapTranslate = translate;
|
|
1322
|
+
}
|
|
1323
|
+
function getCustomMapTranslate() {
|
|
1324
|
+
return _customMapTranslate;
|
|
1325
|
+
}
|
|
1326
|
+
// SET GET: X Offset value
|
|
1327
|
+
function setCustomMapXOffset(xOffset) {
|
|
1328
|
+
_customMapXOffset = xOffset;
|
|
1329
|
+
}
|
|
1330
|
+
function getCustomMapXOffset() {
|
|
1331
|
+
return _customMapXOffset;
|
|
1332
|
+
}
|
|
1333
|
+
// SET GET: Y Offset value
|
|
1334
|
+
function setCustomMapYOffset(yOffset) {
|
|
1335
|
+
_customMapYOffset = yOffset;
|
|
1336
|
+
}
|
|
1337
|
+
function getCustomMapYOffset() {
|
|
1338
|
+
return _customMapYOffset;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Sets an individual or entire floor data array of custom minimap
|
|
1342
|
+
* @param payload
|
|
1343
|
+
*/
|
|
1344
|
+
function setCustomMapFloorData(payload) {
|
|
1345
|
+
log.info("setCustomMapFloorData() ", payload);
|
|
1346
|
+
if (!payload) {
|
|
1347
|
+
log.error("Payload is undefined");
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
if (Array.isArray(payload)) {
|
|
1351
|
+
_customMapFloorData = payload;
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
_customMapFloorData[payload.floor_sequence] = payload;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Gets the floor data of custom map. If index is provided will return floor data of that floor. If no parameter is passed will return the entire array
|
|
1359
|
+
* @param index - index of floor data
|
|
1360
|
+
* @returns
|
|
1361
|
+
*/
|
|
1362
|
+
function getCustomMapFloorData(index) {
|
|
1363
|
+
log.info("getCustomMapFloorData() ", index);
|
|
1364
|
+
if (index != undefined) {
|
|
1365
|
+
return _customMapFloorData[index];
|
|
1366
|
+
}
|
|
1367
|
+
return _customMapFloorData;
|
|
1368
|
+
}
|
|
1369
|
+
function populateCurrentCustomFloor(floor_sequence) {
|
|
1370
|
+
log.info("populateCurrentCustomFloor() ", floor_sequence);
|
|
1371
|
+
if (floor_sequence == undefined) {
|
|
1372
|
+
log.error("sequence is undefined");
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
if (!_customMapFloorData[floor_sequence]) {
|
|
1376
|
+
resetCustomMapSettingValues();
|
|
1377
|
+
const scale = getCustomMapScale();
|
|
1378
|
+
const translate = getCustomMapTranslate();
|
|
1379
|
+
const rotate = getCustomMinimapRotation();
|
|
1380
|
+
const offset_x = getCustomMapXOffset();
|
|
1381
|
+
const offset_y = getCustomMapYOffset();
|
|
1382
|
+
const floorData = {
|
|
1383
|
+
floor_sequence,
|
|
1384
|
+
scale,
|
|
1385
|
+
translate,
|
|
1386
|
+
rotate,
|
|
1387
|
+
offset_x,
|
|
1388
|
+
offset_y
|
|
1389
|
+
};
|
|
1390
|
+
_customMapFloorData[floor_sequence] = floorData;
|
|
1391
|
+
}
|
|
1392
|
+
log.info(" _customMapFloorData[floor_sequence] ", _customMapFloorData[floor_sequence]);
|
|
1393
|
+
setCustomMapScale(_customMapFloorData[floor_sequence].scale);
|
|
1394
|
+
setCustomMapTranslate(_customMapFloorData[floor_sequence].translate);
|
|
1395
|
+
setCustomMinimapRotation(_customMapFloorData[floor_sequence].rotate);
|
|
1396
|
+
setCustomMapXOffset(_customMapFloorData[floor_sequence].offset_x);
|
|
1397
|
+
setCustomMapYOffset(_customMapFloorData[floor_sequence].offset_y);
|
|
1398
|
+
showCurrentCustomFloorData(floor_sequence);
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Shows the custom minimap floor data to the custom minimap UI
|
|
1402
|
+
* @param floor_sequence
|
|
1403
|
+
* @returns
|
|
1404
|
+
*/
|
|
1405
|
+
function showCurrentCustomFloorData(floor_sequence) {
|
|
1406
|
+
log.info("showCurrentCustomFloorData() ", floor_sequence);
|
|
1407
|
+
if (floor_sequence == undefined) {
|
|
1408
|
+
log.error("floor_sequence is undefined");
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (!_customMapFloorData[floor_sequence]) {
|
|
1412
|
+
log.error("Map data for this floor does not exist");
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
log.info("_customMapFloorData[floor_sequence] ", _customMapFloorData[floor_sequence]);
|
|
1416
|
+
// Scaling Slider
|
|
1417
|
+
const scaleSlider = document.getElementById('at-slider-scale');
|
|
1418
|
+
// Translate Slider
|
|
1419
|
+
const translateSlider = document.getElementById('at-slider-translate');
|
|
1420
|
+
// xOffset Slider
|
|
1421
|
+
const xOffsetSlider = document.getElementById('at-slider-xOffset');
|
|
1422
|
+
// yOffset Slider
|
|
1423
|
+
const yOffsetSlider = document.getElementById('at-slider-yOffset');
|
|
1424
|
+
// image image
|
|
1425
|
+
const customMapImage = document.getElementById('at-custom-map-img');
|
|
1426
|
+
// Set initial slider values
|
|
1427
|
+
if (scaleSlider)
|
|
1428
|
+
scaleSlider.value = getCustomMapScale().toString();
|
|
1429
|
+
if (translateSlider)
|
|
1430
|
+
translateSlider.value = getCustomMapTranslate().toString();
|
|
1431
|
+
if (xOffsetSlider)
|
|
1432
|
+
xOffsetSlider.value = getCustomMapXOffset().toString();
|
|
1433
|
+
if (yOffsetSlider)
|
|
1434
|
+
yOffsetSlider.value = getCustomMapYOffset().toString();
|
|
1435
|
+
if (customMapImage) {
|
|
1436
|
+
const newRotation = getCustomMinimapRotation();
|
|
1437
|
+
log.info("__@ newRotation: ", newRotation);
|
|
1438
|
+
setCustomMinimapRotation(newRotation);
|
|
1439
|
+
// Remove the previous rotation class (if any)
|
|
1440
|
+
customMapImage.classList.remove('at_rotate-90', 'at_rotate-180', 'at_rotate-270', 'at_rotate-360');
|
|
1441
|
+
// Add the new rotation class based on newRotation value
|
|
1442
|
+
customMapImage.classList.add(`at_rotate-${newRotation === 0 ? 360 : newRotation}`);
|
|
1443
|
+
customMapImage.src = _customMapFloorData[floor_sequence].floor_image ? _customMapFloorData[floor_sequence].floor_image : 'https://i.ibb.co/043hGg9/377.png';
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Resets the custom map setting to its defaults values
|
|
1448
|
+
*/
|
|
1449
|
+
function resetCustomMapSettingValues() {
|
|
1450
|
+
log.info("resetCustomMapSettingValues()");
|
|
1451
|
+
setCustomMapScale(30);
|
|
1452
|
+
setCustomMapTranslate(1);
|
|
1453
|
+
setCustomMinimapRotation(DEGREE.DEG_0);
|
|
1454
|
+
setCustomMapXOffset(0);
|
|
1455
|
+
setCustomMapYOffset(0);
|
|
1456
|
+
const customMapImage = document.getElementById('at-custom-map-img');
|
|
1457
|
+
if (customMapImage)
|
|
1458
|
+
customMapImage.src = 'https://i.ibb.co/043hGg9/377.png';
|
|
1459
|
+
}
|
|
1031
1460
|
export {
|
|
1032
1461
|
// _miniMapData as minimapData,
|
|
1033
|
-
isMinimapNavigation, setMap, showMinimap, hideMinimap, locateAvatar, resetSweepMarkerColors, renderOverlaySweep, showDirection, toggleMinimapVisibility, setSweepMarkerColor, setStandaloneMap, toggleMinimapFloor, getFloorsInSpace, createDropdown, setMinimapPosition
|
|
1462
|
+
isMinimapNavigation, setMap, showMinimap, hideMinimap, locateAvatar, resetSweepMarkerColors, renderOverlaySweep, showDirection, toggleMinimapVisibility, setSweepMarkerColor, setStandaloneMap, toggleMinimapFloor, getFloorsInSpace, createDropdown, setMinimapPosition,
|
|
1463
|
+
// custom minimap
|
|
1464
|
+
setCustomMap, setupCustomMinimapPane, setCustomMinimapRotation, getCustomMinimapRotation, generateCustomMinimap, setCustomMapScale, setCustomMapTranslate, setCustomMapXOffset, setCustomMapYOffset, getCustomMapScale, getCustomMapTranslate, getCustomMapXOffset, getCustomMapYOffset, setMinAndMax, setCustomMapFloorData, getCustomMapFloorData, resetCustomMapSettingValues };
|