diff --git a/dist/index.html b/dist/index.html index 1e38d81..5a46227 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ furniture-app - + diff --git a/src/components/RoomCanvas.tsx b/src/components/RoomCanvas.tsx index f0eeb4a..bbe3651 100644 --- a/src/components/RoomCanvas.tsx +++ b/src/components/RoomCanvas.tsx @@ -90,16 +90,21 @@ export function RoomCanvas({ state, onStateChange, mode, selectedId, onSelect, s ctx.strokeStyle = 'rgba(255,255,255,0.035)'; ctx.lineWidth = 1; const step = 25; - for (let x = 0; x <= state.room.width; x += step) { + const maxLines = 2000; + const xCount = Math.min(Math.floor(state.room.width / step) + 1, maxLines); + const yCount = Math.min(Math.floor(state.room.height / step) + 1, maxLines); + for (let i = 0; i < xCount; i++) { + const x = i * step; ctx.beginPath(); ctx.moveTo(x, 0); - ctx.lineTo(x, state.room.height); + ctx.lineTo(x, Math.min(state.room.height, step * yCount)); ctx.stroke(); } - for (let y = 0; y <= state.room.height; y += step) { + for (let i = 0; i < yCount; i++) { + const y = i * step; ctx.beginPath(); ctx.moveTo(0, y); - ctx.lineTo(state.room.width, y); + ctx.lineTo(Math.min(state.room.width, step * xCount), y); ctx.stroke(); } diff --git a/src/geometry/collision.ts b/src/geometry/collision.ts index ca96eed..b607c03 100644 --- a/src/geometry/collision.ts +++ b/src/geometry/collision.ts @@ -35,7 +35,8 @@ export function colliderCorners(c: Collider): Point[] { function project(points: Point[], axis: Point): [number, number] { let min = Infinity; let max = -Infinity; - for (const p of points) { + for (let i = 0; i < points.length; i++) { + const p = points[i]; const d = p.x * axis.x + p.y * axis.y; if (d < min) min = d; if (d > max) max = d;