Published
Edited
Apr 15, 2021
1 fork
6 stars
Insert cell
Insert cell
bnbThree({
w: 540, h: 540,
numFrames: 120,
fps: 20,
record: true,
//video: true,
//shutterAngle: .4,
//samplesPerFrame: 16,
createScene: (THREE, sketch, globals) => {
const scene = new THREE.Scene()

const geometry = new THREE.IcosahedronGeometry()
const material = new THREE.MeshNormalMaterial()
const mesh = new THREE.Mesh(geometry, material)
scene.add(mesh)

const camera = new THREE.PerspectiveCamera(75, globals.w / globals.h, 0.1, 5)
camera.position.z = 1.8
camera.lookAt(mesh.position)

const renderer = new THREE.WebGLRenderer({ antialias: true })
renderer.setSize(globals.w, globals.h)
renderer.setClearColor(0x1f1f1f)

// createScene must return a function to update the scene
return (sketch, time, globals) => {
const angle = time * sketch.TAU
mesh.rotation.x = angle
mesh.rotation.y = angle

renderer.render(scene, camera)
// the update function must return the renderer
return renderer
}
}
})
Insert cell
Insert cell
Insert cell
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