Published
Edited
Dec 25, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
snowFlakeRenderable = ({
frag: `
precision mediump float;
uniform float alpha;
void main () {
gl_FragColor = vec4(0.5,0.1,0.9,alpha);
}`,

vert: `
attribute vec2 position;
uniform mat4 projection, view;
void main () {
gl_Position = projection * view * vec4(position, 0, 1);
}`,

attributes: {
position: snowFlake2D.positions
},

uniforms: {
view: snowFlakeViewMatrix,
projection: snowFlakeProjectionMatrix,
alpha: +srcAlpha
},
count : snowFlake2D.positions.length
})
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
snowFlakeViewMatrix = mat4.lookAt([],[ 0, 0, 1000],[0, 0, 0], [0, 1, 0])
Insert cell
snowFlakeProjectionMatrix = mat4.perspective([], Math.PI / 4, canvasWidth / canvasHeight, 500, 5000)
Insert cell
Insert cell
Insert cell
Insert cell
disableBlend = regl({
blend: {
enable: false
}
})
Insert cell
enableBlend = regl({
blend: {
enable: true,
func: {
src:blendOptions.srcFactor,dst:blendOptions.dstFactor //default: src:'src alpha',dst:'one minus src alpha'
},
equation: 'add', // Default. Yoy may or may not add this line.
},
depth: { enable: false }
})
Insert cell
blendOptions
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

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.
Learn more