I made an LED 3D mapping tool that might be of interest

I tried a Christmas-y thing too - no tree, so I created a tree in a mess of LEDs mapped in 3D space with marimapper

cyl = [0.44,0.2,0.5] // location of the top of the "tree"
cs = 0.4 // Slope of the side of the tree
br = 0.1 // radius of the start at the top of the tree
th = 0.05

var t1
export function beforeRender(delta) {
  t1 = time(.1)
}

// cone SDF
function cylsdf(x,y,z) {
  dx = x - cyl[0]
  dy = y - cyl[1]
  dz = z - cyl[2]
  dr = sqrt(dx*dx + dz*dz)
  if (dy <0 ) {
   // chop off the top (more correct would be intersecting with a plane)
   return 999
  }
  return dr - dy*cs
}

// sphere SDF for the "star" at the top of the tree
function stsdf(x,y,z) {
  dx = x - cyl[0]
  dy = y - cyl[1]
  dz = z - cyl[2]
  dr = sqrt(dx*dx + dz*dz + dy*dy)
  return dr - br
}



export function render3D(index,x,y,z) {
  bv = stsdf(x,y,z);
  if (bv < 0) {
    // inside the start
    hsv(0.15, 0.5, 1.0)
    return
  }
 
  cv = cylsdf(x,y,z);
  v = 1 - smoothstep(-0.03, 0.0, cv)
  if (cv > 0 && cv < th) {
    // blinky colors just outside the edge of the cone
    pl = perlin(x * 15.0,y* 15.0,z* 15.0 + t1 * 10.0,99)
    pl2 = perlin(x * 15.0 + 4,y* 15.0+8,z* 15.0 + t1 * 10.0,99)
    hsv(pl2, 1.0, pl)
    return
  }
  // green cone
  hsv(0.33, 1.0, v * 0.66)
}
3 Likes