Platform
Solutions
Resources
Pricing
Sign in
Sign up
Claudio Esperança
Computer Graphics & Visualization @ufrj.br
Workspace
Fork
Published
Computer Graphics
By
Claudio Esperança
Edited
Aug 2, 2020
2 forks
9 stars
Insert cell
Insert cell
renderer
.
domElement
Insert cell
Insert cell
THREE
=
require
(
"three@0.119.1"
)
Insert cell
Insert cell
Insert cell
renderer
=
new
THREE
.
WebGLRenderer
(
{
canvas
:
html
`<canvas width=640 height=480>`
}
)
Insert cell
Insert cell
camera
=
{
let
camera
=
new
THREE
.
PerspectiveCamera
(
70
,
4
/
3
,
0.1
,
100
)
;
camera
.
position
.
set
(
0
,
0
,
2
)
return
camera
;
}
Insert cell
Insert cell
cube
=
{
let
geometry
=
new
THREE
.
BoxGeometry
(
1
,
1
,
1
)
let
material
=
new
THREE
.
MeshStandardMaterial
(
{
color
:
0xff0000
}
)
;
return
new
THREE
.
Mesh
(
geometry
,
material
)
;
}
Insert cell
Insert cell
light
=
{
let
light
=
new
THREE
.
DirectionalLight
(
0xffffff
,
1
)
;
light
.
position
.
set
(
1
,
1
,
10
)
return
light
}
Insert cell
Insert cell
scene
=
{
let
scene
=
new
THREE
.
Scene
(
)
;
scene
.
background
=
new
THREE
.
Color
(
0xCCCCCC
)
;
scene
.
add
(
cube
)
scene
.
add
(
light
)
return
scene
}
Insert cell
Insert cell
{
let
xangle
=
0
,
yangle
=
0
;
for
(
let
frame
=
0
;
;
frame
++
)
{
xangle
+=
0.5
*
Math
.
PI
/
180
;
yangle
+=
0.7
*
Math
.
PI
/
180
;
cube
.
rotation
.
set
(
xangle
,
yangle
,
0
)
;
renderer
.
render
(
scene
,
camera
)
;
yield
frame
;
// Observable way of creating an animation...
}
}
Insert cell
One platform
to build and deploy the best data apps
Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
THREE
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
renderer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
camera
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cube
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
light
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
scene
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML