[Tools] Fireworks Add-On on Blender

2.3k words

Overview

This Blender add-on simplifies the creation of fireworks for 2D and 3D animations, allowing users to quickly generate procedural firework effects with randomized colors, animations, and placements.

How It Works

Single Firework Creation

  • Choose the number of colors (randomized selection).
  • Click “Light it up!” to generate a firework in the current frame.
  • Done!

Multiple Fireworks Generation

  • Define the number of fireworks to be created.
  • Set the radius via “radius max” and “radius area” to prevent overlap.
  • Choose a time range with “Range frame X” and “Range frame Y”, determining when the fireworks will launch within the animation.
  • Click “Light it up more!” to generate multiple fireworks randomly across the scene.


Key Features

Intuitive UI Panel

The add-on provides a custom UI in Blender’s 3D Viewport, making it easy to create fireworks with just a few clicks.

Fireworks UI Panel
1
2
3
4
5
6
7
8
9
10
11
class AddOn(bpy.types.Panel):
bl_label = "Fireworks Tool"
bl_idname = "PT_FirstAddOn"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'CNAM'

def draw(self, context):
layout = self.layout
layout.prop(context.scene, "colors_number")
layout.operator("object.fireworks_operator", icon="FRAME_NEXT")

Firework Generation & Animation

  • Generate single or multiple fireworks, with customizable explosion patterns and random colors.
  • Uses particle systems to create realistic firework effects.
  • Supports frame-based timing to launch fireworks dynamically.
Firework Creation
1
2
3
4
5
6
7
8
class Fireworks(bpy.types.Operator):
bl_idname = "object.fireworks_operator"
bl_label = "Light'it up !"

def execute(self, context):
_scene = bpy.context.scene
CreateFireworks(_scene['colors_number'])
return {'FINISHED'}

Smart Positioning & Collision Prevention

  • Ensures fireworks don’t overlap by checking distances between them.
  • Defines a customizable explosion radius.
Prevent Overlap
1
2
3
4
5
6
def is_too_close(a, b):
x = a['x'] - b['x']
y = a['y'] - b['y']
z = a['z'] - b['z']
d = sqrt(x*x + y*y + z*z)
return d < a['radius'] + b['radius']

Scene Cleanup & Lighting Controls

  • Quick reset feature removes all fireworks in the scene.
  • Lighting toggle allows users to switch between a black background (night mode) and gray background (day mode).
Scene Cleanup
1
2
3
4
5
def clean_scene():
context = bpy.context
scene = context.scene
for c in scene.collection.children:
scene.collection.children.unlink(c)