Spaces:
Running
Running
adding the actual template
Browse files- index.html +101 -0
index.html
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>3D Game Template - Three.js</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
margin: 0;
|
| 10 |
+
overflow: hidden;
|
| 11 |
+
font-family: sans-serif;
|
| 12 |
+
}
|
| 13 |
+
canvas {
|
| 14 |
+
display: block;
|
| 15 |
+
}
|
| 16 |
+
#info {
|
| 17 |
+
position: absolute;
|
| 18 |
+
top: 10px;
|
| 19 |
+
left: 10px;
|
| 20 |
+
background: rgba(0,0,0,0.5);
|
| 21 |
+
color: white;
|
| 22 |
+
padding: 8px 12px;
|
| 23 |
+
border-radius: 5px;
|
| 24 |
+
font-size: 14px;
|
| 25 |
+
z-index: 10;
|
| 26 |
+
}
|
| 27 |
+
</style>
|
| 28 |
+
</head>
|
| 29 |
+
<body>
|
| 30 |
+
<div id="info">3D Game Template Ready</div>
|
| 31 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 32 |
+
<script>
|
| 33 |
+
// Basic Setup
|
| 34 |
+
let scene, camera, renderer;
|
| 35 |
+
|
| 36 |
+
function init() {
|
| 37 |
+
// Scene
|
| 38 |
+
scene = new THREE.Scene();
|
| 39 |
+
scene.background = new THREE.Color(0x87CEEB); // Sky blue
|
| 40 |
+
|
| 41 |
+
// Camera
|
| 42 |
+
camera = new THREE.PerspectiveCamera(
|
| 43 |
+
75,
|
| 44 |
+
window.innerWidth / window.innerHeight,
|
| 45 |
+
0.1,
|
| 46 |
+
1000
|
| 47 |
+
);
|
| 48 |
+
camera.position.set(0, 5, 10);
|
| 49 |
+
|
| 50 |
+
// Renderer
|
| 51 |
+
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 52 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 53 |
+
renderer.shadowMap.enabled = true;
|
| 54 |
+
document.body.appendChild(renderer.domElement);
|
| 55 |
+
|
| 56 |
+
// Lighting
|
| 57 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
|
| 58 |
+
scene.add(ambientLight);
|
| 59 |
+
|
| 60 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
| 61 |
+
directionalLight.position.set(10, 20, 10);
|
| 62 |
+
directionalLight.castShadow = true;
|
| 63 |
+
scene.add(directionalLight);
|
| 64 |
+
|
| 65 |
+
// Ground
|
| 66 |
+
const groundGeometry = new THREE.PlaneGeometry(100, 100);
|
| 67 |
+
const groundMaterial = new THREE.MeshStandardMaterial({ color: 0x228B22 }); // Forest green
|
| 68 |
+
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
| 69 |
+
ground.rotation.x = -Math.PI / 2;
|
| 70 |
+
ground.receiveShadow = true;
|
| 71 |
+
scene.add(ground);
|
| 72 |
+
|
| 73 |
+
// Test Cube
|
| 74 |
+
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
|
| 75 |
+
const cubeMaterial = new THREE.MeshStandardMaterial({ color: 0xff0000 });
|
| 76 |
+
const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
|
| 77 |
+
cube.position.set(0, 0.5, 0);
|
| 78 |
+
cube.castShadow = true;
|
| 79 |
+
scene.add(cube);
|
| 80 |
+
|
| 81 |
+
// Handle window resizing
|
| 82 |
+
window.addEventListener("resize", () => {
|
| 83 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 84 |
+
camera.updateProjectionMatrix();
|
| 85 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 86 |
+
});
|
| 87 |
+
|
| 88 |
+
// Start the animation loop
|
| 89 |
+
animate();
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
function animate() {
|
| 93 |
+
requestAnimationFrame(animate);
|
| 94 |
+
renderer.render(scene, camera);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Start everything
|
| 98 |
+
init();
|
| 99 |
+
</script>
|
| 100 |
+
</body>
|
| 101 |
+
</html>
|