Here's a basic 3D landing page for a web design company using Three.js with some interactive elements. This code creates a modern 3D scene with some basic shapes and text:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Design Company Landing Page</title>
<style>
body {
margin: 0;
overflow: hidden;
background: linear-gradient(45deg, #29323c, #485461);
color: white;
font-family: 'Arial', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#canvas-container {
position: relative;
width: 100%;
height: 100vh;
}
.header {
position: absolute;
top: 20px;
width: 100%;
text-align: center;
padding: 20px;
background: rgba(0, 0, 0, 0.5);
}
h1 {
margin: 0;
font-size: 3em;
color: #ff6b6b;
}
.button {
margin-top: 50px;
padding: 12px 30px;
background: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.button:hover {
background: #ff5252;
}
</style>
</head>
<body>
<div class="header">
<h1>WebCraft Design</h1>
<button class="button">View Our Work</button>
</div>
<div id="canvas-container"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
// Scene setup
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
document.getElementById('canvas-container').appendChild(renderer.domElement);
// Lights
const ambientLight = new THREE.AmbientLight(0x404040);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);
// Sphere
const geometry = new THREE.SphereGeometry(1, 32, 32);
const material = new THREE.MeshStandardMaterial({ color: 0xff6b6b, metalness: 0.3, roughness: 0.8 });
const sphere = new THREE.Mesh(geometry, material);
sphere.position.set(0, 1, -5);
scene.add(sphere);
// Cube
const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);
const cubeMaterial = new THREE.MeshStandardMaterial({ color: 0x4ecdc4, metalness: 0.5 });
const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
cube.position.set(-3, 0, -8);
scene.add(cube);
// Text
(async () => {
const font = await (new THREE.FontLoader()).loadAsync('https://threejs.org/examples/fonts/helvetiker_regular.typeface.json');
const textGeometry = new THREE.TextGeometry('WEB CRAFT', {
font: font,
size: 0.8,
height: 0.2,
curveSegments: 12
});
const textMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff });
const text = new THREE.Mesh(textGeometry, textMaterial);
text.position.set(0, 2, -3);
text.rotation.x = -Math.PI / 4;
scene.add(text);
})();
// Camera position
camera.position.z = 5;
// Mouse controls
let mouseX = 0, mouseY = 0;
const windowHalfX = window.innerWidth / 2;
const windowHalfY = window.innerHeight / 2;
window.addEventListener('mousemove', (event) => {
mouseX = (event.clientX - windowHalfX) * 0.002;
mouseY = (event.clientY - windowHalfY) * 0.002;
});
// Animation loop
function animate() {
requestAnimationFrame(animate);
sphere.rotation.x += 0.01;
sphere.rotation.y += 0.01;
cube.rotation.x += 0.005;
cube.rotation.y += 0.01;
camera.position.x += (mouseX - camera.position.x) * 0.05;
camera.position.y += (-mouseY - camera.position.y) * 0.05;
camera.lookAt(scene.position);
renderer.render(scene, camera);
}
animate();
// Resize handling
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
This code creates a landing page with:
-
A modern 3D scene containing:
- A red sphere
- A green cube
- 3D text saying "WEB CRAFT"
- Interactive camera movement based on mouse position
-
Styling features:
- Gradient background
- Header with company name and call-to-action button
- Smooth animations and transitions
-
Key Three.js features used:
- MeshStandardMaterial for realistic materials
- TextGeometry for 3D text
- Ambient and directional lighting
- Responsive design with window resize handling
To customize this further, you could:
- Add more 3D elements (ebsites, devices, etc.)
- Include animations for different elements
- Add more interactive features
- Customize colors and materials
- Add particle systems or other effects
- Implement a parallax effect
- Add more detailed text and logos
The page will look best in modern browsers and may require some adjustments for mobile responsiveness. The 3D scene will smoothly respond to mouse movements, creating an engaging user experience.