Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在three.js中并行使用摄影机的视图偏移和缩放属性_Javascript_Three.js_Geometry_Trigonometry_Perspectivecamera - Fatal编程技术网

Javascript 如何在three.js中并行使用摄影机的视图偏移和缩放属性

Javascript 如何在three.js中并行使用摄影机的视图偏移和缩放属性,javascript,three.js,geometry,trigonometry,perspectivecamera,Javascript,Three.js,Geometry,Trigonometry,Perspectivecamera,我正试图用透视摄影机编写一个三点js场景。画布将显示整个摄影机视图的一个子区域,并具有缩放因子。我已经仔细检查了我的偏移量是否正确,缩放因子是否合理 在完全垂直适合他们 current zoom 1 x 714.4099378881989 y 0 w 3755.1801242236024 h 3888 当缩放为1时,偏移可以完美工作,但当缩放因子更改时,一切都会偏离轨道。缩放>1也可以按预期工作,没有视图偏移,并且以平截头体的中心为目标。我使用的是轨迹球控件,但它们不应该在这里使用,因为我是

我正试图用透视摄影机编写一个三点js场景。画布将显示整个摄影机视图的一个子区域,并具有缩放因子。我已经仔细检查了我的偏移量是否正确,缩放因子是否合理

在完全垂直适合他们

current zoom 1 
x 714.4099378881989 y 0 w 3755.1801242236024 h 3888
当缩放为1时,偏移可以完美工作,但当缩放因子更改时,一切都会偏离轨道。缩放>1也可以按预期工作,没有视图偏移,并且以平截头体的中心为目标。我使用的是
轨迹球控件
,但它们不应该在这里使用,因为我是通过编程设置所有值的

PerspectiveCamera
类中的三个摄像头更新功能是

    updateProjectionMatrix: function () {

        var near = this.near,
            top = near * Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,
            height = 2 * top,
            width = this.aspect * height,
            left = - 0.5 * width,
            view = this.view;

        if ( this.view !== null && this.view.enabled ) {

            var fullWidth = view.fullWidth,
                fullHeight = view.fullHeight;

            left += view.offsetX * width / fullWidth;
            top -= view.offsetY * height / fullHeight;
            width *= view.width / fullWidth;
            height *= view.height / fullHeight;

        }

        var skew = this.filmOffset;
        if ( skew !== 0 ) left += near * skew / this.getFilmWidth();

        this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );

        this.projectionMatrixInverse.getInverse( this.projectionMatrix );

    },
我最初的反应是fov是全视图,但应该针对子视图进行调整,或者我应该将缩放除以从子视图大小导出的某个因子,但我不确定从何处开始。

解决了这个问题

在我的更新功能中,我正在执行

    this.zoom = zoom;

    this.setViewOffset(
      full.w,
      full.h,
      offset.x,
      offset.y,
      offset.w,
      offset.h
    );

    this.controls.update();
但我需要做的是改变缩放,使其相对于偏移

this.zoom=zoom*(offset.h/full.h)