architwin 1.9.7 → 1.9.9
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 +47 -6
- package/lib/atwinui/components/toolbar/i18n.js +6 -2
- package/lib/atwinui/components/toolbar/spacePartition/roomFormPane.d.ts +1 -0
- package/lib/atwinui/components/toolbar/spacePartition/roomFormPane.js +126 -55
- package/lib/atwinui/components/toolbar/spacePartition/roomTreePane.js +10 -5
- package/lib/atwinui/events.js +140 -56
- package/lib/loaders/polydrawerLoader.d.ts +1 -0
- package/lib/loaders/polydrawerLoader.js +9 -6
- package/lib/types.d.ts +2 -0
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +12 -5
- package/package.json +1 -1
- package/static/atwinui.css +9 -1
package/lib/architwin.js
CHANGED
|
@@ -11,7 +11,7 @@ import axios from "axios";
|
|
|
11
11
|
import { planeType, planeFactory,
|
|
12
12
|
// planeType2,
|
|
13
13
|
planeImageFactory, planeVideoFactory, planePdfFactory, setHudState, gltfType, gltfFactory, boxType, boxFactory, textType, textFactory, css3DType, css3DFactory, planeTypeImage, planeTypeVideo, planeTypePdf, sweepPuckType, puckBackgroundFactory, viewpointType, viewpointFactory, tubeLineType, tubeLineFactory, verticeType, verticeFactory, bufferGeometryType, bufferGeometry } from "./loaders";
|
|
14
|
-
import { meterToMillimeter, generateUUID, formatMatterportUrl, initBundleVersion, isEqual } from "./utils";
|
|
14
|
+
import { meterToMillimeter, generateUUID, formatMatterportUrl, initBundleVersion, isEqual, useHexToRgb } from "./utils";
|
|
15
15
|
import { initToolbarUI, themeManager, toggleActionBarButtons, setActiveActionBtn } from "./atwinui";
|
|
16
16
|
import { SPACE_EVENTS, } from "./types";
|
|
17
17
|
import * as JSZip from "jszip";
|
|
@@ -207,7 +207,7 @@ _vertexPathDeleteUndoHistory = new Array(); // history of deleted vertex (undo)
|
|
|
207
207
|
// _thisVertexComponent:MpSdk.Scene.IComponent, // Current Vertex Component
|
|
208
208
|
// _thisVerticeNode:MpSdk.Scene.INode, // Current VerticeNode
|
|
209
209
|
// _thisVertexPath = new Array()
|
|
210
|
-
let visualize = true, _activeVertex, editMode = false, drawMode = false, _thisVertexNode, _thisVertexComponent, _thisVerticesNode, _thisVertexPath = new Array(), _currentPolygon, _polygonShapePath, _polygonWallDataPath, _polygonDataPath, _verticeComponentsCollection = [], _vertexConnectiveComponentCollection = [], _vertexConnectiveNodeCollection = [], _highestYaxisPoint, _polygonFloorOffset = 0.1, _autoLevelFloorEnabled = true, _floorBaseHeight, _offsetedBaseHeight = _floorBaseHeight ? _floorBaseHeight + _polygonFloorOffset : undefined;
|
|
210
|
+
let visualize = true, _activeVertex, editMode = false, drawMode = false, _thisVertexNode, _thisVertexComponent, _thisVerticesNode, _thisVertexPath = new Array(), _currentPolygon, _polygonShapePath, _polygonWallDataPath, _polygonDataPath, _polygonWallHeightPath, _verticeComponentsCollection = [], _vertexConnectiveComponentCollection = [], _vertexConnectiveNodeCollection = [], _highestYaxisPoint, _polygonFloorOffset = 0.1, _autoLevelFloorEnabled = true, _floorBaseHeight, _offsetedBaseHeight = _floorBaseHeight ? _floorBaseHeight + _polygonFloorOffset : undefined, _wallBaseHeight;
|
|
211
211
|
let _intersectionData, _tubes, _verticeEmitPath, _verticeEditEmitPath;
|
|
212
212
|
let _navigationInputNode;
|
|
213
213
|
let _navigationComponent;
|
|
@@ -2061,6 +2061,9 @@ function get3DXObjects() {
|
|
|
2061
2061
|
*/
|
|
2062
2062
|
function clearSelectedObject() {
|
|
2063
2063
|
log.info('clearSelectedObject()');
|
|
2064
|
+
if (selectedObject && selectedObject.type == 'POLYGON') {
|
|
2065
|
+
_currentPolygon = undefined;
|
|
2066
|
+
}
|
|
2064
2067
|
selectedObject = undefined;
|
|
2065
2068
|
}
|
|
2066
2069
|
function setLighting() {
|
|
@@ -5179,6 +5182,7 @@ function renderPolygon(payload, options) {
|
|
|
5179
5182
|
_sceneObject.addInputPath(polyComponent, 'path', `path_${showcaseObj.id}`);
|
|
5180
5183
|
_sceneObject.addInputPath(polyComponent, 'visible', `visible_${showcaseObj.id}`);
|
|
5181
5184
|
_sceneObject.addInputPath(polyComponent, 'polygonData', `polygonData_${showcaseObj.id}`);
|
|
5185
|
+
_sceneObject.addInputPath(polyComponent, 'wallHeight', `wallHeight_${showcaseObj.id}`);
|
|
5182
5186
|
const newObj = {
|
|
5183
5187
|
object: showcaseObj,
|
|
5184
5188
|
node: polyNode,
|
|
@@ -5208,13 +5212,14 @@ function renderPolygon(payload, options) {
|
|
|
5208
5212
|
if (!_currentPolygon.object.object_data.uuid) {
|
|
5209
5213
|
_currentPolygon.object.object_data.uuid = generateUUID();
|
|
5210
5214
|
}
|
|
5211
|
-
_currentPolygon.object.object_data.json_data =
|
|
5212
|
-
path: payload
|
|
5213
|
-
};
|
|
5215
|
+
_currentPolygon.object.object_data.json_data.path = payload;
|
|
5214
5216
|
_3DXObjects[index] = _currentPolygon;
|
|
5215
5217
|
if (payload.length >= 3) {
|
|
5216
5218
|
console.log(" _3DXObjects[index] ", _3DXObjects[index]);
|
|
5217
5219
|
setPolygonPath(_3DXObjects[index].object.id, payload);
|
|
5220
|
+
if (options.wallHeight) {
|
|
5221
|
+
setPolygonWalHeightPath(_3DXObjects[index].object.id, options.wallHeight);
|
|
5222
|
+
}
|
|
5218
5223
|
}
|
|
5219
5224
|
}
|
|
5220
5225
|
}
|
|
@@ -5224,6 +5229,7 @@ function renderPolygon(payload, options) {
|
|
|
5224
5229
|
}
|
|
5225
5230
|
const targetPolygon = _3DXObjects.find(obj => obj.object.object_data.uuid == payload.uuid);
|
|
5226
5231
|
if (!targetPolygon) {
|
|
5232
|
+
log.info("Creating new partition");
|
|
5227
5233
|
options.path = payload.polygon_json.path;
|
|
5228
5234
|
options.uuid = payload.uuid;
|
|
5229
5235
|
options.polygonData = payload.polygon_json;
|
|
@@ -5243,6 +5249,7 @@ function renderPolygon(payload, options) {
|
|
|
5243
5249
|
_sceneObject.addInputPath(polyComponent, 'path', `path_${showcaseObj.id}`);
|
|
5244
5250
|
_sceneObject.addInputPath(polyComponent, 'wallData', `wallData_${showcaseObj.id}`);
|
|
5245
5251
|
_sceneObject.addInputPath(polyComponent, 'polygonData', `polygonData_${showcaseObj.id}`);
|
|
5252
|
+
_sceneObject.addInputPath(polyComponent, 'wallHeight', `wallHeight_${showcaseObj.id}`);
|
|
5246
5253
|
const eventPath = _sceneObject.addEmitPath(polyComponent, 'polygonclicked');
|
|
5247
5254
|
_sceneObject.spyOnEvent(new PolygonClickSpy(eventPath, showcaseObj, polyNode, polyComponent, dispatchSpaceEvent));
|
|
5248
5255
|
const newObj = {
|
|
@@ -5258,6 +5265,7 @@ function renderPolygon(payload, options) {
|
|
|
5258
5265
|
if (payload.polygon_json.path.length >= 3) {
|
|
5259
5266
|
console.log(" _3DXObjects[index] ", _3DXObjects[index]);
|
|
5260
5267
|
setPolygonDataPath(_3DXObjects[index].object.id, payload.polygon_json);
|
|
5268
|
+
setPolygonWalHeightPath(_3DXObjects[index].object.id, payload.polygon_json.walls[0].wall_height);
|
|
5261
5269
|
}
|
|
5262
5270
|
}
|
|
5263
5271
|
}
|
|
@@ -5350,6 +5358,35 @@ function setPolygonDataPath(id, payload) {
|
|
|
5350
5358
|
_polygonDataPath.set(payload);
|
|
5351
5359
|
return;
|
|
5352
5360
|
}
|
|
5361
|
+
/**
|
|
5362
|
+
* Updates the wall height by passing a new object.
|
|
5363
|
+
* @param {number} id - id of the polygon object
|
|
5364
|
+
* @param {number} wallHeight - height of the wall
|
|
5365
|
+
* @returns {void}
|
|
5366
|
+
*/
|
|
5367
|
+
function setPolygonWalHeightPath(id, payload) {
|
|
5368
|
+
log.info("setPolygonWalHeightPath()");
|
|
5369
|
+
let polygonWallHeightPath;
|
|
5370
|
+
if (!id || !payload) {
|
|
5371
|
+
log.error("id or payload is empty or undefined");
|
|
5372
|
+
return;
|
|
5373
|
+
}
|
|
5374
|
+
if (!_polygonWallHeightPath) {
|
|
5375
|
+
for (const { desc, path } of _sceneObject.pathIterator()) {
|
|
5376
|
+
if (desc.id === `wallHeight_${id}`) {
|
|
5377
|
+
polygonWallHeightPath = path;
|
|
5378
|
+
_polygonWallHeightPath = polygonWallHeightPath;
|
|
5379
|
+
}
|
|
5380
|
+
}
|
|
5381
|
+
if (!_polygonWallHeightPath) {
|
|
5382
|
+
log.error("No mathching input path with this id");
|
|
5383
|
+
return;
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
log.info("_polygonDataPath ", _polygonWallHeightPath);
|
|
5387
|
+
_polygonWallHeightPath.set(payload);
|
|
5388
|
+
return;
|
|
5389
|
+
}
|
|
5353
5390
|
function createVerticeClickPath() {
|
|
5354
5391
|
//_verticeEmitPath = _sceneObject.addEmitPath(_navigationComponent, 'verticeClickSpy')
|
|
5355
5392
|
_verticeEmitPath = _sceneObject.addPath({
|
|
@@ -5710,6 +5747,7 @@ function exitDraw() {
|
|
|
5710
5747
|
_polygonShapePath = undefined;
|
|
5711
5748
|
_polygonWallDataPath = undefined;
|
|
5712
5749
|
_polygonDataPath = undefined;
|
|
5750
|
+
_polygonWallHeightPath = undefined;
|
|
5713
5751
|
_verticeComponentsCollection = [];
|
|
5714
5752
|
_atwin.Pointer.resetTexture();
|
|
5715
5753
|
}
|
|
@@ -5868,7 +5906,10 @@ function setMeshChildrenMaterialProperty(component, name, key, value) {
|
|
|
5868
5906
|
component.mesh.children.forEach(child => {
|
|
5869
5907
|
if (child.name == name) {
|
|
5870
5908
|
if (child.material[key] !== undefined) {
|
|
5871
|
-
|
|
5909
|
+
const { r, g, b } = useHexToRgb(value);
|
|
5910
|
+
child.material[key].r = r;
|
|
5911
|
+
child.material[key].g = g;
|
|
5912
|
+
child.material[key].b = b;
|
|
5872
5913
|
}
|
|
5873
5914
|
}
|
|
5874
5915
|
});
|
|
@@ -118,7 +118,9 @@ i18n
|
|
|
118
118
|
"Saving": "Saving",
|
|
119
119
|
"DeletePartition": "Delete Partition",
|
|
120
120
|
"ModifyPartition": "Modify Partition",
|
|
121
|
-
"InvalidNaN": "Invalid input. Please enter a valid number"
|
|
121
|
+
"InvalidNaN": "Invalid input. Please enter a valid number",
|
|
122
|
+
"CannotPlaceInArea": "Cannot place point at selected area. Please try again",
|
|
123
|
+
"SuccessWallHeight": "Successfully updated wall height"
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
ja: {
|
|
@@ -231,7 +233,9 @@ i18n
|
|
|
231
233
|
"Saving": "保存",
|
|
232
234
|
"DeletePartition": "パーティション削除",
|
|
233
235
|
"ModifyPartition": "パーティションの変更",
|
|
234
|
-
"InvalidNaN": "値が不正です。正しい数値を入力してくさい。"
|
|
236
|
+
"InvalidNaN": "値が不正です。正しい数値を入力してくさい。",
|
|
237
|
+
"CannotPlaceInArea": "ここには設定できません。位置を変えて試してください。",
|
|
238
|
+
"SuccessWallHeight": "壁の高さが正常に更新されました"
|
|
235
239
|
}
|
|
236
240
|
}
|
|
237
241
|
},
|
|
@@ -79,3 +79,4 @@ export declare function getNewlyAddedPartition(): Array<PartitionNode>;
|
|
|
79
79
|
export declare function getDeletedSavedPartitionArray(): Array<PartitionNode>;
|
|
80
80
|
export declare function getDrawingMode(): boolean;
|
|
81
81
|
export declare function setDrawingMode(state: boolean): void;
|
|
82
|
+
export declare function getCurrentPartitionDataArray(): PartitionNode[];
|
|
@@ -10,7 +10,7 @@ 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 } from "../../../events";
|
|
13
|
-
import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon } from '../../../../architwin';
|
|
13
|
+
import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon, setMeshChildrenMaterialProperty, get3DXObjects, getChildrenOfModel, clearSelectedObject } from '../../../../architwin';
|
|
14
14
|
import { generateUUID, extractUUID } from '../../../../utils';
|
|
15
15
|
import { getCurrentEditRoomData } from './roomTreePane';
|
|
16
16
|
import { toggleModal, setModalAction } from "../modal";
|
|
@@ -29,6 +29,7 @@ let currentEditRoomData = null;
|
|
|
29
29
|
let notify = new Notyf({ position: { x: 'left', y: 'bottom' } });
|
|
30
30
|
let newlyAddedPartition = [];
|
|
31
31
|
let deletedSavedPartitionArray = [];
|
|
32
|
+
let currentHighlightedFace = null;
|
|
32
33
|
export function renderRoomFormPane() {
|
|
33
34
|
console.info("__@ renderRoomFormPane");
|
|
34
35
|
const element = document.createElement('div');
|
|
@@ -114,7 +115,8 @@ export function renderRoomFormPane() {
|
|
|
114
115
|
</div>
|
|
115
116
|
<div class="at_partition_footer">
|
|
116
117
|
<!-- Add Partition Button -->
|
|
117
|
-
<div class="at_button at_draw_partition_btn
|
|
118
|
+
<div class="at_button at_draw_partition_btn ${i18n.language === 'ja' ? 'at_draw_partition_btn_jp_font_size' : ''}"
|
|
119
|
+
id="at-draw-partition-form-btn" data-cy="at-draw-partition-form-btn">
|
|
118
120
|
${i18n.t('AddPartition')}
|
|
119
121
|
<span class="mdi mdi-draw"></span>
|
|
120
122
|
</div>
|
|
@@ -173,6 +175,7 @@ export function toggleDrawPartitionButton() {
|
|
|
173
175
|
}
|
|
174
176
|
currentPolygonData = null;
|
|
175
177
|
currentPartitionData = null;
|
|
178
|
+
currentEditPartitionData = null;
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
/**
|
|
@@ -189,6 +192,10 @@ export function displayPartitionFormMode() {
|
|
|
189
192
|
currentEditRoomData = getCurrentEditRoomData();
|
|
190
193
|
populatePartitionForm(currentEditRoomData);
|
|
191
194
|
}
|
|
195
|
+
else {
|
|
196
|
+
clearPartitionForm();
|
|
197
|
+
clearSelectedObject();
|
|
198
|
+
}
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* Populates the partition form with the given room node data.
|
|
@@ -202,6 +209,7 @@ function populatePartitionForm(partition) {
|
|
|
202
209
|
const name = document.getElementById('at-room-name-input');
|
|
203
210
|
name.value = partition.name;
|
|
204
211
|
const floorLevel = document.getElementById('at-room-floor-level-input');
|
|
212
|
+
const wallheight = document.getElementById('at-room-wall-height-input');
|
|
205
213
|
const memo = document.getElementById('at-room-memo-input');
|
|
206
214
|
if (partition.polygon_json != null) {
|
|
207
215
|
memo.value = JSON.parse(partition.polygon_json).memo;
|
|
@@ -211,6 +219,7 @@ function populatePartitionForm(partition) {
|
|
|
211
219
|
savedPartitionDataArray = partition.children;
|
|
212
220
|
if (currentPartitionDataArray.length !== 0) {
|
|
213
221
|
floorLevel.value = JSON.parse(partition.children[0].polygon_json).floor.floor_level;
|
|
222
|
+
wallheight.value = JSON.parse(partition.children[0].polygon_json).walls[0].wall_height;
|
|
214
223
|
displayPartitions(currentPartitionDataArray);
|
|
215
224
|
}
|
|
216
225
|
// const objects = get3DXObjects()
|
|
@@ -304,9 +313,8 @@ function displayPartitions(partitions) {
|
|
|
304
313
|
currentEditPartitionData = partitions.find(partition => partition.uuid === partitionId);
|
|
305
314
|
const targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === partitionId);
|
|
306
315
|
if (currentEditPartitionData) {
|
|
316
|
+
displayFaces(JSON.parse(currentEditPartitionData.polygon_json));
|
|
307
317
|
editPartitionNameInput.value = currentEditPartitionData.name;
|
|
308
|
-
const polygonData = JSON.parse(currentEditPartitionData.polygon_json);
|
|
309
|
-
displayFaces(polygonData);
|
|
310
318
|
const currentPolygon = {
|
|
311
319
|
node: targetObject.node,
|
|
312
320
|
component: targetObject.component,
|
|
@@ -432,19 +440,32 @@ function displayFaces(polygon) {
|
|
|
432
440
|
console.log("displayFaces()", polygon);
|
|
433
441
|
const faceVertexContainer = document.getElementById('at-face-vertex-container');
|
|
434
442
|
faceVertexContainer.innerHTML = '';
|
|
443
|
+
const objectData = get3DXObjects();
|
|
444
|
+
let object;
|
|
445
|
+
if (currentEditPartitionData) {
|
|
446
|
+
object = objectData.find(obj => obj.object.object_data.uuid === currentEditPartitionData.uuid);
|
|
447
|
+
}
|
|
448
|
+
if (currentPartitionData) {
|
|
449
|
+
object = objectData.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
|
|
450
|
+
}
|
|
451
|
+
const modelChildren = getChildrenOfModel(object.component).filter((model) => model.name !== '' && !model.name.includes('wallLabel') && !model.name.includes('edgeLabel'));
|
|
452
|
+
console.log("modelChildren", modelChildren);
|
|
435
453
|
// Display the floor details
|
|
436
454
|
if (polygon.floor) {
|
|
437
|
-
|
|
455
|
+
const floorModel = modelChildren.find(model => model.name.includes(polygon.floor.name));
|
|
456
|
+
faceVertexContainer.appendChild(displayFloor(polygon.floor, floorModel));
|
|
438
457
|
}
|
|
439
458
|
// Display each wall's details
|
|
440
459
|
polygon.walls.forEach((wall) => {
|
|
441
|
-
|
|
460
|
+
const wallModel = modelChildren.find(model => model.name.includes(wall.name));
|
|
461
|
+
faceVertexContainer.appendChild(displayWalls(wall, wallModel));
|
|
442
462
|
});
|
|
443
463
|
// Back button event listener for displaying partition list
|
|
444
464
|
addEventListenerById('at-back-partition', goBackToPartitionList);
|
|
445
465
|
// Toggle visibility of face details when clicked
|
|
446
466
|
batchAddEventListenerByClassName('at_face_name', (event) => {
|
|
447
467
|
const targetElement = event.target;
|
|
468
|
+
console.log("targetElement", targetElement);
|
|
448
469
|
const faceId = extractUUID(targetElement.id);
|
|
449
470
|
const vertexItem = document.getElementById(`at-vertex-list-${faceId}`);
|
|
450
471
|
const isHidden = vertexItem.style.display === 'none' || vertexItem.style.display === '';
|
|
@@ -453,38 +474,56 @@ function displayFaces(polygon) {
|
|
|
453
474
|
const chevronIcon = document.getElementById(`at-expand-btn-${faceId}`).querySelector(isHidden ? '.mdi-chevron-down' : '.mdi-chevron-up');
|
|
454
475
|
chevronIcon.classList.toggle('mdi-chevron-down');
|
|
455
476
|
chevronIcon.classList.toggle('mdi-chevron-up');
|
|
456
|
-
|
|
457
|
-
batchAddEventListenerByClassName('at_face_item', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
458
|
-
// Include click event on its children elements
|
|
459
|
-
const targetElement = event.target.closest('.at_face_item');
|
|
460
|
-
if (!targetElement)
|
|
461
|
-
return;
|
|
462
|
-
// Remove 'selected' class from all items
|
|
463
|
-
document.querySelectorAll('.at_face_item').forEach(item => {
|
|
464
|
-
item.classList.remove('selected');
|
|
465
|
-
});
|
|
466
|
-
document.querySelectorAll('.at_vertex_item').forEach(item => {
|
|
467
|
-
item.classList.remove('selected');
|
|
468
|
-
});
|
|
469
|
-
// Add 'selected' class to the clicked item
|
|
470
|
-
targetElement.classList.add('selected');
|
|
471
|
-
}));
|
|
472
|
-
batchAddEventListenerByClassName('at_vertex_item', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
473
|
-
console.log("event", event);
|
|
474
|
-
// Include when clicked its children elements
|
|
475
|
-
const targetElement = event.target.closest('.at_vertex_item');
|
|
476
|
-
if (!targetElement)
|
|
477
|
-
return;
|
|
477
|
+
// Highlight line in the toolarbar
|
|
478
478
|
// Remove 'selected' class from all items
|
|
479
479
|
document.querySelectorAll('.at_face_item').forEach(item => {
|
|
480
480
|
item.classList.remove('selected');
|
|
481
481
|
});
|
|
482
|
-
document.querySelectorAll('.at_vertex_item').forEach(item => {
|
|
483
|
-
item.classList.remove('selected');
|
|
484
|
-
});
|
|
485
482
|
// Add 'selected' class to the clicked item
|
|
486
|
-
targetElement.
|
|
487
|
-
|
|
483
|
+
const parentElement = targetElement.closest('.at_face_item');
|
|
484
|
+
parentElement.classList.add('selected');
|
|
485
|
+
if (currentHighlightedFace) {
|
|
486
|
+
const object = getCurrentPolygon();
|
|
487
|
+
const modelChildren = getChildrenOfModel(object.component).filter((model) => model.name !== '' && !model.name.includes('wallLabel') && !model.name.includes('edgeLabel'));
|
|
488
|
+
console.log("modelChildren", modelChildren);
|
|
489
|
+
modelChildren.forEach(model => {
|
|
490
|
+
if (model.name === currentHighlightedFace.name) {
|
|
491
|
+
if (currentHighlightedFace.name.includes('floor')) {
|
|
492
|
+
setMeshChildrenMaterialProperty(object.component, model.name, 'color', 0x0000ff);
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
setMeshChildrenMaterialProperty(object.component, model.name, 'color', 0xffd150);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
let targetObject;
|
|
501
|
+
if (currentEditPartitionData) {
|
|
502
|
+
targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === currentEditPartitionData.uuid);
|
|
503
|
+
}
|
|
504
|
+
if (currentPartitionData) {
|
|
505
|
+
targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
|
|
506
|
+
}
|
|
507
|
+
const modelId = targetElement.getAttribute("model-id");
|
|
508
|
+
if (modelId.includes('floor')) {
|
|
509
|
+
setMeshChildrenMaterialProperty(targetObject.component, modelId, 'color', 0x0096FF);
|
|
510
|
+
currentHighlightedFace = {
|
|
511
|
+
component: targetObject.component,
|
|
512
|
+
name: modelId,
|
|
513
|
+
type: 'color',
|
|
514
|
+
value: 0x0096FF
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
setMeshChildrenMaterialProperty(targetObject.component, modelId, 'color', 0xFFF700);
|
|
519
|
+
currentHighlightedFace = {
|
|
520
|
+
component: targetObject.component,
|
|
521
|
+
name: modelId,
|
|
522
|
+
type: 'color',
|
|
523
|
+
value: 0xFFF700
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
});
|
|
488
527
|
}
|
|
489
528
|
/**
|
|
490
529
|
* Handles the transition back to the partition list view by updating the visibility of relevant UI elements.
|
|
@@ -502,6 +541,7 @@ function goBackToPartitionList() {
|
|
|
502
541
|
displayPartitions(currentPartitionDataArray);
|
|
503
542
|
// Clear the current edit partition data
|
|
504
543
|
currentEditPartitionData = null;
|
|
544
|
+
currentPartitionData = null;
|
|
505
545
|
cancelDrawing();
|
|
506
546
|
setDrawingMode(false);
|
|
507
547
|
}
|
|
@@ -510,8 +550,8 @@ function goBackToPartitionList() {
|
|
|
510
550
|
* @param floor - The floor data to display.
|
|
511
551
|
* @returns The created HTML element representing the floor and its associated data.
|
|
512
552
|
*/
|
|
513
|
-
function displayFloor(floor) {
|
|
514
|
-
|
|
553
|
+
function displayFloor(floor, floorModel) {
|
|
554
|
+
const floorModelUUID = floorModel ? floorModel.name : null;
|
|
515
555
|
const element = document.createElement('div');
|
|
516
556
|
element.classList.add('at_face_vertex_item');
|
|
517
557
|
element.innerHTML = `
|
|
@@ -519,9 +559,9 @@ function displayFloor(floor) {
|
|
|
519
559
|
<div class="at_icon_left">
|
|
520
560
|
<span class="mdi mdi-perspective-less"></span>
|
|
521
561
|
</div>
|
|
522
|
-
<div class="at_face_name" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}">
|
|
523
|
-
${i18n.t(
|
|
524
|
-
<span class="mdi mdi-chevron-down" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}"></span>
|
|
562
|
+
<div class="at_face_name" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}">
|
|
563
|
+
${i18n.t(`Floor`)}
|
|
564
|
+
<span class="mdi mdi-chevron-down" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}"></span>
|
|
525
565
|
</div>
|
|
526
566
|
<div class="at_icon_right">
|
|
527
567
|
<span class="mdi mdi-delete-outline"></span>
|
|
@@ -553,13 +593,14 @@ function displayFloor(floor) {
|
|
|
553
593
|
* @param wall - The wall data to display.
|
|
554
594
|
* @returns The created HTML element representing the wall and its associated data.
|
|
555
595
|
*/
|
|
556
|
-
function displayWalls(wall) {
|
|
557
|
-
|
|
596
|
+
function displayWalls(wall, wallModel) {
|
|
597
|
+
const wallModelUUID = wallModel ? wallModel.name : null;
|
|
558
598
|
// Extract the wall name from the format "_wall-{number}" using regex
|
|
559
|
-
const match = wall.name.match(/
|
|
599
|
+
const match = wall.name.match(/wall-(\d+)$/);
|
|
560
600
|
let wallName = '';
|
|
561
601
|
if (match) {
|
|
562
|
-
|
|
602
|
+
const wallNumber = parseInt(match[1]) + 1;
|
|
603
|
+
wallName = `${i18n.t('Wall')} ${wallNumber}`;
|
|
563
604
|
}
|
|
564
605
|
const element = document.createElement('div');
|
|
565
606
|
element.classList.add('at_face_vertex_item');
|
|
@@ -568,9 +609,9 @@ function displayWalls(wall) {
|
|
|
568
609
|
<div class="at_icon_left">
|
|
569
610
|
<span class="mdi mdi-perspective-less at_face_icon_rotate_270"></span>
|
|
570
611
|
</div>
|
|
571
|
-
<div class="at_face_name" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}">
|
|
612
|
+
<div class="at_face_name" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}" model-id="${wallModelUUID}">
|
|
572
613
|
${wallName}
|
|
573
|
-
<span class="mdi mdi-chevron-down" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}"></span>
|
|
614
|
+
<span class="mdi mdi-chevron-down" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}" model-id="${wallModelUUID}"></span>
|
|
574
615
|
</div>
|
|
575
616
|
<div class="at_icon_right at_invisible">
|
|
576
617
|
<span class="mdi mdi-delete-outline"></span>
|
|
@@ -671,6 +712,7 @@ export function clearPartitionForm() {
|
|
|
671
712
|
newlyAddedPartition = [];
|
|
672
713
|
deletedSavedPartitionArray = [];
|
|
673
714
|
savedPartitionDataArray = [];
|
|
715
|
+
currentHighlightedFace = null;
|
|
674
716
|
}
|
|
675
717
|
/**
|
|
676
718
|
* Cancels the drawing action for a partition.
|
|
@@ -680,6 +722,22 @@ export function clearPartitionForm() {
|
|
|
680
722
|
*/
|
|
681
723
|
function cancelDrawing() {
|
|
682
724
|
console.log('cancelDrawing()');
|
|
725
|
+
if (currentHighlightedFace) {
|
|
726
|
+
const object = getCurrentPolygon();
|
|
727
|
+
const modelChildren = getChildrenOfModel(object.component).filter((model) => model.name !== '' && !model.name.includes('wallLabel') && !model.name.includes('edgeLabel'));
|
|
728
|
+
console.log("modelChildren", modelChildren);
|
|
729
|
+
modelChildren.forEach(model => {
|
|
730
|
+
if (model.name === currentHighlightedFace.name) {
|
|
731
|
+
if (currentHighlightedFace.name.includes('floor')) {
|
|
732
|
+
setMeshChildrenMaterialProperty(object.component, model.name, 'color', 0x0000ff);
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
setMeshChildrenMaterialProperty(object.component, model.name, 'color', 0xffd150);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
currentHighlightedFace = null;
|
|
740
|
+
}
|
|
683
741
|
cancelDraw();
|
|
684
742
|
isDrawing = false;
|
|
685
743
|
const drawRoomBtn = document.getElementById('at-draw-partition-form-btn');
|
|
@@ -719,11 +777,12 @@ function startDrawing() {
|
|
|
719
777
|
* @returns {PartitionNode} The room data object with partition and floor details.
|
|
720
778
|
*/
|
|
721
779
|
export function getPartitionFormData() {
|
|
722
|
-
var _a, _b, _c;
|
|
780
|
+
var _a, _b, _c, _d;
|
|
723
781
|
console.log('getPartitionFormData()');
|
|
724
782
|
const name = ((_a = document.getElementById('at-room-name-input')) === null || _a === void 0 ? void 0 : _a.value) || null;
|
|
725
|
-
const
|
|
726
|
-
|
|
783
|
+
const wallheight = ((_b = document.getElementById('at-room-wall-height-input')) === null || _b === void 0 ? void 0 : _b.value) || null;
|
|
784
|
+
const floorLevel = ((_c = document.getElementById('at-room-floor-level-input')) === null || _c === void 0 ? void 0 : _c.value) || null;
|
|
785
|
+
let memo = ((_d = document.getElementById('at-room-memo-input')) === null || _d === void 0 ? void 0 : _d.value) || null;
|
|
727
786
|
const currentUrl = window.location.href;
|
|
728
787
|
const spaceUUID = extractUUID(currentUrl);
|
|
729
788
|
let payload = {
|
|
@@ -739,6 +798,9 @@ export function getPartitionFormData() {
|
|
|
739
798
|
currentPartitionDataArray.forEach(partition => {
|
|
740
799
|
const polygonJson = JSON.parse(partition.polygon_json);
|
|
741
800
|
polygonJson.floor.floor_level = Number(floorLevel);
|
|
801
|
+
polygonJson.walls.forEach(wall => {
|
|
802
|
+
wall.wall_height = Number(wallheight);
|
|
803
|
+
});
|
|
742
804
|
partition.polygon_json = JSON.stringify(polygonJson);
|
|
743
805
|
});
|
|
744
806
|
if (currentEditRoomData) {
|
|
@@ -820,15 +882,14 @@ export function setPolygonData(payload) {
|
|
|
820
882
|
// Set floor UUID and name
|
|
821
883
|
if (payload.floor) {
|
|
822
884
|
payload.floor.uuid = payload.floor.uuid || generateUUID();
|
|
823
|
-
payload.floor.name = `
|
|
885
|
+
payload.floor.name = `floor`;
|
|
824
886
|
}
|
|
825
887
|
// Iterate over walls to set UUID and names
|
|
826
888
|
if (payload.walls && payload.walls.length > 0) {
|
|
827
|
-
payload.walls = payload.walls.map((wall, index) => (Object.assign(Object.assign({}, roundToTwoDecimals(wall)), { name: `
|
|
889
|
+
payload.walls = payload.walls.map((wall, index) => (Object.assign(Object.assign({}, roundToTwoDecimals(wall)), { name: `wall-${index}`, uuid: wall.uuid || generateUUID() })));
|
|
828
890
|
}
|
|
829
891
|
currentPolygonData = payload;
|
|
830
892
|
console.log("setPolygonData() currentPolygonData:", currentPolygonData);
|
|
831
|
-
displayFaces(currentPolygonData);
|
|
832
893
|
}
|
|
833
894
|
/**
|
|
834
895
|
* Returns current polygon data
|
|
@@ -880,10 +941,17 @@ export function setCurrentPartitionData() {
|
|
|
880
941
|
if (currentEditRoomData) {
|
|
881
942
|
newPayload.parent_uuid = currentEditRoomData.uuid; // Set the parent UUID if editing an existing room
|
|
882
943
|
}
|
|
944
|
+
if (currentEditPartitionData) {
|
|
945
|
+
newPayload.name = currentEditPartitionData.name;
|
|
946
|
+
currentPartitionDataArray = currentPartitionDataArray.map(partition => partition.uuid === currentEditPartitionData.uuid
|
|
947
|
+
? Object.assign(Object.assign({}, partition), { uuid: newPayload.uuid }) : partition);
|
|
948
|
+
}
|
|
949
|
+
if (currentHighlightedFace) {
|
|
950
|
+
setMeshChildrenMaterialProperty(currentHighlightedFace.component, currentHighlightedFace.name, currentHighlightedFace.type, currentHighlightedFace.value);
|
|
951
|
+
}
|
|
883
952
|
updatePartitionDataArray(newPayload, currentPartitionDataArray);
|
|
884
953
|
console.log("currentPartitionDataArray", currentPartitionDataArray);
|
|
885
|
-
|
|
886
|
-
// goBackToPartitionList()
|
|
954
|
+
displayFaces(currentPolygonData);
|
|
887
955
|
}
|
|
888
956
|
else {
|
|
889
957
|
const faceVertexContainer = document.getElementById('at-face-vertex-container');
|
|
@@ -904,12 +972,12 @@ function updatePartitionDataArray(payload, currentPartitionDataArray) {
|
|
|
904
972
|
currentPartitionDataArray.splice(existingIndex, 1);
|
|
905
973
|
}
|
|
906
974
|
payload.name = `${i18n.t('Partition')} ${currentPartitionDataArray.length + 1}`;
|
|
907
|
-
|
|
975
|
+
currentPartitionDataArray.push(payload);
|
|
976
|
+
currentPartitionData = payload;
|
|
977
|
+
if (existingIndex === -1) {
|
|
908
978
|
// Add the new partition
|
|
909
|
-
currentPartitionDataArray.push(payload);
|
|
910
979
|
newlyAddedPartition.push(payload);
|
|
911
980
|
console.log("newlyAddedPartition", payload);
|
|
912
|
-
currentPartitionData = payload;
|
|
913
981
|
}
|
|
914
982
|
dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
|
|
915
983
|
}
|
|
@@ -932,3 +1000,6 @@ export function setDrawingMode(state) {
|
|
|
932
1000
|
}
|
|
933
1001
|
isDrawing = state;
|
|
934
1002
|
}
|
|
1003
|
+
export function getCurrentPartitionDataArray() {
|
|
1004
|
+
return currentPartitionDataArray;
|
|
1005
|
+
}
|
|
@@ -12,7 +12,7 @@ import { batchAddEventListenerByClassName, handleDeletePartition, handlePartitio
|
|
|
12
12
|
import i18n from "../i18n";
|
|
13
13
|
import { getCurrentPolygonData, setPartitionFormMode } from "./roomFormPane";
|
|
14
14
|
import { SPACE_EVENTS } from "../../../../types";
|
|
15
|
-
import { _3DXObjects, dispatchSpaceEvent, getChildrenOfModel, goToModel, renderPolygon } from "../../../../architwin";
|
|
15
|
+
import { _3DXObjects, dispatchSpaceEvent, getChildrenOfModel, goToModel, renderPolygon, setSelectedObject } from "../../../../architwin";
|
|
16
16
|
let roomDataArray = [];
|
|
17
17
|
let currentEditRoomData = null;
|
|
18
18
|
let currentSelectedPartitionId = null;
|
|
@@ -209,10 +209,11 @@ export function displayPartitionItems(partitionItems, partitionId, object) {
|
|
|
209
209
|
console.log("__@ partition item: ", item);
|
|
210
210
|
if (!item.hide) {
|
|
211
211
|
// Split wall name to localize
|
|
212
|
-
const match = item.name.match(/
|
|
212
|
+
const match = item.name.match(/wall-(\d+)$/);
|
|
213
|
+
const wallNumber = parseInt(match[1]) + 1;
|
|
213
214
|
const isVisible = item.options.is_visible;
|
|
214
215
|
itemsHTML += `
|
|
215
|
-
<li class="at_toggle">${i18n.t(`Wall`)} ${
|
|
216
|
+
<li class="at_toggle">${i18n.t(`Wall`)} ${wallNumber}
|
|
216
217
|
<span id="${object[index].name}" partition-id="${partitionId}" polygon-item-id="${item.uuid}" class="mdi ${isVisible ? 'mdi-eye ' : 'mdi-eye-off'} at_child_visible_btn at_pull_right"></span>
|
|
217
218
|
</li>
|
|
218
219
|
`;
|
|
@@ -224,7 +225,7 @@ export function displayPartitionItems(partitionItems, partitionId, object) {
|
|
|
224
225
|
const isVisible = partitionItems.options.is_visible;
|
|
225
226
|
if (!partitionItems.hide) {
|
|
226
227
|
itemsHTML += `
|
|
227
|
-
<li class="at_toggle"> ${i18n.t(
|
|
228
|
+
<li class="at_toggle"> ${i18n.t(`Floor`)}
|
|
228
229
|
<span id="${object.name}" partition-id="${partitionId}" polygon-item-id="${partitionItems.uuid}" class="mdi ${isVisible ? 'mdi-eye ' : 'mdi-eye-off'} at_child_visible_btn at_pull_right"></span>
|
|
229
230
|
</li>
|
|
230
231
|
`;
|
|
@@ -281,7 +282,11 @@ function toggleSelectedPartition() {
|
|
|
281
282
|
const targetObjId = targetElement.getAttribute('object-id');
|
|
282
283
|
console.log("toggleSelectedPartition targetObjId: ", targetObjId);
|
|
283
284
|
if (targetObjId) {
|
|
284
|
-
|
|
285
|
+
const target = _3DXObjects.find(obj => obj.object.id == Number.parseInt(targetObjId));
|
|
286
|
+
console.log("__@ Going to model... ", target);
|
|
287
|
+
if (target) {
|
|
288
|
+
setSelectedObject(target.object, target.node, target.component, target.type);
|
|
289
|
+
}
|
|
285
290
|
yield goToModel(Number.parseInt(targetObjId));
|
|
286
291
|
}
|
|
287
292
|
});
|
package/lib/atwinui/events.js
CHANGED
|
@@ -23,7 +23,7 @@ import { isValidUrl, debounce, isElementVisible, extractUUID } 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 { displayRoomTree, updatePartitionVisibilityUI, getSelectedPartitionId, updatePolygonVisibilityData, toggleVisibilityState, setFilteredDisplay, updateRoomVisibilityUI } from "./components/toolbar/spacePartition/roomTreePane";
|
|
26
|
+
import { getCurrentEditRoomData, displayRoomTree, updatePartitionVisibilityUI, getSelectedPartitionId, updatePolygonVisibilityData, toggleVisibilityState, setFilteredDisplay, updateRoomVisibilityUI } from "./components/toolbar/spacePartition/roomTreePane";
|
|
27
27
|
import { toggleDrawPartitionButton, displayPartitionFormMode, setPartitionFormMode, clearPartitionForm, setPolygonData, getPartitionFormData, getPartitionSavingMode, setPartitionSavingMode, getPartitionFormMode, getNewlyAddedPartition, setCurrentPartitionData, getCurrentPartitionData } 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: [
|
|
@@ -261,6 +261,7 @@ function setupIndividualEventListeners() {
|
|
|
261
261
|
handleCancelPartition();
|
|
262
262
|
//handleToggleFloorLevelInput()
|
|
263
263
|
handleFloorLevelInputChange();
|
|
264
|
+
handleWallHeightInputChange();
|
|
264
265
|
handleMarkFloor();
|
|
265
266
|
handleSpacePartitionReport();
|
|
266
267
|
handleUndoDrawAction();
|
|
@@ -1592,6 +1593,7 @@ function handleSavePartition() {
|
|
|
1592
1593
|
dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: partitionEditPayload });
|
|
1593
1594
|
break;
|
|
1594
1595
|
}
|
|
1596
|
+
clearSelectedObject();
|
|
1595
1597
|
notyf.success(`${i18n.t('SuccessRoomSaved')}`);
|
|
1596
1598
|
});
|
|
1597
1599
|
}
|
|
@@ -1610,10 +1612,11 @@ function handleDeletePartition(targetId) {
|
|
|
1610
1612
|
buttonLabel: `${i18n.t('YesDelete')}`
|
|
1611
1613
|
}, () => {
|
|
1612
1614
|
var _a;
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
partitionRow.
|
|
1615
|
+
if (partitionId) { // #15482: new changes to fix room list UI
|
|
1616
|
+
const partitionRow = document.getElementById(`at-div-room-${partitionId}`);
|
|
1617
|
+
// Get the closest parent element (li)
|
|
1618
|
+
const liElement = partitionRow.closest('.at_room_tree_parent');
|
|
1619
|
+
liElement.remove();
|
|
1617
1620
|
dispatchSpaceEvent(SPACE_EVENTS.PARTITION_DISPOSED, targetPartition);
|
|
1618
1621
|
(_a = targetPartition.children) === null || _a === void 0 ? void 0 : _a.map(partition => {
|
|
1619
1622
|
const target = _3DXObjects.find(obj => obj.object.object_data.uuid === partition.uuid);
|
|
@@ -1645,9 +1648,11 @@ function handleCancelPartition() {
|
|
|
1645
1648
|
setSpacePartitionNodes(filteredRoomNodes);
|
|
1646
1649
|
});
|
|
1647
1650
|
const objects = get3DXObjects();
|
|
1648
|
-
const currentPartitionData =
|
|
1651
|
+
const currentPartitionData = getCurrentEditRoomData();
|
|
1649
1652
|
if (currentPartitionData) {
|
|
1650
|
-
|
|
1653
|
+
let partitionsUUIDs = [];
|
|
1654
|
+
partitionsUUIDs = currentPartitionData.children.map(child => child.uuid);
|
|
1655
|
+
const target = objects.find(obj => partitionsUUIDs.includes(obj.object.object_data.uuid));
|
|
1651
1656
|
log.info("handleCancelPartition", {
|
|
1652
1657
|
currentPartitionData,
|
|
1653
1658
|
target
|
|
@@ -1655,15 +1660,22 @@ function handleCancelPartition() {
|
|
|
1655
1660
|
if (target) {
|
|
1656
1661
|
setSelectedObject(target.object, target.node, target.component, target.type);
|
|
1657
1662
|
if (currentPartitionData) {
|
|
1658
|
-
const
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1663
|
+
const currentPartition = currentPartitionData.children.find(child => child.uuid == target.object.object_data.uuid);
|
|
1664
|
+
const polyJson = typeof currentPartition.polygon_json === 'string' ? JSON.parse(currentPartition.polygon_json) : currentPartition.polygon_json;
|
|
1665
|
+
if (polyJson && polyJson.path) {
|
|
1666
|
+
const payload = {
|
|
1667
|
+
uuid: target.object.object_data.uuid,
|
|
1668
|
+
polygon_json: polyJson
|
|
1669
|
+
};
|
|
1670
|
+
renderPolygon(payload);
|
|
1671
|
+
}
|
|
1661
1672
|
}
|
|
1662
1673
|
}
|
|
1663
1674
|
}
|
|
1664
1675
|
else {
|
|
1665
1676
|
log.warn('currentPartitionData is undefined');
|
|
1666
1677
|
}
|
|
1678
|
+
clearSelectedObject();
|
|
1667
1679
|
toggleDisplayPane('at-cancel-room-form-btn');
|
|
1668
1680
|
const drawHistory = {
|
|
1669
1681
|
redoDrawActions: [],
|
|
@@ -1740,20 +1752,92 @@ function handleSpacePartitionReport() {
|
|
|
1740
1752
|
log.error("Error report: ", error);
|
|
1741
1753
|
}
|
|
1742
1754
|
}
|
|
1755
|
+
function handleWallHeightInputChange() {
|
|
1756
|
+
const wallHeightInput = document.getElementById('at-room-wall-height-input');
|
|
1757
|
+
const handleInputChange = debounce(() => {
|
|
1758
|
+
const newWallHeight = Number.parseFloat(wallHeightInput.value);
|
|
1759
|
+
if (!isNaN(newWallHeight) && Math.sign(newWallHeight) == 1) {
|
|
1760
|
+
const objects = get3DXObjects();
|
|
1761
|
+
const latestObj = objects[objects.length - 1];
|
|
1762
|
+
const currentPartitionData = getCurrentEditRoomData();
|
|
1763
|
+
const currentPolygon = getCurrentPolygon();
|
|
1764
|
+
log.info("latestObj ", latestObj);
|
|
1765
|
+
log.info("wallHeight currentPartitionData ", currentPartitionData);
|
|
1766
|
+
log.info("wallHeight _3DXObjects ", _3DXObjects);
|
|
1767
|
+
if (currentPartitionData) {
|
|
1768
|
+
let partitionsUUIDs = [];
|
|
1769
|
+
partitionsUUIDs = currentPartitionData.children.map(child => child.uuid);
|
|
1770
|
+
const target = objects.find(obj => partitionsUUIDs.includes(obj.object.object_data.uuid));
|
|
1771
|
+
log.info("target ", target);
|
|
1772
|
+
if (target) {
|
|
1773
|
+
setSelectedObject(target.object, target.node, target.component, target.type);
|
|
1774
|
+
const polyJson = target.object.object_data.json_data;
|
|
1775
|
+
if (polyJson) {
|
|
1776
|
+
polyJson.walls[0].wall_height = newWallHeight;
|
|
1777
|
+
const payload = {
|
|
1778
|
+
uuid: target.object.object_data.uuid,
|
|
1779
|
+
polygon_json: polyJson
|
|
1780
|
+
};
|
|
1781
|
+
renderPolygon(payload);
|
|
1782
|
+
}
|
|
1783
|
+
else {
|
|
1784
|
+
renderPolygon(polyJson.path, {
|
|
1785
|
+
wallHeight: newWallHeight
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
notyf.success("Updated the partition's floor level");
|
|
1789
|
+
}
|
|
1790
|
+
else {
|
|
1791
|
+
log.error("No matching uuid for the polygon");
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
else if (currentPolygon) {
|
|
1795
|
+
setSelectedObject(currentPolygon.object, currentPolygon.node, currentPolygon.component, currentPolygon.type);
|
|
1796
|
+
const polyJson = currentPolygon.object.object_data.json_data;
|
|
1797
|
+
if (polyJson.walls && polyJson.walls.length > 0) {
|
|
1798
|
+
polyJson.walls[0].wall_height = newWallHeight;
|
|
1799
|
+
const payload = {
|
|
1800
|
+
uuid: latestObj.object.object_data.uuid,
|
|
1801
|
+
polygon_json: polyJson
|
|
1802
|
+
};
|
|
1803
|
+
renderPolygon(payload);
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
renderPolygon(polyJson.path, {
|
|
1807
|
+
wallHeight: newWallHeight
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
notyf.success(`${i18n.t('SuccessWallHeight')}`);
|
|
1811
|
+
}
|
|
1812
|
+
else {
|
|
1813
|
+
log.warn("currentPartitionData and latestObj value is undefined or its type is not valid");
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
else {
|
|
1817
|
+
notyf.error(`${i18n.t('InvalidNaN')}`);
|
|
1818
|
+
}
|
|
1819
|
+
}, 900);
|
|
1820
|
+
wallHeightInput.addEventListener('input', handleInputChange);
|
|
1821
|
+
}
|
|
1743
1822
|
function handleFloorLevelInputChange() {
|
|
1744
1823
|
const floorLevelInput = document.getElementById('at-room-floor-level-input');
|
|
1745
1824
|
// Function to handle input change
|
|
1746
1825
|
const handleInputChange = debounce(() => {
|
|
1747
1826
|
const newFloorLevel = Number.parseFloat(floorLevelInput.value);
|
|
1827
|
+
const formMode = getPartitionFormMode();
|
|
1748
1828
|
if (!isNaN(newFloorLevel)) {
|
|
1829
|
+
//clearSelectedObject()
|
|
1749
1830
|
setFloorBaseHeight(newFloorLevel);
|
|
1750
1831
|
notyf.success(`${i18n.t('SuccessBaseHeight')}`);
|
|
1751
1832
|
const objects = get3DXObjects();
|
|
1752
1833
|
const latestObj = objects[objects.length - 1];
|
|
1753
|
-
const currentPartitionData =
|
|
1834
|
+
const currentPartitionData = getCurrentEditRoomData();
|
|
1835
|
+
const currentPolygon = getCurrentPolygon();
|
|
1754
1836
|
log.info("latestObj ", latestObj);
|
|
1755
1837
|
if (currentPartitionData) {
|
|
1756
|
-
|
|
1838
|
+
let partitionsUUIDs = [];
|
|
1839
|
+
partitionsUUIDs = currentPartitionData.children.map(child => child.uuid);
|
|
1840
|
+
const target = objects.find(obj => partitionsUUIDs.includes(obj.object.object_data.uuid));
|
|
1757
1841
|
if (target) {
|
|
1758
1842
|
setSelectedObject(target.object, target.node, target.component, target.type);
|
|
1759
1843
|
const adjustedFloorBaseHeight = getFloorBaseHeight();
|
|
@@ -1769,8 +1853,8 @@ function handleFloorLevelInputChange() {
|
|
|
1769
1853
|
log.error("No matching uuid for the polygon");
|
|
1770
1854
|
}
|
|
1771
1855
|
}
|
|
1772
|
-
else if (
|
|
1773
|
-
setSelectedObject(
|
|
1856
|
+
else if (currentPolygon) {
|
|
1857
|
+
setSelectedObject(currentPolygon.object, currentPolygon.node, currentPolygon.component, currentPolygon.type);
|
|
1774
1858
|
const adjustedFloorBaseHeight = getFloorBaseHeight();
|
|
1775
1859
|
const polyJson = latestObj.object.object_data.json_data;
|
|
1776
1860
|
const updatedPath = polyJson.path.map(path => {
|
|
@@ -1781,7 +1865,7 @@ function handleFloorLevelInputChange() {
|
|
|
1781
1865
|
notyf.success("Updated the partition's floor level");
|
|
1782
1866
|
}
|
|
1783
1867
|
else {
|
|
1784
|
-
log.
|
|
1868
|
+
log.warn("currentPartitionData and latestObj value is undefined or its type is not valid");
|
|
1785
1869
|
}
|
|
1786
1870
|
}
|
|
1787
1871
|
else {
|
|
@@ -1801,51 +1885,51 @@ function handleMarkFloor() {
|
|
|
1801
1885
|
yield getTargetPosition((coord) => {
|
|
1802
1886
|
const objects = get3DXObjects();
|
|
1803
1887
|
const latestObj = objects[objects.length - 1];
|
|
1804
|
-
const currentPartitionData =
|
|
1888
|
+
const currentPartitionData = getCurrentEditRoomData();
|
|
1805
1889
|
const currentPolygon = getCurrentPolygon();
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1890
|
+
if (Math.sign(coord.y) == 1) {
|
|
1891
|
+
setFloorBaseHeight(coord.y);
|
|
1892
|
+
const adjustedHeight = getFloorBaseHeight();
|
|
1893
|
+
log.info("latestObj ", latestObj);
|
|
1894
|
+
if (currentPartitionData) {
|
|
1895
|
+
let partitionsUUIDs = [];
|
|
1896
|
+
partitionsUUIDs = currentPartitionData.children.map(child => child.uuid);
|
|
1897
|
+
const target = objects.find(obj => partitionsUUIDs.includes(obj.object.object_data.uuid));
|
|
1898
|
+
if (target) {
|
|
1899
|
+
const polyJson = target.object.object_data.json_data;
|
|
1900
|
+
const updatedPath = polyJson.path.map(path => {
|
|
1901
|
+
path.y = adjustedHeight;
|
|
1902
|
+
return path;
|
|
1903
|
+
});
|
|
1904
|
+
renderPolygon(updatedPath);
|
|
1905
|
+
notyf.success("Updated the current partition's floor level");
|
|
1906
|
+
}
|
|
1907
|
+
else {
|
|
1908
|
+
log.warn("No matching uuid for the polygon");
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
else if (currentPolygon) {
|
|
1912
|
+
//setSelectedObject(currentPolygon.object,currentPolygon.node,currentPolygon.component,currentPolygon.type)
|
|
1913
|
+
const polyJson = latestObj.object.object_data.json_data;
|
|
1914
|
+
const updatedPath = polyJson.path.map(path => {
|
|
1915
|
+
path.y = adjustedHeight;
|
|
1916
|
+
return path;
|
|
1917
|
+
});
|
|
1918
|
+
renderPolygon(updatedPath);
|
|
1919
|
+
notyf.success("Updated the partition's floor level");
|
|
1920
|
+
}
|
|
1921
|
+
else {
|
|
1922
|
+
log.warn("currentPolygon is undefined");
|
|
1923
|
+
}
|
|
1924
|
+
const floorLevelInput = document.getElementById('at-room-floor-level-input');
|
|
1925
|
+
if (floorLevelInput) {
|
|
1926
|
+
floorLevelInput.value = adjustedHeight.toFixed(4);
|
|
1927
|
+
}
|
|
1928
|
+
notyf.success(`${i18n.t('SuccessBaseHeight')}`);
|
|
1830
1929
|
}
|
|
1831
|
-
// else if(latestObj && latestObj.type == 'POLYGON'){
|
|
1832
|
-
// setSelectedObject(latestObj.object,latestObj.node,latestObj.component,latestObj.type)
|
|
1833
|
-
// const polyJson:PolygonData = latestObj.object.object_data.json_data
|
|
1834
|
-
// const updatedPath = polyJson.path.map(path => {
|
|
1835
|
-
// path.y = adjustedHeight
|
|
1836
|
-
// return path
|
|
1837
|
-
// })
|
|
1838
|
-
// renderPolygon(updatedPath)
|
|
1839
|
-
// notyf.success("Updated the partition's floor level")
|
|
1840
|
-
// }
|
|
1841
1930
|
else {
|
|
1842
|
-
|
|
1843
|
-
}
|
|
1844
|
-
const floorLevelInput = document.getElementById('at-room-floor-level-input');
|
|
1845
|
-
if (floorLevelInput) {
|
|
1846
|
-
floorLevelInput.value = adjustedHeight.toFixed(4);
|
|
1931
|
+
notyf.error(`${i18n.t('CannotPlaceInArea')}`);
|
|
1847
1932
|
}
|
|
1848
|
-
notyf.success(`${i18n.t('SuccessBaseHeight')}`);
|
|
1849
1933
|
});
|
|
1850
1934
|
}));
|
|
1851
1935
|
}
|
|
@@ -126,6 +126,7 @@ export declare class BufferGeometry {
|
|
|
126
126
|
floorData: any;
|
|
127
127
|
polygonData: any;
|
|
128
128
|
excludeHiddenWallsFromCalculation: boolean;
|
|
129
|
+
wallHeight: number;
|
|
129
130
|
};
|
|
130
131
|
outputs: Record<string, unknown> & MpSdk.Scene.PredefinedOutputs;
|
|
131
132
|
context: MpSdk.Scene.IComponentContext;
|
|
@@ -464,7 +464,8 @@ export class BufferGeometry {
|
|
|
464
464
|
wallData: [],
|
|
465
465
|
floorData: undefined,
|
|
466
466
|
polygonData: undefined,
|
|
467
|
-
excludeHiddenWallsFromCalculation: true
|
|
467
|
+
excludeHiddenWallsFromCalculation: true,
|
|
468
|
+
wallHeight: 2
|
|
468
469
|
};
|
|
469
470
|
this.emits = {
|
|
470
471
|
changed: true,
|
|
@@ -503,7 +504,9 @@ export class BufferGeometry {
|
|
|
503
504
|
};
|
|
504
505
|
this.renderPolygon = () => {
|
|
505
506
|
const THREE = this.context.three;
|
|
506
|
-
const
|
|
507
|
+
const polyData = this.inputs.polygonData;
|
|
508
|
+
console.log("polyData ", polyData);
|
|
509
|
+
const WALL_HEIGHT = polyData && polyData.walls[0].wall_height ? polyData.walls[0].wall_height : this.inputs.wallHeight;
|
|
507
510
|
this.groupedMesh = new THREE.Group();
|
|
508
511
|
let floorDataArray = [];
|
|
509
512
|
let wallDataArray = [];
|
|
@@ -517,7 +520,6 @@ export class BufferGeometry {
|
|
|
517
520
|
transparent: true
|
|
518
521
|
}));
|
|
519
522
|
floorMesh.name = this.inputs.uuid != '' ? `${this.inputs.uuid}_floor` : 'floor';
|
|
520
|
-
const polyData = this.inputs.polygonData;
|
|
521
523
|
const floorConfig = polyData ? polyData.floor : this.inputs.floorData;
|
|
522
524
|
const floorDimension = PolygonCalculator.calculatePolygonProperties(this.inputs.path);
|
|
523
525
|
if (floorConfig && floorConfig.options) {
|
|
@@ -566,6 +568,7 @@ export class BufferGeometry {
|
|
|
566
568
|
floor_sequence: currentFloor,
|
|
567
569
|
floor: floorData,
|
|
568
570
|
walls: wallDataArray,
|
|
571
|
+
wall_height: WALL_HEIGHT,
|
|
569
572
|
totalWallArea,
|
|
570
573
|
totalWallPerimeter,
|
|
571
574
|
options: {
|
|
@@ -721,9 +724,9 @@ export class BufferGeometry {
|
|
|
721
724
|
};
|
|
722
725
|
const wallEdges = vertices.map((v, i) => {
|
|
723
726
|
const edge = {
|
|
724
|
-
start: v
|
|
725
|
-
edge:
|
|
726
|
-
length:
|
|
727
|
+
start: v,
|
|
728
|
+
edge: vertices[(i + 1) % vertices.length],
|
|
729
|
+
length: new THREE.Vector3().subVectors(vertices[(i + 1) % vertices.length], v).length()
|
|
727
730
|
};
|
|
728
731
|
return edge;
|
|
729
732
|
});
|
package/lib/types.d.ts
CHANGED
|
@@ -432,6 +432,7 @@ export interface ComponentOptions {
|
|
|
432
432
|
wallData?: WallPolyData[] | undefined;
|
|
433
433
|
floorData?: FloorPolyData | undefined;
|
|
434
434
|
polygonData?: PolygonData | undefined;
|
|
435
|
+
wallHeight?: number | undefined;
|
|
435
436
|
}
|
|
436
437
|
export interface VectorCoords {
|
|
437
438
|
object_position: Vector3;
|
|
@@ -1026,6 +1027,7 @@ export interface PolygonData {
|
|
|
1026
1027
|
floor_sequence: MpSdk.Floor.FloorData;
|
|
1027
1028
|
floor: FloorPolyData;
|
|
1028
1029
|
walls: Array<WallPolyData>;
|
|
1030
|
+
wall_height: number;
|
|
1029
1031
|
totalWallArea?: number;
|
|
1030
1032
|
totalWallPerimeter?: number;
|
|
1031
1033
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function generateUUID(config?: {
|
|
|
8
8
|
separator?: string;
|
|
9
9
|
}): string;
|
|
10
10
|
export declare function generateRandomUsername(): string;
|
|
11
|
-
export declare function useHexToRgb(hexcode: string): {
|
|
11
|
+
export declare function useHexToRgb(hexcode: string | number): {
|
|
12
12
|
r: number;
|
|
13
13
|
g: number;
|
|
14
14
|
b: number;
|
package/lib/utils.js
CHANGED
|
@@ -72,12 +72,19 @@ export function generateRandomUsername() {
|
|
|
72
72
|
return username;
|
|
73
73
|
}
|
|
74
74
|
export function useHexToRgb(hexcode) {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
let hex;
|
|
76
|
+
if (typeof hexcode === "number") {
|
|
77
|
+
// Convert numeric hex to string and pad with leading zeros if needed
|
|
78
|
+
hex = hexcode.toString(16).padStart(6, "0");
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Remove '#' if present
|
|
82
|
+
hex = hexcode.replace("#", "");
|
|
83
|
+
}
|
|
77
84
|
// Parse hex values for red, green, and blue
|
|
78
|
-
const r = parseInt(
|
|
79
|
-
const g = parseInt(
|
|
80
|
-
const b = parseInt(
|
|
85
|
+
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
86
|
+
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
87
|
+
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
81
88
|
return { r, g, b };
|
|
82
89
|
}
|
|
83
90
|
export function useRgbToHex(color) {
|
package/package.json
CHANGED
package/static/atwinui.css
CHANGED
|
@@ -1049,14 +1049,22 @@
|
|
|
1049
1049
|
background-color: black;
|
|
1050
1050
|
border: solid white 2px;
|
|
1051
1051
|
font-size: smaller;
|
|
1052
|
-
padding:
|
|
1052
|
+
padding: 6px 0.8em 4px;
|
|
1053
1053
|
border-radius: 8px;
|
|
1054
|
+
min-height: 31.3px;
|
|
1055
|
+
align-items: center;
|
|
1056
|
+
justify-content: center;
|
|
1054
1057
|
}
|
|
1055
1058
|
|
|
1059
|
+
|
|
1056
1060
|
.at_draw_partition_btn {
|
|
1057
1061
|
flex-grow: 2;
|
|
1058
1062
|
}
|
|
1059
1063
|
|
|
1064
|
+
.at_draw_partition_btn_jp_font_size {
|
|
1065
|
+
font-size: x-small;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1060
1068
|
.at_draw_partition_btn_active {
|
|
1061
1069
|
background-color: var(--bg-accent);
|
|
1062
1070
|
border: solid white 2px;
|