Meta Description" name="description" />
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>3D Minecraft Mobile Pro</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
body { margin: 0; overflow: hidden; background: #87CEEB; font-family: sans-serif; }
/* Controllers Layout */
#controls { position: absolute; bottom: 20px; left: 20px; display: grid; grid-template-columns: 50px 50px 50px; gap: 5px; }
.ctrl-btn { width: 50px; height: 50px; background: rgba(255,255,255,0.3); border: 2px solid white; border-radius: 10px; display: flex; justify-content: center; align-items: center; color: white; font-weight: bold; user-select: none; }
#inventory { position: absolute; bottom: 20px; right: 20px; display: flex; gap: 10px; }
.inv-btn { width: 50px; height: 50px; border: 3px solid white; border-radius: 8px; }
#msg { position: absolute; top: 10px; width: 100%; text-align: center; color: white; text-shadow: 1px 1px 2px black; }
</style>
</head>
<body>
<div id="msg">Buttons se chalein aur blocks lagayein!</div>
<div id="controls">
<div></div><div class="ctrl-btn" id="up">↑</div><div></div>
<div class="ctrl-btn" id="left">←</div><div class="ctrl-btn" id="down">↓</div><div class="ctrl-btn" id="right">→</div>
</div>
<div id="inventory">
<div class="inv-btn" style="background: #4CAF50;" onclick="currentTile=0"></div>
<div class="inv-btn" style="background: #8B4513;" onclick="currentTile=1"></div>
<div class="inv-btn" style="background: #228B22;" onclick="currentTile=2"></div>
</div>
<script>
let scene, camera, renderer, currentTile = 0;
let moveForward = false, moveBackward = false, moveLeft = false, moveRight = false;
let colors = [0x4CAF50, 0x8B4513, 0x228B22];
scene = new THREE.Scene();
scene.background = new THREE.Color(0x87CEEB);
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Lights
const sun = new THREE.DirectionalLight(0xffffff, 1);
sun.position.set(10, 20, 10);
scene.add(sun);
scene.add(new THREE.AmbientLight(0x606060));
// Geometry
const boxGeo = new THREE.BoxGeometry(1, 1, 1);
// 1. Infinity Ground (Badi Zameen)
for(let x = -20; x < 20; x++) {
for(let z = -20; z < 20; z++) {
createBlock(x, -1, z, 0x4CAF50);
}
}
// 2. Badal (Clouds)
for(let i=0; i<10; i++) {
createBlock(Math.random()*40-20, 10, Math.random()*40-20, 0xffffff);
}
function createBlock(x, y, z, color) {
const material = new THREE.MeshLambertMaterial({ color: color });
const cube = new THREE.Mesh(boxGeo, material);
cube.position.set(x, y, z);
scene.add(cube);
}
camera.position.set(0, 2, 5);
// Movement Logic
const setupBtn = (id, action) => {
const btn = document.getElementById(id);
btn.ontouchstart = () => action(true);
btn.ontouchend = () => action(false);
btn.onmousedown = () => action(true);
btn.onmouseup = () => action(false);
};
setupBtn('up', (v) => moveForward = v);
setupBtn('down', (v) => moveBackward = v);
setupBtn('left', (v) => moveLeft = v);
setupBtn('right', (v) => moveRight = v);
// Click to Place Block
window.onclick = (e) => {
if(e.target.className.includes('btn')) return;
let targetX = Math.round(camera.position.x + Math.sin(camera.rotation.y) * -3);
let targetZ = Math.round(camera.position.z + Math.cos(camera.rotation.y) * -3);
createBlock(targetX, 0, targetZ, colors[currentTile]);
};
function animate() {
requestAnimationFrame(animate);
if (moveForward) camera.translateZ(-0.1);
if (moveBackward) camera.translateZ(0.1);
if (moveLeft) camera.translateX(-0.1);
if (moveRight) camera.translateX(0.1);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
2
2
124KB
594KB
2,917.0ms
2,408.0ms
2,917.0ms