architwin 1.9.2 → 1.9.3

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.js CHANGED
@@ -202,7 +202,7 @@ let _visualize = true, _editPolygonMode = false, _drawPolygonMode = false, _tube
202
202
  // _thisVertexComponent:MpSdk.Scene.IComponent, // Current Vertex Component
203
203
  // _thisVerticeNode:MpSdk.Scene.INode, // Current VerticeNode
204
204
  // _thisVertexPath = new Array()
205
- let visualize = true, _activeVertex, editMode = false, drawMode = false, _thisVertexNode, _thisVertexComponent, _thisVerticesNode, _thisVertexPath = new Array(), _currentPolygon, _polygonShapePath, _verticeComponentsCollection = [], _highestYaxisPoint, _polygonFloorOffset = 0.1, _autoLevelFloorEnabled = true, _floorBaseHeight;
205
+ let visualize = true, _activeVertex, editMode = false, drawMode = false, _thisVertexNode, _thisVertexComponent, _thisVerticesNode, _thisVertexPath = new Array(), _currentPolygon, _polygonShapePath, _verticeComponentsCollection = [], _vertexConnectiveComponentCollection = [], _vertexConnectiveNodeCollection = [], _highestYaxisPoint, _polygonFloorOffset = 0.1, _autoLevelFloorEnabled = true, _floorBaseHeight, _offsetedBaseHeight = _floorBaseHeight ? _floorBaseHeight + _polygonFloorOffset : undefined;
206
206
  let _intersectionData, _tubes, _verticeEmitPath, _verticeEditEmitPath;
207
207
  let _navigationInputNode;
208
208
  let _navigationComponent;
@@ -5312,6 +5312,7 @@ function addVerticeControls(component, index) {
5312
5312
  // Trigger onInputsUpdated
5313
5313
  _activeVertex.inputs.active = false;
5314
5314
  if (_currentPolygon) {
5315
+ //setSelectedObject(_currentPolygon.object,_currentPolygon.node,_currentPolygon.component, 'POLYGON')
5315
5316
  setPolygonPath(_currentPolygon.object.id, _thisVertexPath);
5316
5317
  }
5317
5318
  //@ts-expect-error
@@ -5350,6 +5351,68 @@ function createVerticeControls(component, isDeleting = false) {
5350
5351
  }
5351
5352
  verticeNode.start();
5352
5353
  }
