cutechicken commited on
Commit
4a2055b
โ€ข
1 Parent(s): 24ba110

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +30 -51
game.js CHANGED
@@ -1043,13 +1043,13 @@ class Game {
1043
  // ๊ธฐ๋ณธ ์”ฌ ์„ค์ •
1044
  this.setupScene();
1045
 
1046
- // ์•ˆ๊ฐœ ํšจ๊ณผ
1047
- this.scene.fog = new THREE.FogExp2(0x87CEEB, 0.0008);
1048
- this.scene.background = new THREE.Color(0x87CEEB);
1049
 
1050
  // ์กฐ๋ช… ์„ค์ •
1051
  // ์ฃผ๋ณ€๊ด‘
1052
- const ambientLight = new THREE.AmbientLight(0xffffff, 0.4);
1053
  this.scene.add(ambientLight);
1054
 
1055
  // ๋ฉ”์ธ ํƒœ์–‘๊ด‘
@@ -1072,52 +1072,31 @@ class Game {
1072
 
1073
  this.scene.add(mainLight);
1074
 
1075
- // ๋ณด์กฐ ํƒœ์–‘๊ด‘
1076
- const secondaryLight = new THREE.DirectionalLight(0xffffff, 0.3);
1077
  secondaryLight.position.set(-50, 50, -50);
1078
  this.scene.add(secondaryLight);
1079
 
1080
- // ํ™˜๊ฒฝ๊ด‘
1081
- const hemisphereLight = new THREE.HemisphereLight(
1082
- 0x87CEEB,
1083
- 0xFFE87C,
1084
- 0.3
1085
- );
1086
- this.scene.add(hemisphereLight);
1087
- // ์ง€ํ˜• ์ƒ์„ฑ
1088
- const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100);
1089
- const groundMaterial = new THREE.MeshStandardMaterial({
1090
- color: 0xD2B48C,
1091
- roughness: 0.8,
1092
- metalness: 0.2,
1093
- envMapIntensity: 1.0
1094
- });
1095
-
1096
- const ground = new THREE.Mesh(groundGeometry, groundMaterial);
1097
- ground.rotation.x = -Math.PI / 2;
1098
- ground.receiveShadow = true;
1099
-
1100
- // ์ง€ํ˜• ๋†’์ด ์„ค์ •
1101
- const vertices = ground.geometry.attributes.position.array;
1102
- for (let i = 0; i < vertices.length; i += 3) {
1103
- vertices[i + 2] = 0; // ๋ชจ๋“  ๋†’์ด๋ฅผ 0์œผ๋กœ ์„ค์ •
1104
  }
1105
-
1106
- ground.geometry.attributes.position.needsUpdate = true;
1107
- ground.geometry.computeVertexNormals();
1108
- this.ground = ground;
1109
- this.scene.add(ground);
1110
-
1111
- // ๊ฒฉ์ž ํšจ๊ณผ ์ถ”๊ฐ€
1112
- const gridHelper = new THREE.GridHelper(MAP_SIZE, 50, 0x000000, 0x000000);
1113
- gridHelper.material.opacity = 0.1;
1114
- gridHelper.material.transparent = true;
1115
- gridHelper.position.y = 0.1;
1116
- this.scene.add(gridHelper);
1117
-
1118
- // ์‚ฌ๋ง‰ ์žฅ์‹ ์ถ”๊ฐ€
1119
- await this.addDesertDecorations();
1120
-
1121
  // ํƒฑํฌ ์ดˆ๊ธฐํ™”
1122
  await this.tank.initialize(this.scene, this.loader);
1123
  if (!this.tank.isLoaded) {
@@ -1163,11 +1142,11 @@ class Game {
1163
  this.spawnEnemies();
1164
  this.startGameTimer();
1165
 
1166
- } catch (error) {
1167
- console.error('Game initialization error:', error);
1168
- this.handleLoadingError();
1169
- }
1170
- }
1171
 
1172
  // ๋ ˆ์ด๋” ์—…๋ฐ์ดํŠธ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
1173
  updateRadar() {
 
1043
  // ๊ธฐ๋ณธ ์”ฌ ์„ค์ •
1044
  this.setupScene();
1045
 
1046
+ // ์•ˆ๊ฐœ ํšจ๊ณผ (๋„์‹œ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์กฐ์ •)
1047
+ this.scene.fog = new THREE.FogExp2(0x888888, 0.002);
1048
+ this.scene.background = new THREE.Color(0x888888);
1049
 
1050
  // ์กฐ๋ช… ์„ค์ •
1051
  // ์ฃผ๋ณ€๊ด‘
1052
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); // ๋„์‹œ ํ™˜๊ฒฝ์„ ์œ„ํ•ด ๋ฐ๊ธฐ ์ฆ๊ฐ€
1053
  this.scene.add(ambientLight);
1054
 
1055
  // ๋ฉ”์ธ ํƒœ์–‘๊ด‘
 
1072
 
1073
  this.scene.add(mainLight);
1074
 
1075
+ // ๋ณด์กฐ ์กฐ๋ช… (๋„์‹œ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์กฐ์ •)
1076
+ const secondaryLight = new THREE.DirectionalLight(0xffffff, 0.5);
1077
  secondaryLight.position.set(-50, 50, -50);
1078
  this.scene.add(secondaryLight);
1079
 
1080
+ // ๋„์‹œ ๋งต ๋กœ๋“œ
1081
+ try {
1082
+ const cityMap = await this.loader.loadAsync('/models/map.glb');
1083
+ cityMap.scene.traverse((child) => {
1084
+ if (child.isMesh) {
1085
+ child.castShadow = true;
1086
+ child.receiveShadow = true;
1087
+ child.material.needsUpdate = true;
1088
+
1089
+ // ์ถฉ๋Œ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด obstacles ๋ฐฐ์—ด์— ์ถ”๊ฐ€
1090
+ if (child.geometry) {
1091
+ this.obstacles.push(child);
1092
+ }
1093
+ }
1094
+ });
1095
+ this.scene.add(cityMap.scene);
1096
+ } catch (error) {
1097
+ console.error('Error loading city map:', error);
 
 
 
 
 
 
1098
  }
1099
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1100
  // ํƒฑํฌ ์ดˆ๊ธฐํ™”
1101
  await this.tank.initialize(this.scene, this.loader);
1102
  if (!this.tank.isLoaded) {
 
1142
  this.spawnEnemies();
1143
  this.startGameTimer();
1144
 
1145
+ } catch (error) {
1146
+ console.error('Game initialization error:', error);
1147
+ this.handleLoadingError();
1148
+ }
1149
+ }
1150
 
1151
  // ๋ ˆ์ด๋” ์—…๋ฐ์ดํŠธ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
1152
  updateRadar() {