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