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

**URL:** <https://forum.electromage.com/t/i-made-an-led-3d-mapping-tool-that-might-be-of-interest/3598>\
**Category:** Show and Tell\
**Tags:** mapping\
**Created:** [June 14, 2024, 4:40pm UTC](https://forum.electromage.com/t/i-made-an-led-3d-mapping-tool-that-might-be-of-interest/3598 "2024-06-14T16:40:49Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![ted](https://forum.electromage.com/user_avatar/forum.electromage.com/ted/32/3656_2.png) [@ted](https://forum.electromage.com/u/ted)\
**Post date:** [December 21, 2024, 11:18pm UTC](https://forum.electromage.com/t/i-made-an-led-3d-mapping-tool-that-might-be-of-interest/3598/11 "2024-12-21T23:18:14Z")

</div>

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

[/uploads/default/original/2X/9/986a8641b82e204ef5e3bfcd576bd9f9d6c54cd7.mp4](https://forum.electromage.com/uploads/default/original/2X/9/986a8641b82e204ef5e3bfcd576bd9f9d6c54cd7.mp4)

```auto
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)
}

```

---

_[View the full topic](https://forum.electromage.com/t/i-made-an-led-3d-mapping-tool-that-might-be-of-interest/3598)._
