floor-editor-ts 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floor-editor.es.js +64 -16
- package/dist/floor-editor.es.js.map +1 -1
- package/package.json +1 -1
package/dist/floor-editor.es.js
CHANGED
|
@@ -64737,9 +64737,8 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
64737
64737
|
});
|
|
64738
64738
|
user_effect(() => {
|
|
64739
64739
|
if ($$props.viewOnly) {
|
|
64740
|
-
$$props.floorMaxWidth;
|
|
64741
|
-
$$props.floorMaxHeight;
|
|
64742
64740
|
needsFitToCanvas = true;
|
|
64741
|
+
markDirty();
|
|
64743
64742
|
}
|
|
64744
64743
|
selectedCameraSerial();
|
|
64745
64744
|
showCameraCones();
|
|
@@ -65086,14 +65085,39 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65086
65085
|
function resize() {
|
|
65087
65086
|
const parent = canvas === null || canvas === void 0 ? void 0 : canvas.parentElement;
|
|
65088
65087
|
if (!parent) return;
|
|
65089
|
-
|
|
65090
|
-
|
|
65088
|
+
if (!$$props.viewOnly) {
|
|
65089
|
+
set(width, parent.clientWidth, true);
|
|
65090
|
+
set(height, parent.clientHeight, true);
|
|
65091
|
+
if (canvas) {
|
|
65092
|
+
canvas.width = get(width);
|
|
65093
|
+
canvas.height = get(height);
|
|
65094
|
+
}
|
|
65095
|
+
markDirty();
|
|
65096
|
+
needsFitToCanvas = true;
|
|
65097
|
+
return;
|
|
65098
|
+
}
|
|
65099
|
+
layoutViewOnlyViewport();
|
|
65100
|
+
}
|
|
65101
|
+
/** viewOnly: show full floor — contain fit, nothing clipped */
|
|
65102
|
+
function layoutViewOnlyViewport() {
|
|
65103
|
+
const parent = canvas === null || canvas === void 0 ? void 0 : canvas.parentElement;
|
|
65104
|
+
if (!parent || !get(currentFloor)) return;
|
|
65105
|
+
const bounds = getViewOnlyFitBounds(get(currentFloor));
|
|
65106
|
+
if (!bounds) return;
|
|
65107
|
+
const domWidth = parent.clientWidth;
|
|
65108
|
+
const domHeight = parent.clientHeight;
|
|
65109
|
+
if (domWidth <= 0 || domHeight <= 0) return;
|
|
65110
|
+
set(width, domWidth, true);
|
|
65111
|
+
set(height, domHeight, true);
|
|
65091
65112
|
if (canvas) {
|
|
65092
65113
|
canvas.width = get(width);
|
|
65093
65114
|
canvas.height = get(height);
|
|
65094
65115
|
}
|
|
65116
|
+
set(camX, (bounds.minX + bounds.maxX) / 2);
|
|
65117
|
+
set(camY, (bounds.minY + bounds.maxY) / 2);
|
|
65118
|
+
set(zoom, Math.min(get(width) / bounds.width, get(height) / bounds.height), true);
|
|
65119
|
+
set(zoom, Math.max(get(zoom), .1), true);
|
|
65095
65120
|
markDirty();
|
|
65096
|
-
needsFitToCanvas = true;
|
|
65097
65121
|
}
|
|
65098
65122
|
function drawGrid() {
|
|
65099
65123
|
if (!ctx || !get(showGrid)) return;
|
|
@@ -65595,9 +65619,13 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65595
65619
|
const sy = Math.abs((_item$scale$y = (_item$scale2 = item.scale) === null || _item$scale2 === void 0 ? void 0 : _item$scale2.y) !== null && _item$scale$y !== void 0 ? _item$scale$y : 1);
|
|
65596
65620
|
const w = ((_ref = (_item$width = item.width) !== null && _item$width !== void 0 ? _item$width : cat === null || cat === void 0 ? void 0 : cat.width) !== null && _ref !== void 0 ? _ref : 50) * sx;
|
|
65597
65621
|
const d = ((_ref2 = (_item$depth = item.depth) !== null && _item$depth !== void 0 ? _item$depth : cat === null || cat === void 0 ? void 0 : cat.depth) !== null && _ref2 !== void 0 ? _ref2 : 50) * sy;
|
|
65598
|
-
const
|
|
65599
|
-
|
|
65600
|
-
|
|
65622
|
+
const half = Math.max(w, d) / 2;
|
|
65623
|
+
expand(item.position.x, item.position.y, half);
|
|
65624
|
+
if (item.catalogId === "camera" && showCameraCones()) {
|
|
65625
|
+
const angle = item.rotation * Math.PI / 180;
|
|
65626
|
+
const range = Math.max(w, d) * 6;
|
|
65627
|
+
expand(item.position.x + Math.cos(angle) * range, item.position.y + Math.sin(angle) * range, half);
|
|
65628
|
+
}
|
|
65601
65629
|
}
|
|
65602
65630
|
if (!found) return getFloorWallBounds(floor);
|
|
65603
65631
|
const width = maxX - minX;
|
|
@@ -65612,6 +65640,20 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65612
65640
|
height
|
|
65613
65641
|
};
|
|
65614
65642
|
}
|
|
65643
|
+
/** Bounds for viewOnly fit: walls + furniture bodies + margin, never crops content */
|
|
65644
|
+
function getViewOnlyFitBounds(floor = get(currentFloor)) {
|
|
65645
|
+
const bounds = getFloorContentBounds(floor);
|
|
65646
|
+
if (!bounds) return null;
|
|
65647
|
+
const margin = 40;
|
|
65648
|
+
return {
|
|
65649
|
+
minX: bounds.minX - margin,
|
|
65650
|
+
minY: bounds.minY - margin,
|
|
65651
|
+
maxX: bounds.maxX + margin,
|
|
65652
|
+
maxY: bounds.maxY + margin,
|
|
65653
|
+
width: bounds.width + margin * 2,
|
|
65654
|
+
height: bounds.height + margin * 2
|
|
65655
|
+
};
|
|
65656
|
+
}
|
|
65615
65657
|
function getCanvasFrameStyle() {
|
|
65616
65658
|
return "width: 100%; height: 100%";
|
|
65617
65659
|
}
|
|
@@ -65623,9 +65665,11 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65623
65665
|
}
|
|
65624
65666
|
canvasDirty = false;
|
|
65625
65667
|
ctx.clearRect(0, 0, get(width), get(height));
|
|
65626
|
-
|
|
65627
|
-
|
|
65628
|
-
|
|
65668
|
+
if (!$$props.viewOnly) {
|
|
65669
|
+
ctx.fillStyle = "#f8f9fa";
|
|
65670
|
+
ctx.fillRect(0, 0, get(width), get(height));
|
|
65671
|
+
drawGrid();
|
|
65672
|
+
}
|
|
65629
65673
|
if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
|
|
65630
65674
|
drawBackgroundImage();
|
|
65631
65675
|
const floor = get(currentFloor);
|
|
@@ -65634,7 +65678,8 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65634
65678
|
return;
|
|
65635
65679
|
}
|
|
65636
65680
|
if (needsFitToCanvas) {
|
|
65637
|
-
|
|
65681
|
+
if ($$props.viewOnly) layoutViewOnlyViewport();
|
|
65682
|
+
else zoomToFit();
|
|
65638
65683
|
needsFitToCanvas = false;
|
|
65639
65684
|
}
|
|
65640
65685
|
if (get(wallStart) || get(draggingFurnitureId) || get(draggingDoorId) || get(draggingWindowId) || get(draggingStairId) || get(draggingColumnId) || get(draggingWallEndpoint) || get(draggingWallParallel) || get(draggingCurveHandle) || get(draggingHandle) || get(draggingMultiSelect) || get(draggingRoomId) || get(draggingRoomLabelId) || get(draggingTextAnnotationId) || get(draggingGuideId) || get(measuring) || get(annotating) || get(currentPlacingId) || get(isPlacingStair) || get(isPlacingColumn) || get(marqueeStart) || get(isPanning)) canvasDirty = true;
|
|
@@ -67593,13 +67638,17 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
67593
67638
|
set(camY, bbox.minY + (my - oy) / scale);
|
|
67594
67639
|
}
|
|
67595
67640
|
function zoomToFit() {
|
|
67641
|
+
if ($$props.viewOnly) {
|
|
67642
|
+
layoutViewOnlyViewport();
|
|
67643
|
+
return;
|
|
67644
|
+
}
|
|
67596
67645
|
if (!get(currentFloor)) {
|
|
67597
67646
|
set(camX, 0);
|
|
67598
67647
|
set(camY, 0);
|
|
67599
67648
|
set(zoom, 1);
|
|
67600
67649
|
return;
|
|
67601
67650
|
}
|
|
67602
|
-
const bounds =
|
|
67651
|
+
const bounds = getFloorWallBounds(get(currentFloor));
|
|
67603
67652
|
if (!bounds) {
|
|
67604
67653
|
set(camX, 0);
|
|
67605
67654
|
set(camY, 0);
|
|
@@ -67616,13 +67665,12 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
67616
67665
|
canvas.height = get(height);
|
|
67617
67666
|
}
|
|
67618
67667
|
}
|
|
67619
|
-
const padding =
|
|
67668
|
+
const padding = 0;
|
|
67620
67669
|
const contentW = bounds.width + padding * 2;
|
|
67621
67670
|
const contentH = bounds.height + padding * 2;
|
|
67622
67671
|
set(camX, (bounds.minX + bounds.maxX) / 2);
|
|
67623
67672
|
set(camY, (bounds.minY + bounds.maxY) / 2);
|
|
67624
|
-
|
|
67625
|
-
else set(zoom, Math.max(get(width) / contentW, get(height) / contentH), true);
|
|
67673
|
+
set(zoom, Math.max(get(width) / contentW, get(height) / contentH), true);
|
|
67626
67674
|
set(zoom, Math.max(get(zoom), .1), true);
|
|
67627
67675
|
markDirty();
|
|
67628
67676
|
}
|