floor-editor-ts 1.2.5 → 1.2.7

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.
@@ -62003,10 +62003,6 @@ var drawSymGasLine = (ctx, w, d, color) => {
62003
62003
  ctx.textBaseline = "middle";
62004
62004
  ctx.fillText("G", 0, 0);
62005
62005
  };
62006
- var persons = [];
62007
- var lastSpawnTime = 0;
62008
- var SPAWN_INTERVAL = 1e3;
62009
- var MAX_PERSONS = 20;
62010
62006
  function getHeatmapColor(t, alpha = 1) {
62011
62007
  t = Math.max(0, Math.min(t, 1));
62012
62008
  let r, g, b;
@@ -62033,110 +62029,29 @@ function getHeatmapColor(t, alpha = 1) {
62033
62029
  }
62034
62030
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
62035
62031
  }
62036
- var drawCamera = (ctx, w, d, color, heatmapMatrix, hasPerson = false, showHeatmap = false, showCameraCones = false, highlighted = false) => {
62032
+ var MAX_CONE_RANGE_PX = 220;
62033
+ var drawCamera = (ctx, w, d, color, heatmapMatrix, hasPerson = false, showHeatmap = false, drawCone = false, highlighted = false) => {
62037
62034
  const bodyRadius = 4;
62038
62035
  const lensR = Math.min(w, d) * .25;
62039
- const range = Math.max(w, d) * 6;
62040
62036
  const fov = Math.PI / 2;
62041
- if (showHeatmap || showCameraCones) {
62042
- var _heatmapMatrix$;
62037
+ if (drawCone) {
62043
62038
  ctx.save();
62044
- const coneGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, range);
62045
- const innerAlpha = highlighted ? "88" : showHeatmap ? "55" : "22";
62046
- const midAlpha = highlighted ? "55" : showHeatmap ? "22" : "11";
62047
- coneGradient.addColorStop(0, color + innerAlpha);
62048
- coneGradient.addColorStop(.45, color + midAlpha);
62049
- coneGradient.addColorStop(1, color + "00");
62050
- ctx.fillStyle = coneGradient;
62051
- ctx.globalCompositeOperation = "lighter";
62039
+ const range = Math.min(Math.max(w, d) * 6, MAX_CONE_RANGE_PX);
62040
+ ctx.globalAlpha = highlighted ? .28 : showHeatmap ? .22 : .14;
62041
+ ctx.fillStyle = highlighted ? "#fbbf24" : color;
62052
62042
  ctx.beginPath();
62053
62043
  ctx.moveTo(0, 0);
62054
62044
  ctx.arc(0, 0, range, -fov / 2, fov / 2);
62055
62045
  ctx.closePath();
62056
62046
  ctx.fill();
62057
62047
  if (highlighted) {
62048
+ ctx.globalAlpha = .85;
62058
62049
  ctx.strokeStyle = "#fbbf24";
62059
- ctx.lineWidth = 2.5;
62060
- ctx.globalCompositeOperation = "source-over";
62061
- ctx.beginPath();
62062
- ctx.moveTo(0, 0);
62063
- ctx.arc(0, 0, range, -fov / 2, fov / 2);
62064
- ctx.closePath();
62050
+ ctx.lineWidth = 2;
62065
62051
  ctx.stroke();
62066
62052
  }
62067
62053
  ctx.restore();
62068
- if (showHeatmap && (heatmapMatrix === null || heatmapMatrix === void 0 ? void 0 : heatmapMatrix.length) && ((_heatmapMatrix$ = heatmapMatrix[0]) === null || _heatmapMatrix$ === void 0 ? void 0 : _heatmapMatrix$.length)) {
62069
- const rows = heatmapMatrix.length;
62070
- const cols = heatmapMatrix[0].length;
62071
- const maxValue = Math.max(...heatmapMatrix.flat());
62072
- if (maxValue > 0) {
62073
- ctx.save();
62074
- ctx.globalCompositeOperation = "lighter";
62075
- ctx.filter = "blur(10px)";
62076
- const radius = range / rows * 1.8;
62077
- for (let y = 0; y < rows; y++) for (let x = 0; x < cols; x++) {
62078
- const value = heatmapMatrix[y][x];
62079
- if (!value || value <= 0) continue;
62080
- const intensity = Math.min(value / maxValue, 1);
62081
- const angle = -fov / 2 + (cols === 1 ? .5 : x / (cols - 1)) * fov;
62082
- const r = (y + .5) / rows * range;
62083
- const px = Math.cos(angle) * r;
62084
- const py = Math.sin(angle) * r;
62085
- const gradient = ctx.createRadialGradient(px, py, 0, px, py, radius);
62086
- const alpha = .12 + intensity * .75;
62087
- gradient.addColorStop(0, getHeatmapColor(intensity, alpha));
62088
- gradient.addColorStop(.45, getHeatmapColor(intensity, alpha * .45));
62089
- gradient.addColorStop(1, getHeatmapColor(intensity, 0));
62090
- ctx.fillStyle = gradient;
62091
- ctx.beginPath();
62092
- ctx.arc(px, py, radius, 0, Math.PI * 2);
62093
- ctx.fill();
62094
- }
62095
- ctx.restore();
62096
- }
62097
- }
62098
- if (showHeatmap && hasPerson) {
62099
- const now = Date.now();
62100
- if (persons.length < MAX_PERSONS && now - lastSpawnTime > SPAWN_INTERVAL) {
62101
- lastSpawnTime = now;
62102
- persons.push({
62103
- startTime: now,
62104
- duration: 2e3 + Math.random() * 1e3,
62105
- direction: Math.random() > .5 ? "far-to-near" : "near-to-far",
62106
- angle: (Math.random() - .5) * fov * .8
62107
- });
62108
- }
62109
- persons = persons.filter((p) => {
62110
- let t = (now - p.startTime) / p.duration;
62111
- if (t >= 1) return false;
62112
- t = Math.max(0, Math.min(t, 1));
62113
- let r;
62114
- if (p.direction === "far-to-near") r = range * (.9 - t * .8);
62115
- else r = range * (.1 + t * .8);
62116
- const x = Math.cos(p.angle) * r;
62117
- const y = Math.sin(p.angle) * r;
62118
- ctx.save();
62119
- ctx.translate(x, y);
62120
- ctx.globalCompositeOperation = "lighter";
62121
- const scale = .5 + (1 - r / range);
62122
- ctx.scale(scale, scale);
62123
- ctx.globalAlpha = 1 - t;
62124
- const glow = ctx.createRadialGradient(0, 0, 0, 0, 0, 20);
62125
- glow.addColorStop(0, "rgba(255,0,0,0.8)");
62126
- glow.addColorStop(1, "rgba(255,0,0,0)");
62127
- ctx.fillStyle = glow;
62128
- ctx.beginPath();
62129
- ctx.arc(0, 0, 20, 0, Math.PI * 2);
62130
- ctx.fill();
62131
- ctx.beginPath();
62132
- ctx.arc(0, 0, 6, 0, Math.PI * 2);
62133
- ctx.fillStyle = "red";
62134
- ctx.fill();
62135
- ctx.restore();
62136
- return true;
62137
- });
62138
- } else if (showHeatmap) persons = [];
62139
- } else persons = [];
62054
+ }
62140
62055
  ctx.fillStyle = color + "40";
62141
62056
  ctx.strokeStyle = color;
62142
62057
  ctx.lineWidth = 1;
@@ -62231,12 +62146,12 @@ var iconDrawers = {
62231
62146
  * @param w - pixel width (catalogWidth * zoom)
62232
62147
  * @param d - pixel depth (catalogDepth * zoom)
62233
62148
  */
62234
- function drawFurnitureIcon(ctx, catalogId, w, d, color, strokeColor, heatmapMatrix, hasPerson = false, showHeatmap = false, showCameraCones = false, highlighted = false) {
62149
+ function drawFurnitureIcon(ctx, catalogId, w, d, color, strokeColor, heatmapMatrix, hasPerson = false, showHeatmap = false, drawCone = false, highlighted = false) {
62235
62150
  ctx.fillStyle = color + "60";
62236
62151
  ctx.strokeStyle = strokeColor;
62237
62152
  ctx.lineWidth = 1;
62238
62153
  const drawer = iconDrawers[catalogId];
62239
- if (drawer) drawer(ctx, w, d, color, heatmapMatrix, hasPerson, showHeatmap, showCameraCones, highlighted);
62154
+ if (drawer) drawer(ctx, w, d, color, heatmapMatrix, hasPerson, showHeatmap, drawCone, highlighted);
62240
62155
  else {
62241
62156
  roundRect(ctx, -w / 2, -d / 2, w, d, 2);
62242
62157
  ctx.fill();
@@ -63584,6 +63499,7 @@ function drawFurnitureItem(cs, item, selected, options) {
63584
63499
  const useConfigHeatmap = isCamera && highlighted && !!(options === null || options === void 0 || (_options$cameraHeatma = options.cameraHeatmapMatrix) === null || _options$cameraHeatma === void 0 ? void 0 : _options$cameraHeatma.length);
63585
63500
  const drawHeatmapMatrix = useConfigHeatmap ? options.cameraHeatmapMatrix : item.heatmapMatrix;
63586
63501
  const drawShowHeatmap = item.showHeatmap || useConfigHeatmap;
63502
+ const drawCone = isCamera && (drawShowHeatmap || highlighted || showCameraCones && selected);
63587
63503
  ctx.save();
63588
63504
  ctx.translate(s.x, s.y);
63589
63505
  ctx.rotate(angle);
@@ -63591,7 +63507,7 @@ function drawFurnitureItem(cs, item, selected, options) {
63591
63507
  const itemColor = (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : cat.color;
63592
63508
  const strokeColor = selected ? "#3b82f6" : itemColor;
63593
63509
  ctx.lineWidth = selected ? 2 : 1;
63594
- drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, drawHeatmapMatrix, item.hasPerson, drawShowHeatmap, isCamera ? showCameraCones : false, isCamera ? highlighted : false);
63510
+ drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, drawHeatmapMatrix, item.hasPerson, drawShowHeatmap, drawCone, highlighted);
63595
63511
  const fontSize = Math.max(8, Math.min(12, Math.min(w, d) * .2));
63596
63512
  if (showCameraLabels && Math.min(w, d) > 20) {
63597
63513
  var _item$name;