refboard: cull images by visible bounds

This commit is contained in:
Hiren Kangad
2026-03-13 12:59:20 +05:30
parent dc283124d7
commit cd9db8816c
+3 -2
View File
@@ -205,8 +205,9 @@ const PixiCanvas = forwardRef<PixiCanvasHandle, PixiCanvasProps>(
const nearbyItems = scene.queryRegion(qx, qy, qw, qh); const nearbyItems = scene.queryRegion(qx, qy, qw, qh);
for (const item of nearbyItems) { for (const item of nearbyItems) {
const cx = item.data.x + (item.data.w * Math.abs(item.data.sx)) / 2; const itemBounds = getItemWorldBounds(item);
const cy = item.data.y + (item.data.h * Math.abs(item.data.sy)) / 2; const cx = itemBounds.x + itemBounds.w / 2;
const cy = itemBounds.y + itemBounds.h / 2;
const dist = (cx - vcx) ** 2 + (cy - vcy) ** 2; const dist = (cx - vcx) ** 2 + (cy - vcy) ** 2;
if (item.type === 'image' && (item.displayObject instanceof ImageSprite || item.displayObject instanceof AnimatedGifSprite)) { if (item.type === 'image' && (item.displayObject instanceof ImageSprite || item.displayObject instanceof AnimatedGifSprite)) {