Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created July 8, 2019 12:08
Show Gist options
  • Save mattdesl/3ac03a01175a8730b59be71d5ee922e3 to your computer and use it in GitHub Desktop.
Save mattdesl/3ac03a01175a8730b59be71d5ee922e3 to your computer and use it in GitHub Desktop.
export default {
// Configuration of the program
props: {
// 3D -> 2D projection settings
camera: {
type: 'orthographic',
zoom: 2.25,
position: [ 1, 1, 1 ]
},
// Vertex transformation before screen space transformation
transform: {
rotate: [
({ playhead }) => playhead * Math.PI * 2,
0,
0
]
},
// Shape/dimensions of generative structure
shape: [ 8, 8, 8 ],
// Can pass down any additional user properties
// If you specify a function, it will be evaluated from current props
radius: ({ width }) => width * 0.005
},
// Transform UVW to XYZ in world-space
vertex ({ uv }) {
// Map 0..1 to -1..1
return uv.map(n => n * 2 - 1);
},
// Map the transformed screen-space XY position into renderable nodes
render (data, { radius }) {
return data.map(({ position }) => {
return {
type: 'circle',
position,
radius
};
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment