architwin 1.16.5 → 1.16.8

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.
@@ -279,7 +279,8 @@ i18n
279
279
  "PleaseOffDrawingMode": "Action cannot be done, please turn off drawing mode.",
280
280
  "IotCategoryRequired": "IoT Category is required",
281
281
  "SuccessUpdatedFloorLevel": "Updated the partition's floor level",
282
- "DuplicatePartitionName": "This partition name is already used in this room. Please choose a different name."
282
+ "DuplicatePartitionName": "This partition name is already used in this room. Please choose a different name.",
283
+ "PleaseOnPolygonVisibility": "Action cannot be done, please turn on room visibility.",
283
284
  }
284
285
  },
285
286
  ja: {
@@ -553,7 +554,8 @@ i18n
553
554
  "Successfully Deleted Tag": "タグを削除しました",
554
555
  "IotCategoryRequired": "IoTカテゴリは必須です",
555
556
  "SuccessUpdatedFloorLevel": "区画のフロアオフセット値が更新されました",
556
- "DuplicatePartitionName": "このパーティション名は既にこの部屋で使用されています。別の名前を選択してください。"
557
+ "DuplicatePartitionName": "このパーティション名は既にこの部屋で使用されています。別の名前を選択してください。",
558
+ "PleaseOnPolygonVisibility": "操作を行う前に、部屋の表示をオンにしてください。"
557
559
  }
558
560
  }
559
561
  },
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import i18n from '../i18n';
11
11
  import { SPACE_EVENTS } from "../../../../types";
12
12
  import { batchAddEventListenerByClassName, notyf } from "../../../events";
13
- import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon, setMeshChildrenMaterialProperty, get3DXObjects, getChildrenOfModel, clearSelectedObject, renderPolygon, setWallBaseHeight, clearWallBaseHeight, setDrawingConfig, resetDrawingConfig, goToPosition, partitionHistory } from '../../../../architwin';
13
+ import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon, setMeshChildrenMaterialProperty, get3DXObjects, getChildrenOfModel, clearSelectedObject, renderPolygon, setWallBaseHeight, clearWallBaseHeight, setDrawingConfig, resetDrawingConfig, goToPosition, partitionHistory, hasTimeElapsed, getIsPolygonVisible } from '../../../../architwin';
14
14
  import { generateUUID, extractUUID } from '../../../../utils';
15
- import { getCurrentEditRoomData } from './roomTreePane';
15
+ import { getCurrentEditRoomData, toggleRoomTreeClickDisability } from './roomTreePane';
16
16
  import { toggleModal, setModalAction } from "../modal";
17
17
  import { Notyf } from 'notyf';
18
18
  import log from 'loglevel';
