Textured Triangle Rotation Animation Using Blender Python

Noise Textured Triangle Animation Using Blender Python
On 2 min, 51 sec read

Textured Triangle with Noise & Rotation Animation Using Blender Python

A Sample Project from “Mastering Blender Python API”

If you’re exploring the powerful world of Blender’s Python API, this tutorial offers a small yet visually engaging example that blends geometry creation, material scripting, and animation—all programmatically. This is a preview of one of the practical projects featured in my book “Mastering Blender Python API.”

Whether you’re a beginner or an intermediate user, this project shows how to:

  • Create a custom triangle mesh
  • Apply noise-based procedural textures to each face
  • Animate a rotation to showcase all sides

Step 1: Create the Triangle Mesh

We’ll begin by using bpy to create a simple triangle in the 3D viewport.




import bpy

# Clear the scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

# Create mesh and object
mesh = bpy.data.meshes.new(name="TriangleMesh")
obj = bpy.data.objects.new("Triangle", mesh)
bpy.context.collection.objects.link(obj)

# Define vertices and one triangular face
verts = [(1, 0, 0), (-1, 0, 0), (0, 1, 0)]
faces = [(0, 1, 2)]
mesh.from_pydata(verts, [], faces)
mesh.update()

Step 2: Apply Unique Noise Textures to Each Face

We’ll create materials programmatically and use Blender’s noise texture nodes for variety.




# Create and assign three materials with unique noise textures
for i in range(3):
    mat = bpy.data.materials.new(name=f"NoiseMaterial_{i}")
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    links = mat.node_tree.links

    noise = nodes.new('ShaderNodeTexNoise')
    bsdf = nodes.get("Principled BSDF")
    links.new(noise.outputs['Color'], bsdf.inputs['Base Color'])

    obj.data.materials.append(mat)

# Assign material to the triangle face
obj.data.polygons[0].material_index = 0

This ensures the one face has a rich, randomized pattern. For more faces, you’d assign a unique material index per face.

Step 3: Animate Rotation to View All Sides

Now let’s spin the triangle to see all sides using keyframes:




from math import radians

# Animate Z-axis rotation over 120 frames
for frame in range(0, 121, 40):
    obj.rotation_euler[2] = radians(frame)
    obj.keyframe_insert(data_path="rotation_euler", index=2, frame=frame)

You can preview the animation with the timeline or render it as an MP4/GIF to showcase.

Screenshots and Screencast

Below are some visual results from the final Blender project:

Triangle in Blender viewport
Blender Scripting Tab Displaying Triangle In Blender Viewport

Rendered triangle with noise textures
Blender Rendered Output Displaying Triangle With Noise Textures

Animated Screencast For Blender Python API Textured Triangle Mesh

About the Book: “Mastering Blender Python API”

This example is just a taste of what you’ll learn in “Mastering Blender Python API”—a comprehensive guide covering:

  • Mesh generation
  • Materials and shaders
  • Node automation
  • Rigging and animation
  • Scripting best practices

📖 Click here to learn more or purchase the book

Need Help or a Custom Tutorial?

If you’d like personal help with Blender scripting or Python development, I offer private 1-on-1 tutorials and custom project guidance.

✉ Contact Me:

🚀 Recommended Resources


Disclosure: Some of the links above are referral links. I may earn a commission if you make a purchase at no extra cost to you.

About Edward

Edward is a software engineer, author, and designer dedicated to providing the actionable blueprints and real-world tools needed to navigate a shifting economic landscape.

With a provocative focus on the evolution of technology—boldly declaring that “programming is dead”—Edward’s latest work, The Recession Business Blueprint, serves as a strategic guide for modern entrepreneurship. His bibliography also includes Mastering Blender Python API and The Algorithmic Serpent.

Beyond the page, Edward produces open-source tool review videos and provides practical resources for the “build it yourself” movement.

📚 Explore His Books – Visit the Book Shop to grab your copies today.

💼 Need Support? – Learn more about Services and the ways to benefit from his expertise.

🔨 Build it Yourself – Download Free Plans for Backyard Structures, Small Living, and Woodworking.