Platform
Resources
Pricing
Sign in
Contact us
Claudio Esperança
Computer Graphics & Visualization @ufrj.br
Workspace
Fork
Published
gnugraf 2022
By
Claudio Esperança
Edited
Sep 15, 2022
Fork of
Three.js basics
gnugraf 2022
Visualização e Computação Gráfica usando Observable
WebGL com Three.js
WebGL com regl
Canvas e Observable
Visualização de dados com Observable
Usando SVG com Observable
Cadernos de notas Observable
Insert cell
Insert cell
Insert cell
renderer
.
domElement
Insert cell
Insert cell
THREE
=
require
(
"three"
)
Insert cell
Insert cell
renderer
=
new
THREE
.
WebGLRenderer
(
{
canvas
:
html
`<canvas width=640 height=480>`
}
)
Insert cell
Insert cell
camera
=
{
const
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
;
}
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
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
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
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