or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

animation.mdapplication-framework.mdasset-loading.mdaudio.mdindex.mdinput.mdmathematics.mdscene-graph.mdtask-event.mduser-interface.md

index.mddocs/

0

# Panda3D

1

2

A 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.

3

4

## Package Information

5

6

- **Package Name**: panda3d

7

- **Language**: Python (with C++ core)

8

- **Installation**: `pip install panda3d`

9

10

## Core Imports

11

12

```python

13

from panda3d.core import *

14

```

15

16

For specific functionality:

17

18

```python

19

from panda3d.core import NodePath, Vec3, LVector3f, BitMask32

20

from direct.showbase.ShowBase import ShowBase

21

from direct.actor.Actor import Actor

22

from direct.gui.DirectGui import *

23

from direct.task import Task

24

from direct.interval.IntervalGlobal import *

25

```

26

27

## Basic Usage

28

29

```python

30

from direct.showbase.ShowBase import ShowBase

31

from panda3d.core import Vec3

32

33

class MyApp(ShowBase):

34

def __init__(self):

35

ShowBase.__init__(self)

36

37

# Load a 3D model

38

self.scene = self.loader.loadModel("models/environment")

39

self.scene.reparentTo(self.render)

40

self.scene.setScale(0.25, 0.25, 0.25)

41

self.scene.setPos(-8, 42, 0)

42

43

# Position the camera

44

self.camera.setPos(0, -10, 0)

45

self.camera.lookAt(0, 0, 0)

46

47

app = MyApp()

48

app.run()

49

```

50

51

## Architecture

52

53

Panda3D uses a scene graph architecture with these key components:

54

55

- **Scene Graph**: Hierarchical tree structure using NodePath objects for organizing 3D content

56

- **ShowBase**: Main application framework providing window management, task scheduling, and system integration

57

- **Rendering Pipeline**: Advanced graphics engine with shader support, lighting, and effects

58

- **Asset Loading**: Flexible system for loading models, textures, animations, and audio from various formats

59

- **Task System**: Frame-based task scheduling for game logic and animations

60

- **Event System**: Message passing system for inter-object communication

61

- **Physics Integration**: Support for multiple physics engines (Bullet, ODE, built-in)

62

63

## Capabilities

64

65

### Scene Graph Management

66

67

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.

68

69

```python { .api }

70

class NodePath:

71

def set_pos(self, x: float, y: float, z: float) -> None: ...

72

def set_hpr(self, h: float, p: float, r: float) -> None: ...

73

def set_scale(self, sx: float, sy: float, sz: float) -> None: ...

74

def reparent_to(self, other: NodePath) -> None: ...

75

def remove_node(self) -> None: ...

76

```

77

78

[Scene Graph and 3D Objects](./scene-graph.md)

79

80

### Application Framework

81

82

ShowBase provides the main application framework with window management, initialization, and core system access. Essential for creating any Panda3D application.

83

84

```python { .api }

85

class ShowBase:

86

def __init__(self) -> None: ...

87

def run(self) -> None: ...

88

loader: Loader

89

render: NodePath

90

camera: NodePath

91

taskMgr: TaskManager

92

```

93

94

[Application Framework](./application-framework.md)

95

96

### Mathematics and Linear Algebra

97

98

Comprehensive 3D mathematics library with vectors, matrices, quaternions, and geometric operations essential for 3D graphics and game development.

99

100

```python { .api }

101

class Vec3:

102

def __init__(self, x: float = 0, y: float = 0, z: float = 0) -> None: ...

103

def length(self) -> float: ...

104

def normalized(self) -> Vec3: ...

105

def cross(self, other: Vec3) -> Vec3: ...

106

107

class LMatrix4:

108

def invertFrom(self, other: LMatrix4) -> bool: ...

109

def compose(self, scale: Vec3, hpr: Vec3, trans: Vec3) -> None: ...

110

```

111

112

[Mathematics and Linear Algebra](./mathematics.md)

113

114

### Animation and Interpolation

115

116

Sophisticated animation system supporting keyframe animation, procedural animation, and smooth interpolation between states. Essential for character animation and object movement.

117

118

```python { .api }

119

class Actor:

120

def __init__(self,

121

model: str = None,

122

anims: dict = None,

123

copy: bool = True,

124

flattenable: bool = True,

125

setFinal: bool = False) -> None: ...

126

def loop(self, anim: str) -> None: ...

127

def play(self, anim: str) -> None: ...

128

def stop(self) -> None: ...

129

130

class LerpPosInterval:

131

def __init__(self,

132

nodePath: NodePath,

133

duration: float,

134

pos: Vec3,

135

startPos: Vec3 = None,

136

blendType: str = 'noBlend') -> None: ...

137

```

