-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1522 lines (1308 loc) · 57 KB
/
script.js
File metadata and controls
1522 lines (1308 loc) · 57 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
document.addEventListener('DOMContentLoaded', () => {
const cursor = document.querySelector('.custom-cursor');
const sections = document.querySelectorAll('section');
const interactiveElements = document.querySelectorAll('a, button, .hover-area');
const header = document.querySelector('header');
const footer = document.querySelector('footer');
const menuIcon = document.getElementById('menu-icon');
const navMenu = document.getElementById('navMenu');
// Function to update cursor style
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.bottom >= 0
);
}
function updateCursorStyle() {
let cursorUpdated = false;
if (isInViewport(header)) {
cursor.className = 'custom-cursor header-cursor';
cursorUpdated = true;
}
sections.forEach((section) => {
if (isInViewport(section) && !cursorUpdated) {
cursor.className = `custom-cursor ${section.className}-cursor`;
cursorUpdated = true;
}
});
if (isInViewport(footer) && !cursorUpdated) {
cursor.className = 'custom-cursor footer-cursor';
cursorUpdated = true;
}
if (!cursorUpdated) {
cursor.className = 'custom-cursor';
}
}
// Function to handle menu icon click
menuIcon.addEventListener('click', () => {
navMenu.classList.toggle('active');
menuIcon.classList.toggle('hidden');
});
//handle hovering of menuicon
menuIcon.addEventListener('mouseenter', () => {
menuIcon.classList.add('hover');
});
menuIcon.addEventListener('mouseleave', () => {
menuIcon.classList.remove('hover');
});
// Handle clicks outside of the menu
document.addEventListener('click', (event) => {
if (!navMenu.contains(event.target) && !menuIcon.contains(event.target)) {
navMenu.classList.remove('active');
menuIcon.classList.remove('hidden');
}
});
// Handle custom cursor movement
document.addEventListener('mousemove', (e) => {
cursor.style.left = `${e.clientX}px`;
cursor.style.top = `${e.clientY}px`;
});
// Handle interactive elements
interactiveElements.forEach(el => {
el.addEventListener('mouseenter', () => cursor.classList.add('hidden'));
el.addEventListener('mouseleave', () => cursor.classList.remove('hidden'));
});
// Update cursor style on scroll and resize
window.addEventListener('scroll', updateCursorStyle);
window.addEventListener('resize', updateCursorStyle);
updateCursorStyle(); // Initial cursor style update
});
// loader
document.body.classList.add("loading");
const loader = document.querySelector('.loader')
const home = document.querySelector('#home')
const about = document.querySelector('#about')
const showcase = document.querySelector('#showcase')
const service = document.querySelector('#creative-universe-portfolio')
const insight = document.querySelector('#insights')
window.addEventListener('load', () => {
loader.classList.add('hidden')
home.classList.add('shown')
about.classList.add('shown')
showcase.classList.add('shown')
service.classList.add('shown')
insight.classList.add('shown')
document.body.classList.remove("loading");
})
//button effect
const view_button = document.querySelector('.view-services-btn');
const button_text = document.querySelector('.view-services-btn .text');
// Mouse move
const activate_button = (event) => {
let boundBox = view_button.getBoundingClientRect();
const button_strength = 40;
const text_strength = 80;
const newX = ((event.clientX - boundBox.left) / view_button.offsetWidth) - 0.5;
const newY = ((event.clientY - boundBox.top) / view_button.offsetHeight) - 0.5;
// Applying new positions to button
gsap.to(view_button, {
duration: 1,
x: newX * button_strength,
y: newY * button_strength,
ease: Power4.easeOut
});
// Applying new positions to text
gsap.to(button_text, {
duration: 1,
x: newX * text_strength,
y: newY * text_strength,
ease: Power4.easeOut
});
}
// Mouse leave
const reset_button = (event) => {
gsap.to(view_button, {
duration: 1,
x: 0,
y: 0,
ease: Elastic.easeOut
});
gsap.to(button_text, {
duration: 1,
x: 0,
y: 0,
ease: Elastic.easeOut
});
}
view_button.addEventListener('mousemove', activate_button);
view_button.addEventListener('mouseleave', reset_button);
//hero "hello" animation
document.addEventListener('DOMContentLoaded', (event) => {
const helloText = document.querySelector('.hero h3');
helloText.addEventListener('mouseenter', () => {
if (!helloText.classList.contains('wiggling')) {
helloText.classList.add('wiggling');
}
});
helloText.addEventListener('animationend', () => {
helloText.classList.remove('wiggling');
});
});
// const viewButton = document.querySelector('.view-services-btn');
// const hoverEffect = viewButton.querySelector('.hover-effect');
// viewButton.addEventListener('mouseenter', (e) => {
// const rect = viewButton.getBoundingClientRect();
// const x = e.clientX - rect.left;
// const y = e.clientY - rect.top;
// hoverEffect.style.left = `${x}px`;
// hoverEffect.style.top = `${y}px`;
// const size = Math.max(viewButton.offsetWidth, viewButton.offsetHeight) * 2;
// hoverEffect.style.width = `${size}px`;
// hoverEffect.style.height = `${size}px`;
// });
// viewButton.addEventListener('mouseleave', () => {
// hoverEffect.style.width = '0';
// hoverEffect.style.height = '0';
// });
//contact form -->
// Get the contact lightbox
const contactLightbox = document.getElementById('contact-lightbox');
// Get the button that opens the contact lightbox
const contactBtn = document.querySelector('nav a[href="#contact-lightbox"]');
// Get the <span> element that closes the contact lightbox
const contactSpan = document.querySelector('.contact-close');
// When the user clicks on the button, open the contact lightbox
contactBtn.onclick = function (e) {
e.preventDefault();
contactLightbox.style.display = 'block';
}
// When the user clicks on <span> (x), close the contact lightbox
contactSpan.onclick = function () {
contactLightbox.style.display = 'none';
}
// When the user clicks anywhere outside of the contact lightbox, close it
window.onclick = function (event) {
if (event.target == contactLightbox) {
contactLightbox.style.display = 'none';
}
}
const contactForm = document.getElementById('contact-form');
const clearFormBtn = document.getElementById('clear-form');
const submitButton = contactForm.querySelector('button[type="submit"]');
// Function to clear all form fields
function clearForm() {
contactForm.reset();
}
// Clear button event listener
clearFormBtn.addEventListener('click', clearForm);
// Handle form submission
contactForm.addEventListener('submit', function (e) {
e.preventDefault();
const formData = new FormData(contactForm);
// Convert form data to an object to check field names
const dataObject = {};
formData.forEach((value, key) => {
dataObject[key] = value;
});
// Show loader and disable the submit button
loader.classList.remove('hidden');
submitButton.disabled = true;
// Send form data to the server
fetch('https://portfolio-r2xj.onrender.com/send-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(dataObject)
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Thank you for your message! We will get back to you soon.');
clearForm();
contactLightbox.style.display = 'none';
} else {
alert('There was an error sending your message. Please try again.');
}
})
.catch(error => {
console.error('Error:', error);
alert('There was an error sending your message. Please try again.');
})
.finally(() => {
// Hide loader and enable the submit button
loader.classList.add('hidden');
submitButton.disabled = false;
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Thank you for your message! We will get back to you soon.');
clearForm();
contactLightbox.style.display = 'none';
} else {
alert('There was an error sending your message. Please try again.');
}
})
.catch(error => {
console.error('Error:', error);
alert('There was an error sending your message. Please try again.');
})
.finally(() => {
// Hide loader and enable the submit button
loader.classList.add('hidden');
submitButton.disabled = false;
});
});
// lenis
const lenis = new Lenis()
lenis.on('scroll', (e) => {
console.log(e)
})
lenis.on('scroll', ScrollTrigger.update)
gsap.ticker.add((time) => {
lenis.raf(time * 1000)
})
gsap.ticker.lagSmoothing(0)
//Showcase image parallax
gsap.fromTo(
".showcase-image img",
{ xPercent: 30 },
{
xPercent: 0,
ease: "power1.out",
scrollTrigger: {
trigger: ".showcase",
start: "top bottom",
end: "bottom 95%",
scrub: true,
once: true,
}
}
);
// Create stars
function createStars() {
const starsContainer = document.createElement('div');
starsContainer.classList.add('stars');
for (let i = 0; i < 100; i++) {
const star = document.createElement('div');
star.classList.add('star');
star.style.width = `${Math.random() * 3}px`;
star.style.height = star.style.width;
star.style.left = `${Math.random() * 100}%`;
star.style.top = `${Math.random() * 100}%`;
// Add blink class to some stars
if (Math.random() < 0.5) {
star.classList.add('blink');
}
starsContainer.appendChild(star);
}
document.querySelector('.personal-insights').prepend(starsContainer);
}
// Animate rocket
function animateRocket() {
const rocket = document.createElement('div');
rocket.classList.add('rocket');
document.querySelector('.personal-insights').appendChild(rocket);
const randomizePath = (reverse = false) => {
// Path that covers the entire viewport with alternating directions
const path = reverse
? [
{ x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight },
{ x: window.innerWidth, y: 0 },
{ x: 0, y: Math.random() * window.innerHeight }
]
: [
{ x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight },
{ x: 0, y: 0 },
{ x: window.innerWidth, y: Math.random() * window.innerHeight }
];
return path;
};
const animate = (reverse = false) => {
gsap.to(rocket, {
motionPath: {
path: randomizePath(reverse),
curviness: 1.5
},
duration: 20,
ease: "power1.inOut",
onComplete: () => animate(!reverse) // Switch direction after each path completes
});
};
animate();
}
// Animate insight cards
function animateInsightCards() {
gsap.from(".insight-card", {
y: 50,
opacity: 0,
duration: 1,
stagger: 0.2,
scrollTrigger: {
trigger: ".insights-grid",
start: "top 80%"
}
});
// Floating animation
gsap.to(".insight-card", {
y: "10px",
duration: 2,
repeat: -1,
yoyo: true,
ease: "power1.inOut",
stagger: 0.1
});
}
// Animate quote
function animateQuote() {
const quoteText = document.querySelector(".quote-text").textContent;
const quoteElement = document.querySelector(".quote-text");
quoteElement.textContent = "";
gsap.to(quoteElement, {
duration: 4,
text: {
value: quoteText,
delimiter: ""
},
ease: "none",
scrollTrigger: {
trigger: ".quote-container",
start: "top 80%"
}
});
// Pulsing animation
gsap.to(".quote-container", {
scale: 1.05,
duration: 2,
repeat: -1,
yoyo: true,
ease: "power1.inOut"
});
}
// Add hover animations to insight cards
gsap.utils.toArray(".insight-card").forEach(card => {
card.addEventListener("mouseenter", () => {
gsap.to(card, {
scale: 1.05,
duration: 0.4,
ease: "power1.inOut"
});
gsap.to(card.querySelector('i'), {
scale: 1.2,
color: "#f39c12",
duration: 0.4,
ease: "power1.inOut"
});
});
card.addEventListener("mouseleave", () => {
gsap.to(card, {
scale: 1,
duration: 0.4,
ease: "power1.inOut"
});
gsap.to(card.querySelector('i'), {
scale: 1,
color: "#3498db",
duration: 0.4,
ease: "power1.inOut"
});
});
});
// animated quote
gsap.utils.toArray(".quote-container").forEach(container => {
const text = container.querySelector(".quote-text");
container.addEventListener("mouseenter", () => {
gsap.to(text, {
scale: 1.2,
duration: 0.8,
ease: "slow"
});
});
container.addEventListener("mouseleave", () => {
gsap.to(text, {
scale: 1,
duration: 1,
ease: "elastic.out(1, 0.3)"
});
});
});
//fadeup and sideways of titles
// Animate elements with fade-up effect
gsap.from(".animate-fade-up", {
opacity: 0,
y: 50,
duration: 0.7,
stagger: 0.3,
scrollTrigger: {
trigger: ".animate-fade-up",
start: "top 90%",
}
});
// Animate elements with zoom-in effect
gsap.from(".animate-zoom-in", {
opacity: 0,
scale: 0.8,
duration: 0.6,
scrollTrigger: {
trigger: ".animate-zoom-in",
start: "top 80%",
}
});
// Project Data
const projects = [
{
title: "LearnQuest",
description: "A micro-learning platform that curates personalized educational content using APIs like YouTube, Gemini, and GitHub. Users can explore bite-sized lessons, participate in challenges, and track their learning progress through a simple, intuitive interface.",
techStack: ["Flutter", "Firebase", "Python Backend", "Gemini API", "YouTube API", "Web Scraping"],
link: "project.html?project=learnquest"
},
{
title: "Chat Connect",
description: "A real-time chat application built to facilitate seamless communication with features like instant messaging, typing indicators, and message status updates. It focuses on minimal UI and efficient message handling, ensuring low latency and reliability.",
techStack: ["Flutter", "Firebase", "Cloud Firestore", "Authentication", "Push Notifications"],
link: "project.html?project=chatApp"
},
{
title: "Student-Teacher Portal",
description: "An academic management app designed to streamline communication and task handling between students and teachers. It includes features like assignment tracking, attendance management, announcements, and personal feedback systems.",
techStack: ["Flutter", "Firebase", "Cloud Functions", "Firestore", "Role-based Access Control"],
link: "project.html?project=acdemics"
},
{
title: "Zentry AI Assistant",
description: "A real-time AI voice assistant designed for telephony and institutional automation. It integrates high-accuracy speech-to-text, lightweight reasoning with RAG, and future-ready TTS to deliver human-like conversations in multiple languages. Built around FreeSWITCH and optimized for local deployment, it enables scalable use in education, healthcare, and enterprise support systems.",
techStack: ["FreeSWITCH", "CTranslate2 Whisper", "Phi-3 Mini", "RAG", "Meta MMS", "Python", "FastAPI", "Docker"],
link: "project.html?project=zentryai"
}
];
let currentProjectIndex = 0;
const projectContentDiv = document.getElementById('projectContent'); // The planet visual
const textDetailsContainer = document.getElementById('textDetailsContainer'); // New container for text
const projectTitle = document.getElementById('projectTitle');
const projectDescription = document.getElementById('projectDescription');
const projectTechStack = document.getElementById('projectTechStack');
const projectLinkBtn = document.getElementById('projectLinkBtn');
const loadingIndicator = document.getElementById('loadingIndicator');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const miniMapSVG = document.getElementById('miniMapSVG');
const messageBox = document.getElementById('messageBox');
const messageText = document.getElementById('messageText');
const closeMessageBoxBtn = document.getElementById('closeMessageBox');
const innerViewscreen = document.querySelector('.inner-viewscreen');
const hudGridWrapper = document.querySelector('.hud-grid-wrapper');
const mainContentArea = document.querySelector('.hud-panel-main-content-area');
// HUD elements for dynamic updates
const hudClock = document.getElementById('hudClock');
const hudTarget = document.getElementById('hudTarget');
const sensorTemp = document.getElementById('sensorTemp');
const sensorHum = document.getElementById('sensorHum');
const sensorPres = document.getElementById('sensorPres');
const cpuProgressBar = document.getElementById('cpuProgressBar');
const commSignal = document.getElementById('commSignal');
const commLatency = document.getElementById('commLatency');
const logEntry1 = document.getElementById('logEntry1');
const logEntry2 = document.getElementById('logEntry2');
const logEntry3 = document.getElementById('logEntry3');
const powerMain = document.getElementById('powerMain');
const powerAux = document.getElementById('powerAux');
const scaleIndicator = document.getElementById('scaleIndicator'); // New scale indicator
// Three.js Variables
let scene, camera, renderer, stars, starGeo, starMaterial;
let mouseX = 0, mouseY = 0;
let windowHalfX = window.innerWidth / 2;
let windowHalfY = window.innerHeight / 2;
let animationFrameId;
// Global variables to store planet dimensions for animations
let currentPlanetDiameter;
// Function to initialize Three.js
function initThreeJS() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, innerViewscreen.clientWidth / innerViewscreen.clientHeight, 1, 1000);
camera.position.z = 5;
const canvas = document.getElementById('spaceCanvas');
renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: true, alpha: true });
renderer.setSize(innerViewscreen.clientWidth, innerViewscreen.clientHeight);
renderer.setPixelRatio(window.devicePixelRatio);
starGeo = new THREE.BufferGeometry();
const vertices = [];
for (let i = 0; i < 15000; i++) {
const x = Math.random() * 800 - 400;
const y = Math.random() * 800 - 400;
const z = Math.random() * 800 - 400;
vertices.push(x, y, z);
}
starGeo.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
const starTextureCanvas = document.createElement('canvas');
starTextureCanvas.width = 16;
starTextureCanvas.height = 16;
const context = starTextureCanvas.getContext('2d');
context.beginPath();
context.arc(8, 8, 8, 0, Math.PI * 2, false);
context.fillStyle = 'white';
context.fill();
const starTexture = new THREE.CanvasTexture(starTextureCanvas);
starMaterial = new THREE.PointsMaterial({
color: 0xaaaaaa,
size: 0.8,
map: starTexture,
transparent: true,
opacity: 0.8,
blending: THREE.AdditiveBlending
});
stars = new THREE.Points(starGeo, starMaterial);
scene.add(stars);
document.addEventListener('mousemove', onDocumentMouseMove, false);
window.addEventListener('resize', onWindowResize, false);
}
function onDocumentMouseMove(event) {
mouseX = (event.clientX - windowHalfX) * 0.001;
mouseY = (event.clientY - windowHalfY) * 0.001;
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = innerViewscreen.clientWidth / innerViewscreen.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerViewscreen.clientWidth, innerViewscreen.clientHeight);
createMiniMap();
updateProjectContent(currentProjectIndex); // Recalculate planet and text positions
}
function animate() {
animationFrameId = requestAnimationFrame(animate);
stars.rotation.x += 0.0005;
stars.rotation.y += 0.0005;
stars.position.z += 0.5;
if (stars.position.z > 200) stars.position.z = -200;
camera.position.x += (mouseX - camera.position.x) * .05;
camera.position.y += (-mouseY - camera.position.y) * .05;
camera.lookAt(scene.position);
renderer.render(scene, camera);
}
// --- Text Typing Animation (no cursor) ---
function typeText(element, text, speed = 5) { /* Speed set to 5ms for faster typing */
let i = 0;
element.textContent = ''; // Clear existing text
return new Promise(resolve => {
function type() {
if (i < text.length) {
element.textContent += text.charAt(i);
i++;
setTimeout(type, speed);
} else {
resolve();
}
}
type();
});
}
// --- Dynamic HUD Data Updates ---
const logMessages = [
"Analyzing atmospheric composition.",
"Gravitational field stable.",
"Energy fluctuations detected. Source unknown.",
"Mapping surface topography.",
"Life signs scan initiated.",
"Receiving faint signal. Decrypting...",
"System diagnostics complete. All parameters nominal.",
"Warning: Proximity alert. Unidentified object.",
"Initiating evasive maneuvers.",
"Data packet loss: 0.02%. Re-transmitting.",
"Calculating optimal trajectory."
];
let currentLogIndex = 0;
function updateHudData() {
// Update linear scale indicator
const randomDegree = (Math.random() * 360) - 180; // -180 to +180
const positionPercentage = ((randomDegree + 180) / 360) * 100;
if (scaleIndicator) {
scaleIndicator.style.left = `${positionPercentage}%`;
}
// Left sidebar - Sensor Readout
if (sensorTemp) sensorTemp.textContent = `${(Math.random() * 50 - 20).toFixed(1)}°C`; // -20 to 30 C
if (sensorHum) sensorHum.textContent = `${Math.floor(Math.random() * 100)}%`;
if (sensorPres) sensorPres.textContent = `${(Math.random() * 100 + 950).toFixed(0)}hPa`; // 950 to 1050 hPa
const cpuUsage = Math.floor(Math.random() * 100);
if (cpuProgressBar) {
cpuProgressBar.style.width = `${cpuUsage}%`;
cpuProgressBar.style.background = cpuUsage > 80 ? 'linear-gradient(90deg, rgba(255,0,0,0.5), #f00)' : 'linear-gradient(90deg, rgba(0, 255, 255, 0.5), #0ff)';
}
const signalStrength = Math.random();
if (commSignal) {
commSignal.textContent = signalStrength > 0.9 ? 'STRONG' : (signalStrength > 0.5 ? 'NORMAL' : 'WEAK');
commSignal.style.color = signalStrength > 0.9 ? '#6ee7b7' : (signalStrength > 0.5 ? '#fbbf24' : '#f87171');
}
if (commLatency) commLatency.textContent = `${Math.floor(Math.random() * 100)}ms`;
// Right sidebar - Mission Log
currentLogIndex = (currentLogIndex + 1) % logMessages.length;
if (logEntry1) logEntry1.textContent = logMessages[currentLogIndex];
if (logEntry2) logEntry2.textContent = logMessages[(currentLogIndex + 1) % logMessages.length];
if (logEntry3) logEntry3.textContent = logMessages[(currentLogIndex + 2) % logMessages.length];
// Power Diagnostics
if (powerMain) powerMain.textContent = `${(Math.random() * 100).toFixed(1)}%`;
if (powerAux) powerAux.textContent = `${(Math.random() * 100).toFixed(1)}%`;
}
let lastAnimatedProjectIndex = -1;
// Function to update project content and position elements
async function updateProjectContent(index) {
const project = projects[index];
const isMobile = window.innerWidth <= 768;
// Update dynamic HUD elements that relate to the project
if (hudTarget) hudTarget.textContent = `TARGET: ${project.title.toUpperCase()}`;
// Get dimensions of the main content area
const mainContentAreaWidth = mainContentArea.clientWidth;
const mainContentAreaHeight = mainContentArea.clientHeight;
// --- Planet Positioning (Bottom Corner, visible) ---
// Planet size: 80% of the main content area's height
currentPlanetDiameter = mainContentAreaHeight * 0.8;
if (window.innerWidth <= 768) {
// Clear or set explicit mobile-friendly inline styles for text container
textDetailsContainer.style.width = ''; // Let CSS define width
textDetailsContainer.style.height = ''; // Let CSS define height
textDetailsContainer.style.left = ''; // Let CSS define position
textDetailsContainer.style.right = '';
textDetailsContainer.style.top = '';
textDetailsContainer.style.bottom = '';
textDetailsContainer.style.transform = '';
// Clear or set explicit mobile-friendly inline styles for planet
projectContentDiv.style.width = ''; // Let CSS define width
projectContentDiv.style.height = ''; // Let CSS define height
projectContentDiv.style.left = ''; // Let CSS define position
projectContentDiv.style.right = '';
projectContentDiv.style.top = '';
projectContentDiv.style.bottom = '';
projectContentDiv.style.transform = '';
projectContentDiv.style.opacity = ''; // Let CSS define opacity
projectContentDiv.style.boxShadow = ''; // Let CSS define box-shadow
projectContentDiv.style.background = ''; // Let CSS define background
} else {
projectContentDiv.style.width = `${currentPlanetDiameter}px`;
projectContentDiv.style.height = `${currentPlanetDiameter}px`;
projectContentDiv.style.bottom = `2%`; // Offset from bottom
projectContentDiv.style.transform = `none`; // Remove any transforms
projectContentDiv.style.opacity = 0.6; // Increased opacity for more visibility
projectContentDiv.style.zIndex = 2; // Behind text
if (index % 2 === 0) { // Even index: planet bottom-right
projectContentDiv.style.right = `2%`; // Offset from right
projectContentDiv.style.left = `auto`;
projectContentDiv.style.background = `radial-gradient(circle at 70% 70%, #4a90e2, #2e62a4, #1a3a60)`; /* Blue planet gradient */
projectContentDiv.style.boxShadow = `0 0 40px rgba(74, 144, 226, 0.9)`; /* Stronger blue glow */
} else { // Odd index: planet bottom-left
projectContentDiv.style.left = `2%`; // Offset from left
projectContentDiv.style.right = `auto`;
projectContentDiv.style.background = `radial-gradient(circle at 30% 70%, #4a90e2, #2e62a4, #1a3a60)`; /* Blue planet gradient */
projectContentDiv.style.boxShadow = `0 0 40px rgba(74, 144, 226, 0.9)`; /* Stronger blue glow */
}
// --- Text Container Positioning (Offset from center, opposite to planet) ---
const textContainerHorizontalMargin = mainContentAreaWidth * 0.05; // 5% from side edges
const textContainerVerticalMargin = mainContentAreaHeight * 0.05; // 5% from top/bottom edges
let textCardCalculatedWidth;
let textCardCalculatedLeft;
let textCardCalculatedRight;
// Calculate space for text based on planet's corner presence
if (index % 2 === 0) { // Planet is on the right (bottom-right), text is on the left/center
textCardCalculatedLeft = textContainerHorizontalMargin;
// Text ends before the planet starts, plus a small gap
// Planet takes 80% of height, so it takes up 0.8 * mainContentAreaHeight.
// If it's at the bottom, the space it occupies horizontally is its width (0.8 * mainContentAreaHeight).
// We want to leave a gap from the planet's edge.
const planetOccupiedWidth = currentPlanetDiameter * 0.6; // Assuming 60% of planet width is visible horizontally
textCardCalculatedRight = planetOccupiedWidth + (mainContentAreaWidth * 0.03); // Visible planet width + gap
textCardCalculatedWidth = mainContentAreaWidth - textCardCalculatedLeft - textCardCalculatedRight;
} else { // Planet is on the left (bottom-left), text is on the right/center
// Text starts after the planet ends, plus a small gap
const planetOccupiedWidth = currentPlanetDiameter * 0.6; // Assuming 60% of planet width is visible horizontally
textCardCalculatedLeft = planetOccupiedWidth + (mainContentAreaWidth * 0.03); // Visible planet width + gap
textCardCalculatedRight = textContainerHorizontalMargin;
textCardCalculatedWidth = mainContentAreaWidth - textCardCalculatedLeft - textCardCalculatedRight;
}
// Ensure textCardCalculatedWidth is not too small
if (textCardCalculatedWidth < (mainContentAreaWidth * 0.4)) { // Minimum 40% of main content area width
textCardCalculatedWidth = mainContentAreaWidth * 0.4;
}
// Text container height: Fill most of the vertical space
let textCardHeight = mainContentAreaHeight - (textContainerVerticalMargin * 2);
textDetailsContainer.style.width = `${textCardCalculatedWidth}px`;
textDetailsContainer.style.height = `${textCardHeight}px`;
textDetailsContainer.style.top = `${textContainerVerticalMargin}px`; // Position from top
textDetailsContainer.style.bottom = `${textContainerVerticalMargin}px`; // Position from bottom
textDetailsContainer.style.left = `${textCardCalculatedLeft}px`;
textDetailsContainer.style.right = `${textCardCalculatedRight}px`;
textDetailsContainer.style.transform = `none`; // Remove any transforms
}
// Reset content and opacity for internal elements before animation
projectTitle.textContent = '';
projectDescription.textContent = '';
projectTechStack.innerHTML = '';
projectLinkBtn.style.opacity = 0; // Start button invisible
projectLinkBtn.style.display = 'none'; // Hide it initially
if (isMobile && index === lastAnimatedProjectIndex) {
projectTitle.textContent = project.title;
projectDescription.textContent = project.description;
projectTechStack.innerHTML = project.techStack.map(tech => `<span>${tech}</span>`).join('');
if (project.link) {
projectLinkBtn.href = project.link;
projectLinkBtn.style.display = 'inline-flex';
gsap.to(projectLinkBtn, { opacity: 1, duration: 0 }); // Ensure visible instantly
} else {
projectLinkBtn.style.display = 'none';
gsap.to(projectLinkBtn, { opacity: 0, duration: 0 });
}
gsap.to(textDetailsContainer, { opacity: 1, duration: 0 }); // Ensure container is visible
updateNavigationButtons();
updateMiniMap();
return; // Exit the function early
}
// Update the last animated project index ONLY if we are proceeding with the animation
lastAnimatedProjectIndex = index;
// Hide the whole container before starting sequential reveal
gsap.to(textDetailsContainer, { opacity: 0, duration: 0 });
// Define a GSAP timeline for sequential animations within the text container
const contentTimeline = gsap.timeline({
onComplete: () => {
// After all internal animations are done, fade in the main text container
gsap.to(textDetailsContainer, { opacity: 1, duration: 0.7, ease: "power2.out" });
}
});
// 1. Type the title
contentTimeline.call(async () => {
await typeText(projectTitle, project.title, 300);
});
// 2. Instantly set description after title typing is conceptually complete
contentTimeline.call(() => {
projectDescription.textContent = project.description;
}, [], ">+=0.5"); // Small delay after title typing might finish
// 3. Animate tech stack tags with a staggered effect
contentTimeline.call(() => {
const techSpans = [];
project.techStack.forEach(tech => {
const span = document.createElement('span');
span.textContent = tech;
// Initial styles are already set in CSS for animation (opacity: 0, translateY(10px))
projectTechStack.appendChild(span);
techSpans.push(span);
});
gsap.to(techSpans, {
opacity: 1,
y: 0,
duration: 0.2,
ease: "power2.out",
stagger: 0.1, // Staggered appearance
});
}, [], ">+=0.2"); // Delay after description appears
// 4. Animate the button
if (project.link) {
projectLinkBtn.href = project.link;
contentTimeline.call(() => {
projectLinkBtn.style.display = 'block'; // Make it display before fading in
gsap.to(projectLinkBtn, {
opacity: 1,
duration: 0.5,
ease: "power2.out"
});
}, [], ">+=0.2"); // Delay after tech stack animation
} else {
projectLinkBtn.style.display = 'none';
projectLinkBtn.style.opacity = 0;
}
updateNavigationButtons();
updateMiniMap();
}
function updateNavigationButtons() {
prevBtn.disabled = currentProjectIndex === 0;
nextBtn.disabled = currentProjectIndex === projects.length - 1;
}
// Show loading indicator and prepare for transition
function showLoading() {
loadingIndicator.classList.add('active');
// Animate planet shrinking and fading, moving to center of inner-viewscreen
gsap.to(projectContentDiv, {
opacity: 0,
scale: 0.5, /* Use scale to maintain circular shape */
left: '50%', // Move to center of inner-viewscreen
right: 'auto', // Reset right
x: '-50%', // Center horizontally
top: '50%', // Move to center of inner-viewscreen
y: '-50%', // Center vertically
duration: 0.5,
ease: "power2.in"
});
// Animate text details fading out
gsap.to(textDetailsContainer, {
opacity: 0,
duration: 0.3,
ease: "power2.in"
});
}
// Hide loading indicator and finalize transition
function hideLoading() {
loadingIndicator.classList.remove('active');
// Animate planet growing and fading in, moving back to its original position
gsap.fromTo(projectContentDiv,
{
opacity: 0,
scale: 0.5,
left: '50%', // Start from center
right: 'auto',
x: '-50%',
top: '50%',
y: '-50%',
},
{
opacity: 0.6, // Fade back to subtle background opacity
scale: 1, // Animate to full size
left: currentProjectIndex % 2 === 0 ? `auto` : `2%`, // Back to original left/right
right: currentProjectIndex % 2 !== 0 ? `auto` : `2%`,
x: '0', // Reset GSAP x/y transforms
y: '0',
bottom: `2%`, // Back to original bottom (relative to main-content-area)
top: `auto`, // Remove top
transform: `none`, // Back to original transform
duration: 1,
ease: "power2.out"
}
);
// Text details are animated in `updateProjectContent` after typing
}
async function nextProject() {
if (currentProjectIndex < projects.length - 1) {
showLoading();
currentProjectIndex++;
await warpSpeedEffect();
updateProjectContent(currentProjectIndex);
hideLoading();
}
}