-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
394 lines (352 loc) · 11.1 KB
/
index.html
File metadata and controls
394 lines (352 loc) · 11.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Code Crafters</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
inter: ["Inter", "sans-serif"],
},
},
},
};
</script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<!-- Favicon -->
<link rel="icon" href="/static/favicon/favicon.ico" sizes="32x32" />
<link rel="icon" href="/static/favicon/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/static/favicon/apple-touch-icon.png" />
<link rel="manifest" href="/static/favicon/site.webmanifest" />
</head>
<body>
<style>
body {
margin: 0;
overflow: hidden;
background: black;
font-family: "Inter", sans-serif;
}
#sketch {
width: 100vw;
height: 100vh;
background: black;
}
.loading span {
animation: blur 1.5s calc(var(--i) / 5 * 1s) alternate infinite;
}
@keyframes blur {
to {
filter: blur(5px);
}
}
.hv-center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.hollow {
opacity: 0;
pointer-events: none;
}
</style>
<div id="sketch"></div>
<div
class="fixed z-5 top-0 left-0 loader-screen w-screen h-screen transition-all duration-300 bg-white"
>
<div class="absolute hv-center">
<div class="loading text-3xl tracking-widest whitespace-no-wrap">
<span style="--i: 0">L</span>
<span style="--i: 1">O</span>
<span style="--i: 2">A</span>
<span style="--i: 3">D</span>
<span style="--i: 4">I</span>
<span style="--i: 5">N</span>
<span style="--i: 6">G</span>
</div>
</div>
</div>
<div class="hero-dom opacity-0">
<div class="absolute hv-center">
<div class="flex flex-col items-center space-y-4 whitespace-no-wrap">
<!-- Logo -->
<div class="mb-4">
<img
src="/static/code-crafters-logo.svg"
alt="Code Crafters LLC Logo"
class="h-16 w-auto"
style="filter: brightness(0) invert(1)"
/>
</div>
<div class="text-[42px] text-white font-inter text-center">
Software Solutions
</div>
<div class="text-xl" style="color: #8a8a8a">
<a
href="https://github.com/CodeCraftersLLC"
style="color: #254fd9; text-decoration: none"
>https://github.com/CodeCraftersLLC</a
>
</div>
<div class="text-xl" style="color: #8a8a8a">
contact@codecrafters.llc
</div>
<div class="mt-[120px]">
<div class="text mt-4 text-center max-w-md" style="color: #6a6a6a">
"Simplicity is the ultimate sophistication."
</div>
<div class="text mt-4 text-center max-w-md" style="color: #6a6a6a">
- Leonardo da Vinci
</div>
</div>
</div>
</div>
</div>
<script type="module">
import * as kokomi from "https://esm.sh/kokomi.js";
import * as THREE from "https://esm.sh/three";
import gsap from "https://esm.sh/gsap";
const fragmentShader = /* glsl */ `
uniform float iTime;
uniform vec2 iResolution;
uniform vec2 iMouse;
uniform sampler2D tDiffuse;
varying vec2 vUv;
uniform vec3 uBgColor;
uniform float uRGBShiftIntensity;
uniform float uGrainIntensity;
uniform float uVignetteIntensity;
uniform float uTransitionProgress;
highp float random(vec2 co)
{
highp float a=12.9898;
highp float b=78.233;
highp float c=43758.5453;
highp float dt=dot(co.xy,vec2(a,b));
highp float sn=mod(dt,3.14);
return fract(sin(sn)*c);
}
vec3 grain(vec2 uv,vec3 col,float amount){
float noise=random(uv+iTime);
col+=(noise-.5)*amount;
return col;
}
vec4 RGBShift(sampler2D tex,vec2 uv,float amount){
vec2 rUv=uv;
vec2 gUv=uv;
vec2 bUv=uv;
float noise=random(uv+iTime)*.5+.5;
vec2 offset=amount*vec2(cos(noise),sin(noise));
rUv+=offset;
gUv+=offset*.5;
bUv+=offset*.25;
vec4 rTex=texture(tex,rUv);
vec4 gTex=texture(tex,gUv);
vec4 bTex=texture(tex,bUv);
vec4 col=vec4(rTex.r,gTex.g,bTex.b,gTex.a);
return col;
}
vec3 vignette(vec2 uv,vec3 col,vec3 vigColor,float amount){
vec2 p=uv;
p-=.5;
float d=length(p);
float mask=smoothstep(.5,.3,d);
mask=pow(mask,.6);
float mixFactor=(1.-mask)*amount;
col=mix(col,vigColor,mixFactor);
return col;
}
float sdCircle(vec2 p,float r)
{
return length(p)-r;
}
vec3 transition(vec2 uv,vec3 col,float progress){
float ratio=iResolution.x/iResolution.y;
// circle
vec2 p=uv;
p-=.5;
p.x*=ratio;
float d=sdCircle(p,progress*sqrt(2.2));
float c=smoothstep(-.2,0.,d);
col=mix(vec3(1.),col,1.-c);
return col;
}
void main(){
vec2 uv=vUv;
vec4 tex=RGBShift(tDiffuse,uv,uRGBShiftIntensity);
vec3 col=tex.xyz;
col=grain(uv,col,uGrainIntensity);
col=vignette(uv,col,uBgColor,uVignetteIntensity);
col=transition(uv,col,uTransitionProgress);
gl_FragColor=vec4(col,1.);
}
`;
class Sketch extends kokomi.Base {
create() {
const config = {
bgColor: "#0c0c0c",
};
const params = {
transitionProgress: 0,
enterProgress: 0,
rotateSpeed: 15,
};
this.renderer.setClearColor(new THREE.Color(config.bgColor), 1);
this.camera.position.set(0, 0, 16);
// new kokomi.OrbitControls(this);
const sumFormula = (n) => {
return (n * (n + 1)) / 2;
};
const isOdd = (n) => {
return n % 2 === 1;
};
const circleCount = 3;
const circleImgCountUnit = 12;
const circleImgTotalCount =
circleImgCountUnit * sumFormula(circleCount);
const resourceList = [...Array(circleImgTotalCount).keys()].map(
(_, i) => ({
name: `tex${i + 1}`,
type: "texture",
path: "/static/code-images/0.png",
})
);
const am = new kokomi.AssetManager(this, resourceList);
am.on("ready", () => {
document.querySelector(".loader-screen")?.classList.add("hollow");
const material = new THREE.MeshBasicMaterial();
const r = 6.4;
const scale = 0.8;
const rings = [];
const lines = [];
for (let i = 0; i < circleCount; i++) {
const c1 = sumFormula(i) * circleImgCountUnit;
const c2 = sumFormula(i + 1) * circleImgCountUnit;
const textures = Object.values(am.items).slice(c1, c2);
const ring = new THREE.Group();
this.scene.add(ring);
rings.push(ring);
const meshes = textures.map((tex, j) => {
const line = new THREE.Group();
ring.add(line);
lines.push(line);
const imgScale = 0.005 * scale * (i * 0.36 + 1);
const width = tex.image.width * imgScale;
const height = tex.image.height * imgScale;
const geometry = new THREE.PlaneGeometry(width, height);
const mat = material.clone();
mat.map = tex;
mat.needsUpdate = true;
const mesh = new THREE.Mesh(geometry, mat);
const r2 = r * (i + 1);
const ratio = j / (c2 - c1);
const angle = ratio * Math.PI * 2;
mesh.position.x = r2;
mesh.rotation.z = -Math.PI / 2;
line.rotation.z = angle;
line.add(mesh);
return mesh;
});
}
const ce = new kokomi.CustomEffect(this, {
fragmentShader,
uniforms: {
uBgColor: {
value: new THREE.Color(config.bgColor),
},
uRGBShiftIntensity: {
value: 0.0025,
},
uGrainIntensity: {
value: 0.025,
},
uVignetteIntensity: {
value: 0.8,
},
uTransitionProgress: {
value: 0,
},
},
});
ce.addExisting();
this.ce = ce;
const wheelScroller = new kokomi.WheelScroller();
wheelScroller.listenForScroll();
const dragDetecter = new kokomi.DragDetecter(this);
dragDetecter.detectDrag();
dragDetecter.on("drag", (delta) => {
wheelScroller.scroll.target -= (delta.x || delta.y) * 2;
});
this.update(() => {
wheelScroller.syncScroll();
rings.forEach((ring, i) => {
ring.rotation.z +=
0.0025 *
(isOdd(i) ? -1 : 1) *
(1 + wheelScroller.scroll.delta) *
params.rotateSpeed;
});
lines.forEach((line) => {
line.position.z =
-THREE.MathUtils.lerp(
0,
100,
THREE.MathUtils.mapLinear(
wheelScroller.scroll.delta,
0,
1000,
0,
1
)
) + THREE.MathUtils.lerp(10, 0, params.enterProgress);
});
this.ce.customPass.material.uniforms.uTransitionProgress.value =
params.transitionProgress;
});
const anime = () => {
const t1 = gsap.timeline();
t1.to(params, {
transitionProgress: 1,
duration: 1,
ease: "power1.inOut",
})
.fromTo(
params,
{
enterProgress: 0,
rotateSpeed: 10,
},
{
enterProgress: 1,
rotateSpeed: 1,
duration: 1.5,
ease: "power1.inOut",
},
"-=1"
)
.to(
".hero-dom",
{
opacity: 1,
},
"-=1"
);
};
anime();
});
}
}
const sketch = new Sketch("#sketch");
sketch.create();
</script>
</body>
</html>