Published
Edited
Jun 20, 2020
2 forks
5 stars
Insert cell
Insert cell
w = width
Insert cell
h = width * 118 / 188
Insert cell
{
const scene = new ln.Scene()
const simplex = new SimplexNoise(Date.now())
for (let x = -60; x <= 20; x += 2) {
for (let y = -30; y <= 30; y += 2) {
const p = .8

const cube = new ln.Cube(
new ln.Vector(x - p, y - p, -5),
new ln.Vector(x + p, y + p, 2 + simplex.noise2D(x / 25, y / 25) * 3)
)
cube.paths = function() {
const paths = []
const { x: x1, y: y1, z: z1 } = this.min
const { x: x2, y: y2, z: z2 } = this.max
for(let i = 0; i <= 5; i++) {
const p = i / 5
const x = x1 + (x2 - x1) * p
const y = y1 + (y2 - y1) * p
paths.push([new ln.Vector(x, y1, z1), new ln.Vector(x, y1, z2)])
paths.push([new ln.Vector(x, y2, z1), new ln.Vector(x, y2, z2)])
paths.push([new ln.Vector(x1, y, z1), new ln.Vector(x1, y, z2)])
paths.push([new ln.Vector(x2, y, z1), new ln.Vector(x2, y, z2)])
}
return paths
}
scene.add(cube)
}
}

const eye = new ln.Vector(8, 0, 6)
const center = new ln.Vector(4.8, 0, 0)
const up = new ln.Vector(0, 1, 0)
const paths = scene.render(eye, center, up, w, h, 100, 0.1, 100, 0.01)

return svg`${ln.toSVG(paths, w, h)}`
}
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