Spaces:
Running
Running
cutechicken
commited on
Commit
โข
612e991
1
Parent(s):
fa41962
Update game.js
Browse files
game.js
CHANGED
@@ -444,7 +444,7 @@ class Game {
|
|
444 |
});
|
445 |
}
|
446 |
|
447 |
-
|
448 |
if (!this.tank.isLoaded) return;
|
449 |
|
450 |
const direction = new THREE.Vector3();
|
@@ -475,26 +475,30 @@ class Game {
|
|
475 |
this.tank.turretGroup.rotation.y = rotationAngle;
|
476 |
}
|
477 |
|
478 |
-
// ์นด๋ฉ๋ผ
|
479 |
const tankPos = this.tank.getPosition();
|
480 |
-
const cameraDistance =
|
481 |
-
const cameraHeight =
|
|
|
482 |
|
483 |
-
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
484 |
const tankRotation = this.tank.body.rotation.y;
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
Math.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
);
|
490 |
|
491 |
-
this.camera.
|
492 |
-
// ํฑํฌ์ ์๋จ์ ๋ฐ๋ผ๋ณด๋๋ก ์์
|
493 |
-
this.camera.lookAt(new THREE.Vector3(
|
494 |
-
tankPos.x,
|
495 |
-
tankPos.y + 2, // ํฑํฌ์ ์๋จ ๋ถ๋ถ์ ๋ฐ๋ผ๋ณด๋๋ก
|
496 |
-
tankPos.z
|
497 |
-
));
|
498 |
}
|
499 |
createBuildings() {
|
500 |
const buildingTypes = [
|
|
|
444 |
});
|
445 |
}
|
446 |
|
447 |
+
handleMovement() {
|
448 |
if (!this.tank.isLoaded) return;
|
449 |
|
450 |
const direction = new THREE.Vector3();
|
|
|
475 |
this.tank.turretGroup.rotation.y = rotationAngle;
|
476 |
}
|
477 |
|
478 |
+
// ์ฌ๊ธฐ๋ถํฐ ์นด๋ฉ๋ผ ๋ก์ง์ ์์ ํฉ๋๋ค
|
479 |
const tankPos = this.tank.getPosition();
|
480 |
+
const cameraDistance = 30; // ์นด๋ฉ๋ผ์ ํฑํฌ ์ฌ์ด์ ๊ฑฐ๋ฆฌ
|
481 |
+
const cameraHeight = 15; // ์นด๋ฉ๋ผ์ ๋์ด
|
482 |
+
const lookAtHeight = 5; // ์นด๋ฉ๋ผ๊ฐ ๋ฐ๋ผ๋ณด๋ ๋์ด
|
483 |
|
484 |
+
// ํฑํฌ์ ํ์ ์ ๋ฐ๋ผ ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
485 |
const tankRotation = this.tank.body.rotation.y;
|
486 |
+
|
487 |
+
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ ์์
|
488 |
+
this.camera.position.set(
|
489 |
+
tankPos.x - Math.sin(tankRotation) * cameraDistance,
|
490 |
+
tankPos.y + cameraHeight,
|
491 |
+
tankPos.z - Math.cos(tankRotation) * cameraDistance
|
492 |
+
);
|
493 |
+
|
494 |
+
// ์นด๋ฉ๋ผ๊ฐ ๋ฐ๋ผ๋ณด๋ ์ง์ ์ ํฑํฌ ์์น๋ณด๋ค ์ฝ๊ฐ ์์ชฝ์ผ๋ก ์ค์
|
495 |
+
const lookAtPoint = new THREE.Vector3(
|
496 |
+
tankPos.x + Math.sin(tankRotation) * 10, // ํฑํฌ ์์ชฝ 10 ์ ๋
|
497 |
+
tankPos.y + lookAtHeight, // ํฑํฌ๋ณด๋ค ์ฝ๊ฐ ์
|
498 |
+
tankPos.z + Math.cos(tankRotation) * 10 // ํฑํฌ ์์ชฝ 10 ์ ๋
|
499 |
);
|
500 |
|
501 |
+
this.camera.lookAt(lookAtPoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
}
|
503 |
createBuildings() {
|
504 |
const buildingTypes = [
|