5354
+ /**
5355
+ * Creates the individual vertex nodes and components and attached vertice controls
5356
+ * @param {Vector3} position - Coordinates
5357
+ */
5358
+ function createVertexPoints(position, redrawing = false) {
5359
+ log.info("createVertexPoints()");
5360
+ if (!position) {
5361
+ log.error("Position is undefined");
5362
+ return;
5363
+ }
5364
+ // If no node is active
5365
+ if (_thisVertexNode === undefined) {
5366
+ log.info("_thisVertexNode is undefined. Adding vertex...");
5367
+ let start = Object.assign({}, position);
5368
+ log.info("_floorBaseHeight", _floorBaseHeight);
5369
+ if (_floorBaseHeight !== undefined) {
5370
+ log.info("Using _floorBaseHeight");
5371
+ start.y = _floorBaseHeight;
5372
+ }
5373
+ if (redrawing == false) {
5374
+ start.y += _polygonFloorOffset;
5375
+ }
5376
+ // Generate Tag ID from position
5377
+ const r = (x) => Math.round(x * 100) / 100;
5378
+ let thisName = "x" + r(start.x) + "y" + r(start.y) + "z" + r(start.z);
5379
+ if (redrawing) {
5380
+ thisName = `${thisName}-${uid.rnd()}`;
5381
+ }
5382
+ //@ts-expect-error
5383
+ [_thisVertexNode, _thisVertexComponent] = addVertex(thisName, [start]);
5384
+ _thisVertexPath.push(start);
5385
+ log.info("_thisVertexPath ", _thisVertexPath);
5386
+ if (visualize) {
5387
+ _activeVertex.inputs.collider = false;
5388
+ }
5389
+ //Add to the array so we can re enable the vertex controls of the polygon later
5390
+ _vertexConnectiveComponentCollection.push(_thisVertexComponent);
5391
+ _vertexConnectiveNodeCollection.push(_thisVertexNode);
5392
+ log.info("_thisVertexNode ", _thisVertexNode);
5393
+ createVerticeControls(_thisVertexComponent);
5394
+ }
5395
+ else {
5396
+ log.info("_thisVertexNode is defined");
5397
+ log.info("before position ", position);
5398
+ log.info("before _floorBaseHeight ", _floorBaseHeight);
5399
+ let point = Object.assign({}, position);
5400
+ // _intersectionData.position.y += (_highestYaxisPoint + _polygonFloorOffset)
5401
+ if (_floorBaseHeight !== undefined) {
5402
+ point = {
5403
+ x: position.x,
5404
+ y: _floorBaseHeight,
5405
+ z: position.z
5406
+ };
5407
+ }
5408
+ //point.y += _polygonFloorOffset
5409
+ log.info("after position ", point);
5410
+ _thisVertexPath.push(Object.assign({}, point));
5411
+ _thisVertexComponent.inputs.path = [..._thisVertexPath];
5412
+ // Show Vertices
5413
+ createVerticeControls(_thisVertexComponent);
5414
+ }
5415
+ }
5353
5416
  function createVerticeClickSpy() {
5354
5417
  log.info("createVerticeClickSpy()");
5355
5418
  if (_isVerticeClickSpyCreated) {
@@ -5371,65 +5434,46 @@ function createVerticeClickSpy() {
5371
5434
  log.info("isCtrlPressed ", isCtrlPressed);
5372
5435
  if (isCtrlPressed) {
5373
5436
  if (_drawPolygonMode) {
5437
+ createVertexPoints(_intersectionData.position);
5374
5438
  // If no node is active
5375
- if (_thisVertexNode === undefined) {
5376
- let start = Object.assign({}, _intersectionData.position);
5377
- log.info("_floorBaseHeight", _floorBaseHeight);
5378
- if (_floorBaseHeight !== undefined) {
5379
- log.info("Using _floorBaseHeight");
5380
- start.y = _floorBaseHeight;
5381
- }
5382
- start.y += _polygonFloorOffset;
5383
- // if (!_highestYaxisPoint) {
5384
- // _highestYaxisPoint = _intersectionData.position.y
5385
- // }
5386
- // if (start.y > _highestYaxisPoint) {
5387
- // _highestYaxisPoint = _intersectionData.position.y
5388
- // }
5389
- // if (_floorBaseHeight !== undefined && _floorBaseHeight > _highestYaxisPoint) {
5390
- // _highestYaxisPoint = _floorBaseHeight
5391
- // }
5392
- // start.y += (_highestYaxisPoint + _polygonFloorOffset)
5393
- // Generate Tag ID from position
5394
- const r = (x) => Math.round(x * 100) / 100;
5395
- let thisName = "x" + r(start.x) + "y" + r(start.y) + "z" + r(start.z);
5396
- //@ts-expect-error
5397
- [_thisVertexNode, _thisVertexComponent] = addVertex(thisName, [start]);
5398
- _thisVertexPath.push(start);
5399
- log.info("_thisVertexPath ", _thisVertexPath);
5400
- if (visualize) {
5401
- _activeVertex.inputs.collider = false;
5402
- }
5403
- createVerticeControls(_thisVertexComponent);
5404
- }
5405
- else {
5406
- log.info("before _intersectionData.position ", _intersectionData.position);
5407
- log.info("before _floorBaseHeight ", _floorBaseHeight);
5408
- let point = Object.assign({}, _intersectionData.position);
5409
- // if (!_highestYaxisPoint) {
5410
- // _highestYaxisPoint = _intersectionData.position.y
5411
- // }
5412
- // if (_intersectionData.position.y > _highestYaxisPoint) {
5413
- // _highestYaxisPoint = _intersectionData.position.y
5414
- // }
5415
- // if (_floorBaseHeight !== undefined && _floorBaseHeight > _highestYaxisPoint) {
5416
- // _highestYaxisPoint = _floorBaseHeight
5417
- // }
5418
- // _intersectionData.position.y += (_highestYaxisPoint + _polygonFloorOffset)
5419
- if (_floorBaseHeight !== undefined) {
5420
- point = {
5421
- x: _intersectionData.position.x,
5422
- y: _floorBaseHeight,
5423
- z: _intersectionData.position.z
5424
- };
5425
- }
5426
- //point.y += _polygonFloorOffset
5427
- log.info("after _intersectionData.position ", point);
5428
- _thisVertexPath.push(Object.assign({}, point));
5429
- _thisVertexComponent.inputs.path = [..._thisVertexPath];
5430
- // Show Vertices
5431
- createVerticeControls(_thisVertexComponent);
5432
- }
5439
+ // if (_thisVertexNode === undefined) {
5440
+ // let start = { ..._intersectionData.position };
5441
+ // log.info("_floorBaseHeight", _floorBaseHeight)
5442
+ // if (_floorBaseHeight !== undefined) {
5443
+ // log.info("Using _floorBaseHeight")
5444
+ // start.y = _floorBaseHeight
5445
+ // }
5446
+ // start.y += _polygonFloorOffset
5447
+ // // Generate Tag ID from position
5448
+ // const r = (x) => Math.round(x * 100) / 100;
5449
+ // let thisName = "x" + r(start.x) + "y" + r(start.y) + "z" + r(start.z);
5450
+ // //@ts-expect-error
5451
+ // [_thisVertexNode, _thisVertexComponent] = addVertex(thisName, [start]);
5452
+ // _thisVertexPath.push(start);
5453
+ // log.info("_thisVertexPath ", _thisVertexPath)
5454
+ // if (visualize) {
5455
+ // _activeVertex.inputs.collider = false;
5456
+ // }
5457
+ // createVerticeControls(_thisVertexComponent);
5458
+ // } else {
5459
+ // log.info("before _intersectionData.position ",_intersectionData.position)
5460
+ // log.info("before _floorBaseHeight ",_floorBaseHeight)
5461
+ // let point = {..._intersectionData.position}
5462
+ // // _intersectionData.position.y += (_highestYaxisPoint + _polygonFloorOffset)
5463
+ // if (_floorBaseHeight !== undefined) {
5464
+ // point = {
5465
+ // x: _intersectionData.position.x,
5466
+ // y: _floorBaseHeight,
5467
+ // z: _intersectionData.position.z
5468
+ // }
5469
+ // }
5470
+ // //point.y += _polygonFloorOffset
5471
+ // log.info("after _intersectionData.position ",point)
5472
+ // _thisVertexPath.push({ ...point });
5473
+ // _thisVertexComponent.inputs.path = [..._thisVertexPath];
5474
+ // // Show Vertices
5475
+ // createVerticeControls(_thisVertexComponent);
5476
+ // }
5433
5477
  dispatchSpaceEvent(SPACE_EVENTS.VERTEX_PLACED, {
5434
5478
  position: _intersectionData.position,
5435
5479
  path: _thisVertexPath
@@ -5496,7 +5540,26 @@ function enableVerticeControls(component) {
5496
5540
  log.error("Path of component is empty or undefined");
5497
5541
  return;
5498
5542
  }
5499
- createVerticeControls(component);
5543
+ startDraw();
5544
+ //@ts-expect-error
5545
+ const currenPath = [...component.inputs.path];
5546
+ const last = currenPath.pop();
5547
+ log.info("currenPath ", currenPath);
5548
+ ////@ts-expect-error
5549
+ _thisVertexPath = [...currenPath];
5550
+ const first = _thisVertexPath[0];
5551
+ const r = (x) => Math.round(x * 100) / 100;
5552
+ let name = "x" + r(first.x) + "y" + r(first.y) + "z" + r(first.z);
5553
+ name = `${name}-${uid.rnd()}`;
5554
+ //@ts-expect-error
5555
+ [_thisVertexNode, _thisVertexComponent] = addVertex(name, _thisVertexPath);
5556
+ log.info("_thisVertexPath ", _thisVertexPath);
5557
+ if (visualize) {
5558
+ _activeVertex.inputs.collider = false;
5559
+ }
5560
+ _thisVertexPath.push(Object.assign({}, last));
5561
+ _thisVertexComponent.inputs.path = [..._thisVertexPath];
5562
+ createVerticeControls(_thisVertexComponent);
5500
5563
  }
5501
5564
  /**
5502
5565
  * Deletes the edge of a polygon.
@@ -5760,12 +5823,14 @@ function setFloorBaseHeight(baseHeight) {
5760
5823
  return;
5761
5824
  }
5762
5825
  _floorBaseHeight = baseHeight;
5826
+ _offsetedBaseHeight = _floorBaseHeight + _polygonFloorOffset;
5763
5827
  }
5764
5828
  /**
5765
5829
  * Clear the value of the base height for floors of polygons
5766
5830
  */
5767
5831
  function clearFloorBaseHeight() {
5768
5832
  _floorBaseHeight = undefined;
5833
+ _offsetedBaseHeight = undefined;
5769
5834
  }
5770
5835
  //===================== END VERTEX DRAWING METHODS =========================//
5771
5836
  //===================== START KEYBINDINGS =========================//
@@ -6749,35 +6814,13 @@ class PolygonClickSpy {
6749
6814
  _currentPolygon = {
6750
6815
  node: this.node,
6751
6816
  component: this.component,
6752
- object: this.object_data
6817
+ object: this.object_data,
6818
+ type: 'POLYGON'
6753
6819
  };
6754
6820
  }
6755
6821
  }
6756
6822
  }
6757
6823
  }
6758
- class VerticeEditSpy {
6759
- constructor(path, callback) {
6760
- this.path = path;
6761
- this.callback = callback;
6762
- }
6763
- onEvent(data) {
6764
- log.info("VerticeEditSpy");
6765
- // if (data.collider !== null) {
6766
- // const nodeIterator = _tubes.nodeIterator();
6767
- // let nodes = nodeIterator.next();
6768
- // while (!nodes.done) {
6769
- // const componentIterator = nodes.value.componentIterator();
6770
- // let component = componentIterator.next();
6771
- // component.value.inputs.collider = data.collider;
6772
- // nodes = nodeIterator.next();
6773
- // }
6774
- // }
6775
- // // Trigger onInputsUpdated
6776
- // _activeVertex.inputs.active = false;
6777
- // _activeVertex.inputs.path[data.index] = data.position;
6778
- // _activeVertex.inputs.active = true;
6779
- }
6780
- }
6781
6824
  export { _atwin, _config, _mpConfig, tags, sweeps, selectedObject, previousObjTransform, currentObjTransform, actionHistory, state, _tags, _tagCategories, _tagMessageRecepients, _space, _spaceId, _api, _pointerCoord, _3DXObjects, _meetingParticipants, _generatedObjectIds, tagColors, domMousePosition, isFitScreenOccupied, isCdnMapDataAvailable,
6782
6825
  //minimap
6783
6826
  minimap, _modelDetails, _onMouseClickInstance, transformHistory,
@@ -117,6 +117,7 @@ i18n
117
117
  "MarkBaseHeight": "Click to mark an area as your desired base height",
118
118
  "Saving": "Saving",
119
119
  "DeletePartition": "Delete Partition",
120
+ "ModifyPartition": "Modify Partition"
120
121
  }
121
122
  },
122
123
  ja: {
@@ -228,6 +229,7 @@ i18n
228
229
  "NoPartitionDeleted": "削除できる区画がありません",
229
230
  "Saving": "保存",
230
231
  "DeletePartition": "パーティション削除",
232
+ "ModifyPartition": "パーティションの変更"
231
233
  }
232
234
  }
233
235
  },
