cutechicken commited on
Commit
e239318
โ€ข
1 Parent(s): 6d9fb2e

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +16 -25
game.js CHANGED
@@ -331,48 +331,39 @@ class Game {
331
  this.scene.background = new THREE.Color(0x87CEEB);
332
 
333
  // ์ฃผ๋ณ€๊ด‘ ์„ค์ • - ๋” ๋ฐ๊ฒŒ
334
- const ambientLight = new THREE.AmbientLight(0xffffff, 1.8);
335
  this.scene.add(ambientLight);
336
 
337
- // ํƒœ์–‘๊ด‘ ์„ค์ • - ๊ทธ๋ฆผ์ž ํ’ˆ์งˆ ๋‚ฎ์ถค
338
- const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
339
  directionalLight.position.set(100, 100, 50);
340
  directionalLight.castShadow = true;
341
- directionalLight.shadow.mapSize.width = 1024; // ๊ทธ๋ฆผ์ž ํ•ด์ƒ๋„ ๋‚ฎ์ถค
342
  directionalLight.shadow.mapSize.height = 1024;
343
- directionalLight.shadow.camera.near = 0.5;
344
- directionalLight.shadow.camera.far = 500;
345
- directionalLight.shadow.bias = -0.001;
346
  this.scene.add(directionalLight);
347
 
348
- // ์‚ฌ๋ง‰ ์ง€ํ˜• ์ƒ์„ฑ
349
- const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100); // ์ง€ํ˜• ํ•ด์ƒ๋„ ๋‚ฎ์ถค
350
- const groundTexture = new THREE.TextureLoader().load('/textures/sand.jpg');
351
- groundTexture.wrapS = groundTexture.wrapT = THREE.RepeatWrapping;
352
- groundTexture.repeat.set(25, 25); // ํ…์Šค์ฒ˜ ๋ฐ˜๋ณต ํšŸ์ˆ˜ ๊ฐ์†Œ
353
-
354
- // ์‚ฌ๋ง‰ ์žฌ์งˆ์„ MeshBasicMaterial๋กœ ๋ณ€๊ฒฝ
355
- const groundMaterial = new THREE.MeshBasicMaterial({
356
- map: groundTexture,
357
- color: 0xDEB887 // ๋” ๋ฐ์€ ๋ฒ ์ด์ง€์ƒ‰
358
  });
359
 
360
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
361
  ground.rotation.x = -Math.PI / 2;
362
- ground.receiveShadow = false; // ๊ทธ๋ฆผ์ž ๋ฐ›์ง€ ์•Š๋„๋ก ์„ค์ •
363
 
364
  // ์ง€ํ˜•์˜ ๊ธฐ๋ณต ์ถ”๊ฐ€ (๋‹จ์ˆœํ™”)
365
  const vertices = ground.geometry.attributes.position.array;
366
  let seed = Math.random() * 100;
367
  for (let i = 0; i < vertices.length; i += 3) {
368
- const x = vertices[i] / 100;
369
- const y = vertices[i + 1] / 100;
370
- vertices[i + 2] =
371
- (Math.sin(x + seed) * Math.cos(y + seed) * 1.0);
372
  }
 
373
  ground.geometry.attributes.position.needsUpdate = true;
374
  ground.geometry.computeVertexNormals();
375
-
376
  this.scene.add(ground);
377
 
378
  // ๋‚˜๋จธ์ง€ ์ดˆ๊ธฐํ™” ์ฝ”๋“œ
@@ -390,10 +381,10 @@ class Game {
390
  tankPosition.z - 30
391
  );
392
  this.camera.lookAt(tankPosition);
393
-
394
  this.isLoading = false;
395
  document.getElementById('loading').style.display = 'none';
396
-
397
  this.animate();
398
  this.spawnEnemies();
399
  this.startGameTimer();
 
331
  this.scene.background = new THREE.Color(0x87CEEB);
332
 
333
  // ์ฃผ๋ณ€๊ด‘ ์„ค์ • - ๋” ๋ฐ๊ฒŒ
334
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
335
  this.scene.add(ambientLight);
336
 
337
+ // ํƒœ์–‘๊ด‘ ์„ค์ •
338
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
339
  directionalLight.position.set(100, 100, 50);
340
  directionalLight.castShadow = true;
341
+ directionalLight.shadow.mapSize.width = 1024;
342
  directionalLight.shadow.mapSize.height = 1024;
 
 
 
343
  this.scene.add(directionalLight);
344
 
345
+ // ์‚ฌ๋ง‰ ์ง€ํ˜• ์ƒ์„ฑ (ํ—ฌ๋ฆฌ์ฝฅํ„ฐ ๊ฒŒ์ž„ ์Šคํƒ€์ผ)
346
+ const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100);
347
+ const groundMaterial = new THREE.MeshStandardMaterial({
348
+ color: 0xD2B48C,
349
+ roughness: 0.8,
350
+ metalness: 0.2
 
 
 
 
351
  });
352
 
353
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
354
  ground.rotation.x = -Math.PI / 2;
355
+ ground.receiveShadow = true;
356
 
357
  // ์ง€ํ˜•์˜ ๊ธฐ๋ณต ์ถ”๊ฐ€ (๋‹จ์ˆœํ™”)
358
  const vertices = ground.geometry.attributes.position.array;
359
  let seed = Math.random() * 100;
360
  for (let i = 0; i < vertices.length; i += 3) {
361
+ vertices[i + 2] = Math.sin(vertices[i] * 0.01) * Math.cos(vertices[i + 1] * 0.01) * 20;
 
 
 
362
  }
363
+
364
  ground.geometry.attributes.position.needsUpdate = true;
365
  ground.geometry.computeVertexNormals();
366
+
367
  this.scene.add(ground);
368
 
369
  // ๋‚˜๋จธ์ง€ ์ดˆ๊ธฐํ™” ์ฝ”๋“œ
 
381
  tankPosition.z - 30
382
  );
383
  this.camera.lookAt(tankPosition);
384
+
385
  this.isLoading = false;
386
  document.getElementById('loading').style.display = 'none';
387
+
388
  this.animate();
389
  this.spawnEnemies();
390
  this.startGameTimer();