-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>{{ page.title | escape }}</title> | ||
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}"> | ||
{{ content_for_header }} | ||
</head> | ||
<body> | ||
|
||
<!-- Create a canvas for the torus animation --> | ||
<canvas id="torusCanvas"></canvas> | ||
|
||
<!-- The main content of your page will go here --> | ||
<div class="content"> | ||
{{ content }} | ||
</div> | ||
|
||
<!-- Include Three.js and the animation script --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script> | ||
<script src="{{ "/assets/script.js" | relative_url }}"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Set up the scene, camera, and renderer | ||
const scene = new THREE.Scene(); | ||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | ||
const renderer = new THREE.WebGLRenderer({ canvas: document.querySelector('#torusCanvas'), alpha: true }); | ||
renderer.setSize(window.innerWidth, window.innerHeight); | ||
|
||
// Create a blue torus | ||
const geometry = new THREE.TorusGeometry(1, 0.4, 16, 100); | ||
const material = new THREE.MeshBasicMaterial({ color: 0x0000ff, wireframe: true }); | ||
const torus = new THREE.Mesh(geometry, material); | ||
scene.add(torus); | ||
|
||
// Position the camera | ||
camera.position.z = 5; | ||
|
||
// Animation loop | ||
function animate() { | ||
requestAnimationFrame(animate); | ||
torus.rotation.x += 0.01; | ||
torus.rotation.y += 0.01; | ||
renderer.render(scene, camera); | ||
} | ||
animate(); | ||
|
||
// Adjust canvas on resize | ||
window.addEventListener('resize', () => { | ||
renderer.setSize(window.innerWidth, window.innerHeight); | ||
camera.aspect = window.innerWidth / window.innerHeight; | ||
camera.updateProjectionMatrix(); | ||
}); |