Spaces:
Running
Running
cutechicken
commited on
Commit
โข
2dc54b2
1
Parent(s):
2112778
Update game.js
Browse files
game.js
CHANGED
@@ -586,61 +586,44 @@ 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 |
-
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 |
|