@@ -72,3 +72,5 @@ export declare function setCurrentPartitionData(): Promise<void>;
72
72
  export declare function getCurrentPartitionData(): PartitionNode;
73
73
  export declare function getNewlyAddedPartition(): Array<PartitionNode>;
74
74
  export declare function getDeletedSavedPartitionArray(): Array<PartitionNode>;
75
+ export declare function getDrawingMode(): boolean;
76
+ export declare function setDrawingMode(state: boolean): void;
@@ -15,6 +15,7 @@ import { generateUUID, extractUUID } from '../../../../utils';
15
15
  import { getCurrentEditRoomData } from './roomTreePane';
16
16
  import { toggleModal, setModalAction } from "../modal";
17
17
  import { Notyf } from 'notyf';
18
+ import log from 'loglevel';
18
19
  let isDrawing = false;
19
20
  let roomFormMode = "ADD" /* FORM_MODE.ADD */;
20
21
  let isSaving = false;
@@ -69,6 +70,10 @@ export function renderRoomFormPane() {
69
70
  ${i18n.t('DrawPartition')}
70
71
  <span class="mdi mdi-cube-outline"></span>
71
72
  </div>
73
+ <div class="at_button at_draw_partition_btn at_w-full at_hidden" id="at-modify-partition-form-btn" data-cy="at-modify-partition-form-btn">
74
+ ${i18n.t('ModifyPartition')}
75
+ <span class="mdi mdi-cube-outline"></span>
76
+ </div>
72
77
  <div class="at_partition_list_container at_h-min-40" id="at-partition-list-container" data-cy="at-partition-list-container">
73
78
  <div class="at_face_title" id="at-face-title" style="display: none;">
74
79
  <span class="mdi mdi-chevron-left" id="at-back-partition"></span>
@@ -818,3 +823,13 @@ export function getNewlyAddedPartition() {
818
823
  export function getDeletedSavedPartitionArray() {
819
824
  return deletedSavedPartitionArray;
820
825
  }
826
+ export function getDrawingMode() {
827
+ return isDrawing;
828
+ }
829
+ export function setDrawingMode(state) {
830
+ if (typeof state !== 'boolean') {
831
+ log.error("Invalid parameter value");
832
+ return;
833
+ }
834
+ isDrawing = state;
835
+ }
@@ -34,3 +34,4 @@ export declare function updateParentVisibility(isPartition: boolean, currentBtn:
34
34
  * @returns The current room node being edited.
35
35
  */
36
36
  export declare function getCurrentEditRoomData(): PartitionNode;
37
+ export declare function getSelectedPartitionId(): String;
@@ -14,6 +14,7 @@ import { setPartitionFormMode } from "./roomFormPane";
14
14
  import { _3DXObjects } from "../../../../architwin";
15
15
  let roomDataArray = [];
16
16
  let currentEditRoomData = null;
17
+ let currentSelectedPartitionId = null;
17
18
  /**
18
19
  * Renders and returns the HTML element for the room tree pane.
19
20
  * @returns {HTMLElement} The HTML element representing the room tree pane.
@@ -107,7 +108,7 @@ export function displayPartition(partition) {
107
108
  element.innerHTML = `
108
109
  <li class="at_room_tree_parent">
109
110
  <div class="at_flex at_space_between at_toggle">
110
- <span class="toggle selectable" >▶ ${partition.name}</span>
111
+ <span class="toggle selectable" id="at-room-${partition.uuid}">▶ ${partition.name}</span>
111
112
  <div>
112
113
  <span id="at-room-edit-${partition.uuid}-btn" class="mdi mdi-pencil at_room_edit_btn" target-pane="at-room-form-pane"></span>
113
114
  <span id="at-room-visibility-${partition.uuid}-btn" class="mdi mdi-eye at_room_visible_btn"></span>
@@ -137,7 +138,7 @@ export function displayPartitions(partitions, partitionId) {
137
138
  let partitionHTML = `
138
139
  <li class="at_room_tree_child">
139
140
  <div class="at_flex at_space_between at_toggle">
140
- <span class="toggle selectable">▶ ${i18n.t(`${partitionItem[0]}`)} ${partitionItem[1]}</span>
141
+ <span class="toggle selectable" id="at-partition-${partition.uuid}" parentId="at-partition-${partitionId}">▶ ${i18n.t(`${partitionItem[0]}`)} ${partitionItem[1]}</span>
141
142
  <div>
142
143
  <span id="at-partition-visibility-${partition.uuid}-btn" class="mdi mdi-eye at_room_visible_btn"></span>
143
144
  </div>
@@ -199,6 +200,13 @@ function toggleSelectedPartition() {
199
200
  try {
200
201
  document.querySelectorAll('.at_room_tree .toggle, .at_room_tree .selectable').forEach(function (item) {
201
202
  item.addEventListener('click', function (event) {
203
+ const targetElement = event.target;
204
+ const partitionId = extractUUID(targetElement.id);
205
+ setSelectedPartitionId(partitionId);
206
+ if (item.getAttribute('parentId')) {
207
+ const parentnId = extractUUID(item.getAttribute('parentId'));
208
+ setSelectedPartitionId(parentnId);
209
+ }
202
210
  // Prevent event from propagating to parent elements
203
211
  event.stopPropagation();
204
212
  // Find the parent div of the clicked toggle
@@ -328,3 +336,9 @@ function setCurrentEditRoomData(id) {
328
336
  export function getCurrentEditRoomData() {
329
337
  return currentEditRoomData;
330
338
  }
339
+ function setSelectedPartitionId(partitionId) {
340
+ currentSelectedPartitionId = partitionId;
341
+ }
342
+ export function getSelectedPartitionId() {
343
+ return currentSelectedPartitionId;
344
+ }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { actionBar, renderObjectCards, renderLibraryCards, renderTags, renderTagRow, getTagFormData, addClickEventToTagRow, setActiveCard, setActiveMenu, removeObjectCard, setTagCategoriesOption, toggleDropdown, tagFormMode, selectedTag, renderRecepientOptions, renderTagMessages, createTagMessage, setTagLink, setTagMessagingDetails, renderCategoryDropdownOptions, clearTagFormDropdown, clearActiveActionBtn, clearActiveCard, toggleActionBarButtons, selectedCategoryFilterId, selectedSubCategoryFilterId, filterTagList, toggleModal, setModalAction } from "./components/toolbar";
11
- import { getTargetPosition, addMediaScreen, _3DXObjects, selectedObject, setTransformControls, copyObject, revertTransform, clearSelectedObject, removeTransformControls, getLibrary, getMpTags, renderTag, captureSpaceScreenshot, moveTag, subscribeSpaceEvent, setModelVisibility, disposeModel, disposeTag, _tags, _tagCategories, dispatchSpaceEvent, editTagLabel, editTagDescription, setTagMessageRecepients, setTagMessages, setSelectedTagUuid, renderMeetingSidebar, setTagIcon, setObjectTransformation, getSelectedObject, _atwin, isCdnMapDataAvailable, captureScreenshotAndCameraDetails, _mpConfig, cancelModelPlacement, actionHistory, get3DXObjects, transformHistory, goToModel, themeManager, _partitionNodes, setSpacePartitionNodes, getSpaceId, getPolygonFloorOffset, setPolygonFloorOffset, setFloorBaseHeight, } from "../architwin";
11
+ import { getTargetPosition, addMediaScreen, _3DXObjects, selectedObject, setTransformControls, copyObject, revertTransform, clearSelectedObject, removeTransformControls, getLibrary, getMpTags, renderTag, captureSpaceScreenshot, moveTag, subscribeSpaceEvent, setModelVisibility, disposeModel, disposeTag, _tags, _tagCategories, dispatchSpaceEvent, editTagLabel, editTagDescription, setTagMessageRecepients, setTagMessages, setSelectedTagUuid, renderMeetingSidebar, setTagIcon, setObjectTransformation, getSelectedObject, _atwin, isCdnMapDataAvailable, captureScreenshotAndCameraDetails, _mpConfig, cancelModelPlacement, actionHistory, get3DXObjects, transformHistory, goToModel, themeManager, _partitionNodes, setSpacePartitionNodes, getSpaceId, setFloorBaseHeight, enableVerticeControls, cancelDraw, } from "../architwin";
12
12
  import { Notyf } from 'notyf';
13
13
  import 'notyf/notyf.min.css';
14
14
  import { SPACE_EVENTS } from "../types";
@@ -23,8 +23,8 @@ import { isValidUrl, debounce } from "../utils";
23
23
  import log from 'loglevel';
24
24
  import * as minimap from '../minimap';
25
25
  import { clearActiveThemeCard, getSelectedTheme } from "./components/toolbar/themePane";
26
- import { getCurrentEditRoomData, displayRoomTree, updateParentVisibility } from "./components/toolbar/spacePartition/roomTreePane";
27
- import { toggleDrawPartitionButton, displayPartitionFormMode, setPartitionFormMode, clearPartitionForm, setPolygonData, getPartitionFormData, getPartitionSavingMode, setPartitionSavingMode, getPartitionFormMode, getNewlyAddedPartition } from "./components/toolbar/spacePartition/roomFormPane";
26
+ import { getCurrentEditRoomData, displayRoomTree, updateParentVisibility, getSelectedPartitionId } from "./components/toolbar/spacePartition/roomTreePane";
27
+ import { toggleDrawPartitionButton, displayPartitionFormMode, setPartitionFormMode, clearPartitionForm, setPolygonData, getPartitionFormData, getPartitionSavingMode, setPartitionSavingMode, getPartitionFormMode, getNewlyAddedPartition, setDrawingMode, getDrawingMode } from "./components/toolbar/spacePartition/roomFormPane";
28
28
  let activeToolbarItem, activeActionItem, activePane, activeActionPane, cancelTagPlacementPrompt, cancelModelPlacementPrompt;
29
29
  let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500, types: [
30
30
  {
@@ -248,13 +248,14 @@ function setupIndividualEventListeners() {
248
248
  handleSaveTheme();
249
249
  handlePartitionDisplay();
250
250
  handleDrawPartition();
251
- handleSaveRoom();
252
- handeDeleteRoom();
253
- handleCancelRoom();
251
+ handleSavePartition();
252
+ handleDeletePartition();
253
+ handleCancelPartition();
254
254
  //handleToggleFloorLevelInput()
255
255
  handleFloorLevelInputChange();
256
256
  handleMarkFloor();
257
257
  handleSpacePartitionReport();
258
+ handleModifyPartition();
258
259
  }
259
260
  //================ OBJECT EVENT HANDLERS ===============//
260
261
  function handleTranslateObject() {
@@ -1085,6 +1086,7 @@ function setupSpaceEventSubscriptions() {
1085
1086
  subscribeSpaceEvent(SPACE_EVENTS.TAGPLACER_CREATED, handleTagPlacerCreated);
1086
1087
  subscribeSpaceEvent(SPACE_EVENTS.PARTITION_UPDATED, handlePolygonData);
1087
1088
  subscribeSpaceEvent(SPACE_EVENTS.UPDATE_ROOM_TREE, handleUpdateRoomTree);
1089
+ subscribeSpaceEvent(SPACE_EVENTS.PARTITION_CLICKED, handlePartitionSelected);
1088
1090
  // subscribeSpaceEvent(SPACE_EVENTS.PARTITION_RENDERED, handlePolygonObjectData)
1089
1091
  }
1090
1092
  function handlePolygonData(payload) {
@@ -1370,9 +1372,7 @@ function handleDrawPartition() {
1370
1372
  });
1371
1373
  }
1372
1374
  function handleSavePartition() {
1373
- }
1374
- function handleSaveRoom() {
1375
- log.info("__@ handleSaveRoom()");
1375
+ log.info("__@ handleSavePartition()");
1376
1376
  const saveRoomBtn = document.getElementById('at-save-room-btn');
1377
1377
  saveRoomBtn.addEventListener('click', () => {
1378
1378
  document.getElementById('at-save-room-btn').innerHTML = `
@@ -1416,8 +1416,8 @@ function handleSaveRoom() {
1416
1416
  notyf.success(`${i18n.t('SuccessRoomSaved')}`);
1417
1417
  });
1418
1418
  }
1419
- function handeDeleteRoom() {
1420
- log.info("handeDeleteRoom()");
1419
+ function handleDeletePartition() {
1420
+ log.info("handleDeletePartition()");
1421
1421
  const deleteRoomBtn = document.getElementById('at-delete-room-btn');
1422
1422
  deleteRoomBtn.addEventListener('click', () => {
1423
1423
  const currentEditRoomData = getCurrentEditRoomData();
@@ -1447,7 +1447,7 @@ function handeDeleteRoom() {
1447
1447
  }
1448
1448
  });
1449
1449
  }
1450
- function handleCancelRoom() {
1450
+ function handleCancelPartition() {
1451
1451
  const cancelRoomBtn = document.getElementById('at-cancel-room-form-btn');
1452
1452
  cancelRoomBtn.addEventListener('click', () => {
1453
1453
  getNewlyAddedPartition().map(partition => {
@@ -1503,8 +1503,13 @@ function handleSpacePartitionReport() {
1503
1503
  if (_partitionNodes.length > 0) {
1504
1504
  // Should route to report page
1505
1505
  const spaceId = getSpaceId(window.location.href);
1506
- log.info("__@ Report spaceId: ", spaceId);
1507
- dispatchSpaceEvent(SPACE_EVENTS.DISPLAY_SPACE_PARTITION_REPORT, spaceId);
1506
+ const partitionId = getSelectedPartitionId();
1507
+ const paylaod = {
1508
+ spaceId: spaceId,
1509
+ partitionId: partitionId
1510
+ };
1511
+ log.info("__@ Report payload", paylaod);
1512
+ dispatchSpaceEvent(SPACE_EVENTS.DISPLAY_SPACE_PARTITION_REPORT, paylaod);
1508
1513
  }
1509
1514
  else {
1510
1515
  // Nothing to display
@@ -1517,41 +1522,12 @@ function handleSpacePartitionReport() {
1517
1522
  log.error("Error report: ", error);
1518
1523
  }
1519
1524
  }
1520
- /**
1521
- * Toggles the enabled state of the floor level input based on the checkbox state.
1522
- */
1523
- function handleToggleFloorLevelInput() {
1524
- const checkbox = document.getElementById('at-floor-offset-checkbox');
1525
- const floorLevelInput = document.getElementById('at-room-floor-level-input');
1526
- floorLevelInput.disabled = !checkbox.checked;
1527
- checkbox.addEventListener('change', (e) => {
1528
- const floorLevelInput = document.getElementById('at-room-floor-level-input');
1529
- const isChecked = e.target.checked; // Get the checked state
1530
- log.info("Checkbox checked state:", isChecked);
1531
- floorLevelInput.disabled = !isChecked;
1532
- if (isChecked == false) {
1533
- floorLevelInput.classList.add('at_disabled');
1534
- floorLevelInput.value = '0';
1535
- setPolygonFloorOffset(0);
1536
- }
1537
- else {
1538
- floorLevelInput.value = getPolygonFloorOffset().toString();
1539
- floorLevelInput.classList.remove('at_disabled');
1540
- }
1541
- });
1542
- }
1543
1525
  function handleFloorLevelInputChange() {
1544
1526
  const floorLevelInput = document.getElementById('at-room-floor-level-input');
1545
1527
  // Function to handle input change
1546
1528
  const handleInputChange = debounce(() => {
1547
1529
  const newFloorLevel = Number.parseFloat(floorLevelInput.value);
1548
1530
  if (!isNaN(newFloorLevel)) {
1549
- // if (newOffset > 2) {
1550
- // notyf.open({
1551
- // type: 'info',
1552
- // message: 'Your offset value is very high. Consider lowering it'
1553
- // })
1554
- // }
1555
1531
  setFloorBaseHeight(newFloorLevel);
1556
1532
  notyf.success("Updated floor offset");
1557
1533
  }
@@ -1580,6 +1556,69 @@ function handleMarkFloor() {
1580
1556
  }));
1581
1557
  }
1582
1558
  }
1559
+ function handleModifyPartition() {
1560
+ const modifyBtn = document.getElementById('at-modify-partition-form-btn');
1561
+ if (!modifyBtn) {
1562
+ log.error("Modify partition button element is undefined");
1563
+ return;
1564
+ }
1565
+ modifyBtn.addEventListener('click', () => {
1566
+ const modifyPartitionBtn = document.getElementById('at-modify-partition-form-btn');
1567
+ let selectedPartition = getSelectedObject();
1568
+ const isDrawingEnabled = getDrawingMode();
1569
+ if (isDrawingEnabled) {
1570
+ modifyPartitionBtn.classList.add('at_draw_partition_btn');
1571
+ modifyPartitionBtn.classList.remove('at_draw_partition_btn_active');
1572
+ modifyPartitionBtn.innerHTML = `
1573
+ ${i18n.t('ModifyPartition')}
1574
+ <span class="mdi mdi-check-bold"></span>
1575
+ `;
1576
+ const drawBtn = document.getElementById('at-draw-partition-form-btn');
1577
+ const modifyBtn = document.getElementById('at-modify-partition-form-btn');
1578
+ drawBtn.classList.remove('at_hidden');
1579
+ modifyBtn.classList.add('at_hidden');
1580
+ setDrawingMode(false);
1581
+ cancelDraw();
1582
+ }
1583
+ else {
1584
+ modifyPartitionBtn.classList.remove('at_draw_partition_btn');
1585
+ modifyPartitionBtn.classList.add('at_draw_partition_btn_active');
1586
+ modifyPartitionBtn.innerHTML = `
1587
+ ${i18n.t('DoneDrawing')}
1588
+ <span class="mdi mdi-check-bold"></span>
1589
+ `;
1590
+ if (!selectedPartition) {
1591
+ log.error("No partition selected");
1592
+ notyf.error("No partition selected to modify");
1593
+ return;
1594
+ }
1595
+ if (selectedPartition.type !== 'POLYGON') {
1596
+ log.error("Vertice editing can only be enabled for partitions");
1597
+ notyf.error("Vertice editing can only be enabled for partitions");
1598
+ return;
1599
+ }
1600
+ setDrawingMode(true);
1601
+ enableVerticeControls(selectedPartition.component);
1602
+ }
1603
+ });
1604
+ }
1605
+ function handlePartitionSelected(object) {
1606
+ log.info("handlePartitionSelected() ", object);
1607
+ if (object) {
1608
+ const drawBtn = document.getElementById('at-draw-partition-form-btn');
1609
+ const modifyBtn = document.getElementById('at-modify-partition-form-btn');
1610
+ if (!drawBtn) {
1611
+ log.error("Draw partition button element is undefined");
1612
+ return;
1613
+ }
1614
+ if (!modifyBtn) {
1615
+ log.error("Modify partition button element is undefined");
1616
+ return;
1617
+ }
1618
+ drawBtn.classList.add('at_hidden');
1619
+ modifyBtn.classList.remove('at_hidden');
1620
+ }
1621
+ }
1583
1622
  export {
1584
1623
  //state
1585
1624
  activeToolbarItem, activeActionItem, cancelModelPlacementPrompt,
package/lib/types.d.ts CHANGED
@@ -993,9 +993,11 @@ export interface FloorPolyData {
993
993
  export interface WallPolyData {
994
994
  uuid?: string | undefined;
995
995
  name?: string | undefined;
996
+ index?: number | undefined;
996
997
  options?: {
997
- color: number | undefined;
998
- opacity: number | undefined;
998
+ color?: number | undefined;
999
+ opacity?: number | undefined;
1000
+ visible?: boolean | undefined;
999
1001
  };
1000
1002
  area: number;
1001
1003
  wall_height: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",
@@ -203,6 +203,10 @@ width: 100vw;
203
203
  opacity: 0.6;
204
204
  }
205
205
 
206
+ .at_hidden {
207
+ display: none;
208
+ }
209
+
206
210
  .at_bolder {
207
211
  font-weight: bolder;
208
212
  }