<!DOCTYPE html>
<html>
<head>
<title>3D Sword</title>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
// Create the scene
const scene = new THREE.Scene();
// Create the camera
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
camera.position.z = 5;
// Create the renderer
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Create the geometry
const geometry = new THREE.BoxGeometry(0.1, 1, 0.1);
// Create the material
const material = new THREE.MeshBasicMaterial({ color: 0x888888 });
// Create the sword mesh
const sword = new THREE.Mesh(geometry, material);
// Add the sword to the scene
scene.add(sword);
// Animation loop
function animate() {
requestAnimationFrame(animate);
sword.rotation.x += 0.01;
sword.rotation.y += 0.01;
renderer.render(scene, camera);
}
// Start the animation loop
animate();
</script>
</body>
</html>
<html>
<head>
<title>3D Sword</title>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
// Create the scene
const scene = new THREE.Scene();
// Create the camera
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
camera.position.z = 5;
// Create the renderer
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Create the geometry
const geometry = new THREE.BoxGeometry(0.1, 1, 0.1);
// Create the material
const material = new THREE.MeshBasicMaterial({ color: 0x888888 });
// Create the sword mesh
const sword = new THREE.Mesh(geometry, material);
// Add the sword to the scene
scene.add(sword);
// Animation loop
function animate() {
requestAnimationFrame(animate);
sword.rotation.x += 0.01;
sword.rotation.y += 0.01;
renderer.render(scene, camera);
}
// Start the animation loop
animate();
</script>
</body>
</html>