Weaving Light: Creating a 3D Digital Tapestry in py5

2026/8/3

Textile weaving is one of humanity's oldest technologies, reliant on the precise, mathematical interlacing of threads. In the digital realm, we can simulate this intricate overlapping using 3D rendering and generative code. "Abstract Woven Fiber Tapestry 3D" is an exploration of this concept. By mathematically defining hundreds of virtual threads and intersecting them in three-dimensional space, we can create a luminous, cybernetic fabric that constantly breathes and undulates.The visual result is a macroscopic view of a glowing, neon structure. Three hundred distinct geometric lines twist around a central axis, shifting through the full HSB color spectrum. As the virtual camera gently rocks back and forth, the parallax reveals the deep 3D volume of the weave. Utilizing Python and the py5 library, we can easily orchestrate this complex 3D string-art, relying on additive blending to make the dense intersections burn with intense light.

Visual & Aesthetic Approach

The aesthetic goal is to create something that feels simultaneously highly structured and biologically alive. The structure comes from the strict, algorithmic placement of the lines. The "life" comes from two techniques: continuous background fading and slow trigonometric camera rotation.Instead of clearing the canvas entirely every frame, the sketch draws a highly transparent black rectangle (`alpha = 8`). This creates a short, fading trail behind every moving thread, softening the harsh edges of the geometry and giving the entire tapestry a silky, motion-blurred texture.
# Only partially clear background for trails
py5.fill(0, 0, 0, 8)
py5.no_stroke()
py5.rect(0, 0, py5.width, py5.height)
Combined with py5.blend_mode(py5.ADD), the points where the 300 threads cross one another accumulate light values rapidly, turning the center of the weave into a bright, glowing core.

Code & Technical Breakdown

While the visual output resembles a complex folded surface, the underlying code actually draws straight lines. The curvature is an optical illusion created by the density of the lines, much like physical string art or a spirograph.

The Breathing Camera

To give the viewer a sense of the 3D depth of the weave, the entire canvas is slowly tilted back and forth using sine and cosine waves.
t = py5.frame_count * 0.015
py5.rotate_x(py5.sin(t * 0.3) * 0.5)
py5.rotate_y(py5.cos(t * 0.2) * 0.5)
This ensures the camera is never static, constantly revealing the parallax separation between the top and bottom layers of the digital threads.

Weaving the Threads in 3D

The core of the sketch is a loop that calculates the start and end points of 300 lines. The start points form an undulating, star-like perimeter, while the end points connect to the opposite side of the circle.
num_threads = 300

for i in range(num_threads):
    # Distribute points around a circle
    angle = py5.TWO_PI * i / num_threads + t
    
    # Modulate radius to create a folded shape
    radius = 400 + 200 * py5.sin(angle * 3 + t * 2)
    
    # Use 1D noise to create depth displacement (the "warp" of the weave)
    z_offset = py5.os_noise(i * 0.1, t) * 600 - 300
    
    # Calculate start point
    x = py5.cos(angle) * radius
    y = py5.sin(angle) * radius
    
    # Calculate end point (opposite side of the circle, slightly offset)
    x2 = py5.cos(angle + py5.PI + py5.sin(t)*0.5) * (radius * 0.8)
    y2 = py5.sin(angle + py5.PI + py5.cos(t)*0.5) * (radius * 0.8)
    
    # Draw the 3D thread
    py5.line(x, y, z_offset, x2, y2, -z_offset)
By assigning a positive z_offset to the start point and a negative -z_offset to the end point, the lines pierce completely through the Z-plane. The py5.os_noise() function ensures that adjacent threads have slightly different Z-depths, allowing them to interlace organically without perfectly colliding. The resulting shape is a hyperbolic paraboloid-like structure built entirely out of straight glowing neon lines.
abstract woven fiber tapestry 3d p1

Conclusion

"Abstract Woven Fiber Tapestry 3D" proves that complex, organic forms can emerge from surprisingly simple geometric rules. By treating straight lines as threads and distributing them through 3D space with trigonometric functions and noise, we can digitally weave structures that are impossibly dense and hypnotic. It is a modern, cybernetic interpretation of the oldest textile arts.