Panda3D is a framework for 3D rendering and game development for Python and C++ programs.
npx @tessl/cli install tessl/pypi-panda3d@1.10.0A comprehensive framework for 3D rendering and game development for Python and C++ programs. Panda3D provides a complete suite of tools for creating interactive 3D applications, games, and simulations with powerful graphics, physics, audio, and user interface capabilities.
pip install panda3dfrom panda3d.core import *For specific functionality:
from panda3d.core import NodePath, Vec3, LVector3f, BitMask32
from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
from direct.gui.DirectGui import *
from direct.task import Task
from direct.interval.IntervalGlobal import *from direct.showbase.ShowBase import ShowBase
from panda3d.core import Vec3
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Load a 3D model
self.scene = self.loader.loadModel("models/environment")
self.scene.reparentTo(self.render)
self.scene.setScale(0.25, 0.25, 0.25)
self.scene.setPos(-8, 42, 0)
# Position the camera
self.camera.setPos(0, -10, 0)
self.camera.lookAt(0, 0, 0)
app = MyApp()
app.run()Panda3D uses a scene graph architecture with these key components:
Core scene graph functionality for organizing and manipulating 3D objects in hierarchical structures. The NodePath system provides the primary interface for working with objects in 3D space.
class NodePath:
def set_pos(self, x: float, y: float, z: float) -> None: ...
def set_hpr(self, h: float, p: float, r: float) -> None: ...
def set_scale(self, sx: float, sy: float, sz: float) -> None: ...
def reparent_to(self, other: NodePath) -> None: ...
def remove_node(self) -> None: ...ShowBase provides the main application framework with window management, initialization, and core system access. Essential for creating any Panda3D application.
class ShowBase:
def __init__(self) -> None: ...
def run(self) -> None: ...
loader: Loader
render: NodePath
camera: NodePath
taskMgr: TaskManagerComprehensive 3D mathematics library with vectors, matrices, quaternions, and geometric operations essential for 3D graphics and game development.
class Vec3:
def __init__(self, x: float = 0, y: float = 0, z: float = 0) -> None: ...
def length(self) -> float: ...
def normalized(self) -> Vec3: ...
def cross(self, other: Vec3) -> Vec3: ...
class LMatrix4:
def invertFrom(self, other: LMatrix4) -> bool: ...
def compose(self, scale: Vec3, hpr: Vec3, trans: Vec3) -> None: ...Mathematics and Linear Algebra
Sophisticated animation system supporting keyframe animation, procedural animation, and smooth interpolation between states. Essential for character animation and object movement.
class Actor:
def __init__(self,
model: str = None,
anims: dict = None,
copy: bool = True,
flattenable: bool = True,
setFinal: bool = False) -> None: ...
def loop(self, anim: str) -> None: ...
def play(self, anim: str) -> None: ...
def stop(self) -> None: ...
class LerpPosInterval:
def __init__(self,
nodePath: NodePath,
duration: float,
pos: Vec3,
startPos: Vec3 = None,
blendType: str = 'noBlend') -> None: ...Complete GUI system for creating interactive user interfaces with buttons, text, dialogs, and other widgets. Supports both 2D overlay and 3D-integrated interface elements.
class DirectButton:
def __init__(self, text: str = "", command: callable = None, **options) -> None: ...
def destroy(self) -> None: ...
class DirectFrame:
def __init__(self, **options) -> None: ...
def destroy(self) -> None: ...
class OnscreenText:
def __init__(self, text: str = "", **options) -> None: ...
def setText(self, text: str) -> None: ...Frame-based task scheduling and event-driven programming system. Essential for game logic, animations, and inter-object communication.
class TaskManager:
def add(self, task: callable, name: str, priority: int = 0) -> Task: ...
def remove(self, task: str | Task) -> bool: ...
def doMethodLater(self, delay: float, task: callable, name: str) -> Task: ...
class Messenger:
def send(self, event: str, sentArgs: list = []) -> None: ...
def accept(self, event: str, method: callable) -> None: ...
def ignore(self, event: str) -> None: ...3D positional audio system with support for sound effects, music, and spatial audio positioning. Integrates with the 3D scene for realistic audio environments.
class Audio3DManager:
def __init__(self, audio_manager, listener_target: NodePath = None) -> None: ...
def loadSfx(self, filename: str) -> AudioSound: ...
def attachSoundToObject(self, sound: AudioSound, object: NodePath) -> None: ...
def setListenerVelocity(self, vel: Vec3) -> None: ...Comprehensive input system supporting keyboard, mouse, and gamepad input with event generation and state tracking.
class MouseWatcher:
def hasMouse(self) -> bool: ...
def getMouseX(self) -> float: ...
def getMouseY(self) -> float: ...
# Key event constants and input handling through event systemFlexible system for loading and managing 3D models, textures, animations, and other game assets from various file formats.
class Loader:
def loadModel(self, filename: str) -> NodePath: ...
def loadTexture(self, filename: str) -> Texture: ...
def loadSfx(self, filename: str) -> AudioSound: ...
def loadMusic(self, filename: str) -> AudioSound: ...# Global instances available after importing ShowBase
base: ShowBase # Main application instance
render: NodePath # Main 3D scene root
render2d: NodePath # 2D overlay root
aspect2d: NodePath # Aspect-corrected 2D root
camera: NodePath # Default camera
taskMgr: TaskManager # Global task manager
messenger: Messenger # Global message system
loader: Loader # Asset loading system
globalClock: ClockObject # Global timing system# Core mathematical types (from panda3d.core)
from panda3d.core import LVector3f as Vec3, LVector4f as Vec4
from panda3d.core import LPoint3f as Point3, LMatrix4f as Mat4
from panda3d.core import LQuaternion as Quat
# Scene graph and rendering types
from panda3d.core import NodePath, Texture, AudioSound
from panda3d.core import BitMask32, ClockObject
# Application framework types
from direct.showbase.ShowBase import ShowBase
from direct.task.TaskManagerGlobal import TaskManager
from direct.showbase.MessengerGlobal import Messenger
from direct.showbase.Loader import Loader
# Animation types
from direct.actor.Actor import Actor
from direct.interval.LerpInterval import LerpPosInterval, LerpHprInterval
# GUI types
from direct.gui.DirectGui import DirectButton, DirectFrame
from direct.gui.OnscreenText import OnscreenText
# Audio types
from direct.showbase.Audio3DManager import Audio3DManager
# Common type hints
from typing import Callable, Optional, Union, List, Dict, Tuple