docs: Add design document for spatial workspace architecture refactor and fix card center calculation in layout system.
This commit is contained in:
@@ -271,12 +271,17 @@ export class LayoutStore {
|
|||||||
getCardsInCircle(x: number, y: number, radius: number): LayoutCard[] {
|
getCardsInCircle(x: number, y: number, radius: number): LayoutCard[] {
|
||||||
const result: LayoutCard[] = [];
|
const result: LayoutCard[] = [];
|
||||||
for (const card of this.items.values()) {
|
for (const card of this.items.values()) {
|
||||||
const dx = card.x - x;
|
// Calculate center of candidate card
|
||||||
const dy = card.y - y;
|
const cx = card.x + card.width / 2;
|
||||||
|
const cy = card.y + card.height / 2;
|
||||||
|
|
||||||
|
const dx = cx - x;
|
||||||
|
const dy = cy - y;
|
||||||
|
|
||||||
// Use squared distance to avoid sqrt
|
|
||||||
const distSq = dx * dx + dy * dy;
|
const distSq = dx * dx + dy * dy;
|
||||||
if (distSq < radius * radius) {
|
const limit = radius;
|
||||||
|
|
||||||
|
if (distSq < limit * limit) {
|
||||||
result.push(card);
|
result.push(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +289,9 @@ export class LayoutStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStackBelow(topCard: LayoutCard): string[] {
|
getStackBelow(topCard: LayoutCard): string[] {
|
||||||
const candidates = this.getCardsInCircle(topCard.x, topCard.y, topCard.innerRadius);
|
const centerX = topCard.x + topCard.width / 2;
|
||||||
|
const centerY = topCard.y + topCard.height / 2;
|
||||||
|
const candidates = this.getCardsInCircle(centerX, centerY, topCard.innerRadius);
|
||||||
|
|
||||||
return candidates
|
return candidates
|
||||||
.filter(other => {
|
.filter(other => {
|
||||||
|
|||||||
Reference in New Issue
Block a user