三人组的平原地形

Plain Terrain in ThreeJS

本文关键字:原地 三人组      更新时间:2023-09-26

我正在尝试使用 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 的球体。它显示得很好。

我错过了什么?

相机正在看飞机的"背面"。

平面有两条边,但只有一条是可见的。

两种解决方案:

1)移动相机看飞机的"正面":

this.camera.position.y = 100;

2) 或者,激活doubleSided标志:

plane.doubleSided = true;