I'm trying to add fog to my scene but it just won't render?
I have done some searching but there seem to be no answer to my problem. Here is a screenshot of the problem

This is the code demo: https://jsfiddle.net/7orbmn4t/
var scene = new THREE.Scene();
scene.background = new THREE.Color(0xcce0ff);
scene.fog = new THREE.Fog(0xff0000, 10, 500);
var camera = new THREE.PerspectiveCamera(
90,
window.innerWidth / window.innerHeight,
0.1,
1000
);
camera.rotation.x = 0.7853;
camera.position.set(0, 0, 15);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
scene.add( new THREE.AmbientLight( 0xffffff ) );
var geometry = new THREE.PlaneBufferGeometry(100, 100, 0);
var material = new THREE.MeshLambertMaterial({
color: 0x898989,
fog: true
});
var plane = new THREE.Mesh(geometry, material);
scene.add(plane);
renderer.render(scene, camera);
document.body.appendChild(renderer.domElement);
The fog flag in a material only specifies if the material is affected by fog: material.fog
It doesn't create fog. To do that, you need to create fog first: Fog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With