-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
402 lines (354 loc) · 11.1 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Portfolio</title>
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<style>
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;700&display=swap");
:root {
--primary-color: #f5f5f5; /* Off-white for the shape */
--secondary-color: rgba(
255,
255,
255,
0.1
); /* Semi-transparent white for glass effect */
--accent-color: #4a90e2; /* A nice blue accent color */
--text-color: #ffffff; /* White text */
--bg-color: #000000; /* Black background */
}
body {
font-family: "Source Code Pro", monospace;
line-height: 1.6;
margin: 0;
padding: 0;
background-color: var(--bg-color);
color: var(--text-color);
}
header {
background-color: transparent;
color: var(--text-color);
text-align: center;
padding: 1rem 1.5rem; /* Reduced padding */
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
nav ul {
list-style-type: none;
padding: 0;
display: flex;
justify-content: center;
}
nav ul li {
margin: 0 15px;
}
nav ul li a {
color: var(--text-color);
text-decoration: none;
font-weight: bold;
transition: color 0.3s ease;
}
nav ul li a:hover {
color: var(--accent-color);
}
main {
padding: 3rem;
max-width: 1200px;
margin: 0 auto;
}
section {
margin-bottom: 3rem;
background-color: var(--secondary-color);
border-radius: 8px;
padding: 2rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.project {
background-color: var(--secondary-color);
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.project:hover {
transform: translateY(-5px);
}
form {
display: flex;
flex-direction: column;
}
input,
textarea {
margin-bottom: 1rem;
padding: 0.8rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
background-color: rgba(255, 255, 255, 0.1);
color: var(--text-color);
border-color: var(--accent-color);
}
button {
background-color: var(--accent-color);
color: var(--text-color);
border: none;
padding: 0.8rem 1.5rem;
cursor: pointer;
border-radius: 4px;
font-size: 1rem;
transition: background-color 0.3s ease;
}
button:hover {
background-color: var(--primary-color);
color: var(--bg-color);
}
footer {
background-color: var(--secondary-color);
color: var(--text-color);
text-align: center;
padding: 1rem;
position: fixed;
bottom: 0;
width: 100%;
}
@media (max-width: 768px) {
header {
padding: 1rem;
}
nav ul {
flex-direction: column;
}
nav ul li {
margin-bottom: 10px;
}
main {
padding: 1.5rem;
}
}
#animation-container {
width: 100%;
margin-bottom: 1rem;
}
h1 {
margin-top: 0; /* Remove top margin */
margin-bottom: 1rem; /* Add some space below the title */
}
</style>
</head>
<body>
<header>
<div id="animation-container"></div>
<h1 data-aos="fade-down">David's Portfolio</h1>
<nav>
<ul>
<li>
<a href="#about" data-aos="fade-right" data-aos-delay="100"
>About</a
>
</li>
<li>
<a href="#projects" data-aos="fade-right" data-aos-delay="200"
>Projects</a
>
</li>
<li>
<a href="#contact" data-aos="fade-right" data-aos-delay="300"
>Contact</a
>
</li>
</ul>
</nav>
</header>
<main>
<section id="about" data-aos="fade-up">
<h2>About Me</h2>
<p>
I'm a passionate web developer with a keen eye for design and a love
for creating engaging user experiences.
</p>
</section>
<section id="projects">
<h2 data-aos="fade-up">My Projects</h2>
<div class="project" data-aos="flip-left">
<h3>Project 1</h3>
<p>Description of Project 1</p>
</div>
<div class="project" data-aos="flip-right">
<h3>Project 2</h3>
<p>Description of Project 2</p>
</div>
</section>
<section id="contact" data-aos="zoom-in">
<h2>Contact Me</h2>
<form>
<input type="text" placeholder="Name" required />
<input type="email" placeholder="Email" required />
<textarea placeholder="Message" required></textarea>
<button type="submit">Send</button>
</form>
</section>
</main>
<footer data-aos="fade-up">
<p>© 2023 My Portfolio. All rights reserved.</p>
</footer>
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script>
AOS.init({
duration: 1000,
once: true,
});
</script>
<script type="module">
import * as THREE from "https://unpkg.com/[email protected]/build/three.module.js";
function main() {
const canvas = document.createElement("canvas");
document.getElementById("animation-container").appendChild(canvas);
const renderer = new THREE.WebGLRenderer({ antialias: true, canvas });
const fov = 75;
const aspect = 2; // the canvas default
const near = 0.1;
const far = 5;
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
camera.position.z = 2;
const scene = new THREE.Scene();
// Increased subdivisions for smooth morphing
const boxWidth = 1;
const boxHeight = 1;
const boxDepth = 1;
const segments = 20; // Number of subdivisions
const geometry = new THREE.BoxGeometry(
boxWidth,
boxHeight,
boxDepth,
segments,
segments,
segments
);
const material = new THREE.MeshPhongMaterial({
color: 0x00ff7f,
shininess: 100, // Added shininess for better lighting effect
});
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
const color = 0xffffff;
const intensity = 1;
const light = new THREE.DirectionalLight(color, intensity);
light.position.set(-1, 2, 4);
scene.add(light);
// Store original cube positions
const positionAttribute = geometry.attributes.position;
const vertexCount = positionAttribute.count;
const cubePositions = new Float32Array(positionAttribute.array); // Clone the original positions
// Calculate sphere positions based on cube vertices
const spherePositions = new Float32Array(
positionAttribute.array.length
);
for (let i = 0; i < vertexCount; i++) {
const x = cubePositions[i * 3];
const y = cubePositions[i * 3 + 1];
const z = cubePositions[i * 3 + 2];
const vec = new THREE.Vector3(x, y, z)
.normalize()
.multiplyScalar(0.7); // Adjust scalar for desired sphere size
spherePositions[i * 3] = vec.x;
spherePositions[i * 3 + 1] = vec.y;
spherePositions[i * 3 + 2] = vec.z;
}
// Morph parameter
let morph = { value: 0 };
// GSAP animation for morphing between cube and sphere
gsap.to(morph, {
value: 1,
duration: 3, // Duration for one morph cycle
yoyo: true,
repeat: -1, // Infinite loop
ease: "power1.inOut",
onUpdate: () => {
for (let i = 0; i < vertexCount; i++) {
// Linear interpolation between cube and sphere positions
positionAttribute.array[i * 3] = THREE.MathUtils.lerp(
cubePositions[i * 3],
spherePositions[i * 3],
morph.value
);
positionAttribute.array[i * 3 + 1] = THREE.MathUtils.lerp(
cubePositions[i * 3 + 1],
spherePositions[i * 3 + 1],
morph.value
);
positionAttribute.array[i * 3 + 2] = THREE.MathUtils.lerp(
cubePositions[i * 3 + 2],
spherePositions[i * 3 + 2],
morph.value
);
}
positionAttribute.needsUpdate = true; // Inform Three.js that positions have been updated
geometry.computeVertexNormals(); // Recompute normals for proper lighting
},
});
// GSAP timeline for color shifting
gsap
.timeline({ repeat: -1 })
.to(material.color, {
r: 0,
g: 0,
b: 1,
duration: 2,
onUpdate: () => {
material.color.needsUpdate = true;
},
})
.to(material.color, {
r: 1,
g: 0,
b: 0,
duration: 2,
onUpdate: () => {
material.color.needsUpdate = true;
},
})
.to(material.color, {
r: 0,
g: 1,
b: 0,
duration: 2,
onUpdate: () => {
material.color.needsUpdate = true;
},
});
function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const width = canvas.clientWidth;
const height = canvas.clientHeight;
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
}
return needResize;
}
function render(time) {
time *= 0.001; // Convert to seconds
if (resizeRendererToDisplaySize(renderer)) {
const canvas = renderer.domElement;
camera.aspect = canvas.clientWidth / canvas.clientHeight;
camera.updateProjectionMatrix();
}
// Continuous rotation for a hypnotic effect
cube.rotation.x += 0.005;
cube.rotation.y += 0.005;
renderer.render(scene, camera);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
}
main();
</script>
</body>
</html>