cutechicken commited on
Commit
c6c5eb0
·
verified ·
1 Parent(s): 3132a78

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +27 -18
game.js CHANGED
@@ -326,20 +326,29 @@ class Game {
326
 
327
  async initialize() {
328
  try {
329
- // 안개 효과 조정
330
- this.scene.fog = new THREE.Fog(0xC2B280, 50, 250); // 안개 시작 거리를 늘리고 끝나는 거리도 증가
331
- this.scene.background = new THREE.Color(0x87CEEB); // 하늘색 배경
332
 
333
- const ambientLight = new THREE.AmbientLight(0xffffff, 1.0); // 주변광 강도 증가
 
334
  this.scene.add(ambientLight);
335
 
336
- const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2); // 태양광 강화
337
- directionalLight.position.set(50, 50, 50);
 
338
  directionalLight.castShadow = true;
339
- directionalLight.shadow.mapSize.width = 2048;
340
- directionalLight.shadow.mapSize.height = 2048;
 
 
 
341
  this.scene.add(directionalLight);
342
 
 
 
 
 
343
  // 사막 지형 생성
344
  const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 200, 200);
345
  const groundTexture = new THREE.TextureLoader().load('/textures/sand.jpg');
@@ -349,34 +358,34 @@ class Game {
349
  // 사막 재질 개선
350
  const groundMaterial = new THREE.MeshStandardMaterial({
351
  map: groundTexture,
352
- color: 0xD2B48C,
353
- roughness: 1.0,
354
- metalness: 0.0,
355
- bumpScale: 0.5
 
356
  });
357
 
358
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
359
  ground.rotation.x = -Math.PI / 2;
360
  ground.receiveShadow = true;
361
 
362
- // 사막 지형의 기복 추가
363
  const vertices = ground.geometry.attributes.position.array;
364
  let seed = Math.random() * 100;
365
  for (let i = 0; i < vertices.length; i += 3) {
366
- // Perlin noise를 사용한 자연스러운 높낮이
367
  const x = vertices[i] / 100;
368
  const y = vertices[i + 1] / 100;
369
  vertices[i + 2] =
370
- (Math.sin(x + seed) * Math.cos(y + seed) * 2.0) + // 언덕
371
- (Math.sin(x * 2 + seed) * Math.cos(y * 2 + seed) * 1.0) + // 중간 크기 언덕
372
- (Math.sin(x * 4 + seed) * Math.cos(y * 4 + seed) * 0.5); // 작은 모래 언덕
373
  }
374
  ground.geometry.attributes.position.needsUpdate = true;
375
  ground.geometry.computeVertexNormals();
376
 
377
  this.scene.add(ground);
378
 
379
- // 사막 장식물 추가
380
  await this.addDesertDecorations();
381
  await this.tank.initialize(this.scene, this.loader);
382
 
 
326
 
327
  async initialize() {
328
  try {
329
+ // 안개 효과를 더 멀리 설정하고 밝기 조정
330
+ this.scene.fog = new THREE.Fog(0xC2B280, 100, 500); // 안개 시작 거리와 거리를 늘림
331
+ this.scene.background = new THREE.Color(0x87CEEB);
332
 
333
+ // 주변광 강화
334
+ const ambientLight = new THREE.AmbientLight(0xffffff, 1.5); // 주변광 강도 증가
335
  this.scene.add(ambientLight);
336
 
337
+ // 태양광 설정 개선
338
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5); // 태양광 강도 증가
339
+ directionalLight.position.set(100, 100, 50);
340
  directionalLight.castShadow = true;
341
+ directionalLight.shadow.mapSize.width = 4096; // 그림자 해상도 증가
342
+ directionalLight.shadow.mapSize.height = 4096;
343
+ directionalLight.shadow.camera.near = 0.5;
344
+ directionalLight.shadow.camera.far = 500;
345
+ directionalLight.shadow.bias = -0.0001; // 그림자 아티팩트 감소
346
  this.scene.add(directionalLight);
347
 
348
+ // 보조 조명 추가
349
+ const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0xD2B48C, 1.0);
350
+ this.scene.add(hemisphereLight);
351
+
352
  // 사막 지형 생성
353
  const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 200, 200);
354
  const groundTexture = new THREE.TextureLoader().load('/textures/sand.jpg');
 
358
  // 사막 재질 개선
359
  const groundMaterial = new THREE.MeshStandardMaterial({
360
  map: groundTexture,
361
+ color: 0xDEB887, // 더 밝은 색상으로 변경
362
+ roughness: 0.8,
363
+ metalness: 0.1,
364
+ bumpScale: 0.3,
365
+ emissive: 0x222222, // 약간의 발광 효과 추가
366
  });
367
 
368
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
369
  ground.rotation.x = -Math.PI / 2;
370
  ground.receiveShadow = true;
371
 
372
+ // 지형의 기복 추가 (더 낮은 높이로 조정)
373
  const vertices = ground.geometry.attributes.position.array;
374
  let seed = Math.random() * 100;
375
  for (let i = 0; i < vertices.length; i += 3) {
 
376
  const x = vertices[i] / 100;
377
  const y = vertices[i + 1] / 100;
378
  vertices[i + 2] =
379
+ (Math.sin(x + seed) * Math.cos(y + seed) * 1.0) + // 낮은 언덕
380
+ (Math.sin(x * 2 + seed) * Math.cos(y * 2 + seed) * 0.5) +
381
+ (Math.sin(x * 4 + seed) * Math.cos(y * 4 + seed) * 0.25);
382
  }
383
  ground.geometry.attributes.position.needsUpdate = true;
384
  ground.geometry.computeVertexNormals();
385
 
386
  this.scene.add(ground);
387
 
388
+ // 나머지 초기화 코드...
389
  await this.addDesertDecorations();
390
  await this.tank.initialize(this.scene, this.loader);
391