if(right){dx+=Math.cos(player.yaw)*speed;dz-=Math.sin(player.yaw)*speed} player.x+=dx; player.z+=dz; let ground=height(Math.round(player.x),Math.round(player.z)); if((keys.Space||touch.Space)&&player.y<=ground+2.1)player.vy=8; player.vy-=19*dt; player.y+=player.vy*dt; if(player.y{ a.g.position.x+=Math.sin(now*.0005+a.phase)*dt*.5; a.g.position.z+=Math.cos(now*.0005+a.phase)*dt*.5; }); // Birds flying birds.forEach((b,i)=>{ b.position.x+=Math.sin(now*.0003+i)*dt*2; b.position.z+=Math.cos(now*.0003+i)*dt*2; b.position.y+=Math.sin(now*.003+i)*dt*.2; }); // Hostile mobs moving mobs.forEach((m,i)=>{ m.position.x+=Math.sin(now*.0003+i)*dt*.4; m.position.z+=Math.cos(now*.0003+i)*dt*.4; }); // Day and night let daylight=(Math.sin(clock)+1)/2; sun.intensity=.3+daylight*2.2; scene.background.copy(new THREE.Color(0x101c45).lerp(new THREE.Color(0x87ceeb),daylight)); scene.fog.color.copy(scene.background); renderer.render(scene,camera); } requestAnimationFrame(animate); addEventListener('resize',()=>{ camera.aspect=innerWidth/innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth,innerHeight); });