138

139

[Animation and Characters](./animation.md)

140

141

### User Interface System

142

143

Complete GUI system for creating interactive user interfaces with buttons, text, dialogs, and other widgets. Supports both 2D overlay and 3D-integrated interface elements.

144

145

```python { .api }

146

class DirectButton:

147

def __init__(self, text: str = "", command: callable = None, **options) -> None: ...

148

def destroy(self) -> None: ...

149

150

class DirectFrame:

151

def __init__(self, **options) -> None: ...

152

def destroy(self) -> None: ...

153

154

class OnscreenText:

155

def __init__(self, text: str = "", **options) -> None: ...

156

def setText(self, text: str) -> None: ...

157

```

158

159

[User Interface](./user-interface.md)

160

161

### Task and Event Management

162

163

Frame-based task scheduling and event-driven programming system. Essential for game logic, animations, and inter-object communication.

164

165

```python { .api }

166

class TaskManager:

167

def add(self, task: callable, name: str, priority: int = 0) -> Task: ...

168

def remove(self, task: str | Task) -> bool: ...

169

def doMethodLater(self, delay: float, task: callable, name: str) -> Task: ...

170

171

class Messenger:

172

def send(self, event: str, sentArgs: list = []) -> None: ...

173

def accept(self, event: str, method: callable) -> None: ...

174

def ignore(self, event: str) -> None: ...

175

```

176

177

[Task and Event Management](./task-event.md)

178

179

### Audio System

180

181

3D positional audio system with support for sound effects, music, and spatial audio positioning. Integrates with the 3D scene for realistic audio environments.

182

183

```python { .api }

184

class Audio3DManager:

185

def __init__(self, audio_manager, listener_target: NodePath = None) -> None: ...

186

def loadSfx(self, filename: str) -> AudioSound: ...

187

def attachSoundToObject(self, sound: AudioSound, object: NodePath) -> None: ...

188

def setListenerVelocity(self, vel: Vec3) -> None: ...

189

```

190

191

[Audio and Sound](./audio.md)

192

193

### Input Handling

194

195

Comprehensive input system supporting keyboard, mouse, and gamepad input with event generation and state tracking.

196

197

```python { .api }

198

class MouseWatcher:

199

def hasMouse(self) -> bool: ...

200

def getMouseX(self) -> float: ...

201

def getMouseY(self) -> float: ...

202

203

# Key event constants and input handling through event system

204

```

205

206

[Input and Controls](./input.md)

207

208

### Asset Loading and Management

209

210

Flexible system for loading and managing 3D models, textures, animations, and other game assets from various file formats.

211

212

```python { .api }

213

class Loader:

214

def loadModel(self, filename: str) -> NodePath: ...

215

def loadTexture(self, filename: str) -> Texture: ...

216

def loadSfx(self, filename: str) -> AudioSound: ...

217

def loadMusic(self, filename: str) -> AudioSound: ...

218

```

219

220

[Asset Loading](./asset-loading.md)

221

222

## Global Objects

223

224

```python { .api }

225

# Global instances available after importing ShowBase

226

base: ShowBase # Main application instance

227

render: NodePath # Main 3D scene root

228

render2d: NodePath # 2D overlay root

229

aspect2d: NodePath # Aspect-corrected 2D root

230

camera: NodePath # Default camera

231

taskMgr: TaskManager # Global task manager

232

messenger: Messenger # Global message system

233

loader: Loader # Asset loading system

234

globalClock: ClockObject # Global timing system

235

```

236

237

## Types

238

239

```python { .api }

240

# Core mathematical types (from panda3d.core)

241

from panda3d.core import LVector3f as Vec3, LVector4f as Vec4

242

from panda3d.core import LPoint3f as Point3, LMatrix4f as Mat4

243

from panda3d.core import LQuaternion as Quat

244

245

# Scene graph and rendering types

246

from panda3d.core import NodePath, Texture, AudioSound

247

from panda3d.core import BitMask32, ClockObject

248

249

# Application framework types

250

from direct.showbase.ShowBase import ShowBase

251

from direct.task.TaskManagerGlobal import TaskManager

252

from direct.showbase.MessengerGlobal import Messenger

253

from direct.showbase.Loader import Loader

254

255

# Animation types

256

from direct.actor.Actor import Actor

257

from direct.interval.LerpInterval import LerpPosInterval, LerpHprInterval

258

259

# GUI types

260

from direct.gui.DirectGui import DirectButton, DirectFrame

261

from direct.gui.OnscreenText import OnscreenText

262

263

# Audio types

264

from direct.showbase.Audio3DManager import Audio3DManager

265

266

# Common type hints

267

from typing import Callable, Optional, Union, List, Dict, Tuple

268

```