Skip to content

Commit

Permalink
3DModel-component
Browse files Browse the repository at this point in the history
  • Loading branch information
AB10110F committed Jul 21, 2023
1 parent 9cfdab2 commit b82050f
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 2 deletions.
50 changes: 50 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"@types/p5": "^1.6.2",
"@types/react": "18.2.7",
"@types/react-dom": "18.2.4",
"@types/three": "^0.154.0",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
"lucide-react": "^0.260.0",
"next": "13.4.4",
"p5": "^1.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"three": "^0.154.0",
"typescript": "5.0.4"
}
}
20 changes: 20 additions & 0 deletions src/app/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
font-size: 100px;
}

.home
{
width: 70%;
display: flex;
flex-direction: row;
justify-content: space-between;
}

.canvasContainer
{
width: 380px;
background-color: rgb(31, 31, 31);
border: 1px solid rgb(113, 113, 113);
}

.canvasContent
{
height: 180px;
}

.projects
{
display: flex;
Expand Down
17 changes: 16 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from './page.module.css'
import { Metadata } from 'next'
import Terminal from '@/components/Terminal'
import Typewriter from '@/components/Typewriter'
import Model from '@/components/Model'
import localFont from 'next/font/local'
import { ChevronRight, X, Minus, Square } from 'lucide-react';

Expand All @@ -12,7 +13,21 @@ export default function Home() {
return (
<main className={styles.main}>
<Typewriter text={' Front-End Developer'}/> {/* TODO What is wrong with the position 1? */}
<Terminal/>
<div className={styles.home}>
<Terminal/>
<div className={styles.canvasContainer}>
<section className={styles.windowOptions}>
<article>
<Minus />
<Square />
<X />
</article>
</section>
<section className={styles.canvasContent}>
<Model/>
</section>
</div>
</div>
<h1 className={dotFont.className}>Projects</h1>
<div className={styles.projects}>
<div className={styles.windowContainer}>
Expand Down
51 changes: 51 additions & 0 deletions src/components/Model.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use client"
import React, { useEffect, useRef } from 'react';
import * as THREE from 'three';



const AsciiCube = () => {
const canvasRef = useRef<HTMLCanvasElement>(null!);

useEffect(() => {
const canvas = canvasRef.current;
const renderer = new THREE.WebGLRenderer({ canvas });

const width = 380;
const height = 400;

canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;

renderer.setSize(width, height);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
30,
width / height,
0.1,
1000
);
camera.position.z = 5;

const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0xffffff });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);

const animate = () => {
requestAnimationFrame(animate);

cube.rotation.x += 0.01;
cube.rotation.y += 0.01;

renderer.render(scene, camera);
};

animate();
}, []);

return <canvas ref={canvasRef} />;
};

export default AsciiCube;
2 changes: 1 addition & 1 deletion src/css/terminal.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.windowContainer
{
width: 50%;
width: 60%;
box-sizing: border-box;
animation: bottom 1s ease;
}
Expand Down

0 comments on commit b82050f

Please sign in to comment.