【问题标题】:Plain Terrain in ThreeJSThreeJS中的平原地形
【发布时间】:2012-05-13 06:02:49
【问题描述】:

我正在尝试使用 ThreeJS 绘制平面地形,但它不起作用。

这是我的飞机创建代码:

var plane = new THREE.Mesh(new THREE.PlaneGeometry(300, 300), new THREE.MeshBasicMaterial({
        color: 0x0000ff
    }));
plane.overdraw = true;
this.scene.add(plane);

相当直接。其实我只是从某个网站复制的。

这是我初始化场景和相机的方式:

    this.camera =
        new THREE.PerspectiveCamera(
        45, // view angle
        width / height, // aspect
        0.1, // near
        10000); // far

    this.scene = new THREE.Scene();

    // add the camera to the scene
    this.scene.add(this.camera);

    // the camera starts at 0,0,0
    // so pull it back
    this.camera.position.z = 800;
    this.camera.position.y = -100;

我的中心还有一个半径为 20 的球体。它显示得很好。

我错过了什么?

【问题讨论】:

    标签: javascript three.js terrain


    【解决方案1】:

    相机正在观察飞机的“背面”。

    飞机有两个侧面,但只有一个是可见的。

    两种解决方案:

    1) 移动相机看平面的“正面”:

    this.camera.position.y = 100;
    

    2) 或者,激活doubleSided 标志:

    plane.doubleSided = true;
    

    【讨论】:

    • 谢谢。了解一些有用的东西;)
    猜你喜欢
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 2015-12-03
    • 2021-09-10
    • 2013-10-08
    • 1970-01-01
    相关资源
    最近更新 更多