fix the following problems: in your code, if the user goes to the blocks below, it does not go down, i.e. does not go strictly on the blocks. also add a strict designation of where exactly the block is added and make it so that you can not add a block hanging in the air. remove glitter from the blocks<!DOCTYPE html>
<html>
<head>
    <title>Infinite Minecraft Clone</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
        }
        canvas {
            width: 100vw;
            height: 100vh;
            display: block;
        }
        #instructions {
            position: fixed;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            background: rgba(0,0,0,0.5);
            padding: 10px;
            border-radius: 5px;
        }
        #debug {
            position: fixed;
            top: 10px;
            right: 10px;
            color: white;
            font-family: Arial, sans-serif;
            background: rgba(0,0,0,0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div id="instructions">
        WASD - Move<br>
        SPACE - Jump<br>
        LEFT CLICK - Remove block<br>
        RIGHT CLICK - Place block<br>
        MOUSE - Look around
    </div>
    <div id="debug"></div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <script>
        // Initialize Three.js
        const scene = new THREE.Scene();
        scene.background = new THREE.Color(0x87CEEB);

        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);

        // Lighting
        const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
        scene.add(ambientLight);

        const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
        directionalLight.position.set(10, 20, 10);
        scene.add(directionalLight);

        // Chunk management
        const CHUNK_SIZE = 16;
        const RENDER_DISTANCE = 4;
        const loadedChunks = new Map();

        // Simplified noise function for terrain generation
        function noise(x, z) {
            return Math.sin(x * 0.1) * Math.cos(z * 0.1) * 5 + 
                   Math.sin(x * 0.3 + z * 0.2) * 2;
        }

        // Block creation
        const blockGeometry = new THREE.BoxGeometry(1, 1, 1);
        const blockMaterial = new THREE.MeshPhongMaterial({
            color: 0x2E8B57,
            specular: 0x444444,
            shininess: 30
        });

        // Generate a single chunk
        function generateChunk(chunkX, chunkZ) {
            const chunk = new THREE.Group();
            chunk.name = `chunk_${chunkX}_${chunkZ}`;

            for (let x = 0; x < CHUNK_SIZE; x++) {
                for (let z = 0; z < CHUNK_SIZE; z++) {
                    const worldX = chunkX * CHUNK_SIZE + x;
                    const worldZ = chunkZ * CHUNK_SIZE + z;
                    
                    // Generate height using noise
                    const height = Math.floor(noise(worldX, worldZ)) + 1;
                    
                    // Create blocks from bottom to height
                    for (let y = -5; y < height; y++) {
                        const block = new THREE.Mesh(blockGeometry, blockMaterial);
                        block.position.set(worldX, y, worldZ);
                        chunk.add(block);
                    }
                }
            }
            
            return chunk;
        }

        // Load chunks around position
        function loadChunksAroundPosition(position) {
            const centerChunkX = Math.floor(position.x / CHUNK_SIZE);
            const centerChunkZ = Math.floor(position.z / CHUNK_SIZE);

            // Track which chunks should be kept
            const chunksToKeep = new Set();

            // Load new chunks
            for (let dx = -RENDER_DISTANCE; dx <= RENDER_DISTANCE; dx++) {
                for (let dz = -RENDER_DISTANCE; dz <= RENDER_DISTANCE; dz++) {
                    const chunkX = centerChunkX + dx;
                    const chunkZ = centerChunkZ + dz;
                    const chunkKey = `${chunkX},${chunkZ}`;
                    chunksToKeep.add(chunkKey);

                    if (!loadedChunks.has(chunkKey)) {
                        const chunk = generateChunk(chunkX, chunkZ);
                        loadedChunks.set(chunkKey, chunk);
                        scene.add(chunk);
                    }
                }
            }

            // Unload distant chunks
            for (const [key, chunk] of loadedChunks) {
                if (!chunksToKeep.has(key)) {
                    scene.remove(chunk);
                    loadedChunks.delete(key);
                }
            }

            // Update debug info
            document.getElementById('debug').textContent = 
                `Loaded chunks: ${loadedChunks.size}\n` +
                `Position: ${Math.round(position.x)}, ${Math.round(position.y)}, ${Math.round(position.z)}`;
        }

        // Player movement variables
        const player = {
            position: new THREE.Vector3(0, 5, 0),
            velocity: new THREE.Vector3(),
            onGround: false,
            speed: 0.2,
            jumpForce: 0.3
        };

        // Camera controls
        let pitch = 0;
        let yaw = 0;

        // Movement controls
        const keys = {};

        // Raycaster for block placement/removal
        const raycaster = new THREE.Raycaster();

        // Block placement helper function
        function placeBlock(intersectPoint, normal) {
            const position = new THREE.Vector3()
                .copy(intersectPoint)
                .add(normal)
                .round();

            const chunkX = Math.floor(position.x / CHUNK_SIZE);
            const chunkZ = Math.floor(position.z / CHUNK_SIZE);
            const chunkKey = `${chunkX},${chunkZ}`;
            const chunk = loadedChunks.get(chunkKey);

            if (chunk) {
                const block = new THREE.Mesh(blockGeometry, blockMaterial);
                block.position.copy(position);
                chunk.add(block);
            }
        }

        // Event listeners
        document.addEventListener('keydown', (e) => keys[e.key.toLowerCase()] = true);
        document.addEventListener('keyup', (e) => keys[e.key.toLowerCase()] = false);

        document.addEventListener('mousedown', (e) => {
            if (document.pointerLockElement === document.body) {
                raycaster.setFromCamera(new THREE.Vector2(0, 0), camera);
                
                // Check intersection with all chunks
                const intersects = raycaster.intersectObjects(
                    Array.from(loadedChunks.values()).flatMap(chunk => chunk.children)
                );

                if (intersects.length > 0) {
                    if (e.button === 0) { // Left click - remove block
                        intersects[0].object.parent.remove(intersects[0].object);
                    } else if (e.button === 2) { // Right click - add block
                        placeBlock(intersects[0].point, intersects[0].face.normal);
                    }
                }
            }
        });

        document.addEventListener('mousemove', (e) => {
            if (document.pointerLockElement === document.body) {
                yaw -= e.movementX * 0.002;
                pitch -= e.movementY * 0.002;
                pitch = Math.max(-Math.PI/2, Math.min(Math.PI/2, pitch));
            }
        });

        document.addEventListener('contextmenu', (e) => e.preventDefault());

        renderer.domElement.addEventListener('click', () => {
            document.body.requestPointerLock();
        });

        // Animation loop
        function animate() {
            requestAnimationFrame(animate);

            // Handle movement
            if (keys['w']) {
                player.position.x -= Math.sin(yaw) * player.speed;
                player.position.z -= Math.cos(yaw) * player.speed;
            }
            if (keys['s']) {
                player.position.x += Math.sin(yaw) * player.speed;
                player.position.z += Math.cos(yaw) * player.speed;
            }
            if (keys['a']) {
                player.position.x -= Math.cos(yaw) * player.speed;
                player.position.z += Math.sin(yaw) * player.speed;
            }
            if (keys['d']) {
                player.position.x += Math.cos(yaw) * player.speed;
                player.position.z -= Math.sin(yaw) * player.speed;
            }
            if (keys[' '] && player.onGround) {
                player.velocity.y = player.jumpForce;
                player.onGround = false;
            }

            // Apply gravity
            if (!player.onGround) {
                player.velocity.y -= 0.015;
            }
            player.position.y += player.velocity.y;

            // Simple ground collision
            const heightAtPosition = noise(player.position.x, player.position.z);
            if (player.position.y < heightAtPosition) {
                player.position.y = heightAtPosition;
                player.velocity.y = 0;
                player.onGround = true;
            }

            // Update chunks based on player position
            loadChunksAroundPosition(player.position);

            // Update camera position and rotation
            camera.position.copy(player.position);
            camera.position.y += 1.6; // Eye height
            camera.rotation.order = 'YXZ';
            camera.rotation.y = yaw;
            camera.rotation.x = pitch;

            renderer.render(scene, camera);
        }

        // Handle window resize
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        animate();
    </script>
</body>
</html>