雾隐藏Skybox(THREE.JS R76)

时间:2016-05-05 05:57:01

标签: javascript three.js skybox

我有一个相机留在的圆柱体。我有雾设置所以管的末端不可见 - 但是我希望通过圆柱的alpha地图侧可以看到天空盒。雾阻挡了能见度,我想知道需要做些什么来解决这个问题。

var POS_X = 0,
    POS_Y = 0,
    POS_Z = 0,
    FOV = 60,
    WIDTH = window.innerWidth,
    HEIGHT = window.innerHeight,
    NEAR = 1,
    FAR = 120000, //Camera Far Distance
    renderer = new THREE.WebGLRenderer({antialias:true}),

............

function addFog(){
    scene.fog = new THREE.Fog(0x000000, 100, 40000);
}

............

function addSkybox(){
    var materialArray = [],
        imgArray = ["skybox_right.jpg", "skybox_left.jpg",
        "skybox_front.jpg", "skybox_back.jpg",
        "skybox_top.jpg", "skybox_bottom.jpg"];

    for (var i = 0; i < 6; i++){
        materialArray.push( new THREE.MeshBasicMaterial({
            map: loader.load( imgArray[i] ),
            side: THREE.BackSide
        }));
    }

    var skyMat = new THREE.MeshFaceMaterial( materialArray ),
        skyGeo = new THREE.BoxGeometry( 100000, 100000, 100000, 1, 1, 1),
        sky = new THREE.Mesh(skyGeo, skyMat);

    sky.name="skybox";
    scene.add(sky);
}

1 个答案:

答案 0 :(得分:2)

您只需添加fog: false即可忽略雾效果。

for (var i = 0; i < 6; i++){
    materialArray.push( new THREE.MeshBasicMaterial({
        map: loader.load( imgArray[i] ),
        side: THREE.BackSide,
        fog: false
    }));
}