cutechicken commited on
Commit
2dc54b2
โ€ข
1 Parent(s): 2112778

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +37 -54
game.js CHANGED
@@ -586,61 +586,44 @@ class Enemy {
586
  }
587
 
588
  async initialize(loader) {
589
- console.log('Starting enemy tank initialization...');
590
- try {
591
- // Load body
592
- console.log('Loading t90Body.glb...');
593
- const bodyResult = await loader.loadAsync('/models/t90Body.glb');
594
- console.log('t90Body.glb loaded successfully');
595
- this.body = bodyResult.scene;
596
-
597
- // Load turret
598
- console.log('Loading t90Turret.glb...');
599
- const turretResult = await loader.loadAsync('/models/t90Turret.glb');
600
- console.log('t90Turret.glb loaded successfully');
601
- this.turret = turretResult.scene;
602
-
603
- console.log('Setting up turret group...');
604
- this.turretGroup.position.y = 0.2;
605
- this.turretGroup.add(this.turret);
606
- this.body.add(this.turretGroup);
607
-
608
- console.log('Applying transforms...');
609
- this.body.position.copy(this.position);
610
- this.body.scale.set(ENEMY_SCALE, ENEMY_SCALE, ENEMY_SCALE);
611
-
612
- // Setup shadows
613
- console.log('Setting up shadows...');
614
- this.body.traverse((child) => {
615
- if (child.isMesh) {
616
- child.castShadow = true;
617
- child.receiveShadow = true;
618
- child.material.shadowSide = THREE.BackSide;
619
- }
620
- });
621
-
622
- this.turret.traverse((child) => {
623
- if (child.isMesh) {
624
- child.castShadow = true;
625
- child.receiveShadow = true;
626
- child.material.shadowSide = THREE.BackSide;
627
- }
628
- });
629
-
630
- console.log('Adding to scene...');
631
- this.scene.add(this.body);
632
- this.isLoaded = true;
633
- console.log('Enemy tank initialization complete!');
634
- } catch (error) {
635
- console.error('Error loading enemy tank model:', error);
636
- console.error('Error details:', {
637
- message: error.message,
638
- stack: error.stack,
639
- name: error.name
640
- });
641
- this.isLoaded = false;
642
- }
643
  }
 
644
  update(playerPosition) {
645
  if (!this.body || !this.isLoaded) return;
646
 
 
586
  }
587
 
588
  async initialize(loader) {
589
+ try {
590
+ const bodyResult = await loader.loadAsync('/models/t90Body.glb');
591
+ this.body = bodyResult.scene;
592
+
593
+ const turretResult = await loader.loadAsync('/models/t90Turret.glb');
594
+ this.turret = turretResult.scene;
595
+
596
+ this.turretGroup.position.y = 0.2;
597
+ this.turretGroup.add(this.turret);
598
+ this.body.add(this.turretGroup);
599
+
600
+ this.body.position.copy(this.position);
601
+ this.body.scale.set(ENEMY_SCALE, ENEMY_SCALE, ENEMY_SCALE);
602
+
603
+ // ๊ทธ๋ฆผ์ž ์„ค์ • ์ตœ์ ํ™”
604
+ this.body.traverse((child) => {
605
+ if (child.isMesh) {
606
+ child.castShadow = true;
607
+ child.receiveShadow = false; // ๊ทธ๋ฆผ์ž ๋ฐ›๊ธฐ ๋น„ํ™œ์„ฑํ™”
608
+ child.material.shadowSide = THREE.FrontSide; // ๊ทธ๋ฆผ์ž ์ตœ์ ํ™”
609
+ }
610
+ });
611
+
612
+ this.turret.traverse((child) => {
613
+ if (child.isMesh) {
614
+ child.castShadow = true;
615
+ child.receiveShadow = false; // ๊ทธ๋ฆผ์ž ๋ฐ›๊ธฐ ๋น„ํ™œ์„ฑํ™”
616
+ child.material.shadowSide = THREE.FrontSide; // ๊ทธ๋ฆผ์ž ์ตœ์ ํ™”
617
+ }
618
+ });
619
+
620
+ this.scene.add(this.body);
621
+ this.isLoaded = true;
622
+ } catch (error) {
623
+ console.error('Error loading enemy tank model:', error);
624
+ this.isLoaded = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
  }
626
+ }
627
  update(playerPosition) {
628
  if (!this.body || !this.isLoaded) return;
629