cutechicken commited on
Commit
2a18e50
β€’
1 Parent(s): 080df83

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +25 -12
game.js CHANGED
@@ -519,33 +519,46 @@ class Game {
519
  roughness: 0.8,
520
  metalness: 0.2
521
  });
522
-
523
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
524
  ground.rotation.x = -Math.PI / 2;
525
  ground.receiveShadow = true;
526
 
527
- // 더 μ™„λ§Œν•œ μ§€ν˜• 생성
528
  const vertices = ground.geometry.attributes.position.array;
529
- const heightScale = 10; // 높이 μŠ€μΌ€μΌ κ°μ†Œ
530
- const frequency = 0.005; // 주파수 κ°μ†Œλ‘œ 더 μ™„λ§Œν•œ 경사 생성
531
 
532
  for (let i = 0; i < vertices.length; i += 3) {
533
  const x = vertices[i];
534
  const y = vertices[i + 1];
535
- // Perlin λ…Έμ΄μ¦ˆμ™€ μœ μ‚¬ν•œ 효과λ₯Ό λ‚΄λŠ” μˆ˜μ •λœ μˆ˜μ‹
536
- vertices[i + 2] =
537
- (Math.sin(x * frequency) * Math.cos(y * frequency) * heightScale) +
538
- (Math.sin(x * frequency * 2) * Math.cos(y * frequency * 2) * heightScale * 0.5);
539
 
540
- // 맡 κ°€μž₯자리둜 갈수둝 높이λ₯Ό μ μ§„μ μœΌλ‘œ μ€„μž„
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  const distanceFromCenter = Math.sqrt(x * x + y * y) / (MAP_SIZE * 0.5);
542
- const edgeFactor = Math.max(0, 1 - distanceFromCenter);
543
- vertices[i + 2] *= edgeFactor;
 
 
544
  }
545
 
546
  ground.geometry.attributes.position.needsUpdate = true;
547
  ground.geometry.computeVertexNormals();
548
- this.ground = ground; // μ§€ν˜• μ°Έμ‘° μ €μž₯
549
  this.scene.add(ground);
550
 
551
  // 사막 μž₯식 μΆ”κ°€
 
519
  roughness: 0.8,
520
  metalness: 0.2
521
  });
 
522
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
523
  ground.rotation.x = -Math.PI / 2;
524
  ground.receiveShadow = true;
525
 
526
+ // 더 λ‹€μ–‘ν•œ μ§€ν˜• 생성
527
  const vertices = ground.geometry.attributes.position.array;
528
+ const heightScale = 15; // 높이 μŠ€μΌ€μΌ
529
+ const baseFrequency = 0.008; // 기본 주파수
530
 
531
  for (let i = 0; i < vertices.length; i += 3) {
532
  const x = vertices[i];
533
  const y = vertices[i + 1];
 
 
 
 
534
 
535
+ // μ—¬λŸ¬ 주파수λ₯Ό μ‘°ν•©ν•œ μ§€ν˜• 생성
536
+ let height = 0;
537
+
538
+ // 큰 언덕 (κΈ°λ³Έ μ§€ν˜•)
539
+ height += Math.sin(x * baseFrequency) * Math.cos(y * baseFrequency) * heightScale;
540
+
541
+ // 쀑간 크기 μ§€ν˜•
542
+ height += Math.sin(x * baseFrequency * 2) * Math.cos(y * baseFrequency * 2) * (heightScale * 0.5);
543
+
544
+ // μž‘μ€ ꡴곑
545
+ height += Math.sin(x * baseFrequency * 4) * Math.cos(y * baseFrequency * 4) * (heightScale * 0.25);
546
+
547
+ // 랜덀 λ…Έμ΄μ¦ˆ μΆ”κ°€ (μ•„μ£Ό μž‘μ€ ꡴곑)
548
+ const noise = (Math.random() - 0.5) * heightScale * 0.1;
549
+ height += noise;
550
+
551
+ // 맡 κ°€μž₯자리둜 갈수둝 높이λ₯Ό λΆ€λ“œλŸ½κ²Œ κ°μ†Œ
552
  const distanceFromCenter = Math.sqrt(x * x + y * y) / (MAP_SIZE * 0.5);
553
+ const edgeFactor = Math.pow(Math.max(0, 1 - distanceFromCenter), 2); // λΆ€λ“œλŸ¬μš΄ 감쇠
554
+
555
+ // μ΅œμ’… 높이 μ„€μ •
556
+ vertices[i + 2] = height * edgeFactor;
557
  }
558
 
559
  ground.geometry.attributes.position.needsUpdate = true;
560
  ground.geometry.computeVertexNormals();
561
+ this.ground = ground;
562
  this.scene.add(ground);
563
 
564
  // 사막 μž₯식 μΆ”κ°€