【问题标题】:Orthographic Frustum?正交平截头体?
【发布时间】:2015-06-02 09:27:57
【问题描述】:

当我使用透视相机检查点是否在平截头体内时,它可以工作。但是当我使用正交相机进行检查时,截锥体框显得不准确。平面设置正确。如果使用正交相机,我是否还忽略了其他需要更改的内容?

这是我设置飞机的方式..

    if((this.mouse.screenx>mouse.screen.x && this.mouse.screeny<mouse.screen.y)||
    (this.mouse.screenx<mouse.screen.x && this.mouse.screeny>mouse.screen.y)){
        topPlane.setFromCoplanarPoints(camera.position, topRight, topLeft  );
        rightPlane.setFromCoplanarPoints(camera.position, bottomRight, topRight  );
        bottomPlane.setFromCoplanarPoints(camera.position, bottomLeft,bottomRight  );
        leftPlane.setFromCoplanarPoints(camera.position, topLeft, bottomLeft  );
    }else{
        topPlane.setFromCoplanarPoints(camera.position, topLeft , topRight );
        rightPlane.setFromCoplanarPoints(camera.position, topRight , bottomRight );
        bottomPlane.setFromCoplanarPoints(camera.position,bottomRight , bottomLeft );
        leftPlane.setFromCoplanarPoints(camera.position, bottomLeft , topLeft );
    }
    nearPlane.setFromNormalAndCoplanarPoint(vector,camera.position);
    vector.set( 0, 0, 1 );
    vector.applyQuaternion( camera.quaternion );
    var vector2 = new THREE.Vector3( 0, 0, -config.camera.far );
    vector2.applyQuaternion( camera.quaternion );
    vector2.add(camera.position);
    farPlane.setFromNormalAndCoplanarPoint(vector,vector2);

【问题讨论】:

    标签: three.js orthographic frustum


    【解决方案1】:

    好的,我想通了。 我正在创建我的平面,以便它们从相机的位置延伸,但是,这会产生一个锥形的截锥体。 在正交模式下,没有锥度——一切都是直的,因此截锥平面不应该从相机延伸。

    我所做的是获取相机的方向:

        var vector = new THREE.Vector3( 0, 0, -1 );
        vector.applyQuaternion( camera.quaternion );
    

    然后我用它来创建每个平面——例如:

            var top = topRight.clone(), right = bottomRight.clone(), bottom = bottomLeft.clone(), left = topLeft.clone();
            top.add(vector), right.add(vector), bottom.add(vector), left.add(vector);
    
                topPlane.setFromCoplanarPoints(top, topLeft , topRight );
                rightPlane.setFromCoplanarPoints(right, topRight , bottomRight );
                bottomPlane.setFromCoplanarPoints(bottom,bottomRight , bottomLeft );
                leftPlane.setFromCoplanarPoints(left, bottomLeft , topLeft );
    

    我有它,所以截锥体可以倒置 - 所以一定要检查飞机是否面向正确的方向。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-28
      • 1970-01-01
      • 2015-01-31
      • 2011-07-16
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      相关资源
      最近更新 更多