floor-editor-ts 1.1.7 → 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.
@@ -65098,11 +65098,11 @@ function FloorPlanCanvas($$anchor, $$props) {
65098
65098
  }
65099
65099
  layoutViewOnlyViewport();
65100
65100
  }
65101
- /** viewOnly: fit walls to fill the entire viewport no gray margins */
65101
+ /** viewOnly: show full floor contain fit, nothing clipped */
65102
65102
  function layoutViewOnlyViewport() {
65103
65103
  const parent = canvas === null || canvas === void 0 ? void 0 : canvas.parentElement;
65104
65104
  if (!parent || !get(currentFloor)) return;
65105
- const bounds = getFloorWallBounds(get(currentFloor));
65105
+ const bounds = getViewOnlyFitBounds(get(currentFloor));
65106
65106
  if (!bounds) return;
65107
65107
  const domWidth = parent.clientWidth;
65108
65108
  const domHeight = parent.clientHeight;
@@ -65113,12 +65113,9 @@ function FloorPlanCanvas($$anchor, $$props) {
65113
65113
  canvas.width = get(width);
65114
65114
  canvas.height = get(height);
65115
65115
  }
65116
- const padding = 12;
65117
- const contentW = bounds.width + padding * 2;
65118
- const contentH = bounds.height + padding * 2;
65119
65116
  set(camX, (bounds.minX + bounds.maxX) / 2);
65120
65117
  set(camY, (bounds.minY + bounds.maxY) / 2);
65121
- set(zoom, Math.max(get(width) / contentW, get(height) / contentH), true);
65118
+ set(zoom, Math.min(get(width) / bounds.width, get(height) / bounds.height), true);
65122
65119
  set(zoom, Math.max(get(zoom), .1), true);
65123
65120
  markDirty();
65124
65121
  }
@@ -65596,6 +65593,67 @@ function FloorPlanCanvas($$anchor, $$props) {
65596
65593
  height
65597
65594
  };
65598
65595
  }
65596
+ function getFloorContentBounds(floor = get(currentFloor)) {
65597
+ if (!floor) return null;
65598
+ let minX = Infinity;
65599
+ let maxX = -Infinity;
65600
+ let minY = Infinity;
65601
+ let maxY = -Infinity;
65602
+ let found = false;
65603
+ const expand = (x, y, pad = 0) => {
65604
+ minX = Math.min(minX, x - pad);
65605
+ maxX = Math.max(maxX, x + pad);
65606
+ minY = Math.min(minY, y - pad);
65607
+ maxY = Math.max(maxY, y + pad);
65608
+ found = true;
65609
+ };
65610
+ for (const wall of floor.walls) {
65611
+ expand(wall.start.x, wall.start.y, wall.thickness / 2);
65612
+ expand(wall.end.x, wall.end.y, wall.thickness / 2);
65613
+ if (wall.curvePoint) expand(wall.curvePoint.x, wall.curvePoint.y, wall.thickness / 2);
65614
+ }
65615
+ for (const item of floor.furniture) {
65616
+ var _item$scale$x, _item$scale, _item$scale$y, _item$scale2, _ref, _item$width, _ref2, _item$depth;
65617
+ const cat = getCatalogItem(item.catalogId);
65618
+ const sx = Math.abs((_item$scale$x = (_item$scale = item.scale) === null || _item$scale === void 0 ? void 0 : _item$scale.x) !== null && _item$scale$x !== void 0 ? _item$scale$x : 1);
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);
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;
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;
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
+ }
65629
+ }
65630
+ if (!found) return getFloorWallBounds(floor);
65631
+ const width = maxX - minX;
65632
+ const height = maxY - minY;
65633
+ if (width <= 0 || height <= 0) return null;
65634
+ return {
65635
+ minX,
65636
+ minY,
65637
+ maxX,
65638
+ maxY,
65639
+ width,
65640
+ height
65641
+ };
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
+ }
65599
65657
  function getCanvasFrameStyle() {
65600
65658
  return "width: 100%; height: 100%";
65601
65659
  }