floor-editor-ts 1.4.7 → 1.4.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.
@@ -11309,10 +11309,9 @@ function drawZoneShape(cs, zone, selected) {
11309
11309
  ctx.fillStyle = color;
11310
11310
  ctx.fillText(zone.name, bx + 6, by + 4);
11311
11311
  }
11312
- const r = selected ? 9 : 7;
11313
- for (let i = 0; i < pts.length; i++) {
11312
+ if (selected) for (let i = 0; i < pts.length; i++) {
11314
11313
  const s = wts(cs, pts[i].x, pts[i].y);
11315
- drawVertexIndexBadge(ctx, s.x, s.y, i, color, r);
11314
+ drawVertexIndexBadge(ctx, s.x, s.y, i, color, 9);
11316
11315
  }
11317
11316
  ctx.restore();
11318
11317
  }
@@ -11911,6 +11910,11 @@ function emitCameraMappingChanged(data) {
11911
11910
  if (!((_data$serial = data.serial) === null || _data$serial === void 0 ? void 0 : _data$serial.trim())) return;
11912
11911
  emitFloorCallback("cameraMappingChanged", data);
11913
11912
  }
11913
+ function emitCameraFloorClicked(serial) {
11914
+ const s = serial === null || serial === void 0 ? void 0 : serial.trim();
11915
+ if (!s) return;
11916
+ emitFloorCallback("cameraFloorClicked", { serial: s });
11917
+ }
11914
11918
  function cameraItemToCallbackProps(item) {
11915
11919
  var _item$props, _ref, _item$name, _item$props2;
11916
11920
  if (!item.serial) return null;
@@ -63830,7 +63834,7 @@ function CameraFovEditor($$anchor, $$props) {
63830
63834
  ctx.setLineDash([]);
63831
63835
  ctx.globalAlpha = 1;
63832
63836
  }
63833
- for (let i = 0; i < placed.length; i++) drawVertexIndexBadge(ctx, placed[i].x * s, placed[i].y * s, i, color, 10);
63837
+ if (get(editing) || get(polySelected)) for (let i = 0; i < placed.length; i++) drawVertexIndexBadge(ctx, placed[i].x * s, placed[i].y * s, i, color, 10);
63834
63838
  ctx.restore();
63835
63839
  }
63836
63840
  }
