Published
Edited
Sep 29, 2020
4 stars
Insert cell
Insert cell
Insert cell
draw()
Insert cell
Insert cell
function *draw() {
while (true) {
camera(function () {
regl.clear({color: [0, 0, 0, 1]})
drawBunny()
})
yield regl.container
}
}
Insert cell
Insert cell
Insert cell
createCamera = require('https://bundle.run/regl-camera@2.1.1')
Insert cell
bunny = require('https://bundle.run/bunny@1.0.1')
Insert cell
normals = require('https://bundle.run/angle-normals@1.0.0')
Insert cell
drawBunny = regl({
frag: `
precision mediump float;
varying vec3 vnormal;
void main () {
gl_FragColor = vec4(abs(vnormal), 1.0);
}`,
vert: `
precision mediump float;
uniform mat4 projection, view;
attribute vec3 position, normal;
varying vec3 vnormal;
void main () {
vnormal = normal;
gl_Position = projection * view * vec4(position, 1.0);
}`,
attributes: {
position: bunny.positions,
normal: normals(bunny.cells, bunny.positions)
},
elements: bunny.cells
})
Insert cell
camera = createCamera(regl, {
center: [0, 3.5, 0],
theta: 3.0 * Math.PI/4.0,
phi: Math.PI/6.0,
distance: 20.0,
damping: 0,
noScroll: true,
renderOnDirty: true
})
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.
Learn more