|
82 | 82 |
|
83 | 83 | // CONTROLS
|
84 | 84 |
|
85 |
| - var fly = false; |
| 85 | + controls = new THREE.TrackballControls( camera ); |
86 | 86 |
|
87 |
| - if ( !fly ) { |
| 87 | + controls.rotateSpeed = 1.0; |
| 88 | + controls.zoomSpeed = 1.2; |
| 89 | + controls.panSpeed = 0.8; |
88 | 90 |
|
89 |
| - controls = new THREE.TrackballControls( camera ); |
90 |
| - controls.target.set( 0, 0, 0 ); |
| 91 | + controls.noZoom = false; |
| 92 | + controls.noPan = false; |
91 | 93 |
|
92 |
| - controls.rotateSpeed = 1.0; |
93 |
| - controls.zoomSpeed = 1.2; |
94 |
| - controls.panSpeed = 0.8; |
95 |
| - |
96 |
| - controls.noZoom = false; |
97 |
| - controls.noPan = false; |
98 |
| - |
99 |
| - controls.staticMoving = false; |
100 |
| - controls.dynamicDampingFactor = 0.15; |
101 |
| - |
102 |
| - controls.keys = [ 65, 83, 68 ]; |
103 |
| - |
104 |
| - } else { |
105 |
| - |
106 |
| - controls = new THREE.FirstPersonControls( camera ); |
107 |
| - |
108 |
| - controls.movementSpeed = 25; |
109 |
| - controls.lookSpeed = 0.05; |
110 |
| - controls.lookVertical = true; |
111 |
| - |
112 |
| - controls.lon = -90; |
113 |
| - |
114 |
| - } |
| 94 | + controls.staticMoving = false; |
| 95 | + controls.dynamicDampingFactor = 0.15; |
115 | 96 |
|
| 97 | + controls.keys = [ 65, 83, 68 ]; |
116 | 98 |
|
117 | 99 | // TEXTURES
|
| 100 | + |
118 | 101 | var textureLoader = new THREE.TextureLoader();
|
119 | 102 |
|
120 | 103 | var texture = textureLoader.load( "textures/disturb.jpg" );
|
121 | 104 | texture.repeat.set( 20, 10 );
|
122 | 105 | texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
123 | 106 | texture.format = THREE.RGBFormat;
|
124 | 107 |
|
125 |
| - var texture2 = textureLoader.load( "textures/planets/moon_1024.jpg" ); |
126 |
| - texture2.repeat.set( 2, 1 ); |
127 |
| - texture2.wrapS = texture2.wrapT = THREE.RepeatWrapping; |
128 |
| - texture2.format = THREE.RGBFormat; |
129 |
| - |
130 | 108 | // MATERIALS
|
131 | 109 |
|
132 | 110 | var groundMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture } );
|
133 |
| - var objectMaterial = new THREE.MeshStandardMaterial( { color: 0x000000, map: texture2, roughness: 0.2, metalness: 1.0 } ); |
| 111 | + var objectMaterial = new THREE.MeshStandardMaterial( { color: 0xffffff, roughness: 0.5, metalness: 1.0 } ); |
134 | 112 |
|
135 | 113 | // GROUND
|
136 | 114 |
|
137 | 115 | var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 800, 400, 2, 2 ), groundMaterial );
|
138 |
| - mesh.position.y = -5; |
| 116 | + mesh.position.y = - 5; |
139 | 117 | mesh.rotation.x = - Math.PI / 2;
|
140 | 118 | scene.add( mesh );
|
141 | 119 |
|
|
164 | 142 |
|
165 | 143 | // LIGHTS
|
166 | 144 |
|
167 |
| - scene.add( new THREE.AmbientLight( 0x111111 ) ); |
168 |
| - |
169 | 145 | var intensity = 2.5;
|
170 | 146 | var distance = 100;
|
| 147 | + var decay = 2.0; |
| 148 | + |
171 | 149 | var c1 = 0xff0040, c2 = 0x0040ff, c3 = 0x80ff80, c4 = 0xffaa00, c5 = 0x00ffaa, c6 = 0xff1100;
|
172 |
| - //var c1 = 0xffffff, c2 = 0xffffff, c3 = 0xffffff, c4 = 0xffffff, c5 = 0xffffff, c6 = 0xffffff; |
173 | 150 |
|
174 | 151 | var sphere = new THREE.SphereGeometry( 0.25, 16, 8 );
|
175 | 152 |
|
176 |
| - light1 = new THREE.PointLight( c1, intensity, distance ); |
| 153 | + light1 = new THREE.PointLight( c1, intensity, distance, decay ); |
177 | 154 | light1.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c1 } ) ) );
|
178 | 155 | scene.add( light1 );
|
179 | 156 |
|
180 |
| - light2 = new THREE.PointLight( c2, intensity, distance ); |
| 157 | + light2 = new THREE.PointLight( c2, intensity, distance, decay ); |
181 | 158 | light2.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c2 } ) ) );
|
182 | 159 | scene.add( light2 );
|
183 | 160 |
|
184 |
| - light3 = new THREE.PointLight( c3, intensity, distance ); |
| 161 | + light3 = new THREE.PointLight( c3, intensity, distance, decay ); |
185 | 162 | light3.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c3 } ) ) );
|
186 | 163 | scene.add( light3 );
|
187 | 164 |
|
188 |
| - light4 = new THREE.PointLight( c4, intensity, distance ); |
| 165 | + light4 = new THREE.PointLight( c4, intensity, distance, decay ); |
189 | 166 | light4.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c4 } ) ) );
|
190 | 167 | scene.add( light4 );
|
191 | 168 |
|
192 |
| - light5 = new THREE.PointLight( c5, intensity, distance ); |
| 169 | + light5 = new THREE.PointLight( c5, intensity, distance, decay ); |
193 | 170 | light5.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c5 } ) ) );
|
194 | 171 | scene.add( light5 );
|
195 | 172 |
|
196 |
| - light6 = new THREE.PointLight( c6, intensity, distance ); |
| 173 | + light6 = new THREE.PointLight( c6, intensity, distance, decay ); |
197 | 174 | light6.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c6 } ) ) );
|
198 | 175 | scene.add( light6 );
|
199 | 176 |
|
200 |
| - var dlight = new THREE.DirectionalLight( 0xffffff, 0.1 ); |
201 |
| - dlight.position.set( 0.5, -1, 0 ).normalize(); |
| 177 | + var dlight = new THREE.DirectionalLight( 0xffffff, 0.05 ); |
| 178 | + dlight.position.set( 0.5, 1, 0 ).normalize(); |
202 | 179 | scene.add( dlight );
|
203 | 180 |
|
204 | 181 | // RENDERER
|
|
0 commit comments