import {fitWindowScale} from './BlenderWindowFrame'; export const PEEKING_DOOR_ASPECT=.74; export interface MaskBounds {x:number;y:number;width:number;height:number} /** Door geometry is independent of the uploaded photograph. The legacy photo aperture * remains available for conservative foreground-detail clearance. The runtime * corner camera follows the physical door dimensions. */ export function peekingLayout(viewAspect:number,photoAspect:number) { const scale=fitWindowScale(viewAspect,PEEKING_DOOR_ASPECT)*.82; const legacy=fitWindowScale(viewAspect,photoAspect)*.82; const width=scale*PEEKING_DOOR_ASPECT*.8,height=scale*.8; const cameraBounds:[number,number,number]=[legacy*photoAspect*.8,legacy*.8,.6]; return {width,height,cameraBounds,clearanceScale:Math.min(width,height,...cameraBounds.slice(0,2))}; } /** No pose synthesis: place the actual selected silhouette. Default crops the * lower edge behind the sill; manual XY remains available even at scale 1. */ export function placePeekingDog(layout:{width:number;height:number},aspect:number,bounds:MaskBounds,z:number,zoom:number,panX:number,panY:number) { const h=layout.height,w=layout.width; const objectHeight=Math.min(.48*h,.43*w/(Math.max(.01,bounds.width)*aspect/Math.max(.01,bounds.height)))*zoom; const height=objectHeight/Math.max(.01,bounds.height),width=height*aspect; const centerX=.24*w+panX*.35*w,top=-.56*h+objectHeight+panY*.35*h; const x=centerX-(bounds.x+bounds.width/2-.5)*width; const y=top-(.5-bounds.y)*height; return {x,y,z,width,height}; }