Skip to main content

Add your description here

Project description

BPY Widget

Interactive Blender 3D viewport widget for notebooks with real-time Eevee Next rendering.

BPY Widget Demo Python License

🚀 Features

  • Interactive 3D Viewport: Real-time camera control with mouse/touch
    • 🖱️ Drag to rotate camera
    • 📏 Scroll to zoom in/out
    • 📱 Touch support for mobile devices
  • High-Performance Rendering: Powered by Blender's Eevee Next engine
  • Live Performance Metrics: FPS counter and render time display
  • Seamless Notebook Integration: Reactive updates and state synchronization
  • Easy to Use: Simple API with automatic scene setup

📋 Requirements

  • Python 3.11+

🛠️ Installation

From Source

git clone https://github.com/yourusername/bpy-widget.git
cd bpy-widget
pip install -e .

Using UV (Recommended)

uv sync

🎯 Quick Start

import marimo as mo
from bpy_widget import BpyWidget

# Create widget with custom size
widget = BpyWidget(width=800, height=600)

# Display in notebook
widget

📚 Examples

Basic Usage

Run the example notebook:

marimo edit examples/basic_usage.py

Custom Scene

from bpy_widget import BlenderWidget

# Create widget
widget = BlenderWidget(width=1024, height=768)

# Access Blender API
widget.clear_scene()
widget.setup_camera(location=(10, -10, 8))
widget.setup_lighting()

# Add objects
widget.create_suzanne()
widget.create_test_cube()

# Render
widget.render()

Material Creation

# Apply to object
widget.objects["Suzanne"].data.materials.clear()
widget.objects["Suzanne"].data.materials.append(chrome)

# Update view
widget.render()

🔧 API Reference

BlenderWidget

Main widget class for interactive 3D viewport.

Constructor

BlenderWidget(width=512, height=512, auto_init=True)
  • width: Viewport width in pixels
  • height: Viewport height in pixels
  • auto_init: Automatically initialize scene with defaults

Properties

  • scene: Current Blender scene
  • objects: Dictionary of scene objects
  • context: Blender context
  • data: Blender data
  • ops: Blender operators

Methods

  • clear_scene(): Remove all objects from scene
  • setup_camera(location, rotation): Position camera
  • setup_lighting(): Add default lighting
  • create_material(name, base_color, metallic, roughness): Create PBR material
  • create_suzanne(): Add Suzanne mesh
  • create_test_cube(): Add test cube
  • render(): Update viewport rendering
  • debug_info(): Print scene information

🎨 Architecture

The widget uses a modular architecture:

  • widget.py: Main widget class with AnyWidget integration
  • core/: Core Blender functionality modules
    • camera.py: Camera positioning and controls
    • rendering.py: Render pipeline setup
    • lighting.py: Scene lighting utilities
    • materials.py: Material creation helpers
  • static/: Frontend assets
    • widget.js: Interactive controls and display
    • widget.css: Styling

⚡ Performance

  • ** Rendering**: ~3 FPS interactive performance
  • Smart Throttling: Updates batched
  • Minimal Overhead: Direct pixel buffer access
  • Responsive Controls: Local state for instant feedback

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Blender Foundation for the amazing bpy module
  • Marimo team for the reactive notebook platform
  • AnyWidget for the widget framework

🐛 Known Issues

  • Initial audio warning from Blender can be ignored
  • Performance may vary based on scene complexity
  • Touch controls require modern browser support

📮 Support

For issues and questions:

  • Open an issue on GitHub
  • Check existing issues for solutions
  • Include system info and error messages

Made with ❤️ for the Blender and Marimo communities

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpy_widget-0.1.0.tar.gz (78.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bpy_widget-0.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file bpy_widget-0.1.0.tar.gz.

File metadata

  • Download URL: bpy_widget-0.1.0.tar.gz
  • Upload date:
  • Size: 78.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bpy_widget-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1d683b0dce47ebd736abbcc0f61d60588a35d0f428eb8d274933e2c6a5a5de5
MD5 fff00258fdeba830ead55ffc038a8e5c
BLAKE2b-256 1e3432d5dc3e689e9516a56c2b8b9f7b726cd0f4ecd1ccdca20cbca89b12456b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpy_widget-0.1.0.tar.gz:

Publisher: python-publish.yml on bjoernbethge/bpy-widget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bpy_widget-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bpy_widget-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bpy_widget-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f08ff5a3c60b2e0bd2b69c1deba971aca3eb45e12dfb3046d59d64e677d11d2
MD5 f021de0d3202f112124c799480512059
BLAKE2b-256 808ea9e1d5ea1e6b87f126281d1a4aa64a1cc0acc5a0f76229dd1860deaec18b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpy_widget-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on bjoernbethge/bpy-widget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page