Textured Triangle Rotation Animation Using Blender Python

Noise Textured Triangle Animation Using Blender Python
Noise Textured Triangle Animation Using Blender Python

Live stream set for 2025-06-28 at 14:00:00 Eastern

Ask questions in the live chat about any programming or lifestyle topic.

This livestream will be on YouTube or you can watch below.

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:

About Edward

Edward is a software engineer, web developer, and author dedicated to helping people achieve their personal and professional goals through actionable advice and real-world tools.

As the author of impactful books including Learning JavaScript, Learning Python, Learning PHP and Mastering Blender Python API, Edward writes with a focus on personal growth, entrepreneurship, and practical success strategies. His work is designed to guide, motivate, and empower.

In addition to writing, Edward offers professional "full-stack development," "database design," "1-on-1 tutoring," "consulting sessions,", tailored to help you take the next step. Whether you are launching a business, developing a brand, or leveling up your mindset, Edward will be there to support you.

Edward also offers online courses designed to deepen your learning and accelerate your progress. Explore the programming on languages like JavaScript, Python and PHP to find the perfect fit for your journey.

📖 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.
🎓 Ready to Learn? – Check out his Online Courses to turn your ideas into results.

Leave a Reply

Your email address will not be published. Required fields are marked *