@@ -203,107 +203,120 @@ export function renderRoomFormPane() {
203
203
  */
204
204
  export function toggleDrawPartitionButton() {
205
205
  console.log("toggleDrawPartitionButton()");
206
- if (!isDrawing) {
207
- startDrawing();
208
- }
209
- else {
210
- const partitionItem = document.getElementById('at-partition-item-container');
211
- const partitionList = document.getElementById('at-partition-list-container');
212
- const vertexList = document.getElementById('at-face-vertex-container');
213
- const partitionNameInput = document.getElementById('at-edit-partition-name-input');
214
- partitionNameInput.value = '';
215
- const formMode = getPartitionFormMode();
216
- if (formMode == "ADD" /* FORM_MODE.ADD */) {
217
- tempCurrentPolygon = getCurrentPolygon();
206
+ const isPolygonVisible = getIsPolygonVisible();
207
+ log.info("isPolygonVisible", isPolygonVisible);
208
+ if (isPolygonVisible) {
209
+ if (!isDrawing) {
210
+ startDrawing();
218
211
  }
219
- cancelDrawing();
220
- goBackToPartitionList();
221
- if (currentPartitionDataArray.length !== 0) {
222
- partitionItem.style.display = 'flex';
223
- vertexList.style.display = 'none';
224
- partitionList.style.justifyContent = 'start';
212
+ else {
213
+ const partitionItem = document.getElementById('at-partition-item-container');
214
+ const partitionList = document.getElementById('at-partition-list-container');
215
+ const vertexList = document.getElementById('at-face-vertex-container');
216
+ const partitionNameInput = document.getElementById('at-edit-partition-name-input');
217
+ partitionNameInput.value = '';
218
+ const formMode = getPartitionFormMode();
219
+ if (formMode == "ADD" /* FORM_MODE.ADD */) {
220
+ tempCurrentPolygon = getCurrentPolygon();
221
+ }
222
+ cancelDrawing();
223
+ goBackToPartitionList();
224
+ if (currentPartitionDataArray.length !== 0) {
225
+ partitionItem.style.display = 'flex';
226
+ vertexList.style.display = 'none';
227
+ partitionList.style.justifyContent = 'start';
228
+ }
229
+ currentPolygonData = null;
230
+ currentPartitionData = null;
231
+ isEditPartition = false;
232
+ previousPartitionData = null;
225
233
  }
226
- currentPolygonData = null;
227
- currentPartitionData = null;
228
- isEditPartition = false;
229
- previousPartitionData = null;
234
+ partitionHistory.clearHistory();
235
+ toggleUndoRedoButtons(false, false);
236
+ }
237
+ else {
238
+ notify.error(i18n.t("PleaseOnPolygonVisibility"));
230
239
  }
231
- partitionHistory.clearHistory();
232
- toggleUndoRedoButtons(false, false);
233
240
  }
234
241
  export function toggleDrawWindowButton() {
235
242
  var _a, _b, _c;
236
243
  log.info("toggleDrawWindowButton()", getCurrentPolygon(), _3DXObjects);
237
244
  setCurrentPolygon(undefined);
238
245
  const addDoorButton = document.getElementById('at-add-window-door-btn');
239
- if (!isDrawing) {
240
- isDrawing = true;
241
- drawingMode = 'window';
242
- // clearSelectedObject()
243
- if (!isEditWindow) {
244
- addDoorButton.classList.remove('at_add_window_door_btn');
245
- addDoorButton.classList.add('at_add_window_door_btn_active');
246
- addDoorButton.innerHTML = `
247
- ${i18n.t('DoneDrawing')}
248
- <span class="mdi mdi-check-bold"></span>
249
- `;
250
- currentWindowIndex = (_a = currentWall.windows) === null || _a === void 0 ? void 0 : _a.length;
251
- }
252
- const objectIndex = _3DXObjects.findIndex(obj => obj.object.id == currentObject.object.id);
253
- log.info("objectIndex", objectIndex);
254
- drawingConfig = {
255
- lineTypeComponentConfig: {
256
- renderPolygonOnAdd: false,
257
- drawingMode: drawingMode,
258
- targetIndex: (_c = currentEditWindowIndex !== null && currentEditWindowIndex !== void 0 ? currentEditWindowIndex : (_b = currentWall.windows) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
259
- polygonData: currentPolygonData,
260
- targetUUID: currentWall.uuid,
261
- objectIndex: objectIndex
246
+ const isPolygonVisible = getIsPolygonVisible();
247
+ if (isPolygonVisible) {
248
+ if (!isDrawing) {
249
+ isDrawing = true;
250
+ drawingMode = 'window';
251
+ // clearSelectedObject()
252
+ if (!isEditWindow) {
253
+ addDoorButton.classList.remove('at_add_window_door_btn');
254
+ addDoorButton.classList.add('at_add_window_door_btn_active');
255
+ addDoorButton.innerHTML = `
256
+ ${i18n.t('DoneDrawing')}
257
+ <span class="mdi mdi-check-bold"></span>
258
+ `;
259
+ currentWindowIndex = (_a = currentWall.windows) === null || _a === void 0 ? void 0 : _a.length;
262
260
  }
263
- };
264
- log.info("drawingConfig", drawingConfig);
265
- setDrawingConfig(drawingConfig);
266
- startDraw();
267
- }
268
- else {
269
- isDrawing = false;
270
- drawingMode = null;
271
- currentWindowIndex = null;
272
- currentPartitionData.polygon_json = JSON.stringify(currentPolygonData);
273
- addDoorButton.classList.remove('at_add_window_door_btn_active');
274
- addDoorButton.classList.add('at_add_window_door_btn');
275
- addDoorButton.innerHTML = `
276
- ${i18n.t('AddWindowDoor')}
277
- <span class="mdi mdi-window-closed-variant"></span>
278
- `;
279
- cancelDraw();
280
- resetDrawingConfig();
281
- setCurrentPolygon(currentObject);
282
- let payload;
283
- if (currentPartitionData) {
284
- payload = {
285
- uuid: currentPartitionData.uuid,
286
- polygon_json: currentPolygonData
261
+ const objectIndex = _3DXObjects.findIndex(obj => obj.object.id == currentObject.object.id);
262
+ log.info("objectIndex", objectIndex);
263
+ drawingConfig = {
264
+ lineTypeComponentConfig: {
265
+ renderPolygonOnAdd: false,
266
+ drawingMode: drawingMode,
267
+ targetIndex: (_c = currentEditWindowIndex !== null && currentEditWindowIndex !== void 0 ? currentEditWindowIndex : (_b = currentWall.windows) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
268
+ polygonData: currentPolygonData,
269
+ targetUUID: currentWall.uuid,
270
+ objectIndex: objectIndex
271
+ }
287
272
  };
273
+ log.info("drawingConfig", drawingConfig);
274
+ setDrawingConfig(drawingConfig);
275
+ startDraw();
288
276
  }
289
- // Re-render polygon
290
- renderPolygon(payload);
291
- const objectIndex = _3DXObjects.findIndex(obj => obj.object.object_id == currentObject.object.object_id);
292
- if (objectIndex != null) {
293
- log.info("objectIndex", objectIndex);
294
- if (_3DXObjects[objectIndex].children) {
295
- _3DXObjects[objectIndex].children.map((win) => __awaiter(this, void 0, void 0, function* () {
296
- var _d;
297
- log.info("WIND", win);
298
- if (win.index == ((_d = currentWall.windows) === null || _d === void 0 ? void 0 : _d.length) - 1 && win.wallUUID == currentWall.uuid) {
299
- yield disposeModel(win);
300
- }
301
- }));
277
+ else {
278
+ isDrawing = false;
279
+ drawingMode = null;
280
+ currentWindowIndex = null;
281
+ currentPartitionData.polygon_json = JSON.stringify(currentPolygonData);
282
+ addDoorButton.classList.remove('at_add_window_door_btn_active');
283
+ addDoorButton.classList.add('at_add_window_door_btn');
284
+ addDoorButton.innerHTML = `
285
+ ${i18n.t('AddWindowDoor')}
286
+ <span class="mdi mdi-window-closed-variant"></span>
287
+ `;
288
+ cancelDraw();
289
+ resetDrawingConfig();
290
+ setCurrentPolygon(currentObject);
291
+ let payload;
292
+ if (currentPartitionData) {
293
+ payload = {
294
+ uuid: currentPartitionData.uuid,
295
+ polygon_json: currentPolygonData
296
+ };
297
+ }
298
+ // Re-render polygon
299
+ renderPolygon(payload);
300
+ const objectIndex = _3DXObjects.findIndex(obj => obj.object.object_id == currentObject.object.object_id);
301
+ if (objectIndex != null) {
302
+ log.info("objectIndex", objectIndex);
303
+ if (_3DXObjects[objectIndex].children) {
304
+ _3DXObjects[objectIndex].children.map((win) => __awaiter(this, void 0, void 0, function* () {
305
+ var _d;
306
+ log.info("WIND", win);
307
+ if (win.index == ((_d = currentWall.windows) === null || _d === void 0 ? void 0 : _d.length) - 1 && win.wallUUID == currentWall.uuid) {
308
+ yield disposeModel(win);
309
+ }
310
+ }));
311
+ }
302
312
  }
303
313
  }
314
+ partitionHistory.clearHistory();
315
+ toggleUndoRedoButtons(false, false);
316
+ }
317
+ else {
318
+ notify.error(i18n.t("PleaseOnPolygonVisibility"));
304
319
  }
305
- partitionHistory.clearHistory();
306
- toggleUndoRedoButtons(false, false);
307
320
  }
308
321
  /**
309
322
  * Displays the partition form based on the current form mode.
@@ -427,7 +440,13 @@ function displayPartitions(partitions) {
427
440
  // Set up event listener for the partition edit button
428
441
  batchAddEventListenerByClassName('at_edit_partition_btn', (event) => {
429
442
  console.log('Event', event);
430
- handlePartitionRowEditBtnClickEvent(partitions, event.target);
443
+ const isPolygonVisible = getIsPolygonVisible();
444
+ if (isPolygonVisible) {
445
+ handlePartitionRowEditBtnClickEvent(partitions, event.target);
446
+ }
447
+ else {
448
+ notify.error(i18n.t("PleaseOnPolygonVisibility"));
449
+ }
431
450
  });
432
451
  // Set up event listener for confirming partition name change
433
452
  addEventListenerById('at-confirm-edit-partition-name', () => {
@@ -440,7 +459,9 @@ function displayPartitions(partitions) {
440
459
  const roomChildren = currentEditRoomData.children;
441
460
  const nameFound = roomChildren.find(child => child.name === newPartitionName && child.uuid != currentPartitionData.uuid);
442
461
  if (nameFound != undefined) {
443
- notyf.error(`${i18n.t('DuplicatePartitionName')}`);
462
+ if (hasTimeElapsed(300)) {
463
+ notyf.error(`${i18n.t('DuplicatePartitionName')}`);
464
+ }
444
465
  }
445
466
  else {
446
467
  const partitionIndex = currentPartitionDataArray.findIndex(partition => partition.uuid === currentPartitionData.uuid);
@@ -932,6 +953,11 @@ function setupEditWindow(element, window) {
932
953
  return;
933
954
  // Show inputs when edit icon is clicked
934
955
  editBtn.addEventListener("click", () => {
956
+ const isPolygonVisible = getIsPolygonVisible();
957
+ if (!isPolygonVisible) {
958
+ notify.error(`${i18n.t('PleaseOnPolygonVisibility')}`);
959
+ return;
960
+ }
935
961
  if (isDrawing) {
936
962
  notify.error(`${i18n.t('PleaseOffDrawingMode')}`);
937
963
  return;
@@ -1496,6 +1522,7 @@ export function setPolygonData(payload) {
1496
1522
  else {
1497
1523
  setCurrentPartitionData(undefined);
1498
1524
  }
1525
+ setTimeout(() => toggleRoomTreeClickDisability(false), 500);
1499
1526
  }
1500
1527
  /**
1501
1528
  * Returns current polygon data
@@ -110,3 +110,8 @@ export declare function toggleHighlightedPartitionItem(partitionId: string): voi
110
110
  export declare function calculateMidPoint(coords: Array<{
111
111
  start: Vector3;
112
112
  }>): Vector3;
113
+ /**
114
+ * Toggles Room Tree container capability to receive click events
115
+ * @param toggle - Boolean value that determines state of toggle to perform
116
+ */
117
+ export declare function toggleRoomTreeClickDisability(toggle: boolean): void;
@@ -341,6 +341,7 @@ function toggleSelectedPartition() {
341
341
  toggleDisplayPane(event.target.id);
342
342
  }));
343
343
  batchAddEventListenerByClassName('at_room_visible_btn', (event) => __awaiter(this, void 0, void 0, function* () {
344
+ toggleRoomTreeClickDisability(true);
344
345
  log.info('Event', event);
345
346
  const target = event.target;
346
347
  // Prevent event from propagating up to parent elements
@@ -352,30 +353,28 @@ function toggleSelectedPartition() {
352
353
  }));
353
354
  batchAddEventListenerByClassName('at_child_visible_btn', (event) => __awaiter(this, void 0, void 0, function* () {
354
355
  var _a;
355
- const btn = event.target;
356
- const li = btn.closest('li');
357
- const isWindow = (_a = li === null || li === void 0 ? void 0 : li.id) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('window');
358
- const polygonId = btn.id;
359
- const wallId = btn.getAttribute('polygon-item-id');
360
- event.stopPropagation();
361
- if (isWindow) {
362
- handleWindowVisibility(btn, true);
363
- return;
356
+ toggleRoomTreeClickDisability(true);
357
+ const target = event.currentTarget;
358
+ const li = target.closest('li');
359
+ if ((_a = li === null || li === void 0 ? void 0 : li.getAttribute('id')) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('window')) {
360
+ event.stopPropagation();
361
+ handleWindowVisibility(target, true);
364
362
  }
365
- const parentVisibleState = yield handlePolygonVisibility(polygonId);
366
- // no DOM reads after this point that depend on btn/li meaning
367
- yield new Promise(resolve => {
368
- requestAnimationFrame(() => resolve());
369
- });
370
- if (!wallId)
371
- return;
372
- const windowItems = document.querySelectorAll(`li.at_window_row_item[wall-id="${wallId}"]`);
373
- windowItems.forEach((windowLi) => {
374
- const visibilityBtn = windowLi.querySelector('.at_child_visible_btn');
375
- if (visibilityBtn) {
376
- handleWindowVisibility(visibilityBtn, false, parentVisibleState);
363
+ else {
364
+ const wallId = target.getAttribute('polygon-item-id');
365
+ const windowItems = document.querySelectorAll(`li.at_window_row_item[wall-id="${wallId}"]`);
366
+ yield new Promise(resolve => setTimeout(resolve, 1));
367
+ yield new Promise(resolve => requestAnimationFrame(resolve));
368
+ const parentVisibleState = yield handlePolygonVisibility(target.id);
369
+ if (windowItems && windowItems.length > 0) {
370
+ windowItems.forEach((windowLi) => {
371
+ const visibilityBtn = windowLi.querySelector('.at_child_visible_btn');
372
+ if (visibilityBtn) {
373
+ handleWindowVisibility(visibilityBtn, false, parentVisibleState);
374
+ }
375
+ });
377
376
  }
378
- });
377
+ }
379
378
  }));
380
379
  batchAddEventListenerByClassName('at_partition_wall_row_item', (event) => __awaiter(this, void 0, void 0, function* () {
381
380
  event.stopPropagation();
@@ -686,6 +685,7 @@ function updatePolygonData(currPartition, isVisible, isUpdateAllChildren) {
686
685
  }
687
686
  currPartition.polygon_json = JSON.stringify(polygonJson);
688
687
  log.info("updatePolygonData: ", JSON.parse(currPartition.polygon_json));
688
+ toggleRoomTreeClickDisability(false); // enable back room tree for click events
689
689
  // Dispatch event: PARTITION_EDITED
690
690
  dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currPartition, isUpdateTree: false });
691
691
  });
@@ -922,3 +922,14 @@ export function calculateMidPoint(coords) {
922
922
  z: sum.z / count
923
923
  };
924
924
  }
925
+ /**
926
+ * Toggles Room Tree container capability to receive click events
927
+ * @param toggle - Boolean value that determines state of toggle to perform
928
+ */
929
+ export function toggleRoomTreeClickDisability(toggle) {
930
+ const roomTreeElement = document.getElementById('at-room-tree');
931
+ if (roomTreeElement) {
932
+ roomTreeElement.style.pointerEvents = toggle ? "none" : "auto";
933
+ roomTreeElement.style.opacity = toggle ? "0.5" : "1";
934
+ }
935
+ }
@@ -669,53 +669,53 @@ export class BufferGeometry {
669
669
  }
670
670
  this.groupedMesh.add(floorMesh);
671
671
  try {
672
- let twiceSignedArea = 0;
673
- let centroidX = 0;
674
- let centroidZ = 0;
675
- for (let i = 0; i < shapeCoords.length; i++) {
676
- const p1 = shapeCoords[i];
677
- const p2 = shapeCoords[(i + 1) % shapeCoords.length];
678
- const cross = p1.x * p2.y - p2.x * p1.y;
679
- twiceSignedArea += cross;
680
- centroidX += (p1.x + p2.x) * cross;
681
- centroidZ += (p1.y + p2.y) * cross;
682
- }
683
- let centerX;
684
- let centerZ;
685
- if (Math.abs(twiceSignedArea) > 1e-8) {
686
- const polygonArea = twiceSignedArea * 0.5;
687
- centerX = centroidX / (6 * polygonArea);
688
- centerZ = centroidZ / (6 * polygonArea);
689
- }
690
- else {
691
- // Fallback: average of vertices
692
- const sum = shapeCoords.reduce((acc, p) => ({ x: acc.x + p.x, z: acc.z + p.y }), { x: 0, z: 0 });
693
- centerX = sum.x / shapeCoords.length;
694
- centerZ = sum.z / shapeCoords.length;
695
- }
696
- const floorMaterial = polyData && polyData.floor.material ? polyData.floor.material : undefined;
697
- // const floorLabelText = `Floor_Cement: ${floorDimension.area.toFixed(2)}m²`;
698
- const floorLabelText = `Floor ${floorMaterial ? '_' + floorMaterial : ' (' + i18n.t('Area') + ')'} : ${floorDimension.area.toFixed(2)}m²`;
699
- // const floorLabelText = `${floorMaterial ? floorMaterial : i18n.t('Area')}: ${floorDimension.area.toFixed(2)}m²`;
700
- const floorCanvas = this.createLabelCanvas(floorLabelText);
701
- const labelWidth = Math.max(1, Math.min(5, Math.sqrt(Math.max(0.0001, floorDimension.area))));
702
- const labelHeight = labelWidth / 4;
703
- const floorLabelGeometry = new THREE.PlaneGeometry(labelWidth, labelHeight);
704
- const floorLabelMaterial = new THREE.MeshBasicMaterial({
705
- map: new THREE.CanvasTexture(floorCanvas),
706
- transparent: true,
707
- side: THREE.DoubleSide,
708
- });
709
- const floorCenterLabel = new THREE.Mesh(floorLabelGeometry, floorLabelMaterial);
710
- // Lay flat on the floor (XZ plane) and slightly offset in Y to avoid z-fighting
711
- floorCenterLabel.rotation.x = -Math.PI / 2;
712
- floorCenterLabel.position.set(centerX, floorLevel + 0.02, centerZ);
713
- floorCenterLabel.name = this.inputs.uuid != '' ? `${this.inputs.uuid}_floorCenterLabel` : `floorCenterLabel`;
714
- if (floorConfig && floorConfig.options) {
715
- floorCenterLabel.visible = floorConfig.options.is_visible;
672
+ if (this.inputs.drawingMode == 'floor') {
673
+ let twiceSignedArea = 0;
674
+ let centroidX = 0;
675
+ let centroidZ = 0;
676
+ for (let i = 0; i < shapeCoords.length; i++) {
677
+ const p1 = shapeCoords[i];
678
+ const p2 = shapeCoords[(i + 1) % shapeCoords.length];
679
+ const cross = p1.x * p2.y - p2.x * p1.y;
680
+ twiceSignedArea += cross;
681
+ centroidX += (p1.x + p2.x) * cross;
682
+ centroidZ += (p1.y + p2.y) * cross;
683
+ }
684
+ let centerX;
685
+ let centerZ;
686
+ if (Math.abs(twiceSignedArea) > 1e-8) {
687
+ const polygonArea = twiceSignedArea * 0.5;
688
+ centerX = centroidX / (6 * polygonArea);
689
+ centerZ = centroidZ / (6 * polygonArea);
690
+ }
691
+ else {
692
+ // Fallback: average of vertices
693
+ const sum = shapeCoords.reduce((acc, p) => ({ x: acc.x + p.x, z: acc.z + p.y }), { x: 0, z: 0 });
694
+ centerX = sum.x / shapeCoords.length;
695
+ centerZ = sum.z / shapeCoords.length;
696
+ }
697
+ const floorMaterial = polyData && polyData.floor.material ? polyData.floor.material : undefined;
698
+ const floorLabelText = `Floor ${floorMaterial ? '_' + floorMaterial : ' (' + i18n.t('Area') + ')'} : ${floorDimension.area.toFixed(2)}m²`;
699
+ const floorCanvas = this.createLabelCanvas(floorLabelText);
700
+ const labelWidth = Math.max(1, Math.min(5, Math.sqrt(Math.max(0.0001, floorDimension.area))));
701
+ const labelHeight = labelWidth / 4;
702
+ const floorLabelGeometry = new THREE.PlaneGeometry(labelWidth, labelHeight);
703
+ const floorLabelMaterial = new THREE.MeshBasicMaterial({
704
+ map: new THREE.CanvasTexture(floorCanvas),
705
+ transparent: true,
706
+ side: THREE.DoubleSide,
707
+ });
708
+ const floorCenterLabel = new THREE.Mesh(floorLabelGeometry, floorLabelMaterial);
709
+ // Lay flat on the floor (XZ plane) and slightly offset in Y to avoid z-fighting
710
+ floorCenterLabel.rotation.x = -Math.PI / 2;
711
+ floorCenterLabel.position.set(centerX, floorLevel + 0.02, centerZ);
712
+ floorCenterLabel.name = this.inputs.uuid != '' ? `${this.inputs.uuid}_floorCenterLabel` : `floorCenterLabel`;
713
+ if (floorConfig && floorConfig.options) {
714
+ floorCenterLabel.visible = floorConfig.options.is_visible;
715
+ }
716
+ this.floorLabels.push(floorCenterLabel);
717
+ this.groupedMesh.add(floorCenterLabel);
716
718
  }
717
- this.floorLabels.push(floorCenterLabel);
718
- this.groupedMesh.add(floorCenterLabel);
719
719
  }
720
720
  catch (e) {
721
721
  log.error('Error creating floor center label', e);
package/lib/minimap.d.ts CHANGED
@@ -39,7 +39,7 @@ declare function getFloorsInSpace(): FloorData[];
39
39
  * @param mapId - id of an html element where the map will be attached to
40
40
  * @returns
41
41
  */
42
- declare function setStandaloneMap(modelId: string, appKey: string, mapId: string): Promise<void>;
42
+ declare function setStandaloneMap(modelId: string, appKey: string, mapId: string, floorSequence?: number): Promise<void>;
43
43
  /**
44
44
  * This function creates the dropdown (HTLMElement) for available positions that Minimap can be set
45
45
  * @param mapPositions An array of strings representing the minimap positions (e.g., 'topLeft','bottomRight').
package/lib/minimap.js CHANGED
@@ -795,6 +795,9 @@ function toggleMinimapFloor(action) {
795
795
  toggleSweepMarkerFloors(sequence);
796
796
  return floorMatch;
797
797
  }
798
+ // function changeMinimapFloor(sequence: number): FloorData {
799
+ // _currentFloor = sequence
800
+ // }
798
801
  /**
799
802
  * Returns an array of objects containing the floor data of a space. This function will only have data if you are displaying
800
803
  * a standalone minimap
@@ -809,8 +812,9 @@ function getFloorsInSpace() {
809
812
  * @param mapId - id of an html element where the map will be attached to
810
813
  * @returns
811
814
  */
812
- function setStandaloneMap(modelId, appKey, mapId) {
815
+ function setStandaloneMap(modelId, appKey, mapId, floorSequence = 0) {
813
816
  return __awaiter(this, void 0, void 0, function* () {
817
+ log.info("setStandaloneMap floor: ", floorSequence);
814
818
  log.info("setStandaloneMap");
815
819
  if (!modelId) {
816
820
  log.error("modelId is undefined");
@@ -873,9 +877,9 @@ function setStandaloneMap(modelId, appKey, mapId) {
873
877
  _mapContainer.appendChild(minimap);
874
878
  }
875
879
  //Set the current floor sequence for standalone as the first floor always so give it 0
876
- _mapContainer.setAttribute('class', 'floor' + 0);
877
- _currentFloor = 0;
878
- setImg(minimap, 0, true);
880
+ _mapContainer.setAttribute('class', 'floor' + floorSequence);
881
+ _currentFloor = floorSequence !== null && floorSequence !== void 0 ? floorSequence : 0;
882
+ setImg(minimap, floorSequence, true);
879
883
  document.body.classList.add('minimap');
880
884
  if (sweepData && sweepData.data.model.locations.length > 0) {
881
885
  sweepData.data.model.locations.forEach((swp, index) => {
@@ -903,7 +907,7 @@ function setStandaloneMap(modelId, appKey, mapId) {
903
907
  }
904
908
  });
905
909
  }
906
- toggleSweepMarkerFloors(0);
910
+ toggleSweepMarkerFloors(floorSequence);
907
911
  });
908
912
  }
909
913
  /**
package/lib/types.d.ts CHANGED
@@ -760,6 +760,7 @@ export declare enum SPACE_EVENTS {
760
760
  FLOOR_IMAGE_UPLOADED = "FLOOR_IMAGE_UPLOADED",
761
761
  FLOOR_IMAGE_UPLOAD_FAILED = "FLOOR_IMAGE_UPLOAD_FAILED",
762
762
  FLOOR_IMAGE_ROTATED = "FLOOR_IMAGE_ROTATED",
763
+ FLOOR_CHANGED = "FLOOR_CHANGED",
763
764
  CUSTOM_SWEEP_SCALE_UPDATED = "CUSTOM_SWEEP_SCALE_UPDATED",
764
765
  CUSTOM_SWEEP_TRANSLATE_UPDATED = "CUSTOM_SWEEP_TRANSLATE_UPDATED",
765
766
  CUSTOM_SWEEP_OFFSETX_UPDATED = "CUSTOM_SWEEP_OFFSETX_UPDATED",
package/lib/types.js CHANGED
@@ -103,6 +103,7 @@ export var SPACE_EVENTS;
103
103
  SPACE_EVENTS["FLOOR_IMAGE_UPLOADED"] = "FLOOR_IMAGE_UPLOADED";
104
104
  SPACE_EVENTS["FLOOR_IMAGE_UPLOAD_FAILED"] = "FLOOR_IMAGE_UPLOAD_FAILED";
105
105
  SPACE_EVENTS["FLOOR_IMAGE_ROTATED"] = "FLOOR_IMAGE_ROTATED";
106
+ SPACE_EVENTS["FLOOR_CHANGED"] = "FLOOR_CHANGED";
106
107
  SPACE_EVENTS["CUSTOM_SWEEP_SCALE_UPDATED"] = "CUSTOM_SWEEP_SCALE_UPDATED";
107
108
  SPACE_EVENTS["CUSTOM_SWEEP_TRANSLATE_UPDATED"] = "CUSTOM_SWEEP_TRANSLATE_UPDATED";
108
109
  SPACE_EVENTS["CUSTOM_SWEEP_OFFSETX_UPDATED"] = "CUSTOM_SWEEP_OFFSETX_UPDATED";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.16.5",
3
+ "version": "1.16.8",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",