@@ -66766,6 +66770,8 @@ function FloorPlanCanvas($$anchor, $$props) {
66766
66770
  */
66767
66771
  let fovSelectionOnly = /* @__PURE__ */ state(false);
66768
66772
  let draggingFovVertex = /* @__PURE__ */ state(null);
66773
+ /** Body-drag anchor (world) — same idea as zoneDragLast */
66774
+ let fovDragLast = /* @__PURE__ */ state(null);
66769
66775
  let editingTextAnnotationId = /* @__PURE__ */ state(null);
66770
66776
  let editingTextAnnotationPos = /* @__PURE__ */ state(proxy({
66771
66777
  x: 0,
@@ -67245,12 +67251,12 @@ function FloorPlanCanvas($$anchor, $$props) {
67245
67251
  if (!mapStr) continue;
67246
67252
  const pts = mapCoordinatesToWorldPoints(mapStr, bounds);
67247
67253
  if (pts.length < 2) continue;
67248
- const isActive = get(selectedFovSerial) === fi.serial || (active === null || active === void 0 ? void 0 : active.id) === fi.id;
67254
+ const isActive = get(selectedFovSerial) === fi.serial || get(currentSelectedId) === fi.id;
67249
67255
  const color = ((_fi$props3 = fi.props) === null || _fi$props3 === void 0 ? void 0 : _fi$props3.zoneColor) || fi.color || "#22c55e";
67250
67256
  ctx.save();
67251
67257
  ctx.strokeStyle = color;
67252
67258
  ctx.fillStyle = color;
67253
- ctx.globalAlpha = isActive ? .22 : .12;
67259
+ ctx.globalAlpha = isActive ? .28 : $$props.viewOnly ? .22 : .16;
67254
67260
  ctx.lineWidth = isActive ? 2.5 : 1.5;
67255
67261
  ctx.setLineDash(isActive ? [] : [6, 4]);
67256
67262
  ctx.beginPath();
@@ -67265,9 +67271,9 @@ function FloorPlanCanvas($$anchor, $$props) {
67265
67271
  ctx.globalAlpha = 1;
67266
67272
  ctx.stroke();
67267
67273
  ctx.setLineDash([]);
67268
- for (let i = 0; i < pts.length; i++) {
67274
+ if (isActive && !$$props.viewOnly) for (let i = 0; i < pts.length; i++) {
67269
67275
  const s = worldToScreen(pts[i].x, pts[i].y);
67270
- drawVertexIndexBadge(ctx, s.x, s.y, i, color, isActive ? 9 : 7);
67276
+ drawVertexIndexBadge(ctx, s.x, s.y, i, color, 9);
67271
67277
  }
67272
67278
  ctx.restore();
67273
67279
  }
@@ -67986,7 +67992,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67986
67992
  else zoomToFit();
67987
67993
  needsFitToCanvas = false;
67988
67994
  }
67989
- 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(draggingZoneId) || get(draggingFovVertex) != null || get(zoneRectDragStart) || get(zonePolyDraft).length > 0 || get(fovPolyDraft).length > 0 || get(currentTool) === "cameraFov" || get(measuring) || get(annotating) || get(currentPlacingId) || get(isPlacingStair) || get(isPlacingColumn) || get(marqueeStart) || get(isPanning)) canvasDirty = true;
67995
+ 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(draggingZoneId) || get(draggingFovVertex) != null || get(fovDragLast) || get(zoneRectDragStart) || get(zonePolyDraft).length > 0 || get(fovPolyDraft).length > 0 || get(currentTool) === "cameraFov" || get(measuring) || get(annotating) || get(currentPlacingId) || get(isPlacingStair) || get(isPlacingColumn) || get(marqueeStart) || get(isPanning)) canvasDirty = true;
67990
67996
  updateDetectedRooms();
67991
67997
  const selId = get(currentSelectedId);
67992
67998
  const multiIds = get(currentSelectedIds);
@@ -69091,9 +69097,31 @@ function FloorPlanCanvas($$anchor, $$props) {
69091
69097
  return;
69092
69098
  }
69093
69099
  if (tool === "select") {
69094
- const objectAboveZone = get(showFurniture) && (!!findFurnitureAt$1(wp) || !!findHandleAt$1(wp)) || get(layerVis).columns && !!findColumnAt$1(wp) || get(showStairs) && !!findStairAt$1(wp);
69095
- if (!objectAboveZone) {
69100
+ const objectAbove = get(showFurniture) && (!!findFurnitureAt$1(wp) || !!findHandleAt$1(wp)) || get(layerVis).columns && !!findColumnAt$1(wp) || get(showStairs) && !!findStairAt$1(wp);
69101
+ if (!objectAbove) {
69096
69102
  var _$$get9;
69103
+ const fovHit = findFovCameraAt(wp);
69104
+ if (fovHit === null || fovHit === void 0 ? void 0 : fovHit.serial) {
69105
+ var _fovHit$props;
69106
+ const bounds = getInteriorFloorBounds(get(currentFloor));
69107
+ const pts = bounds ? mapCoordinatesToWorldPoints((_fovHit$props = fovHit.props) === null || _fovHit$props === void 0 ? void 0 : _fovHit$props.mapCoordinates, bounds) : [];
69108
+ const vIdx = pts.length ? findFovVertexAt(wp, pts) : -1;
69109
+ set(selectedFovSerial, fovHit.serial, true);
69110
+ set(fovSelectionOnly, true);
69111
+ set(draggingFovVertex, vIdx >= 0 ? vIdx : null, true);
69112
+ set(fovDragLast, vIdx >= 0 ? null : {
69113
+ x: wp.x,
69114
+ y: wp.y
69115
+ }, true);
69116
+ set(selectedZoneId, null);
69117
+ selectedElementId.set(fovHit.id);
69118
+ emitCameraFloorClicked(fovHit.serial);
69119
+ set(selectedTextAnnotationId, null);
69120
+ set(selectedAnnotationId, null);
69121
+ set(selectedMeasurementId, null);
69122
+ beginUndoGroup();
69123
+ return;
69124
+ }
69097
69125
  if (((_$$get9 = get(currentFloor)) === null || _$$get9 === void 0 || (_$$get9 = _$$get9.zones) === null || _$$get9 === void 0 ? void 0 : _$$get9.length) && get(layerVis).zones) {
69098
69126
  const zHit = findZoneAt(wp, get(currentFloor).zones, get(zoom));
69099
69127
  if (zHit) {
@@ -69120,26 +69148,9 @@ function FloorPlanCanvas($$anchor, $$props) {
69120
69148
  return;
69121
69149
  }
69122
69150
  }
69123
- const fovHit = findFovCameraAt(wp);
69124
- if (fovHit === null || fovHit === void 0 ? void 0 : fovHit.serial) {
69125
- var _fovHit$props;
69126
- const bounds = getInteriorFloorBounds(get(currentFloor));
69127
- const pts = bounds ? mapCoordinatesToWorldPoints((_fovHit$props = fovHit.props) === null || _fovHit$props === void 0 ? void 0 : _fovHit$props.mapCoordinates, bounds) : [];
69128
- const vIdx = pts.length ? findFovVertexAt(wp, pts) : -1;
69129
- set(selectedFovSerial, fovHit.serial, true);
69130
- set(fovSelectionOnly, true);
69131
- set(draggingFovVertex, vIdx >= 0 ? vIdx : null, true);
69132
- set(selectedZoneId, null);
69133
- selectedElementId.set(fovHit.id);
69134
- set(selectedTextAnnotationId, null);
69135
- set(selectedAnnotationId, null);
69136
- set(selectedMeasurementId, null);
69137
- if (vIdx >= 0) beginUndoGroup();
69138
- return;
69139
- }
69140
69151
  }
69141
69152
  set(selectedZoneId, null);
69142
- if (!objectAboveZone) {
69153
+ if (!objectAbove) {
69143
69154
  set(selectedFovSerial, null);
69144
69155
  set(fovSelectionOnly, false);
69145
69156
  }
@@ -69446,6 +69457,7 @@ function FloorPlanCanvas($$anchor, $$props) {
69446
69457
  if (fi) {
69447
69458
  var _fi$props4;
69448
69459
  selectElement(fi.id, e.shiftKey, e.ctrlKey || e.metaKey);
69460
+ if (fi.catalogId === "camera") emitCameraFloorClicked(fi.serial);
69449
69461
  set(fovSelectionOnly, false);
69450
69462
  if (fi.catalogId === "camera" && fi.serial && ((_fi$props4 = fi.props) === null || _fi$props4 === void 0 ? void 0 : _fi$props4.mapCoordinates)) {
69451
69463
  set(selectedFovSerial, fi.serial, true);
@@ -69629,21 +69641,30 @@ function FloorPlanCanvas($$anchor, $$props) {
69629
69641
  x: snap(get(mousePos).x),
69630
69642
  y: snap(get(mousePos).y)
69631
69643
  }, true);
69632
- if (get(draggingFovVertex) != null && get(selectedFovSerial) && get(currentFloor)) {
69644
+ if (get(selectedFovSerial) && get(currentFloor) && (get(draggingFovVertex) != null || get(fovDragLast))) {
69633
69645
  const bounds = getInteriorFloorBounds(get(currentFloor));
69634
69646
  const cam = get(currentFloor).furniture.find((f) => f.catalogId === "camera" && f.serial === get(selectedFovSerial));
69635
69647
  if (cam && bounds) {
69636
69648
  var _cam$props2;
69637
69649
  const pts = mapCoordinatesToWorldPoints((_cam$props2 = cam.props) === null || _cam$props2 === void 0 ? void 0 : _cam$props2.mapCoordinates, bounds);
69638
- if (pts[get(draggingFovVertex)]) {
69650
+ if (get(draggingFovVertex) != null && pts[get(draggingFovVertex)]) {
69639
69651
  const next = pts.map((p) => ({ ...p }));
69640
69652
  next[get(draggingFovVertex)] = {
69641
69653
  x: snap(get(mousePos).x),
69642
69654
  y: snap(get(mousePos).y)
69643
69655
  };
69644
69656
  setCameraMapCoordinatesFromWorld(get(selectedFovSerial), next);
69657
+ } else if (get(fovDragLast) && pts.length) {
69658
+ const dx = get(mousePos).x - get(fovDragLast).x;
69659
+ const dy = get(mousePos).y - get(fovDragLast).y;
69660
+ set(fovDragLast, {
69661
+ x: get(mousePos).x,
69662
+ y: get(mousePos).y
69663
+ }, true);
69664
+ setCameraMapCoordinatesFromWorld(get(selectedFovSerial), translatePoints(pts, dx, dy));
69645
69665
  }
69646
69666
  }
69667
+ return;
69647
69668
  }
69648
69669
  if (get(draggingZoneId) && ((_$$get12 = get(currentFloor)) === null || _$$get12 === void 0 ? void 0 : _$$get12.zones)) {
69649
69670
  const z = get(currentFloor).zones.find((z) => z.id === get(draggingZoneId));
@@ -69971,9 +69992,10 @@ function FloorPlanCanvas($$anchor, $$props) {
69971
69992
  set(draggingZoneVertex, null);
69972
69993
  set(zoneDragLast, null);
69973
69994
  }
69974
- if (get(draggingFovVertex) != null) {
69995
+ if (get(draggingFovVertex) != null || get(fovDragLast)) {
69975
69996
  endUndoGroup();
69976
69997
  set(draggingFovVertex, null);
69998
+ set(fovDragLast, null);
69977
69999
  }
69978
70000
  if (get(draggingRoomLabelId)) {
69979
70001
  const dx = get(mousePos).x - roomLabelDragStart.x;