Spaces:
Running
Running
cutechicken
commited on
Commit
•
59becbb
1
Parent(s):
70004e8
Update game.js
Browse files
game.js
CHANGED
@@ -586,47 +586,61 @@ class Enemy {
|
|
586 |
}
|
587 |
|
588 |
async initialize(loader) {
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
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;
|