cutechicken commited on
Commit
312c87c
ยท
verified ยท
1 Parent(s): f609e63

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +18 -17
game.js CHANGED
@@ -531,9 +531,13 @@ class Fighter {
531
  this.velocity.y -= gravityAcceleration;
532
  }
533
 
534
- // ์†๋„ ๋ฒกํ„ฐ ๊ณ„์‚ฐ
535
  const noseDirection = new THREE.Vector3(0, 0, 1);
536
- noseDirection.applyEuler(this.rotation);
 
 
 
 
537
 
538
  if (!this.stallWarning) {
539
  // ์ •์ƒ ๋น„ํ–‰ ์‹œ
@@ -590,17 +594,9 @@ class Fighter {
590
 
591
  // ๋ฉ”์‹œ ์œ„์น˜ ๋ฐ ํšŒ์ „ ์—…๋ฐ์ดํŠธ
592
  this.mesh.position.copy(this.position);
593
-
594
- // ์ง๋ฒŒ ๋ฝ์„ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ์ฟผํ„ฐ๋‹ˆ์–ธ์œผ๋กœ ํšŒ์ „ ์ ์šฉ
595
- const tempQuaternion = new THREE.Quaternion();
596
- const rotationEuler = new THREE.Euler(
597
- this.rotation.x,
598
- this.rotation.y + 3 * Math.PI / 2,
599
- this.rotation.z,
600
- 'YXZ' // ์˜ค์ผ๋Ÿฌ ์ˆœ์„œ ๋ณ€๊ฒฝ์œผ๋กœ ์ง๋ฒŒ ๋ฝ ๋ฐฉ์ง€
601
- );
602
- tempQuaternion.setFromEuler(rotationEuler);
603
- this.mesh.quaternion.copy(tempQuaternion);
604
 
605
  // ๊ฒฝ๊ณ  ๊นœ๋นก์ž„ ํƒ€์ด๋จธ
606
  this.warningBlinkTimer += deltaTime;
@@ -638,7 +634,9 @@ class Fighter {
638
 
639
  // ๊ธฐ์ˆ˜ ๋์—์„œ ๋ฐœ์‚ฌ (๋” ์•ž์ชฝ์—์„œ)
640
  const muzzleOffset = new THREE.Vector3(0, 0, 10);
641
- muzzleOffset.applyEuler(this.rotation);
 
 
642
  bullet.position.copy(this.position).add(muzzleOffset);
643
 
644
  // ํƒ„ํ™˜์„ ๋ฐœ์‚ฌ ๋ฐฉํ–ฅ์œผ๋กœ ํšŒ์ „
@@ -650,7 +648,7 @@ class Fighter {
650
 
651
  const bulletSpeed = 1500; // 1000์—์„œ 1500์œผ๋กœ ์ฆ๊ฐ€ (50% ๋น ๋ฅด๊ฒŒ)
652
  const direction = new THREE.Vector3(0, 0, 1);
653
- direction.applyEuler(this.rotation);
654
  bullet.velocity = direction.multiplyScalar(bulletSpeed);
655
 
656
  scene.add(bullet);
@@ -713,8 +711,11 @@ class Fighter {
713
  const backward = new THREE.Vector3(0, 0, -1);
714
  const up = new THREE.Vector3(0, 1, 0);
715
 
716
- backward.applyEuler(this.rotation);
717
- up.applyEuler(this.rotation);
 
 
 
718
 
719
  const cameraPosition = this.position.clone()
720
  .add(backward.multiplyScalar(this.cameraDistance))
 
531
  this.velocity.y -= gravityAcceleration;
532
  }
533
 
534
+ // ์†๋„ ๋ฒกํ„ฐ ๊ณ„์‚ฐ - ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง๋ฒŒ ๋ฝ ํšŒํ”ผ
535
  const noseDirection = new THREE.Vector3(0, 0, 1);
536
+
537
+ // ํšŒ์ „ ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์ง์ ‘ ๊ตฌ์„ฑํ•˜์—ฌ ์ ์šฉ
538
+ const rotationMatrix = new THREE.Matrix4();
539
+ rotationMatrix.makeRotationFromEuler(new THREE.Euler(this.rotation.x, this.rotation.y, this.rotation.z, 'YXZ'));
540
+ noseDirection.applyMatrix4(rotationMatrix);
541
 
542
  if (!this.stallWarning) {
543
  // ์ •์ƒ ๋น„ํ–‰ ์‹œ
 
594
 
595
  // ๋ฉ”์‹œ ์œ„์น˜ ๋ฐ ํšŒ์ „ ์—…๋ฐ์ดํŠธ
596
  this.mesh.position.copy(this.position);
597
+ this.mesh.rotation.x = this.rotation.x;
598
+ this.mesh.rotation.y = this.rotation.y + 3 * Math.PI / 2;
599
+ this.mesh.rotation.z = this.rotation.z;
 
 
 
 
 
 
 
 
600
 
601
  // ๊ฒฝ๊ณ  ๊นœ๋นก์ž„ ํƒ€์ด๋จธ
602
  this.warningBlinkTimer += deltaTime;
 
634
 
635
  // ๊ธฐ์ˆ˜ ๋์—์„œ ๋ฐœ์‚ฌ (๋” ์•ž์ชฝ์—์„œ)
636
  const muzzleOffset = new THREE.Vector3(0, 0, 10);
637
+ const rotationMatrix = new THREE.Matrix4();
638
+ rotationMatrix.makeRotationFromEuler(new THREE.Euler(this.rotation.x, this.rotation.y, this.rotation.z, 'YXZ'));
639
+ muzzleOffset.applyMatrix4(rotationMatrix);
640
  bullet.position.copy(this.position).add(muzzleOffset);
641
 
642
  // ํƒ„ํ™˜์„ ๋ฐœ์‚ฌ ๋ฐฉํ–ฅ์œผ๋กœ ํšŒ์ „
 
648
 
649
  const bulletSpeed = 1500; // 1000์—์„œ 1500์œผ๋กœ ์ฆ๊ฐ€ (50% ๋น ๋ฅด๊ฒŒ)
650
  const direction = new THREE.Vector3(0, 0, 1);
651
+ direction.applyMatrix4(rotationMatrix);
652
  bullet.velocity = direction.multiplyScalar(bulletSpeed);
653
 
654
  scene.add(bullet);
 
711
  const backward = new THREE.Vector3(0, 0, -1);
712
  const up = new THREE.Vector3(0, 1, 0);
713
 
714
+ const rotationMatrix = new THREE.Matrix4();
715
+ rotationMatrix.makeRotationFromEuler(new THREE.Euler(this.rotation.x, this.rotation.y, this.rotation.z, 'YXZ'));
716
+
717
+ backward.applyMatrix4(rotationMatrix);
718
+ up.applyMatrix4(rotationMatrix);
719
 
720
  const cameraPosition = this.position.clone()
721
  .add(backward.multiplyScalar(this.cameraDistance))