-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
97 lines (82 loc) · 2.74 KB
/
index.js
File metadata and controls
97 lines (82 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
gsap.from("h1", {duration: 1, y: -50, opacity: 0, ease: "power2.out"});
gsap.from("h2", {duration: 1, y: -50, opacity: 0, ease: "power2.out", delay: 0.5});
gsap.utils.toArray("h3").forEach(h3 => {
gsap.from(h3, {
scrollTrigger: {
trigger: h3,
start: "top 90%",
toggleActions: "play none none reverse"
},
y: 50,
opacity: 0,
duration: 0.8,
ease: "power2.out"
});
});
gsap.utils.toArray("img").forEach(img => {
gsap.from(img, {
scrollTrigger: {
trigger: img,
start: "top 90%",
toggleActions: "play none none reverse"
},
y: 50,
opacity: 0,
duration: 0.8,
ease: "power2.out",
delay: 0.2 // slight delay after h3 animation
});
});
// Three.js setup
let scene, camera, renderer, textMesh;
function initThreeJS() {
const container = document.getElementById('threejs-container');
// Scene
scene = new THREE.Scene();
// Camera
camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
camera.position.z = 5;
// Renderer
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.appendChild(renderer.domElement);
// Lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);
const pointLight = new THREE.PointLight(0xffffff, 1);
pointLight.position.set(5, 5, 5);
scene.add(pointLight);
// Font Loader
const loader = new THREE.FontLoader();
loader.load('https://threejs.org/examples/fonts/helvetiker_regular.typeface.json', function (font) {
const textGeometry = new THREE.TextGeometry('Sree Raj', {
font: font,
size: 1,
height: 0.2,
curveSegments: 12,
bevelEnabled: true,
bevelThickness: 0.03,
bevelSize: 0.02,
bevelOffset: 0,
bevelSegments: 5
});
textGeometry.center();
const textMaterial = new THREE.MeshPhongMaterial({ color: 0x0077ff });
textMesh = new THREE.Mesh(textGeometry, textMaterial);
scene.add(textMesh);
});
// Handle window resize
window.addEventListener('resize', onWindowResize, false);
animate();
}
function onWindowResize() {
const container = document.getElementById('threejs-container');
camera.aspect = container.clientWidth / container.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(container.clientWidth, container.clientHeight);
}
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
initThreeJS();