【问题标题】:How to adjust the Camera position so that objects can be viewed in enough size with three.js?如何调整相机位置,以便可以使用 three.js 以足够大小查看对象?
【发布时间】:2013-02-07 09:36:31
【问题描述】:

我制作了一个应用程序,它从外部文件中获取值来创建几何图形。我在这方面非常成功。默认情况下,我的对象以非常小的尺寸查看。但是当我尝试使用鼠标滚球时,我可以看到场景中的实际对象,因为它放大了场景。但是,当我的场景被实例化时,我怎么能获得这种大小的对象。

工作应用程序的链接:http://studenter.miun.se/~sagh0900/TrackBallAlt.Html

这是场景及其对象的缩放版本视图

【问题讨论】:

    标签: camera three.js


    【解决方案1】:

    您可以使用其中任何一个来获取网格的边界框或球体的大小。

    // This computes it.
    mesh.geometry.computeBoundingSphere();
    
    // This gets it
    var radius = mesh.geometry.boundingSphere.radius;
    
    
    // Compute the bounding box
    mesh.geometry.computeBoundingBox();
    
    // This now has a min and max structure with x and y values of the box
    mesh.geometry.boundingBox
    

    获得这些信息后,您可以设置摄像头,使物体在视野中​​。

    【讨论】:

      猜你喜欢
      • 2013-08-26
      • 2011-03-21
      • 2021-11-04
      • 1970-01-01
      • 2016-07-03
      • 2013-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多