architwin 1.14.10 → 1.14.12
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 +1 -1
- package/lib/atwinui/components/toolbar/i18n.js +2 -2
- package/lib/atwinui/components/toolbar/spacePartition/roomFormPane.js +28 -44
- package/lib/atwinui/components/toolbar/spacePartition/roomTreePane.js +1 -1
- package/lib/atwinui/events.js +1 -0
- package/lib/loaders/polydrawerLoader.d.ts +16 -0
- package/lib/loaders/polydrawerLoader.js +130 -15
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -445,11 +445,11 @@ i18n
|
|
|
445
445
|
"CancelRequest": "リクエストを拒否",
|
|
446
446
|
"ViewingRemoteSpace": "先方のスペースを表示",
|
|
447
447
|
"LeaveSession": "画面共有を終了",
|
|
448
|
-
"IsSharingTheirSpace": "
|
|
448
|
+
"IsSharingTheirSpace": "上記のユーザが画面共有をしています:",
|
|
449
449
|
"ToYou": "",
|
|
450
450
|
"ViewingInstructions": "画面共有中は供している人しかスペース内を動かすことができません",
|
|
451
451
|
"Pending": "承認待ち",
|
|
452
|
-
"NowSharing": "
|
|
452
|
+
"NowSharing": "画面共有中",
|
|
453
453
|
"ConfirmLeaveSession": "画面共有を終了しますか?",
|
|
454
454
|
"ConfirmLeaveSessionReminder": "",
|
|
455
455
|
"InSession": "共有中",
|
|
@@ -54,7 +54,7 @@ export function renderRoomFormPane() {
|
|
|
54
54
|
</div>
|
|
55
55
|
<form class="at_form_container at_scrollable_container at_h-min-70" id="at-room-form" data-cy="at-room-form">
|
|
56
56
|
<div class="at-field at_flex_row">
|
|
57
|
-
<label for="">${i18n.t('Name')}</label>
|
|
57
|
+
<label for="" style="font-size: 0.95rem;">${i18n.t('Name')}</label>
|
|
58
58
|
<input class="at_field_input at_w-full" type="text" name="room_name" id="at-room-name-input" data-cy="at-room-name-input" placeholder="Room 1">
|
|
59
59
|
</div>
|
|
60
60
|
<div class="at-field at_flex_column">
|
|
@@ -105,13 +105,13 @@ export function renderRoomFormPane() {
|
|
|
105
105
|
<span class="mdi mdi-chevron-left at_back_btn" id="at-back-floors"></span>
|
|
106
106
|
<label for="">
|
|
107
107
|
<span class="mdi mdi-vector-polygon"></span>
|
|
108
|
-
|
|
108
|
+
<span id="at-wall-name"></span>
|
|
109
109
|
</label>
|
|
110
110
|
<div> </div>
|
|
111
111
|
</div>
|
|
112
112
|
|
|
113
113
|
<div class="at_edit_name" id="at-edit-wall-material" style="display: none;">
|
|
114
|
-
<input class="at_edit_name_input" type="text" id="at-edit-wall-input" data-cy="at-edit-wall-material-input" placeholder="${i18n.t('EnterWallMaterial')}" disabled>
|
|
114
|
+
<input class="at_edit_name_input" type="text" id="at-edit-wall-input" data-cy="at-edit-wall-material-input" placeholder="${i18n.t('EnterWallMaterial')}" disabled style="font-size: 0.75rem !important;">
|
|
115
115
|
<span class="mdi mdi-pencil" style="display: none; cursor: pointer;" id="at-wall-edit-material-btn"></span>
|
|
116
116
|
<span class="mdi mdi-check" id="at-confirm-edit-wall-btn" style="display: none;"></span>
|
|
117
117
|
</div>
|
|
@@ -247,6 +247,7 @@ export function toggleDrawWindowButton() {
|
|
|
247
247
|
targetUUID: currentWall.uuid
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
|
+
log.info("drawingConfig", drawingConfig);
|
|
250
251
|
setDrawingConfig(drawingConfig);
|
|
251
252
|
startDraw();
|
|
252
253
|
}
|
|
@@ -733,43 +734,17 @@ function displayFaces(polygon) {
|
|
|
733
734
|
floorMaterialEdit.style.display = "none";
|
|
734
735
|
floorMaterialConfirm.style.display = "block";
|
|
735
736
|
}));
|
|
736
|
-
addEventListenerById('at-confirm-edit-wall-btn', (
|
|
737
|
+
addEventListenerById('at-confirm-edit-wall-btn', () => __awaiter(this, void 0, void 0, function* () {
|
|
737
738
|
console.log('@caroline wall check', wallMaterial, currentWall.material, currentWall);
|
|
738
739
|
const wallEditMaterial = document.getElementById('at-wall-edit-material-btn');
|
|
739
740
|
const wallConfirmMaterial = document.getElementById('at-confirm-edit-wall-btn');
|
|
740
741
|
const wallMaterialInput = document.getElementById('at-edit-wall-input');
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
currentPartitionData.polygon_json = JSON.stringify(partitionData);
|
|
749
|
-
console.log('@caroline partition data: ', currentPartitionData);
|
|
750
|
-
}
|
|
751
|
-
currentPartitionDataArray.some(partition => {
|
|
752
|
-
const parsed = JSON.parse(partition.polygon_json);
|
|
753
|
-
parsed.walls.find(wall => {
|
|
754
|
-
if (wall.uuid == currentWall.uuid) {
|
|
755
|
-
wall.material = wallMaterial;
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
});
|
|
759
|
-
console.log('[wall] currentPartition: ', currentPartition);
|
|
760
|
-
if (currentPartition) {
|
|
761
|
-
const wall = currentPartition.object.object_data.json_data.walls.find(wall => wall.uuid == currentWall.uuid);
|
|
762
|
-
wall.material = wallMaterial;
|
|
763
|
-
}
|
|
764
|
-
currentWall.material = wallMaterial;
|
|
765
|
-
//rerender to display material value in space
|
|
766
|
-
const polyData = {
|
|
767
|
-
uuid: currentPartition.object.object_data.uuid,
|
|
768
|
-
polygon_json: partitionData
|
|
769
|
-
};
|
|
770
|
-
// renderPolygon(polyData)
|
|
771
|
-
console.log('[wall] Partition to be saved: ', currentPartitionData, JSON.parse(currentPartitionData.polygon_json));
|
|
772
|
-
dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
|
|
742
|
+
const newMaterial = wallMaterialInput.value.trim();
|
|
743
|
+
log.info("newMaterial", newMaterial);
|
|
744
|
+
currentWall.material = newMaterial;
|
|
745
|
+
log.info("currentWall", currentWall);
|
|
746
|
+
log.info("currentObject", currentObject);
|
|
747
|
+
saveWallChanges();
|
|
773
748
|
wallMaterialInput.disabled = true;
|
|
774
749
|
wallEditMaterial.style.display = "block";
|
|
775
750
|
wallConfirmMaterial.style.display = "none";
|
|
@@ -804,8 +779,8 @@ function displayWall(wall) {
|
|
|
804
779
|
<div class="at_subitem_left">
|
|
805
780
|
<span class="mdi mdi-vector-line"></span>
|
|
806
781
|
</div>
|
|
807
|
-
<div class="at_subitem_center" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}">
|
|
808
|
-
${
|
|
782
|
+
<div class="at_subitem_center" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}" style="width: 150px !important;">
|
|
783
|
+
${i18n.t('WindowsDoors')}
|
|
809
784
|
<span class="mdi mdi-chevron-up" id="at-chevron-${wall.uuid}"></span>
|
|
810
785
|
</div>
|
|
811
786
|
<div class="at_subitem_right at_invisible">
|
|
@@ -932,10 +907,10 @@ function setupEditWindow(element, window) {
|
|
|
932
907
|
confirmBtn.style.display = "none";
|
|
933
908
|
const windowTooltip = document.getElementById(`at-window-name-tooltip-${window.index}`);
|
|
934
909
|
windowTooltip.innerText = `${window.name}`;
|
|
935
|
-
|
|
910
|
+
saveWallChanges();
|
|
936
911
|
});
|
|
937
912
|
}
|
|
938
|
-
function
|
|
913
|
+
function saveWallChanges() {
|
|
939
914
|
updateWallInPolygon(currentWall);
|
|
940
915
|
updatePartitionData();
|
|
941
916
|
setCurrentPolygon(currentObject);
|
|
@@ -995,7 +970,7 @@ function setupDeleteWindow(element, window) {
|
|
|
995
970
|
});
|
|
996
971
|
// Save + rerender window
|
|
997
972
|
currentObject.object.object_data.json_data = currentPolygonData;
|
|
998
|
-
|
|
973
|
+
saveWallChanges();
|
|
999
974
|
notify.success(`${i18n.t('SuccessWindowDelete')}`);
|
|
1000
975
|
log.info("currentPartition polygonJson", JSON.parse(currentPartitionData.polygon_json));
|
|
1001
976
|
log.info("currentObject", currentObject);
|
|
@@ -1076,7 +1051,7 @@ function displayFloor(floor, walls, floorModel) {
|
|
|
1076
1051
|
</div>
|
|
1077
1052
|
|
|
1078
1053
|
<div class="at_edit_name" id="at-edit-floor-material">
|
|
1079
|
-
<input class="at_edit_name_input at_ml_1" type="text" id="at-edit-floor-material-input" data-cy="at-edit-floor-material-input" value="${floor.material ? floor.material : ''}" placeholder="${i18n.t('EnterFloorMaterial')}">
|
|
1054
|
+
<input class="at_edit_name_input at_ml_1" type="text" id="at-edit-floor-material-input" data-cy="at-edit-floor-material-input" value="${floor.material ? floor.material : ''}" placeholder="${i18n.t('EnterFloorMaterial')}" style="font-size: 0.75rem !important;">
|
|
1080
1055
|
<span class="mdi mdi-pencil at_mr-1" style="display: none; cursor: pointer;" id="at-floor-edit-material-btn"></span>
|
|
1081
1056
|
<span class="mdi mdi-check at_mr-1" id="at-confirm-edit-floor-name" style="display: none;"></span>
|
|
1082
1057
|
</div>
|
|
@@ -1431,6 +1406,7 @@ export function setCurrentPartitionData() {
|
|
|
1431
1406
|
}
|
|
1432
1407
|
if (drawingMode === 'partition') {
|
|
1433
1408
|
displayFaceLists();
|
|
1409
|
+
currentObject = currentObjectData;
|
|
1434
1410
|
}
|
|
1435
1411
|
}, 50); // Check every 50ms
|
|
1436
1412
|
});
|
|
@@ -1495,7 +1471,7 @@ function updatePartitionDataArray(payload, currentPartitionDataArray) {
|
|
|
1495
1471
|
if (existingIndex === -1) {
|
|
1496
1472
|
if (payload.name == null)
|
|
1497
1473
|
payload.name = partitionName.value || `${i18n.t('Partition')} ${currentPartitionDataArray.length + 1}`;
|
|
1498
|
-
log.info("
|
|
1474
|
+
log.info("payload", payload.name);
|
|
1499
1475
|
// Add the new partition
|
|
1500
1476
|
currentPartitionDataArray.push(payload);
|
|
1501
1477
|
newlyAddedPartition.push(payload);
|
|
@@ -1640,7 +1616,6 @@ export function handlePartitionWallEditBtn(wallUuid) {
|
|
|
1640
1616
|
log.info("currentPartitionData", currentPartitionData);
|
|
1641
1617
|
log.info("polygonJson", JSON.parse(currentPartitionData.polygon_json));
|
|
1642
1618
|
log.info("getCurrentPolygon()", getCurrentPolygon());
|
|
1643
|
-
setDrawingMode(false);
|
|
1644
1619
|
const elements = {
|
|
1645
1620
|
'at-face-title': 'none',
|
|
1646
1621
|
'at-window-door-title': 'flex',
|
|
@@ -1654,6 +1629,7 @@ export function handlePartitionWallEditBtn(wallUuid) {
|
|
|
1654
1629
|
});
|
|
1655
1630
|
const faceVertexContainer = document.getElementById('at-face-vertex-container');
|
|
1656
1631
|
faceVertexContainer.innerHTML = '';
|
|
1632
|
+
const wallName = document.getElementById('at-wall-name');
|
|
1657
1633
|
currentWall = JSON.parse(currentPartitionData.polygon_json).walls.find((wall) => wall.uuid == wallUuid);
|
|
1658
1634
|
log.info("currenWall", currentWall);
|
|
1659
1635
|
const wallBottomMidPoint = {
|
|
@@ -1665,10 +1641,18 @@ export function handlePartitionWallEditBtn(wallUuid) {
|
|
|
1665
1641
|
z: ((currentWall.edges[0].start.z + currentWall.edges[1].start.z + currentWall.edges[2].start.z + currentWall.edges[3].start.z) / 4),
|
|
1666
1642
|
};
|
|
1667
1643
|
yield goToPosition(wallBottomMidPoint);
|
|
1644
|
+
const match = currentWall.name.match(/wall-(\d+)$/);
|
|
1645
|
+
if (match) {
|
|
1646
|
+
console.log('@caroline wall test display: ', match);
|
|
1647
|
+
const wallNumber = parseInt(match[1]) + 1;
|
|
1648
|
+
wallName.innerText = `${i18n.t('Wall')} ${wallNumber}`;
|
|
1649
|
+
}
|
|
1668
1650
|
faceVertexContainer.append(displayWall(currentWall));
|
|
1669
1651
|
//sets material and icon
|
|
1670
1652
|
setWallMaterial(currentWall.material);
|
|
1671
1653
|
setWallMaterialIcon(currentWall.material);
|
|
1654
|
+
currentPolygonData = JSON.parse(currentPartitionData.polygon_json);
|
|
1655
|
+
setDrawingMode(false);
|
|
1672
1656
|
cancelDrawing();
|
|
1673
1657
|
});
|
|
1674
1658
|
}
|
|
@@ -404,7 +404,7 @@ function toggleSelectedPartition() {
|
|
|
404
404
|
handlePartitionRowEditBtnClickEvent(currentEditRoomData.children, partitionRowEdit);
|
|
405
405
|
if (isWall) {
|
|
406
406
|
const polygonId = target.getAttribute('polygon-item-id');
|
|
407
|
-
handlePartitionWallEditBtn(polygonId);
|
|
407
|
+
yield handlePartitionWallEditBtn(polygonId);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
else {
|
package/lib/atwinui/events.js
CHANGED
|
@@ -1530,6 +1530,7 @@ function handleVertexPlace(payload) {
|
|
|
1530
1530
|
if (isToolbarFeatureEnabled('roomCreation')) {
|
|
1531
1531
|
log.info("getDrawingMode()", getDrawingMode());
|
|
1532
1532
|
if (getDrawingMode() === 'window') {
|
|
1533
|
+
log.info("current polygon", getCurrentPolygon());
|
|
1533
1534
|
}
|
|
1534
1535
|
if (getDrawingMode() === 'partition') {
|
|
1535
1536
|
// setCurrentPartitionData()
|
|
@@ -137,6 +137,8 @@ export declare class BufferGeometry {
|
|
|
137
137
|
windowData: any;
|
|
138
138
|
targetIndex: any;
|
|
139
139
|
targetUUID: any;
|
|
140
|
+
deductWindowFromWallArea: boolean;
|
|
141
|
+
windowOutlineColor: number;
|
|
140
142
|
};
|
|
141
143
|
outputs: Record<string, unknown> & MpSdk.Scene.PredefinedOutputs;
|
|
142
144
|
context: MpSdk.Scene.IComponentContext;
|
|
@@ -157,6 +159,20 @@ export declare class BufferGeometry {
|
|
|
157
159
|
onTick: (delta: any) => void;
|
|
158
160
|
onDestroy(): void;
|
|
159
161
|
createLabelCanvas(text: string): HTMLCanvasElement;
|
|
162
|
+
/**
|
|
163
|
+
* Projects 3D window coordinates to 2D for accurate area calculation
|
|
164
|
+
* @param path3D Array of 3D coordinates
|
|
165
|
+
* @returns Object with area and perimeter calculated from projected 2D coordinates
|
|
166
|
+
*/
|
|
167
|
+
calculateWindowDimensions(path3D: Array<{
|
|
168
|
+
x: number;
|
|
169
|
+
y: number;
|
|
170
|
+
z: number;
|
|
171
|
+
}>): {
|
|
172
|
+
area: number;
|
|
173
|
+
perimeter: number;
|
|
174
|
+
};
|
|
175
|
+
calculateWallNormal(wallIndex: number, startPoint: any, endPoint: any): THREE.Vector3;
|
|
160
176
|
renderWindow(WALL_HEIGHT: number): void;
|
|
161
177
|
renderWalls(WALL_HEIGHT: number, metadata?: PolygonData): (WallPolyData[] | EdgePolyData[])[];
|
|
162
178
|
renderWindows(windows: WindowPolyData[]): void;
|
|
@@ -511,6 +511,8 @@ export class BufferGeometry {
|
|
|
511
511
|
windowData: undefined,
|
|
512
512
|
targetIndex: undefined,
|
|
513
513
|
targetUUID: undefined,
|
|
514
|
+
deductWindowFromWallArea: true,
|
|
515
|
+
windowOutlineColor: 0x253D5B
|
|
514
516
|
};
|
|
515
517
|
this.emits = {
|
|
516
518
|
changed: true,
|
|
@@ -693,6 +695,17 @@ export class BufferGeometry {
|
|
|
693
695
|
if (wall.windows && wall.windows.length > 0) {
|
|
694
696
|
acc = [...acc, ...wall.windows];
|
|
695
697
|
wallDataArray[index].windows = wall.windows;
|
|
698
|
+
// if (this.inputs.deductWindowFromWallArea) {
|
|
699
|
+
// // Calculate total window area for this wall
|
|
700
|
+
// let totalWindowArea = 0;
|
|
701
|
+
// if (wall.windows && wall.windows.length > 0) {
|
|
702
|
+
// totalWindowArea = wall.windows.reduce((sum, window) => {
|
|
703
|
+
// return sum + (window.area || 0);
|
|
704
|
+
// }, 0);
|
|
705
|
+
// }
|
|
706
|
+
// // Subtract window area from wall area
|
|
707
|
+
// wallDataArray[index].area = Math.max(0, wallDataArray[index].area - totalWindowArea);
|
|
708
|
+
// }
|
|
696
709
|
}
|
|
697
710
|
return acc;
|
|
698
711
|
}, []);
|
|
@@ -728,7 +741,8 @@ export class BufferGeometry {
|
|
|
728
741
|
if (!polyData.walls[targetWallIndex].windows)
|
|
729
742
|
polyData.walls[targetWallIndex].windows = [];
|
|
730
743
|
const currentWindowCount = polyData.walls[targetWallIndex].windows ? polyData.walls[targetWallIndex].windows.length + 1 : 0;
|
|
731
|
-
|
|
744
|
+
// Calculate window dimensions using proper 3D to 2D projection
|
|
745
|
+
const windowDimension = this.calculateWindowDimensions(this.inputs.path);
|
|
732
746
|
let windowDataArray = [];
|
|
733
747
|
for (let i = 0; i < this.inputs.path.length; i++) {
|
|
734
748
|
const startPoint = this.inputs.path[i];
|
|
@@ -771,6 +785,15 @@ export class BufferGeometry {
|
|
|
771
785
|
log.error("Error rendering windows ", error);
|
|
772
786
|
}
|
|
773
787
|
polyData.walls[targetWallIndex].windows[this.inputs.targetIndex] = (windowData);
|
|
788
|
+
if (this.inputs.deductWindowFromWallArea) {
|
|
789
|
+
let totalWindowArea = 0;
|
|
790
|
+
if (polyData.walls[targetWallIndex].windows && polyData.walls[targetWallIndex].windows.length > 0) {
|
|
791
|
+
totalWindowArea = polyData.walls[targetWallIndex].windows.reduce((sum, window) => {
|
|
792
|
+
return sum + (window.area || 0);
|
|
793
|
+
}, 0);
|
|
794
|
+
}
|
|
795
|
+
polyData.walls[targetWallIndex].area = Math.max(0, polyData.walls[targetWallIndex].area - totalWindowArea);
|
|
796
|
+
}
|
|
774
797
|
partitionData = polyData;
|
|
775
798
|
}
|
|
776
799
|
}
|
|
@@ -817,6 +840,83 @@ export class BufferGeometry {
|
|
|
817
840
|
return canvas;
|
|
818
841
|
}
|
|
819
842
|
;
|
|
843
|
+
/**
|
|
844
|
+
* Projects 3D window coordinates to 2D for accurate area calculation
|
|
845
|
+
* @param path3D Array of 3D coordinates
|
|
846
|
+
* @returns Object with area and perimeter calculated from projected 2D coordinates
|
|
847
|
+
*/
|
|
848
|
+
calculateWindowDimensions(path3D) {
|
|
849
|
+
const THREE = this.context.three;
|
|
850
|
+
if (!path3D || path3D.length < 3) {
|
|
851
|
+
return PolygonCalculator.calculatePolygonProperties(path3D, true);
|
|
852
|
+
}
|
|
853
|
+
const p0 = new THREE.Vector3(path3D[0].x, path3D[0].y, path3D[0].z);
|
|
854
|
+
const p1 = new THREE.Vector3(path3D[1].x, path3D[1].y, path3D[1].z);
|
|
855
|
+
const p2 = new THREE.Vector3(path3D[2].x, path3D[2].y, path3D[2].z);
|
|
856
|
+
const v1 = new THREE.Vector3().subVectors(p1, p0);
|
|
857
|
+
const v2 = new THREE.Vector3().subVectors(p2, p0);
|
|
858
|
+
const normal = new THREE.Vector3().crossVectors(v1, v2);
|
|
859
|
+
const normalLen = normal.length();
|
|
860
|
+
if (normalLen > 0) {
|
|
861
|
+
normal.divideScalar(normalLen);
|
|
862
|
+
const uAxis = v1.clone().normalize();
|
|
863
|
+
const vAxis = new THREE.Vector3().crossVectors(normal, uAxis).normalize();
|
|
864
|
+
const shapePoints2D = [];
|
|
865
|
+
for (let j = 0; j < path3D.length; j++) {
|
|
866
|
+
const pj = new THREE.Vector3(path3D[j].x, path3D[j].y, path3D[j].z);
|
|
867
|
+
const rel = new THREE.Vector3().subVectors(pj, p0);
|
|
868
|
+
const x = rel.dot(uAxis);
|
|
869
|
+
const y = rel.dot(vAxis);
|
|
870
|
+
shapePoints2D.push(new THREE.Vector2(x, y));
|
|
871
|
+
}
|
|
872
|
+
let twiceSignedArea = 0;
|
|
873
|
+
let perimeter = 0;
|
|
874
|
+
console.log('Window projection debug:');
|
|
875
|
+
console.log('Original 3D points:', path3D);
|
|
876
|
+
console.log('Projected 2D points:', shapePoints2D);
|
|
877
|
+
for (let j = 0; j < shapePoints2D.length; j++) {
|
|
878
|
+
const p1 = shapePoints2D[j];
|
|
879
|
+
const p2 = shapePoints2D[(j + 1) % shapePoints2D.length];
|
|
880
|
+
const cross = p1.x * p2.y - p2.x * p1.y;
|
|
881
|
+
twiceSignedArea += cross;
|
|
882
|
+
const distance = Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
|
883
|
+
perimeter += distance;
|
|
884
|
+
console.log(`Edge ${j}: p1(${p1.x.toFixed(3)}, ${p1.y.toFixed(3)}) -> p2(${p2.x.toFixed(3)}, ${p2.y.toFixed(3)}), cross=${cross.toFixed(3)}, distance=${distance.toFixed(3)}`);
|
|
885
|
+
}
|
|
886
|
+
const area = Math.abs(twiceSignedArea * 0.5);
|
|
887
|
+
console.log(`Final calculation: twiceSignedArea=${twiceSignedArea.toFixed(3)}, area=${area.toFixed(3)}, perimeter=${perimeter.toFixed(3)}`);
|
|
888
|
+
return { area, perimeter };
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
return PolygonCalculator.calculatePolygonProperties(path3D, true);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
calculateWallNormal(wallIndex, startPoint, endPoint) {
|
|
895
|
+
const THREE = this.context.three;
|
|
896
|
+
const wallDirection = new THREE.Vector3(endPoint.x - startPoint.x, endPoint.y - startPoint.y, endPoint.z - startPoint.z).normalize();
|
|
897
|
+
if (this.inputs.path.length >= 3) {
|
|
898
|
+
const p0 = new THREE.Vector3(this.inputs.path[0].x, this.inputs.path[0].y, this.inputs.path[0].z);
|
|
899
|
+
const p1 = new THREE.Vector3(this.inputs.path[1].x, this.inputs.path[1].y, this.inputs.path[1].z);
|
|
900
|
+
const p2 = new THREE.Vector3(this.inputs.path[2].x, this.inputs.path[2].y, this.inputs.path[2].z);
|
|
901
|
+
const v1 = new THREE.Vector3().subVectors(p1, p0);
|
|
902
|
+
const v2 = new THREE.Vector3().subVectors(p2, p0);
|
|
903
|
+
const polygonNormal = new THREE.Vector3().crossVectors(v1, v2).normalize();
|
|
904
|
+
const wallNormal = new THREE.Vector3().crossVectors(wallDirection, polygonNormal).normalize();
|
|
905
|
+
// If the normal is too small (wall is parallel to polygon normal), use a fallback
|
|
906
|
+
if (wallNormal.lengthSq() < 0.001) {
|
|
907
|
+
// Use the wall direction rotated 90 degrees around the Y axis
|
|
908
|
+
wallNormal.set(-wallDirection.z, 0, wallDirection.x).normalize();
|
|
909
|
+
}
|
|
910
|
+
return wallNormal;
|
|
911
|
+
}
|
|
912
|
+
// Fallback: use the original method if we don't have enough points
|
|
913
|
+
const up = new THREE.Vector3(0, 1, 0);
|
|
914
|
+
const wallNormal = new THREE.Vector3().crossVectors(wallDirection, up).normalize();
|
|
915
|
+
if (wallNormal.lengthSq() < 0.001) {
|
|
916
|
+
wallNormal.set(1, 0, 0);
|
|
917
|
+
}
|
|
918
|
+
return wallNormal;
|
|
919
|
+
}
|
|
820
920
|
renderWindow(WALL_HEIGHT) {
|
|
821
921
|
// const THREE = this.context.three
|
|
822
922
|
// const windowData:WindowPolyData = this.inputs.windowData
|
|
@@ -864,7 +964,19 @@ export class BufferGeometry {
|
|
|
864
964
|
wallMesh.add(outlineMesh);
|
|
865
965
|
wallMesh.name = this.inputs.uuid != '' ? `${this.inputs.uuid}_wall-${i}` : `wall-${i}`;
|
|
866
966
|
const wallLength = new THREE.Vector3(endPoint.x - startPoint.x, endPoint.y - startPoint.y, endPoint.z - startPoint.z).length();
|
|
867
|
-
|
|
967
|
+
let wallArea = wallLength * WALL_HEIGHT;
|
|
968
|
+
if (this.inputs.deductWindowFromWallArea && metadata) {
|
|
969
|
+
const currentWallIndex = wallDataArray.length == 0 ? wallDataArray.length : wallDataArray.length - 1;
|
|
970
|
+
let totalWindowArea = 0;
|
|
971
|
+
if (metadata.walls[currentWallIndex].windows && metadata.walls[currentWallIndex].windows.length > 0) {
|
|
972
|
+
totalWindowArea = metadata.walls[currentWallIndex].windows.reduce((sum, window) => {
|
|
973
|
+
const dimension = this.calculateWindowDimensions(window.path);
|
|
974
|
+
return sum + (dimension.area || 0);
|
|
975
|
+
}, 0);
|
|
976
|
+
}
|
|
977
|
+
// Subtract window area from wall area
|
|
978
|
+
wallArea = Math.max(0, wallArea - totalWindowArea);
|
|
979
|
+
}
|
|
868
980
|
// Create wall label
|
|
869
981
|
let wallMaterial;
|
|
870
982
|
if (metadata && metadata.walls[i] && metadata.walls[i].material)
|
|
@@ -879,14 +991,9 @@ export class BufferGeometry {
|
|
|
879
991
|
z: (startPoint.z + endPoint.z) / 2
|
|
880
992
|
};
|
|
881
993
|
const direction = new THREE.Vector3(endPoint.x - startPoint.x, endPoint.y - startPoint.y, endPoint.z - startPoint.z).normalize();
|
|
882
|
-
// Calculate the normal vector to the wall
|
|
883
|
-
|
|
884
|
-
const wallNormal =
|
|
885
|
-
// For flat walls, if the normal is close to zero (wall is vertical along Y),
|
|
886
|
-
if (wallNormal.lengthSq() < 0.001) {
|
|
887
|
-
// Wall is perfectly vertical, use a default normal
|
|
888
|
-
wallNormal.set(1, 0, 0);
|
|
889
|
-
}
|
|
994
|
+
// Calculate the normal vector to the wall based on polygon winding order
|
|
995
|
+
// Negate to keep labels inside, remove the negate to render all labels outside
|
|
996
|
+
const wallNormal = this.calculateWallNormal(i, startPoint, endPoint).negate();
|
|
890
997
|
// Negation to position labels on the original side of the wall
|
|
891
998
|
// wallNormal.negate();
|
|
892
999
|
const edgeLength = direction.length();
|
|
@@ -975,7 +1082,7 @@ export class BufferGeometry {
|
|
|
975
1082
|
is_deleted: wallDeleted
|
|
976
1083
|
},
|
|
977
1084
|
index: i,
|
|
978
|
-
area:
|
|
1085
|
+
area: wallArea,
|
|
979
1086
|
width: wallDimensions.width,
|
|
980
1087
|
perimeter: wallDimensions.perimeter,
|
|
981
1088
|
wall_height: WALL_HEIGHT,
|
|
@@ -1045,8 +1152,12 @@ export class BufferGeometry {
|
|
|
1045
1152
|
depthWrite: false
|
|
1046
1153
|
}));
|
|
1047
1154
|
windowMesh.name = windows[i].uuid ? `${windows[i].uuid}_window` : `window-${i}`;
|
|
1155
|
+
const outlineGeometry = new THREE.EdgesGeometry(windowGeometry);
|
|
1156
|
+
const outlineMaterial = new THREE.LineBasicMaterial({ color: this.inputs.windowOutlineColor, linewidth: 3 });
|
|
1157
|
+
const outlineMesh = new THREE.LineSegments(outlineGeometry, outlineMaterial);
|
|
1158
|
+
windowMesh.add(outlineMesh);
|
|
1048
1159
|
// Add window center label if material is defined
|
|
1049
|
-
if (windows[i].material) {
|
|
1160
|
+
if (windows[i].material || windows[i].name) {
|
|
1050
1161
|
try {
|
|
1051
1162
|
let twiceSignedArea = 0;
|
|
1052
1163
|
let centroidU = 0;
|
|
@@ -1071,9 +1182,13 @@ export class BufferGeometry {
|
|
|
1071
1182
|
centerU = sum.x / shapePoints2D.length;
|
|
1072
1183
|
centerV = sum.y / shapePoints2D.length;
|
|
1073
1184
|
}
|
|
1074
|
-
//
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1185
|
+
// Calculate window area using the projected 2D coordinates
|
|
1186
|
+
const windowDimension = this.calculateWindowDimensions(windows[i].path);
|
|
1187
|
+
let windowLabelText = windows[i].name ? `${windows[i].name}` : windowMesh.name;
|
|
1188
|
+
windowLabelText = windows[i].material ? `${windowLabelText}_${windows[i].material}: ${windowDimension.area.toFixed(2)}m²` : `${windowLabelText}: ${windowDimension.area.toFixed(2)}m²`;
|
|
1189
|
+
log.info("windowLabelText ", windowLabelText);
|
|
1190
|
+
//const windowLabel = windows[i].name ? `${windows[i].name}_${windows[i].material}` : `Window ${i}_${windows[i].material}`
|
|
1191
|
+
const windowCanvas = this.createLabelCanvas(windowLabelText);
|
|
1077
1192
|
const windowArea = Math.abs(twiceSignedArea * 0.5);
|
|
1078
1193
|
const labelWidth = Math.max(0.5, Math.min(2, Math.sqrt(Math.max(0.0001, windowArea))));
|
|
1079
1194
|
const labelHeight = labelWidth / 4;
|
package/lib/types.d.ts
CHANGED
|
@@ -461,6 +461,7 @@ export interface ComponentOptions {
|
|
|
461
461
|
drawingMode?: string | undefined;
|
|
462
462
|
targetIndex?: number | undefined;
|
|
463
463
|
targetUUID?: string | undefined;
|
|
464
|
+
deductWindowFromWallArea?: boolean | undefined;
|
|
464
465
|
}
|
|
465
466
|
export interface VectorCoords {
|
|
466
467
|
object_position: Vector3;
|