cutechicken commited on
Commit
c0b45d7
β€’
1 Parent(s): 9c345a3

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +24 -105
game.js CHANGED
@@ -853,74 +853,29 @@ class Game {
853
  this.scene.add(hemisphereLight);
854
 
855
  // μ§€ν˜• 생성 μˆ˜μ •
856
- const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100);
857
- const groundMaterial = new THREE.MeshStandardMaterial({
858
- color: 0xD2B48C,
859
- roughness: 0.8,
860
- metalness: 0.2,
861
- envMapIntensity: 1.0
862
- });
863
-
864
- const ground = new THREE.Mesh(groundGeometry, groundMaterial);
865
- ground.rotation.x = -Math.PI / 2;
866
- ground.receiveShadow = true;
867
-
868
- // μ§€ν˜• 높이 μ„€μ •
869
- const vertices = ground.geometry.attributes.position.array;
870
- const heightScale = 15;
871
- const baseFrequency = 0.008;
872
-
873
- // 평지 μ˜μ—­ μ •μ˜
874
- const flatlandRadius = MAP_SIZE * 0.3;
875
- const transitionZone = MAP_SIZE * 0.1;
876
-
877
- for (let i = 0; i < vertices.length; i += 3) {
878
- const x = vertices[i];
879
- const y = vertices[i + 1];
880
-
881
- const distanceFromCenter = Math.sqrt(x * x + y * y);
882
-
883
- if (distanceFromCenter < flatlandRadius) {
884
- vertices[i + 2] = 0;
885
- }
886
- else if (distanceFromCenter < flatlandRadius + transitionZone) {
887
- const transitionFactor = (distanceFromCenter - flatlandRadius) / transitionZone;
888
- let height = 0;
889
-
890
- height += Math.sin(x * baseFrequency) * Math.cos(y * baseFrequency) * heightScale;
891
- height += Math.sin(x * baseFrequency * 2) * Math.cos(y * baseFrequency * 2) * (heightScale * 0.5);
892
- height += Math.sin(x * baseFrequency * 4) * Math.cos(y * baseFrequency * 4) * (heightScale * 0.25);
893
-
894
- vertices[i + 2] = height * transitionFactor;
895
- }
896
- else {
897
- let height = 0;
898
- height += Math.sin(x * baseFrequency) * Math.cos(y * baseFrequency) * heightScale;
899
- height += Math.sin(x * baseFrequency * 2) * Math.cos(y * baseFrequency * 2) * (heightScale * 0.5);
900
- height += Math.sin(x * baseFrequency * 4) * Math.cos(y * baseFrequency * 4) * (heightScale * 0.25);
901
- vertices[i + 2] = height;
902
- }
903
- }
904
-
905
- ground.geometry.attributes.position.needsUpdate = true;
906
- ground.geometry.computeVertexNormals();
907
- this.ground = ground;
908
- this.scene.add(ground);
909
-
910
- // λ“±κ³ μ„  효과
911
- const contourMaterial = new THREE.LineBasicMaterial({
912
- color: 0x000000,
913
- opacity: 0.15,
914
- transparent: true
915
- });
916
 
917
- const contourLines = new THREE.LineSegments(
918
- new THREE.EdgesGeometry(groundGeometry),
919
- contourMaterial
920
- );
921
- contourLines.rotation.x = -Math.PI / 2;
922
- contourLines.position.y = 0.1;
923
- this.scene.add(contourLines);
924
 
925
  // 격자 효과
926
  const gridHelper = new THREE.GridHelper(flatlandRadius * 2, 50, 0x000000, 0x000000);
@@ -1097,44 +1052,8 @@ class Game {
1097
  }
1098
 
1099
  getHeightAtPosition(x, z) {
1100
- if (!this.ground) return 0;
1101
-
1102
- // μ§€ν˜•μ˜ 정점 데이터
1103
- const vertices = this.ground.geometry.attributes.position.array;
1104
- const segmentsX = Math.sqrt(vertices.length / 3) - 1;
1105
- const segmentsZ = segmentsX;
1106
-
1107
- // 맡 μ’Œν‘œλ₯Ό μ§€ν˜• 격자 μ’Œν‘œλ‘œ λ³€ν™˜
1108
- const gridX = ((x + MAP_SIZE / 2) / MAP_SIZE) * segmentsX;
1109
- const gridZ = ((z + MAP_SIZE / 2) / MAP_SIZE) * segmentsZ;
1110
-
1111
- // κ°€μž₯ κ°€κΉŒμš΄ 격자점 μ°ΎκΈ°
1112
- const x1 = Math.floor(gridX);
1113
- const z1 = Math.floor(gridZ);
1114
- const x2 = Math.min(x1 + 1, segmentsX);
1115
- const z2 = Math.min(z1 + 1, segmentsZ);
1116
-
1117
- // κ²©μžμ λ“€μ˜ 높이 κ°€μ Έμ˜€κΈ°
1118
- const getHeight = (x, z) => {
1119
- if (x < 0 || x > segmentsX || z < 0 || z > segmentsZ) return 0;
1120
- const index = (z * (segmentsX + 1) + x) * 3 + 2;
1121
- return vertices[index];
1122
- };
1123
-
1124
- const h11 = getHeight(x1, z1);
1125
- const h21 = getHeight(x2, z1);
1126
- const h12 = getHeight(x1, z2);
1127
- const h22 = getHeight(x2, z2);
1128
-
1129
- // λ³΄κ°„μœΌλ‘œ μ •ν™•ν•œ 높이 계산
1130
- const fx = gridX - x1;
1131
- const fz = gridZ - z1;
1132
-
1133
- const h1 = h11 * (1 - fx) + h21 * fx;
1134
- const h2 = h12 * (1 - fx) + h22 * fx;
1135
-
1136
- return h1 * (1 - fz) + h2 * fz;
1137
- }
1138
 
1139
  findValidSpawnPosition() {
1140
  const margin = 50;
 
853
  this.scene.add(hemisphereLight);
854
 
855
  // μ§€ν˜• 생성 μˆ˜μ •
856
+ // μ§€ν˜• 생성 μˆ˜μ •
857
+ const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE);
858
+ const groundMaterial = new THREE.MeshStandardMaterial({
859
+ color: 0xD2B48C,
860
+ roughness: 0.8,
861
+ metalness: 0.2,
862
+ envMapIntensity: 1.0
863
+ });
864
+
865
+ const ground = new THREE.Mesh(groundGeometry, groundMaterial);
866
+ ground.rotation.x = -Math.PI / 2;
867
+ ground.receiveShadow = true;
868
+
869
+ // λͺ¨λ“  μ •μ μ˜ 높이λ₯Ό 0으둜 μ„€μ •
870
+ const vertices = ground.geometry.attributes.position.array;
871
+ for (let i = 0; i < vertices.length; i += 3) {
872
+ vertices[i + 2] = 0;
873
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
 
875
+ ground.geometry.attributes.position.needsUpdate = true;
876
+ ground.geometry.computeVertexNormals();
877
+ this.ground = ground;
878
+ this.scene.add(ground);
 
 
 
879
 
880
  // 격자 효과
881
  const gridHelper = new THREE.GridHelper(flatlandRadius * 2, 50, 0x000000, 0x000000);
 
1052
  }
1053
 
1054
  getHeightAtPosition(x, z) {
1055
+ return 0; // 항상 높이 0 λ°˜ν™˜
1056
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1057
 
1058
  findValidSpawnPosition() {
1059
  const margin = 50;