MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / WebGLInitializer

Function WebGLInitializer

apps/baseai.dev/src/components/home/webgl.tsx:8–499  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import '../../styles/webgl.css';
7
8const WebGLInitializer = () => {
9 const mountRef = useRef<HTMLDivElement | null>(null);
10
11 useEffect(() => {
12 const scene = new THREE.Scene();
13 const camera = new THREE.PerspectiveCamera(
14 75,
15 window.innerWidth / window.innerHeight,
16 0.1,
17 1000
18 );
19 const renderer = new THREE.WebGLRenderer({
20 alpha: true,
21 antialias: true
22 });
23 renderer.setSize(window.innerWidth, window.innerHeight);
24 if (mountRef.current) {
25 mountRef.current.appendChild(renderer.domElement);
26 }
27
28 const canvas = document.createElement('canvas');
29 canvas.width = window.innerWidth;
30 canvas.height = window.innerHeight;
31
32 const textDiv = document.createElement('div');
33 textDiv.style.position = 'absolute';
34 textDiv.style.left = '0';
35 textDiv.style.top = '0';
36 textDiv.style.width = '100%';
37 textDiv.style.height = '100%';
38 textDiv.style.fontWeight = 'bold';
39 textDiv.style.fontFamily = 'Grotesk';
40 textDiv.style.color = 'rgba(255,255,255,1)';
41 textDiv.style.display = 'flex';
42 textDiv.style.justifyContent = 'center';
43 textDiv.style.alignItems = 'center';
44 textDiv.textContent = 'BASE AI';
45 textDiv.style.zIndex = '-1';
46
47 const PIXEL_RATIO = 2;
48 const createHighResBackgroundTexture = async (
49 width: number,
50 height: number
51 ) => {
52 const scale = PIXEL_RATIO;
53 textDiv.style.width = `${width}px`;
54 textDiv.style.height = `${height}px`;
55 textDiv.style.fontSize = `${width * 0.192}px`;
56
57 await document.fonts.ready;
58 document.body.appendChild(textDiv);
59
60 const lineHeight = window.getComputedStyle(textDiv).lineHeight;
61 const y = parseFloat(lineHeight);
62
63 const canvas = await html2canvas(textDiv, {
64 backgroundColor: '#000000',
65 scale: scale,

Callers

nothing calls this directly

Calls 4

createInitialTextureFunction · 0.85
calculateCameraZFunction · 0.70
animateFunction · 0.70
updateCameraPositionFunction · 0.70

Tested by

no test coverage detected