@@ -29,21 +29,6 @@ const WebGLInitializer = () => {
29
29
canvas . width = window . innerWidth ;
30
30
canvas . height = window . innerHeight ;
31
31
32
- // const fontFace = new FontFace(
33
- // 'Grotesk',
34
- // 'url(/AlteHaasGroteskBold.ttf)'
35
- // );
36
- // document.fonts.add(fontFace);
37
-
38
- // const style = document.createElement('style');
39
- // style.innerHTML = `
40
- // @import url(/AlteHaasGroteskBold.ttf);
41
- // body {
42
- // font-family: 'Grotesk', sans-serif;
43
- // }
44
- // `;
45
- // document.head.appendChild(style);
46
-
47
32
const textDiv = document . createElement ( 'div' ) ;
48
33
textDiv . style . position = 'absolute' ;
49
34
textDiv . style . left = '0' ;
@@ -54,7 +39,6 @@ const WebGLInitializer = () => {
54
39
textDiv . style . fontFamily = 'Grotesk' ;
55
40
textDiv . style . color = 'rgba(255,255,255,1)' ;
56
41
textDiv . style . display = 'flex' ;
57
- // textDiv.style.lineHeight = '0px';
58
42
textDiv . style . justifyContent = 'center' ;
59
43
textDiv . style . alignItems = 'center' ;
60
44
textDiv . textContent = 'BASE AI' ;
@@ -73,7 +57,7 @@ const WebGLInitializer = () => {
73
57
await document . fonts . ready ;
74
58
document . body . appendChild ( textDiv ) ;
75
59
76
- const lineHeight = window . getComputedStyle ( textDiv ) . lineHeight ; // e.g., "20px"
60
+ const lineHeight = window . getComputedStyle ( textDiv ) . lineHeight ;
77
61
const y = parseFloat ( lineHeight ) ;
78
62
79
63
const canvas = await html2canvas ( textDiv , {
@@ -84,7 +68,6 @@ const WebGLInitializer = () => {
84
68
logging : false ,
85
69
y : y * 0 ,
86
70
x : 0 ,
87
- // foreignObjectRendering: true,
88
71
onclone : document => {
89
72
Array . from ( document . querySelectorAll ( '*' ) ) . forEach ( e => {
90
73
let existingStyle = e . getAttribute ( 'style' ) || '' ;
@@ -133,7 +116,6 @@ const WebGLInitializer = () => {
133
116
}
134
117
) ;
135
118
136
- // Custom shader material for the enhanced liquid wavy effect
137
119
const material = new THREE . ShaderMaterial ( {
138
120
transparent : true ,
139
121
uniforms : {
@@ -409,7 +391,6 @@ const WebGLInitializer = () => {
409
391
`
410
392
} ) ;
411
393
412
- // Create a mesh with the geometry and material
413
394
const sphere = new THREE . Mesh ( geometry , material ) ;
414
395
scene . add ( sphere ) ;
415
396
@@ -418,7 +399,7 @@ const WebGLInitializer = () => {
418
399
function calculateCameraZ ( screenWidth : number , screenHeight : number ) {
419
400
let cameraZ ;
420
401
421
- // Breakpoints based on screen width and height
402
+
422
403
if ( screenWidth <= 768 ) {
423
404
if ( screen . availWidth < screen . availHeight ) {
424
405
cameraZ = 4.5 ;
@@ -427,46 +408,41 @@ const WebGLInitializer = () => {
427
408
}
428
409
} else if ( screenWidth > 768 && screenWidth <= 1920 ) {
429
410
if ( screenHeight <= 1080 ) {
430
- cameraZ = 2 ; // Full HD screens (1920x1080)
411
+ cameraZ = 2 ;
431
412
} else {
432
- cameraZ = 1.9 ; // Higher aspect ratio or larger height
413
+ cameraZ = 1.9 ;
433
414
}
434
415
} else if ( screenWidth > 1920 && screenWidth <= 2440 ) {
435
416
if ( screenHeight <= 1080 ) {
436
- cameraZ = 1.75 ; // Wide screens with Full HD height
417
+ cameraZ = 1.75 ;
437
418
} else {
438
- cameraZ = 1.65 ; // Taller screens with higher resolutions
419
+ cameraZ = 1.65 ;
439
420
}
440
421
} else if ( screenWidth > 2440 ) {
441
422
if ( screenHeight <= 1440 ) {
442
- cameraZ = 1.5 ; // Ultra-wide or larger 2K displays
423
+ cameraZ = 1.5 ;
443
424
} else {
444
- cameraZ = 1.4 ; // 4K and above
425
+ cameraZ = 1.4 ;
445
426
}
446
427
}
447
428
448
429
return cameraZ ;
449
430
}
450
431
451
- // Get screen width and height
452
432
const screenWidth = window . innerWidth ;
453
433
const screenHeight = window . innerHeight ;
454
434
455
- // Calculate camera Z position based on breakpoints
456
435
const cameraZ = calculateCameraZ ( screenWidth , screenHeight ) ;
457
436
if ( cameraZ ) camera . position . z = cameraZ ;
458
437
459
- // Raycaster setup
460
438
const raycaster = new THREE . Raycaster ( ) ;
461
439
const mouse = new THREE . Vector2 ( ) ;
462
440
463
- // Animation loop
464
441
const animate = ( ) => {
465
442
requestAnimationFrame ( animate ) ;
466
- material . uniforms . u_time . value += 0.02 ; // Update time for animation
443
+ material . uniforms . u_time . value += 0.02 ;
467
444
material . uniforms . u_viewVector . value = camera . position ;
468
445
469
- // Update mouse position in the shader
470
446
raycaster . setFromCamera ( mouse , camera ) ;
471
447
const intersects = raycaster . intersectObject ( sphere ) ;
472
448
if ( intersects . length > 0 ) {
@@ -501,13 +477,6 @@ const WebGLInitializer = () => {
501
477
502
478
updateCameraPosition ( ) ;
503
479
504
- // Update background texture with new dimensions
505
- createHighResBackgroundTexture ( width , height ) . then ( texture => {
506
- scene . background = texture ;
507
- if ( material . uniforms && material . uniforms . u_background ) {
508
- material . uniforms . u_background . value = texture ;
509
- }
510
- } ) ;
511
480
createHighResBackgroundTexture ( width , height ) . then ( texture => {
512
481
scene . background = texture ;
513
482
if ( material . uniforms && material . uniforms . u_background ) {
@@ -529,4 +498,4 @@ const WebGLInitializer = () => {
529
498
return < div ref = { mountRef } /> ;
530
499
} ;
531
500
532
- export default WebGLInitializer ;
501
+ export default WebGLInitializer ;
0 commit comments