|
10 | 10 | background-color: #efd1b5; |
11 | 11 | color: #61443e; |
12 | 12 | } |
| 13 | + body, #container { |
| 14 | + overflow: hidden; |
| 15 | + } |
13 | 16 | a { |
14 | 17 | color: #a06851; |
15 | 18 | } |
|
40 | 43 | import Stats from 'three/addons/libs/stats.module.js'; |
41 | 44 | import { GUI } from './jsm/libs/lil-gui.module.min.js'; |
42 | 45 |
|
| 46 | + import { FirstPersonControls } from 'three/addons/controls/FirstPersonControls.js'; |
43 | 47 | import { ImprovedNoise } from 'three/addons/math/ImprovedNoise.js'; |
44 | 48 |
|
45 | 49 | let container, stats; |
|
53 | 57 |
|
54 | 58 | var params = { |
55 | 59 | "Fog type": "DensityFog", |
56 | | - "Fog color": "#efd1b5", |
| 60 | + "Fog color": "#b7dc50", |
57 | 61 | } |
58 | 62 |
|
59 | 63 | init(); |
|
63 | 67 |
|
64 | 68 | container = document.getElementById( 'container' ); |
65 | 69 |
|
66 | | - camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 ); |
| 70 | + camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 ); |
67 | 71 |
|
68 | 72 | scene = new THREE.Scene(); |
69 | 73 | scene.background = new THREE.Color(); |
70 | 74 |
|
71 | 75 | fogs = { |
72 | 76 | "RangeFog": new THREE.RangeFog(), |
73 | | - "DensityFog": new THREE.DensityFog(), |
74 | | - } |
| 77 | + "DensityFog": new THREE.DensityFog(undefined, 0.001, false), |
| 78 | + }; |
75 | 79 |
|
76 | 80 | setFogColor( params[ "Fog color" ] ); |
77 | 81 |
|
78 | 82 | var data = generateHeight( worldWidth, worldDepth ); |
79 | 83 |
|
80 | | - camera.position.y = data[ 0.5 * worldWidth + 0.5 * worldDepth * worldWidth ] * 10 + 500; |
| 84 | + camera.position.y = data[ 0.5 * worldWidth + 0.5 * worldDepth * worldWidth ] * 10 + 300; |
81 | 85 |
|
82 | 86 | var geometry = new THREE.PlaneGeometry( 7500, 7500, worldWidth - 1, worldDepth - 1 ); |
83 | 87 | geometry.rotateX( - Math.PI / 2 ); |
|
102 | 106 | renderer.setSize( window.innerWidth, window.innerHeight ); |
103 | 107 | container.appendChild( renderer.domElement ); |
104 | 108 |
|
| 109 | + controls = new FirstPersonControls( camera, renderer.domElement ); |
| 110 | + controls.movementSpeed = 100; |
| 111 | + controls.lookSpeed = 0.03; |
| 112 | + |
105 | 113 | stats = new Stats(); |
106 | 114 | container.appendChild( stats.dom ); |
107 | 115 |
|
|
121 | 129 | fogGuis = { |
122 | 130 | "RangeFog": gui.addFolder( "RangeFog" ), |
123 | 131 | "DensityFog": gui.addFolder( "DensityFog" ) |
124 | | - } |
| 132 | + }; |
125 | 133 |
|
126 | 134 | setFogType( params[ "Fog type" ] ); |
127 | 135 |
|
|
167 | 175 |
|
168 | 176 | renderer.setSize( window.innerWidth, window.innerHeight ); |
169 | 177 |
|
| 178 | + controls.handleResize(); |
| 179 | + |
170 | 180 | } |
171 | 181 |
|
172 | 182 | function generateHeight( width, height ) { |
|
271 | 281 |
|
272 | 282 | function render() { |
273 | 283 |
|
| 284 | + controls.update( clock.getDelta() ); |
274 | 285 | renderer.render( scene, camera ); |
275 | 286 |
|
276 | 287 | } |
|
0 commit comments