Skip to content
Snippets Groups Projects
Commit df25d7ff authored by Asal Sahami Moghaddam's avatar Asal Sahami Moghaddam
Browse files

fanzor

parent e24ebc43
No related branches found
No related tags found
No related merge requests found
...@@ -2,21 +2,27 @@ import React, { useEffect } from 'react'; ...@@ -2,21 +2,27 @@ import React, { useEffect } from 'react';
import * as THREE from 'three'; import * as THREE from 'three';
export const ProteinViewer: React.FC = () => { export const ProteinViewer: React.FC = () => {
const viewerRef = useRef<HTMLDivElement>(null); // Ref for the div container
useEffect(() => { useEffect(() => {
//Set up the scene, camera, and renderer
const scene = new THREE.Scene(); const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000); // Adjust aspect ratio if needed
const renderer = new THREE.WebGLRenderer({ antialias: true }); const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
//Add lighting to the scene renderer.setSize(200, 200);
// Append the renderer to the div container instead of body
if (viewerRef.current) {
viewerRef.current.appendChild(renderer.domElement);
}
const light = new THREE.DirectionalLight(0xffffff, 1); const light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(0, 1, 2); light.position.set(0, 1, 2);
scene.add(light); scene.add(light);
camera.position.z = 5; // Adjust the camera position camera.position.z = 5;
//Render loop
// Render loop
const animate = () => { const animate = () => {
requestAnimationFrame(animate); requestAnimationFrame(animate);
renderer.render(scene, camera); renderer.render(scene, camera);
...@@ -25,11 +31,23 @@ export const ProteinViewer: React.FC = () => { ...@@ -25,11 +31,23 @@ export const ProteinViewer: React.FC = () => {
// Clean up on component unmount // Clean up on component unmount
return () => { return () => {
document.body.removeChild(renderer.domElement); if (viewerRef.current) {
viewerRef.current.removeChild(renderer.domElement);
}
}; };
}, []); }, []);
return null; // No JSX to return as we're appending the canvas directly to the body return (
<div
ref={viewerRef}
style={{
width: '400px', // Customize the width
height: '400px', // Customize the height
margin: '0 auto', // Center it if you want
border: '1px solid #ddd', // Optional: border around the viewer
}}
/>
);
}; };
export default ProteinViewer; export default ProteinViewer;
\ No newline at end of file
...@@ -168,7 +168,7 @@ export function Engineering() { ...@@ -168,7 +168,7 @@ export function Engineering() {
<div className="bg-lb box" > <div className="bg-lb box" >
<H3 id="Nikase" text="Nikase"></H3> <H3 id="Nikase" text="Nikase"></H3>
<p><LoremShort></LoremShort></p> <p><LoremShort></LoremShort></p>
<img src="https://static.igem.wiki/teams/5247/fanzor/movie2-ezgif-com-video-to-gif-converter.gif"></img> <img src="https://static.igem.wiki/teams/5247/fanzor/movie4-ezgif-com-video-to-gif-converter.gif"></img>
</div> </div>
<div className="box" > <div className="box" >
<p id="nik1"> <p id="nik1">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment