1const clamp=(n,a,b)=>Math.max(a,Math.min(b,n)); 2export function clearViewport(canvas,overlays=[]){ 3 let rectangles=[{left:canvas.left+8,top:canvas.top+8,right:canvas.right-8,bottom:canvas.bottom-8}]; 4 for(const overlay of overlays){ 5 const next=[]; 6 for(const r of rectangles){ 7 const l=Math.max(r.left,overlay.left),t=Math.max(r.top,overlay.top),right=Math.min(r.right,overlay.right),bottom=Math.min(r.bottom,overlay.bottom); 8 if(l>=right||t>=bottom){next.push(r);continue;} 9 next.push({left:r.left,top:r.top,right:l,bottom:r.bottom},{left:right,top:r.top,right:r.right,bottom:r.bottom}, 10 {left:r.left,top:r.top,right:r.right,bottom:t},{left:r.left,top:bottom,right:r.right,bottom:r.bottom}); 11 } 12 rectangles=next.filter(r=>r.right-r.left>16&&r.bottom-r.top>16).sort((a,b)=>(b.right-b.left)*(b.bottom-b.top)-(a.right-a.left)*(a.bottom-a.top)).slice(0,64); 13 } 14 return rectangles[0]||null; 15} 16export function viewingPose(destination,{width,height,fov,clear},eye=1.62){ 17 const zone=destination.zone;if(!zone||!clear||width<=0||height<=0)return null; 18 const tan=Math.tan(fov*Math.PI/360),aspect=width/height,[photoWidth,photoHeight]=destination.placement.profile.aperture; 19 const usableWidth=(clear.right-clear.left)/width,usableHeight=(clear.bottom-clear.top)/height; 20 const required=Math.max(photoWidth/(2*tan*aspect*usableWidth*.9),photoHeight/(2*tan*usableHeight*.9))+destination.placement.profile.depth/2; 21 const distance=clamp(Math.max(required,Math.hypot(destination.point.x-zone.origin.x,destination.point.z-zone.origin.z)),zone.near,zone.far); 22 const point={x:zone.origin.x+Math.sin(zone.rotation)*distance,y:zone.origin.y,z:zone.origin.z+Math.cos(zone.rotation)*distance}; 23 const target=destination.target,dx=point.x-target.x,dz=point.z-target.z; 24 const ndcX=(clear.left+clear.right)/width-1,ndcY=1-(clear.top+clear.bottom)/height; 25 const yaw=Math.atan2(dx,dz)+Math.atan(ndcX*tan*aspect); 26 const pitch=clamp(Math.atan2(target.y-(point.y+eye),Math.hypot(dx,dz))-Math.atan(ndcY*tan),-.75,.65); 27 return {point,yaw,pitch,constrained:required>zone.far}; 28}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.