floor-editor-ts 1.0.10 → 1.1.0
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 +134 -1
- package/dist/floor-editor.es.js.map +1 -1
- package/package.json +1 -1
package/dist/floor-editor.es.js
CHANGED
|
@@ -62605,6 +62605,48 @@ function wts(cs, wx, wy) {
|
|
|
62605
62605
|
y: (wy - cs.camY) * cs.zoom + cs.height / 2
|
|
62606
62606
|
};
|
|
62607
62607
|
}
|
|
62608
|
+
function getFloorBounds(floor, options = {}) {
|
|
62609
|
+
var _floor$walls;
|
|
62610
|
+
if (!((_floor$walls = floor.walls) === null || _floor$walls === void 0 ? void 0 : _floor$walls.length)) return null;
|
|
62611
|
+
let minX = Infinity;
|
|
62612
|
+
let maxX = -Infinity;
|
|
62613
|
+
let minY = Infinity;
|
|
62614
|
+
let maxY = -Infinity;
|
|
62615
|
+
let found = false;
|
|
62616
|
+
function expand(x, y, pad = 0) {
|
|
62617
|
+
minX = Math.min(minX, x - pad);
|
|
62618
|
+
maxX = Math.max(maxX, x + pad);
|
|
62619
|
+
minY = Math.min(minY, y - pad);
|
|
62620
|
+
maxY = Math.max(maxY, y + pad);
|
|
62621
|
+
found = true;
|
|
62622
|
+
}
|
|
62623
|
+
for (const wall of floor.walls) {
|
|
62624
|
+
const pad = options.includeWallThickness ? wall.thickness / 2 : 0;
|
|
62625
|
+
if (wall.curvePoint) {
|
|
62626
|
+
const segments = 24;
|
|
62627
|
+
for (let i = 0; i <= segments; i++) {
|
|
62628
|
+
const t = i / segments;
|
|
62629
|
+
const mt = 1 - t;
|
|
62630
|
+
expand(mt * mt * wall.start.x + 2 * mt * t * wall.curvePoint.x + t * t * wall.end.x, mt * mt * wall.start.y + 2 * mt * t * wall.curvePoint.y + t * t * wall.end.y, pad);
|
|
62631
|
+
}
|
|
62632
|
+
} else {
|
|
62633
|
+
expand(wall.start.x, wall.start.y, pad);
|
|
62634
|
+
expand(wall.end.x, wall.end.y, pad);
|
|
62635
|
+
}
|
|
62636
|
+
}
|
|
62637
|
+
if (!found) return null;
|
|
62638
|
+
const width = maxX - minX;
|
|
62639
|
+
const height = maxY - minY;
|
|
62640
|
+
if (width <= 0 || height <= 0) return null;
|
|
62641
|
+
return {
|
|
62642
|
+
minX,
|
|
62643
|
+
minY,
|
|
62644
|
+
maxX,
|
|
62645
|
+
maxY,
|
|
62646
|
+
width,
|
|
62647
|
+
height
|
|
62648
|
+
};
|
|
62649
|
+
}
|
|
62608
62650
|
function drawWall(cs, w, selected, showDimensions, dimSettings) {
|
|
62609
62651
|
const { ctx, zoom, width, height } = cs;
|
|
62610
62652
|
const s = wts(cs, w.start.x, w.start.y);
|
|
@@ -64133,6 +64175,80 @@ function drawMinimap(cs, minimapCanvas, floor, getWorldBBox) {
|
|
|
64133
64175
|
mctx.lineWidth = 1;
|
|
64134
64176
|
mctx.strokeRect(0, 0, mw, mh);
|
|
64135
64177
|
}
|
|
64178
|
+
function drawFloorHeatmap(cs, floor, heatmapMatrix, detectedRooms) {
|
|
64179
|
+
var _heatmapMatrix$;
|
|
64180
|
+
const { ctx, zoom } = cs;
|
|
64181
|
+
const rows = heatmapMatrix.length;
|
|
64182
|
+
const cols = ((_heatmapMatrix$ = heatmapMatrix[0]) === null || _heatmapMatrix$ === void 0 ? void 0 : _heatmapMatrix$.length) || 0;
|
|
64183
|
+
if (rows === 0 || cols === 0) return;
|
|
64184
|
+
const maxValue = Math.max(...heatmapMatrix.flat());
|
|
64185
|
+
if (maxValue <= 0) return;
|
|
64186
|
+
const bounds = getFloorBounds(floor);
|
|
64187
|
+
if (!bounds) return;
|
|
64188
|
+
const { minX, minY, maxX, maxY } = bounds;
|
|
64189
|
+
const boxW = bounds.width;
|
|
64190
|
+
const boxH = bounds.height;
|
|
64191
|
+
if (boxW <= 0 || boxH <= 0) return;
|
|
64192
|
+
const cellW = boxW / cols;
|
|
64193
|
+
const cellH = boxH / rows;
|
|
64194
|
+
ctx.save();
|
|
64195
|
+
const boundP1 = wts(cs, minX, minY);
|
|
64196
|
+
const boundP2 = wts(cs, maxX, maxY);
|
|
64197
|
+
ctx.beginPath();
|
|
64198
|
+
ctx.rect(Math.min(boundP1.x, boundP2.x), Math.min(boundP1.y, boundP2.y), Math.abs(boundP2.x - boundP1.x), Math.abs(boundP2.y - boundP1.y));
|
|
64199
|
+
ctx.clip();
|
|
64200
|
+
let hasRoomClip = false;
|
|
64201
|
+
ctx.beginPath();
|
|
64202
|
+
for (const room of detectedRooms) {
|
|
64203
|
+
const poly = getRoomPolygon(room, floor.walls);
|
|
64204
|
+
if (poly.length < 3) continue;
|
|
64205
|
+
const screenPoly = poly.map((p) => wts(cs, p.x, p.y));
|
|
64206
|
+
ctx.moveTo(screenPoly[0].x, screenPoly[0].y);
|
|
64207
|
+
for (let i = 1; i < screenPoly.length; i++) ctx.lineTo(screenPoly[i].x, screenPoly[i].y);
|
|
64208
|
+
ctx.closePath();
|
|
64209
|
+
hasRoomClip = true;
|
|
64210
|
+
}
|
|
64211
|
+
if (hasRoomClip) ctx.clip();
|
|
64212
|
+
ctx.globalCompositeOperation = "source-over";
|
|
64213
|
+
ctx.filter = `blur(${Math.min(14, Math.max(3, 5 * zoom))}px)`;
|
|
64214
|
+
const radius = Math.max(cellW, cellH) * zoom * 1.15;
|
|
64215
|
+
for (let y = 0; y < rows; y++) for (let x = 0; x < cols; x++) {
|
|
64216
|
+
const value = heatmapMatrix[y][x];
|
|
64217
|
+
if (!value || value <= 0) continue;
|
|
64218
|
+
const intensity = Math.min(value / maxValue, 1);
|
|
64219
|
+
const s = wts(cs, minX + (x + .5) * cellW, minY + (y + .5) * cellH);
|
|
64220
|
+
const gradient = ctx.createRadialGradient(s.x, s.y, 0, s.x, s.y, radius);
|
|
64221
|
+
const alpha = .08 + intensity * .45;
|
|
64222
|
+
gradient.addColorStop(0, getHeatmapColor(intensity, alpha));
|
|
64223
|
+
gradient.addColorStop(.35, getHeatmapColor(intensity, alpha * .35));
|
|
64224
|
+
gradient.addColorStop(1, getHeatmapColor(intensity, 0));
|
|
64225
|
+
ctx.fillStyle = gradient;
|
|
64226
|
+
ctx.beginPath();
|
|
64227
|
+
ctx.arc(s.x, s.y, radius, 0, Math.PI * 2);
|
|
64228
|
+
ctx.fill();
|
|
64229
|
+
}
|
|
64230
|
+
ctx.filter = "none";
|
|
64231
|
+
ctx.globalCompositeOperation = "source-over";
|
|
64232
|
+
ctx.strokeStyle = "rgba(255, 255, 255, 0.22)";
|
|
64233
|
+
ctx.lineWidth = Math.max(.5, 1 / zoom);
|
|
64234
|
+
ctx.beginPath();
|
|
64235
|
+
for (let x = 0; x <= cols; x++) {
|
|
64236
|
+
const wx = minX + x * cellW;
|
|
64237
|
+
const p1 = wts(cs, wx, minY);
|
|
64238
|
+
const p2 = wts(cs, wx, maxY);
|
|
64239
|
+
ctx.moveTo(p1.x, p1.y);
|
|
64240
|
+
ctx.lineTo(p2.x, p2.y);
|
|
64241
|
+
}
|
|
64242
|
+
for (let y = 0; y <= rows; y++) {
|
|
64243
|
+
const wy = minY + y * cellH;
|
|
64244
|
+
const p1 = wts(cs, minX, wy);
|
|
64245
|
+
const p2 = wts(cs, maxX, wy);
|
|
64246
|
+
ctx.moveTo(p1.x, p1.y);
|
|
64247
|
+
ctx.lineTo(p2.x, p2.y);
|
|
64248
|
+
}
|
|
64249
|
+
ctx.stroke();
|
|
64250
|
+
ctx.restore();
|
|
64251
|
+
}
|
|
64136
64252
|
//#endregion
|
|
64137
64253
|
//#region src/lib/utils/hitTesting.ts
|
|
64138
64254
|
function pointInPolygon(p, poly) {
|
|
@@ -65317,6 +65433,7 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65317
65433
|
return id === selId || multiIds.has(id);
|
|
65318
65434
|
}
|
|
65319
65435
|
drawRooms$1();
|
|
65436
|
+
if (floor && $$props.heatmapEnabled) drawFloorHeatmap(getCS(), floor, $$props.heatmapMatrix || [], get(detectedRooms));
|
|
65320
65437
|
if (!$$props.viewOnly) drawSnapPoints$1();
|
|
65321
65438
|
if (get(layerVis).walls) {
|
|
65322
65439
|
for (const w of floor.walls) drawWall$1(w, isSelected(w.id));
|
|
@@ -70335,7 +70452,9 @@ function App($$anchor, $$props) {
|
|
|
70335
70452
|
let config = /* @__PURE__ */ state(proxy({
|
|
70336
70453
|
viewOnly: false,
|
|
70337
70454
|
floorMaxWidth: 600,
|
|
70338
|
-
floorMaxHeight: 400
|
|
70455
|
+
floorMaxHeight: 400,
|
|
70456
|
+
heatmapEnabled: false,
|
|
70457
|
+
heatmapMatrix: []
|
|
70339
70458
|
}));
|
|
70340
70459
|
(_$$props$stores = $$props.stores) === null || _$$props$stores === void 0 || _$$props$stores.floorData.subscribe((v) => set(floorData, v, true));
|
|
70341
70460
|
(_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => set(config, v, true));
|
|
@@ -70446,6 +70565,14 @@ function App($$anchor, $$props) {
|
|
|
70446
70565
|
var _$$get4;
|
|
70447
70566
|
return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxHeight;
|
|
70448
70567
|
});
|
|
70568
|
+
let $3 = /* @__PURE__ */ user_derived(() => {
|
|
70569
|
+
var _$$get5;
|
|
70570
|
+
return (_$$get5 = get(config)) === null || _$$get5 === void 0 ? void 0 : _$$get5.heatmapMatrix;
|
|
70571
|
+
});
|
|
70572
|
+
let $4 = /* @__PURE__ */ user_derived(() => {
|
|
70573
|
+
var _$$get6;
|
|
70574
|
+
return (_$$get6 = get(config)) === null || _$$get6 === void 0 ? void 0 : _$$get6.heatmapEnabled;
|
|
70575
|
+
});
|
|
70449
70576
|
FloorPlanCanvas(node_4, {
|
|
70450
70577
|
get viewOnly() {
|
|
70451
70578
|
return get($0);
|
|
@@ -70455,6 +70582,12 @@ function App($$anchor, $$props) {
|
|
|
70455
70582
|
},
|
|
70456
70583
|
get floorMaxHeight() {
|
|
70457
70584
|
return get($2);
|
|
70585
|
+
},
|
|
70586
|
+
get heatmapMatrix() {
|
|
70587
|
+
return get($3);
|
|
70588
|
+
},
|
|
70589
|
+
get heatmapEnabled() {
|
|
70590
|
+
return get($4);
|
|
70458
70591
|
}
|
|
70459
70592
|
});
|
|
70460
70593
|
}
|