You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
17 KiB
35 lines
17 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../../chunks/tslib.es6 ../../../core/Accessor ../../../core/Logger ../../../core/mathUtils ../../../core/screenUtils ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../core/libs/gl-matrix-2/math/mat4 ../../../core/libs/gl-matrix-2/factories/mat4f64 ../../../core/libs/gl-matrix-2/math/vec2 ../../../core/libs/gl-matrix-2/factories/vec2f64 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../chunks/vec42 ../../../core/libs/gl-matrix-2/factories/vec4f64 ../../../geometry/support/frustum ../../../geometry/support/ray ../../../geometry/support/vector ../../ViewingMode ../webgl-engine/lib/fov ../webgl-engine/lib/rendererUtils".split(" "), |
|
function(e,d,F,u,D,f,L,M,G,p,q,E,H,h,r,l,t,z,I,J,K,v,k){var A;d=A=class extends d{constructor(a){super(a);this._ray=I.create();this._viewport=t.fromValues(0,0,1,1);this._padding=t.fromValues(0,0,0,0);this._fov=55/180*Math.PI;this._nearFar=H.fromValues(1,1E3);this._viewDirty=!0;this._viewMatrix=q.create();this._viewProjectionDirty=!0;this._viewProjectionMatrix=q.create();this._viewInverseTransposeMatrixDirty=!0;this._viewInverseTransposeMatrix=q.create();this._frustumDirty=!0;this._frustum=z.create(); |
|
this._fullViewport=t.create();this._pixelRatio=1;this.column=this.row=0;this._columns=this._rows=1;this._center=r.create();this._up=r.create();this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(a){this._pixelRatio=0<a?a:1}get rows(){return this._rows}set rows(a){this._rows=Math.max(1,a)}get columns(){return this._columns}set columns(a){this._columns=Math.max(1,a)}get eye(){return this._ray.origin}set eye(a){this._compareAndSetView(a,this._ray.origin)}get center(){return this._center}set center(a){this._compareAndSetView(a, |
|
this._center,"_center")}get ray(){h.subtract(this._ray.direction,this.center,this.eye);return this._ray}get up(){return this._up}set up(a){this._compareAndSetView(a,this._up,"_up")}get viewMatrix(){this._ensureViewClean();return this._viewMatrix}set viewMatrix(a){p.copy(this._viewMatrix,a);this.notifyChange("_viewMatrix");this._viewDirty=!1;this._frustumDirty=this._viewProjectionDirty=this._viewInverseTransposeMatrixDirty=!0}get viewForward(){this._ensureViewClean();return h.set(r.create(),-this._viewMatrix[2], |
|
-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){this._ensureViewClean();return h.set(r.create(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){this._ensureViewClean();return h.set(r.create(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(a){this._nearFar[0]!==a&&(this._nearFar[0]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(a){this._nearFar[1]!== |
|
a&&(this._nearFar[1]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(a){this.x=a[0];this.y=a[1];this.width=a[2];this.height=a[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const a=l.scale(t.create(),this._viewport,1/this.pixelRatio),b=this._get("screenViewport");return b&&l.equals(a,b)?b:a}get screenPadding(){if(1===this.pixelRatio)return this._padding;const a=l.scale(t.create(),this._padding, |
|
1/this.pixelRatio),b=this._get("screenPadding");return b&&l.equals(a,b)?b:a}get x(){return this._viewport[0]}set x(a){a+=this._padding[k.PaddingSide.LEFT];this._viewport[0]!==a&&(this._viewport[0]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(a){a+=this._padding[k.PaddingSide.BOTTOM];this._viewport[1]!==a&&(this._viewport[1]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(a){this._viewport[2]!== |
|
a&&(this._viewport[2]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(a){this._viewport[3]!==a&&(this._viewport[3]=a,this._frustumDirty=this._viewProjectionDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[k.PaddingSide.RIGHT]+this._padding[k.PaddingSide.LEFT]}set fullWidth(a){this.width=a-(this._padding[k.PaddingSide.RIGHT]+this._padding[k.PaddingSide.LEFT])}get fullHeight(){return this._viewport[3]+ |
|
this._padding[k.PaddingSide.TOP]+this._padding[k.PaddingSide.BOTTOM]}set fullHeight(a){this.height=a-(this._padding[k.PaddingSide.TOP]+this._padding[k.PaddingSide.BOTTOM])}get fullViewport(){this._fullViewport[0]=this._viewport[0]-this._padding[k.PaddingSide.LEFT];this._fullViewport[1]=this._viewport[1]-this._padding[k.PaddingSide.BOTTOM];this._fullViewport[2]=this.fullWidth;this._fullViewport[3]=this.fullHeight;return this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(a){l.exactEquals(this._padding, |
|
a)||(this._viewport[0]+=a[k.PaddingSide.LEFT]-this._padding[k.PaddingSide.LEFT],this._viewport[1]+=a[k.PaddingSide.BOTTOM]-this._padding[k.PaddingSide.BOTTOM],this._viewport[2]-=a[k.PaddingSide.RIGHT]+a[k.PaddingSide.LEFT]-(this._padding[k.PaddingSide.RIGHT]+this._padding[k.PaddingSide.LEFT]),this._viewport[3]-=a[k.PaddingSide.TOP]+a[k.PaddingSide.BOTTOM]-(this._padding[k.PaddingSide.TOP]+this._padding[k.PaddingSide.BOTTOM]),l.copy(this._padding,a),this._frustumDirty=this._viewProjectionDirty=!0, |
|
this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){this._viewProjectionDirty&&(p.multiply(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1);return this._viewProjectionMatrix}get projectionMatrix(){return this._projectionMatrixInternal}get inverseProjectionMatrix(){return p.invert(q.create(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||q.create()}get fov(){return this._fov}set fov(a){this._fov=a;this._frustumDirty= |
|
this._viewProjectionDirty=!0}get fovX(){return v.fovd2fovx(this._fov,this.width,this.height)}set fovX(a){this._fov=v.fovx2fovd(a,this.width,this.height);this._frustumDirty=this._viewProjectionDirty=!0}get fovY(){return v.fovd2fovy(this._fov,this.width,this.height)}set fovY(a){this._fov=v.fovy2fovd(a,this.width,this.height);this._frustumDirty=this._viewProjectionDirty=!0}get distance(){return h.distance(this.center,this.eye)}get frustum(){this._recomputeFrustum();return this._frustum}get viewInverseTransposeMatrix(){if(this._viewInverseTransposeMatrixDirty|| |
|
this._viewDirty)p.invert(this._viewInverseTransposeMatrix,this.viewMatrix),p.transpose(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1;return this._viewInverseTransposeMatrix}depthNDCToWorld(a){return 2*this.near*this.far/(this.far+this.near-(2*a-1)*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!= |
|
this.relativeElevation&&0<=this.relativeElevation}get _projectionMatrixInternal(){var a=this.width,b=this.height,c=this.near*Math.tan(this.fovY/2)*2,n=c*this._aspect,w=c/this.rows,x=n/this.columns;n=-n/2+this.column*x;x=n+x;c=-c/2+this.row*w;w=c+w;a=p.frustum(q.create(),n*(1+2*this._padding[k.PaddingSide.LEFT]/a),x*(1+2*this._padding[k.PaddingSide.RIGHT]/a),c*(1+2*this._padding[k.PaddingSide.BOTTOM]/b),w*(1+2*this._padding[k.PaddingSide.TOP]/b),this.near,this.far);return(b=this._get("projectionMatrix"))&& |
|
p.equals(b,a)?b:a}copyFrom(a){h.copy(this._ray.origin,a.eye);this.center=a.center;this.up=a.up;l.copy(this._viewport,a.viewport);this.notifyChange("_viewport");l.copy(this._padding,a.padding);this.notifyChange("_padding");E.copy(this._nearFar,a.nearFar);this.notifyChange("_nearFar");this._fov=a.fov;this.row=a.row;this.column=a.column;this.rows=a.rows;this.columns=a.columns;this.relativeElevation=a.relativeElevation;this._viewDirty=a._viewDirty;this._viewDirty||(p.copy(this._viewMatrix,a.viewMatrix), |
|
this.notifyChange("_viewMatrix"));this._viewProjectionDirty=!0;this._frustumDirty=a._frustumDirty;this._frustumDirty||(z.copy(this._frustum,a.frustum),this._frustumDirty=!1);a._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(p.copy(this._viewInverseTransposeMatrix,a.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1);l.copy(this._fullViewport,a.fullViewport);this.pixelRatio=a.pixelRatio;return this}copyViewFrom(a){this.eye=a.eye;this.center=a.center;this.up= |
|
a.up}clone(){return(new A).copyFrom(this)}equals(a){return h.exactEquals(this.eye,a.eye)&&h.exactEquals(this.center,a.center)&&h.exactEquals(this.up,a.up)&&l.exactEquals(this._viewport,a.viewport)&&l.exactEquals(this._padding,a.padding)&&E.exactEquals(this.nearFar,a.nearFar)&&this._fov===a.fov&&this.pixelRatio===a.pixelRatio&&this.relativeElevation===a.relativeElevation&&this.row===a.row&&this.column===a.column&&this.rows===a.rows&&this.columns===a.columns}almostEquals(a){var b=Math.max(1,1/this.pixelRatio, |
|
1/a.pixelRatio);if(.001<=Math.abs(a.fov-this._fov)||l.squaredDistance(a.screenPadding,this.screenPadding)>=b||l.squaredDistance(this.screenViewport,a.screenViewport)>=b||this.row!==a.row||this.column!==a.column||this.rows!==a.rows||this.columns!==a.columns)return!1;h.sub(m,a.eye,a.center);h.sub(B,this.eye,this.center);b=h.dot(m,B);const c=h.sqrLen(m),n=h.sqrLen(B);return b*b>=(1-1E-10)*c*n&&h.sqrDist(a.eye,this.eye)<2.5E-7*Math.max(c,n)}computeRenderPixelSizeAt(a){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(a))}computeRenderPixelSizeAtDist(a){return a* |
|
this.perRenderPixelRatio}computeScreenPixelSizeAt(a){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(a))}_viewDirectionDistance(a){return Math.abs(J.projectPointSignedLength(this.viewForward,h.subtract(m,a,this.eye)))}computeScreenPixelSizeAtDist(a){return a*this.perScreenPixelRatio}computeDistanceFromRadius(a,b){return a/Math.tan(Math.min(this.fovX,this.fovY)/(2*(b||1)))}getScreenCenter(a=D.createScreenPointArray()){a[0]=(this.padding[k.PaddingSide.LEFT]+this.width/2)/this.pixelRatio; |
|
a[1]=(this.padding[k.PaddingSide.TOP]+this.height/2)/this.pixelRatio;return a}getRenderCenter(a,b=.5,c=.5){a[0]=this.padding[k.PaddingSide.LEFT]+this.width*b;a[1]=this.padding[k.PaddingSide.BOTTOM]+this.height*c;a[2]=.5;return a}setGLViewport(a){const b=this.viewport,c=this.padding;a.setViewport(b[0]-c[3],b[1]-c[2],b[2]+c[1]+c[3],b[3]+c[0]+c[2])}applyProjection(a,b){a!==g&&h.copy(g,a);g[3]=1;l.transformMat4(g,g,this.projectionMatrix);a=Math.abs(g[3]);h.scale(g,g,1/a);const c=this.fullViewport;b[0]= |
|
u.lerp(0,c[0]+c[2],.5+.5*g[0]);b[1]=u.lerp(0,c[1]+c[3],.5+.5*g[1]);b[2]=.5*(g[2]+1);b[3]=a}unapplyProjection(a,b){const c=this.fullViewport;g[0]=(a[0]/(c[0]+c[2])*2-1)*a[3];g[1]=(a[1]/(c[1]+c[3])*2-1)*a[3];g[2]=(2*a[2]-1)*a[3];g[3]=a[3];null!=this.inverseProjectionMatrix&&(l.transformMat4(g,g,this.inverseProjectionMatrix),b[0]=g[0],b[1]=g[1],b[2]=g[2])}projectToScreen(a,b){this.projectToRenderScreen(a,C);this.renderToScreen(C,b);return b}projectToRenderScreen(a,b){g[0]=a[0];g[1]=a[1];g[2]=a[2];g[3]= |
|
1;l.transformMat4(g,g,this.viewProjectionMatrix);if(0===g[3])return null;a=g;h.scale(a,a,1/Math.abs(g[3]));var c=this.fullViewport;const n=u.lerp(0,c[0]+c[2],.5+.5*a[0]);c=u.lerp(0,c[1]+c[3],.5+.5*a[1]);"x"in b?(b.x=n,b.y=c):(b[0]=n,b[1]=c,2<b.length&&(b[2]=.5*(a[2]+1)));return b}unprojectFromScreen(a,b){return this.unprojectFromRenderScreen(this.screenToRender(a,C),b)}unprojectFromRenderScreen(a,b){p.multiply(y,this.projectionMatrix,this.viewMatrix);if(!p.invert(y,y))return null;const c=this.fullViewport; |
|
g[0]=2*(a[0]-c[0])/c[2]-1;g[1]=2*(a[1]-c[1])/c[3]-1;g[2]=2*a[2]-1;g[3]=1;l.transformMat4(g,g,y);if(0===g[3])return null;b[0]=g[0]/g[3];b[1]=g[1]/g[3];b[2]=g[2]/g[3];return b}constrainWindowSize(a,b,c,n){a*=this.pixelRatio;b*=this.pixelRatio;return[Math.round(Math.max(a-c/2,0)),Math.round(Math.max(this.fullHeight-b-n/2,0)),Math.round(c- -Math.min(a-c/2,0)- -Math.min(this.fullWidth-a-c/2,0)),Math.round(n- -Math.min(this.fullHeight-b-n/2,0)- -Math.min(b-n/2,0))]}computeUp(a){a===K.ViewingMode.Global? |
|
this._computeUpGlobal():this._computeUpLocal()}screenToRender(a,b){const c=this.fullHeight-a[1]*this.pixelRatio;b[0]=a[0]*this.pixelRatio;b[1]=c;return b}renderToScreen(a,b){const c=(this.fullHeight-a[1])/this.pixelRatio;b[0]=a[0]/this.pixelRatio;b[1]=c}_computeUpGlobal(){h.subtract(m,this.center,this.eye);const a=h.length(this.center);1>a?(h.set(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(h.dot(m,this.center))>.9999*h.length(m)*a||(h.cross(this._up,m,this.center),h.cross(this._up, |
|
this._up,m),h.normalize(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){h.direction(m,this.eye,this.center);.9999>=Math.abs(m[2])&&(h.scale(m,m,m[2]),h.set(this._up,-m[0],-m[1],1-m[2]),h.normalize(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(a,b,c=""){"number"===typeof a[0]&&isFinite(a[0])&&"number"===typeof a[1]&&isFinite(a[1])&&"number"===typeof a[2]&&isFinite(a[2])?h.exactEquals(a,b)||(h.copy(b,a),this._markViewDirty(), |
|
c.length&&this.notifyChange(c)):F.getLogger("esri.views.3d.webgl-engine.lib.RenderCamera").warn("RenderCamera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewProjectionDirty=this._frustumDirty=this._viewDirty=!0}_recomputeFrustum(){this._frustumDirty&&(z.fromMatrix(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(p.lookAt(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty= |
|
!1,this._viewInverseTransposeMatrixDirty=!0)}};e.__decorate([f.property()],d.prototype,"_viewport",void 0);e.__decorate([f.property()],d.prototype,"_padding",void 0);e.__decorate([f.property()],d.prototype,"_fov",void 0);e.__decorate([f.property()],d.prototype,"_nearFar",void 0);e.__decorate([f.property()],d.prototype,"_viewDirty",void 0);e.__decorate([f.property()],d.prototype,"_viewMatrix",void 0);e.__decorate([f.property()],d.prototype,"_pixelRatio",void 0);e.__decorate([f.property()],d.prototype, |
|
"pixelRatio",null);e.__decorate([f.property()],d.prototype,"row",void 0);e.__decorate([f.property()],d.prototype,"column",void 0);e.__decorate([f.property()],d.prototype,"_rows",void 0);e.__decorate([f.property()],d.prototype,"rows",null);e.__decorate([f.property()],d.prototype,"_columns",void 0);e.__decorate([f.property()],d.prototype,"columns",null);e.__decorate([f.property()],d.prototype,"eye",null);e.__decorate([f.property()],d.prototype,"center",null);e.__decorate([f.property()],d.prototype, |
|
"_center",void 0);e.__decorate([f.property()],d.prototype,"up",null);e.__decorate([f.property()],d.prototype,"_up",void 0);e.__decorate([f.property()],d.prototype,"viewMatrix",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"viewForward",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"viewUp",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"viewRight",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"nearFar",null);e.__decorate([f.property()],d.prototype, |
|
"near",null);e.__decorate([f.property()],d.prototype,"far",null);e.__decorate([f.property()],d.prototype,"viewport",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"screenViewport",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"screenPadding",null);e.__decorate([f.property()],d.prototype,"x",null);e.__decorate([f.property()],d.prototype,"y",null);e.__decorate([f.property()],d.prototype,"width",null);e.__decorate([f.property()],d.prototype,"height",null);e.__decorate([f.property()], |
|
d.prototype,"fullWidth",null);e.__decorate([f.property()],d.prototype,"fullHeight",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"_aspect",null);e.__decorate([f.property()],d.prototype,"padding",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"projectionMatrix",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"inverseProjectionMatrix",null);e.__decorate([f.property()],d.prototype,"fov",null);e.__decorate([f.property()],d.prototype,"fovX",null);e.__decorate([f.property()], |
|
d.prototype,"fovY",null);e.__decorate([f.property()],d.prototype,"viewInverseTransposeMatrix",null);e.__decorate([f.property({readOnly:!0})],d.prototype,"_projectionMatrixInternal",null);e.__decorate([f.property()],d.prototype,"relativeElevation",void 0);e=d=A=e.__decorate([G.subclass("esri.views.3d.webgl.RenderCamera")],d);const g=t.create(),y=q.create(),m=r.create(),B=r.create(),C=D.createRenderScreenPointArray3();return e}); |