| | |
| | | setShowAreas(false); |
| | | }; |
| | | |
| | | export const focusAreaSprite = (sprite) => { |
| | | export const focusAreaSprite = (sprite, rightPanelWidth) => { |
| | | if (!sprite || !app || !mapContainer) { |
| | | return; |
| | | } |
| | |
| | | const paddedHeight = (height || 1000) * 1.25; |
| | | const viewportWidth = app.renderer.width || 1920; |
| | | const viewportHeight = app.renderer.height || 1080; |
| | | const effectiveViewportWidth = Math.max(1, viewportWidth - rightPanelWidth); |
| | | |
| | | let focusScale = Math.min( |
| | | (viewportWidth * 0.65) / paddedWidth, |
| | | (effectiveViewportWidth * 0.65) / paddedWidth, |
| | | (viewportHeight * 0.65) / paddedHeight |
| | | ); |
| | | focusScale = Math.min(Math.max(focusScale, 0.03), 0.25); |
| | |
| | | const bounds = sprite.getBounds(); |
| | | const centerX = bounds.x + bounds.width / 2; |
| | | const centerY = bounds.y + bounds.height / 2; |
| | | const visibleCenterX = (viewportWidth - rightPanelWidth) / 2; |
| | | |
| | | const targetPos = { |
| | | x: viewportWidth / 2 - centerX, |
| | | x: visibleCenterX - centerX, |
| | | y: viewportHeight / 2 - centerY, |
| | | }; |
| | | |