/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{e as t,p as r,v as s,r as o,g as n}from"./p-DfdVaPrt.js";class i{constructor(r,s){this.width=r;this.height=s;this.center=t.center(this.dimensions)}static fromDimensions(t){return new i(t.width,t.height)}transformNdcPointToViewport(t){return r.create(t.x*this.center.x+this.center.x,-t.y*this.center.y+this.center.y)}transformVectorToViewport(t){return this.transformNdcPointToViewport(t)}transformWorldToViewport(t,r){const o=s.transformMatrix(t,r);return this.transformVectorToViewport(o)}transformPointToViewport(t,s){const{x:o,y:n}=this.calculateFrameScale(s);return r.scale(t,1*o,1*n)}transformPointToFrame(t,s){const{x:o,y:n}=this.calculateFrameScale(s);return r.scale(t,1/o,1/n)}transformPointToWorldSpace(t,r,s){const o=this.transformPointToFrame(t,r);const n=this.transformPointToRay(t,r,r.camera);return r.getWorldPoint(o,n,s)}transformPointToRay(t,r,n){const i=this.transformScreenPointToNdc(t,r);if(n.isPerspective()){const t=s.fromMatrixPosition(n.worldMatrix);const r=s.transformNdcToWorldSpace(s.create(i.x,i.y,.5),n.worldMatrix,n.projectionMatrixInverse);const e=s.normalize(s.subtract(r,t));return o.create({origin:t,direction:e})}else{const t=s.transformNdcToWorldSpace(s.create(i.x,i.y,0),n.worldMatrix,n.projectionMatrixInverse);return o.create({origin:t,direction:s.normalize(n.viewVector)})}}transformScreenPointToNdc(t,s){const o=this.transformPointToFrame(t,s);return r.create(o.x/s.imageAttr.frameDimensions.width*2-1,-(o.y/s.imageAttr.frameDimensions.height)*2+1)}calculateDrawRect(t){const{x:r,y:s}=this.calculateFrameScale(t);return n.scale(t.imageAttr.imageRect,r,s)}calculateFrameScale(t){const{frameDimensions:s}=t.imageAttr;const o=n.fromDimensions(s);const i=n.fromDimensions(this.dimensions);const e=n.containFit(i,o);const c=e.width/o.width;const a=e.height/o.height;return r.create(c,a)}get dimensions(){return t.create(this.width,this.height)}}export{i as V};
//# sourceMappingURL=p-Dn7vK758.js.map