How to use the FogExp2 function from three

Find comprehensive JavaScript three.FogExp2 code examples handpicked from public code repositorys.

28
29
30
31
32
33
34
35
36
37
camera.position.set(0, 45, 240);
controls = new OrbitControls(camera, renderer.domElement);
controls.maxDistance = 500;

scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0, 0.00255 );

var SIZE = {x: Math.max(window.innerHeight, window.innerWidth) / 2, y: 30}

function createLines() {
fork icon40
star icon163
watch icon13

47
48
49
50
51
52
53
54
55

var background = 0x000000;
this.renderer.setClearColor(background, 1);

this.scene = new THREE.Scene();
this.scene.fog = new THREE.FogExp2(background);

var directionalLight1 = new THREE.DirectionalLight(0xFFFFFF, 1.2);
directionalLight1.position.set(0.2, 0.2, -1).normalize();
fork icon17
star icon78
watch icon8

+ 20 other calls in file

176
177
178
179
180
181
182
183
184
185
this.camera = new THREE.PerspectiveCamera(this.cameraDefaults.fov, this.aspectRatio, this.cameraDefaults.near, this.cameraDefaults.far);
this.resetCamera();
// world
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(0xffffff);
// this.scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 );

//坐标轴辅助
var helper = new THREE.GridHelper(1200, 10, 0xFF4444, 0x404040);
this.scene.add(helper);
fork icon13
star icon28
watch icon7

65
66
67
68
69
70
71
72
73
74
```javascript
var scene = new THREE.Scene();
```
定义完Scene后,我们可以设置Scene的Fog属性,来营造烟雾效果。即离得越远的物品可见度越低。
```javascript
scene.fog = new THREE.FogExp2(0x000000, 0.0025);
```
之后所有的物件都会被Add到Scene之上:
```
scene.add(someObject);
fork icon16
star icon20
watch icon3

450
451
452
453
454
455
456
457
458
459
460
    allScenes.push(icosahedronScene);
}


function initializeStarField(framework) {
    var scene = new THREE.Scene();
    scene.fog = new THREE.FogExp2( 0x000000, 0.0007 );
    var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 2000);
    camera.position.set(1, 1, -100);
    camera.lookAt(new THREE.Vector3(0,0,0));
    var controls = new OrbitControls(camera, framework.renderer.domElement);
fork icon14
star icon4
watch icon0

+ 5 other calls in file

43
44
45
46
47
48
49
50
51
52

camera = new THREE.PerspectiveCamera( 25, SCREEN_WIDTH / SCREEN_HEIGHT, 50, 1e7 );
camera.position.z = radius * 5;

scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.00000025 );

controls = new THREE.FlyControls( camera );

controls.movementSpeed = 1000;
fork icon0
star icon3
watch icon5

29
30
31
32
33
34
35
36
37
38
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 1200;
scene = new THREE.Scene();

scene.fog = new THREE.FogExp2( 0x000000, 0.0008 );
geometry = new THREE.Geometry();

var textureLoader = new THREE.TextureLoader();
sprite1 = textureLoader.load( "/images/sprite1.png" );
fork icon0
star icon1
watch icon0

72
73
74
75
76
77
78
79
80
81
_renderer.shadowMap.type = THREE.PCFSoftShadowMap;
_renderer.shadowMap.enabled = true;
document.body.appendChild(_renderer.domElement);

_scene = new THREE.Scene();
_scene.fog = new THREE.FogExp2( settings.bgColor, 0.001 );

_camera = new THREE.PerspectiveCamera( 45, 1, 10, 3000);
_camera.position.set(300, 60, 300).normalize().multiplyScalar(1000);
settings.camera = _camera;
fork icon0
star icon0
watch icon0

+ 2 other calls in file

153
154
155
156
157
158
159
160
161
162
renderer.setClearColor('#0a0a0a', 1);
renderer.setSize(width * resolution, height * resolution);
$viewport.append(renderer.domElement);

scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(parameters.fogColor, 0.01);

light = new THREE.DirectionalLight('#ffffff', 0.5);
light.position.set(0.2, 1, 0.5);
scene.add(light);
fork icon0
star icon0
watch icon0

38
39
40
41
42
43
44
45
46
47
renderer.setSize(WIDTH, HEIGHT)
renderer.shadowMap.enabled = true
renderer.shadowMap.type = THREE.PCFSoftShadowMap
document.body.appendChild(renderer.domElement)

scene.fog = new THREE.FogExp2(0xffffff, 0)

const plane = getPlane(40, 40)
plane.rotation.x = radiants(-90)
plane.receiveShadow = true
fork icon0
star icon0
watch icon4

+ 2 other calls in file

124
125
126
127
128
129
130
131
132
133
     var hhtemp = null;
     var btemp;

     var scene = new THREE.Scene();
     scene.background = new THREE.Color(0x6c768d);
     scene.fog = new THREE.FogExp2(0x6c768d, 0.012);

     var renderer = new THREE.WebGLRenderer({ antialias: true });
     renderer.setPixelRatio(window.devicePixelRatio);
     renderer.setSize(window.innerWidth, window.innerHeight);
fork icon0
star icon0
watch icon2

+ 12 other calls in file

104
105
106
107
108
109
110
111
112
113
osmRenderer.prototype.createScene = function () {
    // Scene, grey background, fog
    const scene = new THREE.Scene();

    scene.background = new THREE.Color(0xf0f0f0 );
    scene.fog = new THREE.FogExp2(0xf0f0f0, 0.001);

    // lights
    let light = new THREE.DirectionalLight( 0xffffff );
    light.position.set( 1, 1, 1 );
fork icon0
star icon0
watch icon2

+ 3 other calls in file

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)