сделай более нормально добавь небо голубое и снизу зеленое как трава и деревья а красных врагов сделай из спрайтов https://img.itch.zone/aW1hZ2UvOTE0NjQ4LzUxNzA3ODYuZ2lm/347x500/ZCzGDU.gif


код:
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <title>Простой 3D Шутер</title>
    <style>
        body { margin: 0; overflow: hidden; }
        canvas { display: block; }
    </style>
</head>
<body>
    <!-- Подключаем библиотеку Three.js с CDN -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.148/build/three.min.js"></script>
    <script>
        // Создаем сцену, камеру и рендерер
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer();
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        // Добавляем плоскость (пол)
        const floorGeometry = new THREE.PlaneGeometry(200, 200);
        const floorMaterial = new THREE.MeshBasicMaterial({ color: 0x808080, wireframe: true });
        const floor = new THREE.Mesh(floorGeometry, floorMaterial);
        floor.rotation.x = -Math.PI / 2;
        scene.add(floor);

        // Создаем игрока
        const player = new THREE.Object3D();
        player.position.set(0, 1.6, 0);
        scene.add(player);
        player.add(camera);

        // Контролы движения
        let moveForward = false;
        let moveBackward = false;
        let moveLeft = false;
        let moveRight = false;

        const velocity = new THREE.Vector3();
        const direction = new THREE.Vector3();

        // Создаем врагов
        const enemies = [];
        function createEnemy() {
            const enemyGeometry = new THREE.BoxGeometry(1, 1, 1);
            const enemyMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 });
            const enemy = new THREE.Mesh(enemyGeometry, enemyMaterial);
            enemy.position.set(
                (Math.random() - 0.5) * 100,
                0.5,
                (Math.random() - 0.5) * 100
            );
            scene.add(enemy);
            enemies.push(enemy);
        }

        for (let i = 0; i < 10; i++) {
            createEnemy();
        }

        // Стрельба
        const bullets = [];
        function shoot() {
            const bulletGeometry = new THREE.SphereGeometry(0.1, 8, 8);
            const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0xffff00 });
            const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
            bullet.position.copy(player.position);
            bullet.quaternion.copy(camera.quaternion);
            scene.add(bullet);
            bullets.push(bullet);
        }

        // Обработчики событий клавиатуры
        document.addEventListener('keydown', function(event) {
            switch(event.code) {
                case 'KeyW':
                    moveForward = true;
                    break;
                case 'KeyS':
                    moveBackward = true;
                    break;
                case 'KeyA':
                    moveLeft = true;
                    break;
                case 'KeyD':
                    moveRight = true;
                    break;
                case 'Space':
                    shoot();
                    break;
            }
        });

        document.addEventListener('keyup', function(event) {
            switch(event.code) {
                case 'KeyW':
                    moveForward = false;
                    break;
                case 'KeyS':
                    moveBackward = false;
                    break;
                case 'KeyA':
                    moveLeft = false;
                    break;
                case 'KeyD':
                    moveRight = false;
                    break;
            }
        });

        // Управление камерой с помощью мыши
        let isLocked = false;

        const pointerLockChange = function () {
            if (document.pointerLockElement === document.body) {
                isLocked = true;
            } else {
                isLocked = false;
            }
        };

        document.addEventListener('pointerlockchange', pointerLockChange, false);
        document.addEventListener('click', function () {
            document.body.requestPointerLock();
        }, false);

        document.addEventListener('mousemove', function (event) {
            if (isLocked) {
                const movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
                const movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;

                player.rotation.y -= movementX * 0.002;
                camera.rotation.x -= movementY * 0.002;
                camera.rotation.x = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, camera.rotation.x));
            }
        }, false);

        // Анимация
        let prevTime = performance.now();
        function animate() {
            requestAnimationFrame(animate);

            const time = performance.now();
            const delta = (time - prevTime) / 1000;

            velocity.x -= velocity.x * 10.0 * delta;
            velocity.z -= velocity.z * 10.0 * delta;

            direction.z = Number(moveForward) - Number(moveBackward);
            direction.x = Number(moveRight) - Number(moveLeft);
            direction.normalize();

            if (moveForward || moveBackward) velocity.z -= direction.z * 400.0 * delta;
            if (moveLeft || moveRight) velocity.x -= direction.x * 400.0 * delta;

            player.translateX(velocity.x * delta);
            player.translateZ(velocity.z * delta);

            // Обновляем пули
            for (let i = bullets.length - 1; i >= 0; i--) {
                const bullet = bullets[i];
                bullet.translateZ(-1);

                // Проверка столкновения с врагами
                for (let j = enemies.length - 1; j >= 0; j--) {
                    const enemy = enemies[j];
                    if (bullet.position.distanceTo(enemy.position) < 0.5) {
                        scene.remove(enemy);
                        enemies.splice(j, 1);
                        scene.remove(bullet);
                        bullets.splice(i, 1);
                        break;
                    }
                }

                // Удаляем пули, которые улетели далеко
                if (bullet.position.length() > 200) {
                    scene.remove(bullet);
                    bullets.splice(i, 1);
                }
            }

            // Простейший ИИ для врагов
            enemies.forEach(function(enemy) {
                enemy.lookAt(player.position);
                enemy.translateZ(0.02);
            });

            renderer.render(scene, camera);
            prevTime = time;
        }

        animate();

        // Обработка изменения размера окна
        window.addEventListener('resize', function() {
            camera.aspect = window.innerWidth/window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        }, false);
    </script>
</body>
</html>