Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bielefeld-CeBiTec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2024 Competition
Bielefeld-CeBiTec
Commits
aab35ce8
Commit
aab35ce8
authored
6 months ago
by
Asal Sahami Moghaddam
Browse files
Options
Downloads
Patches
Plain Diff
fanzor
parent
35ba8825
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#425868
passed
6 months ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Fanzorviewer.tsx
+4
-4
4 additions, 4 deletions
src/components/Fanzorviewer.tsx
src/components/three-extended.d.ts
+10
-0
10 additions, 0 deletions
src/components/three-extended.d.ts
with
14 additions
and
4 deletions
src/components/Fanzorviewer
→
src/components/Fanzorviewer
.tsx
+
4
−
4
View file @
aab35ce8
...
@@ -4,19 +4,19 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
...
@@ -4,19 +4,19 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
const
ProteinViewer
:
React
.
FC
=
()
=>
{
const
ProteinViewer
:
React
.
FC
=
()
=>
{
useEffect
(()
=>
{
useEffect
(()
=>
{
//
Step 1:
Set up the scene, camera, and renderer
//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
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
1000
);
const
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
const
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
//
Step 2:
Add lighting to the scene
//Add lighting to the scene
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
);
//
Step 3:
Load the GLB model using GLTFLoader
//Load the GLB model using GLTFLoader
const
loader
=
new
GLTFLoader
();
const
loader
=
new
GLTFLoader
();
loader
.
load
(
`
${
process
.
env
.
PUBLIC_URL
}
/Fanzor.glb`
,
(
gltf
)
=>
{
loader
.
load
(
`
${
process
.
env
.
PUBLIC_URL
}
/Fanzor.glb`
,
(
gltf
)
=>
{
scene
.
add
(
gltf
.
scene
);
// Add the protein model to the scene
scene
.
add
(
gltf
.
scene
);
// Add the protein model to the scene
...
@@ -27,7 +27,7 @@ const ProteinViewer: React.FC = () => {
...
@@ -27,7 +27,7 @@ const ProteinViewer: React.FC = () => {
camera
.
position
.
z
=
5
;
// Adjust the camera position
camera
.
position
.
z
=
5
;
// Adjust the camera position
//
Step 4:
Render loop
//Render loop
const
animate
=
()
=>
{
const
animate
=
()
=>
{
requestAnimationFrame
(
animate
);
requestAnimationFrame
(
animate
);
renderer
.
render
(
scene
,
camera
);
renderer
.
render
(
scene
,
camera
);
...
...
This diff is collapsed.
Click to expand it.
src/components/three-extended.d.ts
0 → 100644
+
10
−
0
View file @
aab35ce8
declare
module
'
three/examples/jsm/loaders/GLTFLoader
'
{
export
class
GLTFLoader
{
load
(
url
:
string
,
onLoad
:
(
gltf
:
{
scene
:
THREE
.
Group
})
=>
void
,
onProgress
?:
(
event
:
ProgressEvent
)
=>
void
,
onError
?:
(
event
:
ErrorEvent
)
=>
void
):
void
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment