Skip to content

Commit

Permalink
first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Dec 11, 2024
1 parent 7944f9e commit 712ef81
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"framer-motion": "^11.13.5",
"motion": "^11.13.5",
"next": "15.0.4",
"react": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.2.0",
"three": "^0.171.0"
},
Expand Down
23 changes: 21 additions & 2 deletions src/components/robot/robotRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, { useEffect, useRef } from "react";
import * as THREE from "three";
import URDFLoader from "urdf-loader";

const URDF_URL = "/cad/gpr-20241204.urdf";

const RobotRenderer: React.FC = () => {
const mountRef = useRef<HTMLDivElement | null>(null);

Expand All @@ -17,16 +19,24 @@ const RobotRenderer: React.FC = () => {
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);

if (mountRef.current) {
mountRef.current.appendChild(renderer.domElement);
}

const loader = new URDFLoader();
loader.load("/cad/gpr-20241204.urdf", (robot: THREE.Object3D) => {
loader.load(URDF_URL, (robot: THREE.Object3D) => {
scene.add(robot);
});

const light = new THREE.AmbientLight(0x404040);
scene.add(light);

const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);

camera.position.z = 5;

const animate = () => {
Expand All @@ -36,14 +46,23 @@ const RobotRenderer: React.FC = () => {

animate();

const handleResize = () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
};

window.addEventListener("resize", handleResize);

return () => {
if (mountRef.current) {
mountRef.current.removeChild(renderer.domElement);
}
window.removeEventListener("resize", handleResize);
};
}, []);

return <div ref={mountRef} />;
return <div ref={mountRef} className="w-full h-full" />;
};

export default RobotRenderer;
12 changes: 6 additions & 6 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import RobotRenderer from "@/components/robot/robotRenderer";

const HeaderSection = () => {
return (
<section className="pt-16 bg-black text-white">
<div className="flex flex-col items-center text-center pt-10">
<section className="pt-16">
<div className="flex flex-col items-center text-center pt-10 px-4 max-w-full">
<h1 className="text-5xl mt-16">
The world&apos;s first humanoid robot for those who prefer transparency over trust.
</h1>
Expand All @@ -21,25 +21,25 @@ const HeaderSection = () => {

const RobotSection = () => {
return (
<div className="flex flex-col items-center text-center pt-10">
<div className="flex flex-col items-center text-center pt-10 max-w-full aspect-square border-2 rounded-lg my-8">
<RobotRenderer />
</div>
);
};

const BuyNowSection = () => {
return (
<div className="flex flex-col items-center text-center pt-10">
<div className="flex flex-col items-center text-center pt-10 max-w-full">
<CTAButton />
</div>
);
};

export default function Home() {
return (
<div className="min-h-screen flex flex-col bg-black text-white">
<div className="min-h-screen flex flex-col">
<NavBar />
<main className="flex-grow p-8 max-w-7xl mx-auto">
<main className="flex-grow p-8 max-w-7xl mx-auto px-4 w-full">
<HeaderSection />
<RobotSection />
<BuyNowSection />
Expand Down
13 changes: 0 additions & 13 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,3 @@ pre {
@apply font-normal;
font-style: normal;
}

.scroll-lock {
overflow: hidden;
height: 100vh; /* Prevents resizing quirks */
}

::-webkit-scrollbar-thumb {
display: none;
}

::-webkit-scrollbar {
display: none;
}

0 comments on commit 712ef81

Please sign in to comment.