Spaces:
Running
Running
cutechicken
commited on
Commit
β’
b9015a6
1
Parent(s):
e37b3e1
Update game.js
Browse files
game.js
CHANGED
@@ -1945,23 +1945,19 @@ this.enemies.forEach(enemy => {
|
|
1945 |
}
|
1946 |
// ν¬λ‘μ€ν€μ΄ μ
λ°μ΄νΈ λ©μλ μΆκ°
|
1947 |
updateCrosshair() {
|
1948 |
-
// νλ©΄
|
1949 |
-
|
1950 |
-
this.raycaster.setFromCamera(raycasterDirection, this.camera);
|
1951 |
|
1952 |
-
// μ
|
1953 |
-
const
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
// λ°μ΄λ© λ°μ€μμ κ΅μ°¨ μ¬λΆλ‘ νλ¨
|
1961 |
-
return intersects;
|
1962 |
-
});
|
1963 |
|
1964 |
-
|
|
|
1965 |
this.crosshair.classList.add('target-detected');
|
1966 |
} else {
|
1967 |
this.crosshair.classList.remove('target-detected');
|
|
|
1945 |
}
|
1946 |
// ν¬λ‘μ€ν€μ΄ μ
λ°μ΄νΈ λ©μλ μΆκ°
|
1947 |
updateCrosshair() {
|
1948 |
+
// νλ©΄ μ€μ μ’νλ₯Ό μ¬μ©νλ λ μ΄μΊμ€ν° μμ±
|
1949 |
+
this.raycaster.setFromCamera(new THREE.Vector2(0, 0), this.camera);
|
|
|
1950 |
|
1951 |
+
// μ μ μ°¨ λ©μλ€λ§ λͺ¨μμ λ°°μ΄ μμ±
|
1952 |
+
const enemyMeshes = this.enemies
|
1953 |
+
.filter(enemy => enemy.mesh && enemy.isLoaded)
|
1954 |
+
.map(enemy => enemy.mesh);
|
1955 |
+
|
1956 |
+
// λ μ΄μ μ μ μ°¨ λ©μλ€μ κ΅μ°¨ κ²μ¬
|
1957 |
+
const intersects = this.raycaster.intersectObjects(enemyMeshes, true);
|
|
|
|
|
|
|
|
|
1958 |
|
1959 |
+
// κ΅μ°¨μ μ΄ μμΌλ©΄ ν¬λ‘μ€ν€μ΄ μν λ³κ²½
|
1960 |
+
if (intersects.length > 0) {
|
1961 |
this.crosshair.classList.add('target-detected');
|
1962 |
} else {
|
1963 |
this.crosshair.classList.remove('target-detected');
|