cutechicken commited on
Commit
02ae9d9
ยท
verified ยท
1 Parent(s): c6c5eb0

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +17 -24
game.js CHANGED
@@ -326,66 +326,59 @@ class Game {
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');
355
  groundTexture.wrapS = groundTexture.wrapT = THREE.RepeatWrapping;
356
- groundTexture.repeat.set(50, 50);
357
 
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
 
 
326
 
327
  async initialize() {
328
  try {
329
+ // ์•ˆ๊ฐœ ํšจ๊ณผ ์ œ๊ฑฐ
330
+ this.scene.fog = null;
331
  this.scene.background = new THREE.Color(0x87CEEB);
332
 
333
+ // ์ฃผ๋ณ€๊ด‘ ์„ค์ •
334
+ const ambientLight = new THREE.AmbientLight(0xffffff, 1.2);
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
+ // ์‚ฌ๋ง‰ ์žฌ์งˆ ์ตœ์ ํ™”
355
  const groundMaterial = new THREE.MeshStandardMaterial({
356
  map: groundTexture,
357
+ color: 0xDEB887,
358
  roughness: 0.8,
359
  metalness: 0.1,
360
+ bumpScale: 0.3
 
361
  });
362
 
363
  const ground = new THREE.Mesh(groundGeometry, groundMaterial);
364
  ground.rotation.x = -Math.PI / 2;
365
  ground.receiveShadow = true;
366
 
367
+ // ์ง€ํ˜•์˜ ๊ธฐ๋ณต ์ถ”๊ฐ€ (๋‹จ์ˆœํ™”)
368
  const vertices = ground.geometry.attributes.position.array;
369
  let seed = Math.random() * 100;
370
  for (let i = 0; i < vertices.length; i += 3) {
371
  const x = vertices[i] / 100;
372
  const y = vertices[i + 1] / 100;
373
  vertices[i + 2] =
374
+ (Math.sin(x + seed) * Math.cos(y + seed) * 1.0);
 
 
375
  }
376
  ground.geometry.attributes.position.needsUpdate = true;
377
  ground.geometry.computeVertexNormals();
378
 
379
  this.scene.add(ground);
380
 
381
+ // ๋‚˜๋จธ์ง€ ์ดˆ๊ธฐํ™” ์ฝ”๋“œ
382
  await this.addDesertDecorations();
383
  await this.tank.initialize(this.scene, this.loader);
384