Published
Edited
Mar 4, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
while (true) {
camera2(status => {
regl2.clear({ color: [0.5, 0.5, 0.6, 1] });
drawBoundaryFaces();
});
yield regl2.canvas;
}
}
Insert cell
drawBoundaryFaces = regl2({
vert: `
precision mediump float;
attribute vec3 position,normal;
attribute float owner;
uniform mat4 view, projection;
varying vec3 N,P;
void main () {
N = normalize((view*vec4(normal, 0)).xyz);
P = (view*vec4(position, 1)).xyz;
gl_Position = projection*view*vec4(position, 1);
}
`,

//
// Next, we define a fragment shader to tell the GPU what color to draw.
//
frag: `
precision mediump float;
varying vec3 N,P;
void main () {
gl_FragColor = vec4(vec3(dot(N,-normalize(P))),1);
}
`,
// Finally we need to give the vertices to the GPU
attributes: {
position: regl2.buffer(boundaryTriangleMeshPoints[0]),
normal: regl2.buffer(boundaryTriangleMeshPoints[1]),
owner: regl2.buffer(boundaryTriangleMeshPoints[2])
},
uniforms: {},
// And also tell it how many vertices to draw
count: boundaryTriangleMeshPoints[0].length / 3,
primitive: "triangles"
})
Insert cell
ownerTexture = regl2.texture({
data: new Uint32Array(owner),
width: owner.length,
height: 1,
format: "depth",
type: "uint32",
mag: "nearest",
min: "nearest",
wrap: "clamp"
})
Insert cell
neighborTexture = regl2.texture({
data: new Uint32Array(neighbors.neighborCellIndex),
width: owner.length,
height: 1,
format: "depth",
type: "uint32",
mag: "nearest",
min: "nearest",
wrap: "clamp"
})
Insert cell
Insert cell
Insert cell
Insert cell
regl2 = {
const myCanvas = html`<canvas width="960" height="500">`;
const regl = createRegl({
canvas: myCanvas,
extensions: ['WEBGL_depth_texture']
});
regl.canvas = myCanvas;
return regl;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Math.sqrt(65328)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
camera2 = createCamera(regl2, cameraSpecs)
Insert cell
cameraSpecs = ({
center: pointsCenter,
//theta: Math.PI / 2.0,
//phi: Math.PI / 4,
distance: .125,
fovy: Math.PI / 5,
near: 0.001,
far: 1,
damping: 0,
noScroll: true,
renderOnDirty: false
})
Insert cell
Insert cell
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