cutechicken commited on
Commit
59becbb
1 Parent(s): 70004e8

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +54 -40
game.js CHANGED
@@ -586,47 +586,61 @@ class Enemy {
586
  }
587
 
588
  async initialize(loader) {
589
- try {
590
- // Load body and turret separately
591
- const bodyResult = await loader.loadAsync('/models/t90Body.glb');
592
- this.body = bodyResult.scene;
593
-
594
- const turretResult = await loader.loadAsync('/models/t90Turret.glb');
595
- this.turret = turretResult.scene;
596
-
597
- // Set up turret group
598
- this.turretGroup.position.y = 0.2;
599
- this.turretGroup.add(this.turret);
600
- this.body.add(this.turretGroup);
601
-
602
- // Apply transforms to body
603
- this.body.position.copy(this.position);
604
- this.body.scale.set(ENEMY_SCALE, ENEMY_SCALE, ENEMY_SCALE);
605
-
606
- // Set up shadows for both body and turret
607
- this.body.traverse((child) => {
608
- if (child.isMesh) {
609
- child.castShadow = true;
610
- child.receiveShadow = true;
611
- child.material.shadowSide = THREE.BackSide;
612
- }
613
- });
614
-
615
- this.turret.traverse((child) => {
616
- if (child.isMesh) {
617
- child.castShadow = true;
618
- child.receiveShadow = true;
619
- child.material.shadowSide = THREE.BackSide;
620
- }
621
- });
622
-
623
- this.scene.add(this.body);
624
- this.isLoaded = true;
625
- } catch (error) {
626
- console.error('Error loading enemy tank model:', error);
627
- this.isLoaded = false;
628
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  }
 
630
 
631
  update(playerPosition) {
632
  if (!this.body || !this.isLoaded) return;
 
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
 
645
  update(playerPosition) {
646
  if (!this.body || !this.isLoaded) return;