-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
358 lines (310 loc) · 12.7 KB
/
script.js
File metadata and controls
358 lines (310 loc) · 12.7 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
// Interactive video examples functionality
document.addEventListener('DOMContentLoaded', function() {
const thumbnails = document.querySelectorAll('.thumbnail');
const videoPlayer = document.getElementById('examples-video-player');
thumbnails.forEach(thumbnail => {
thumbnail.addEventListener('click', function() {
const videoSrc = this.getAttribute('data-video');
// Update video source
videoPlayer.src = videoSrc;
// Remove active class from all thumbnails
thumbnails.forEach(thumb => thumb.classList.remove('active'));
// Add active class to clicked thumbnail
this.classList.add('active');
// Play the video
videoPlayer.load();
videoPlayer.play();
});
});
// Set first thumbnail as active by default
if (thumbnails.length > 0) {
thumbnails[0].classList.add('active');
}
});
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add scroll effect to navbar
window.addEventListener('scroll', function() {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 100) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = 'none';
}
});
// Add loading animation for images
document.addEventListener('DOMContentLoaded', function() {
const images = document.querySelectorAll('img');
images.forEach(img => {
img.addEventListener('load', function() {
this.style.opacity = '1';
});
img.style.opacity = '0';
img.style.transition = 'opacity 0.3s ease';
});
});
// Add intersection observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all sections for animation
document.querySelectorAll('section').forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
observer.observe(section);
});
// Smooth scrolling for navigation links
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
const navLinks = document.querySelectorAll('.nav-menu a[href^="#"]');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 80; // Account for fixed header
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Add active class to navigation links on scroll
const sections = document.querySelectorAll('section[id]');
const navItems = document.querySelectorAll('.nav-menu a');
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop - 100;
const sectionHeight = section.clientHeight;
if (window.pageYOffset >= sectionTop && window.pageYOffset < sectionTop + sectionHeight) {
current = section.getAttribute('id');
}
});
navItems.forEach(item => {
item.classList.remove('active');
if (item.getAttribute('href') === `#${current}`) {
item.classList.add('active');
}
});
});
// Add hover effects for buttons
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-2px)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Lazy loading for images
const images = document.querySelectorAll('img');
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.style.opacity = '1';
img.style.transform = 'translateY(0)';
observer.unobserve(img);
}
});
});
images.forEach(img => {
img.style.opacity = '0';
img.style.transform = 'translateY(20px)';
img.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
imageObserver.observe(img);
});
// Add copy functionality to citation
const citationBox = document.querySelector('.citation-box');
if (citationBox) {
citationBox.addEventListener('click', function() {
const text = this.querySelector('code').textContent;
navigator.clipboard.writeText(text).then(() => {
// Show a temporary "Copied!" message
const originalContent = this.innerHTML;
this.innerHTML = '<div style="text-align: center; color: #10b981; font-size: 1.1rem; padding: 2rem;">Copied to clipboard!</div>';
setTimeout(() => {
this.innerHTML = originalContent;
}, 2000);
});
});
citationBox.style.cursor = 'pointer';
citationBox.title = 'Click to copy citation';
}
});
// Add CSS for active navigation state
const style = document.createElement('style');
style.textContent = `
.nav-menu a.active {
color: #2563eb !important;
font-weight: 600;
}
.citation-box:hover {
transform: scale(1.02);
transition: transform 0.3s ease;
}
`;
document.head.appendChild(style);
// Lightbox for Gallery
const lightboxModal = document.getElementById('lightbox-modal');
const lightboxImg = document.getElementById('lightbox-img');
const lightboxClose = document.getElementById('lightbox-close');
// Add event listeners for all lightbox triggers (gallery and repainting)
document.querySelectorAll('.gallery-img, .lightbox-trigger').forEach(el => {
el.addEventListener('click', function(e) {
e.preventDefault();
const fullImg = this.getAttribute('data-full') || this.querySelector('img')?.getAttribute('src');
if (fullImg) {
lightboxImg.src = fullImg;
lightboxModal.style.display = 'block';
}
});
});
// Close lightbox
lightboxClose.addEventListener('click', function() {
lightboxModal.style.display = 'none';
lightboxImg.src = '';
});
lightboxModal.addEventListener('click', function(e) {
if (e.target === lightboxModal) {
lightboxModal.style.display = 'none';
lightboxImg.src = '';
}
});
// === Dynamic Demo Examples Thumbnails and Video Player ===
document.addEventListener('DOMContentLoaded', function() {
const videoFiles = [
{ video: 'video_demo/example_1-1.mp4', thumb: 'thumbnails/example_1_thumb.jpg' },
{ video: 'video_demo/example_2-1.mp4', thumb: 'thumbnails/example_2_thumb.jpg' },
{ video: 'video_demo/example_3-1.mp4', thumb: 'thumbnails/example_3_thumb.jpg' },
{ video: 'video_demo/example_4-1.mp4', thumb: 'thumbnails/example_4_thumb.jpg' },
{ video: 'video_demo/example_5-1.mp4', thumb: 'thumbnails/example_5_thumb.jpg' },
{ video: 'video_demo/example_6-1.mp4', thumb: 'thumbnails/example_6_thumb.jpg' },
{ video: 'video_demo/example_7-1.mp4', thumb: 'thumbnails/example_7_thumb.jpg' },
{ video: 'video_demo/example_8-1.mp4', thumb: 'thumbnails/example_8_thumb.jpg' },
];
const thumbnailsContainer = document.getElementById('examples-thumbnails');
const videoPlayer = document.getElementById('examples-video-player');
let caption = document.getElementById('examples-caption');
if (!caption) {
caption = document.createElement('div');
caption.id = 'examples-caption';
caption.className = 'application-caption';
videoPlayer.parentNode.appendChild(caption);
}
thumbnailsContainer.innerHTML = '';
videoFiles.forEach((obj, idx) => {
const thumbDiv = document.createElement('div');
thumbDiv.className = 'app-thumbnail';
thumbDiv.style.cursor = 'pointer';
thumbDiv.style.borderRadius = '8px';
thumbDiv.style.overflow = 'hidden';
thumbDiv.style.border = '2px solid transparent';
thumbDiv.style.width = '120px';
thumbDiv.style.height = '80px';
thumbDiv.style.position = 'relative';
thumbDiv.style.background = '#eee';
const img = document.createElement('img');
img.src = obj.thumb;
img.alt = 'Example video thumbnail';
img.style.width = '100%';
img.style.height = '100%';
img.style.objectFit = 'cover';
thumbDiv.appendChild(img);
thumbDiv.addEventListener('click', function() {
document.querySelectorAll('.app-thumbnail').forEach(t => t.style.border = '2px solid transparent');
thumbDiv.style.border = '2px solid #2563eb';
videoPlayer.src = obj.video;
videoPlayer.load();
videoPlayer.play();
caption.textContent = `Example ${idx + 1}`;
});
// Set first as active
if (idx === 0) {
setTimeout(() => {
thumbDiv.style.border = '2px solid #2563eb';
videoPlayer.src = obj.video;
videoPlayer.load();
caption.textContent = `Example 1`;
}, 100);
}
thumbnailsContainer.appendChild(thumbDiv);
});
});
// === Applications Interactive Gallery ===
const appVideos = [
{ src: 'application_1_resized.mp4', caption: 'Relighting', thumb: 'thumbnails/application_1_thumb.jpg' },
{ src: 'application_2.mp4', caption: 'Interactable Scene', thumb: 'thumbnails/application_2_thumb.jpg' },
{ src: 'application_3_resized.mp4', caption: 'Physically Based Interaction', thumb: 'thumbnails/application_3_thumb.jpg' }
];
const appThumbs = document.getElementById('applications-thumbnails');
const appPlayer = document.getElementById('applications-video-player');
const appCaption = document.getElementById('applications-caption');
if (appThumbs && appPlayer && appCaption) {
appVideos.forEach((vid, idx) => {
// Create thumbnail from static image
const thumbDiv = document.createElement('div');
thumbDiv.className = 'app-thumbnail';
thumbDiv.style.cursor = 'pointer';
thumbDiv.style.borderRadius = '8px';
thumbDiv.style.overflow = 'hidden';
thumbDiv.style.border = '2px solid transparent';
thumbDiv.style.width = '120px';
thumbDiv.style.height = '80px';
thumbDiv.style.position = 'relative';
thumbDiv.style.background = '#eee';
// Use static image for thumbnail
const img = document.createElement('img');
img.src = vid.thumb;
img.alt = 'Application video thumbnail';
img.style.width = '100%';
img.style.height = '100%';
img.style.objectFit = 'cover';
thumbDiv.appendChild(img);
thumbDiv.addEventListener('click', function() {
document.querySelectorAll('.app-thumbnail').forEach(t => t.style.border = '2px solid transparent');
thumbDiv.style.border = '2px solid #2563eb';
appPlayer.src = vid.src;
appPlayer.load();
appPlayer.play();
appCaption.textContent = vid.caption;
});
// Set first as active
if (idx === 0) {
setTimeout(() => {
thumbDiv.style.border = '2px solid #2563eb';
appPlayer.src = vid.src;
appPlayer.load();
appCaption.textContent = vid.caption;
}, 100);
}
appThumbs.appendChild(thumbDiv);
});
}