Spaces:
Running
Running
cutechicken
commited on
Commit
โข
475b62f
1
Parent(s):
d9a71bb
Update game.js
Browse files
game.js
CHANGED
@@ -1948,7 +1948,21 @@ updateCrosshair() {
|
|
1948 |
this.raycaster.setFromCamera(new THREE.Vector2(), this.camera);
|
1949 |
const intersects = this.raycaster.intersectObjects(this.scene.children, true);
|
1950 |
|
1951 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1952 |
this.crosshair.classList.add('target-detected');
|
1953 |
} else {
|
1954 |
this.crosshair.classList.remove('target-detected');
|
|
|
1948 |
this.raycaster.setFromCamera(new THREE.Vector2(), this.camera);
|
1949 |
const intersects = this.raycaster.intersectObjects(this.scene.children, true);
|
1950 |
|
1951 |
+
// ์ถฉ๋ํ ๊ฐ์ฒด๋ค ์ค ์ ์ ์ฐจ๊ฐ ์๋์ง ํ์ธ
|
1952 |
+
const hasEnemyTank = intersects.some(intersect => {
|
1953 |
+
// ๊ต์ฐจํ ๊ฐ์ฒด๋ ๊ทธ ๋ถ๋ชจ ๊ฐ์ฒด ์ค์ ์ ์ ์ฐจ๊ฐ ์๋์ง ํ์ธ
|
1954 |
+
let current = intersect.object;
|
1955 |
+
while (current) {
|
1956 |
+
// enemies ๋ฐฐ์ด์ ์๋ ๋ฉ์์ ๋น๊ต
|
1957 |
+
if (this.enemies.some(enemy => enemy.mesh === current)) {
|
1958 |
+
return true;
|
1959 |
+
}
|
1960 |
+
current = current.parent;
|
1961 |
+
}
|
1962 |
+
return false;
|
1963 |
+
});
|
1964 |
+
|
1965 |
+
if (hasEnemyTank) {
|
1966 |
this.crosshair.classList.add('target-detected');
|
1967 |
} else {
|
1968 |
this.crosshair.classList.remove('target-detected');
|