Three-dimensional-Games
比 Ursina 更简洁、比 Panda3D 更好用的 Python 3D 游戏引擎 ✨
from three_dimensional_games import *
game = init(title="我的 3D 游戏") # 开头:初始化
ground = Entity(model='plane', texture='grass', scale=(50, 1, 50), collider='box')
player = FirstPerson() # 第一人称(也有 SecondPerson / ThirdPerson)
player.position = (0, 3, 0)
run() # 结尾:启动
安装
pip install Three-dimensional-Games
导入时用下划线写法:import three_dimensional_games 或 from three_dimensional_games import *。
核心特点
| 特点 | Three-dimensional-Games | Ursina | Panda3D |
|---|---|---|---|
| 初始化 | 一行 game = init() |
app = Ursina() |
手动一堆设置 |
| 启动 | 一行 run() |
app.run() |
base.run() |
| 内置贴图 | ✅ 53 种 | ~20 种 | 几乎没有 |
| 内置模型 | ✅ cube/plane/quad/cylinder/cone | 少量 | 需自备 |
| 联机模块 | ✅ 一行开房(公网/局域网) | ❌ 自己写 | ❌ 自己写 |
| 第一/二/三人称 | ✅ 三个都有 | 只有第一人称 | 自己写 |
| 物理重力+碰撞 | ✅ 内置刚体与碰撞解算 | 部分 | 复杂 |
| 补间动画 | ✅ 任意属性都能补间 | 有(仅位置/缩放等) | 自己写 |
| 粒子系统 | ✅ 内置 | 无原生 | 自己搭 |
| 音效模块 | ✅ 内置,还能纯代码发声 | 有 | 有 |
| 触发区 | ✅ 内置 | 无原生 | 自己写 |
| 存档读档 | ✅ 一个 json 存全场景 | 无原生 | 自己写 |
| 公网 UPnP 穿透 | ✅ 自动 | ❌ | ❌ |
| 局域网自动发现 | ✅ 有 | ❌ | ❌ |
常用功能速查
初始化与启动
game = init(title="游戏名", window_size=(1280, 720), show_fps=True)
...
run()
三种视角
player = FirstPerson() # FPS,WASD 走、空格跳、鼠标转视角
player = SecondPerson() # 第二人称(反向视角)
player = ThirdPerson() # 第三人称追尾视角
物理(重力、掉落、碰撞)
ground = Entity(model='plane', scale=(50, 1, 50), collider='box') # 静态地面
box = Entity(model='cube', position=(0, 5, 0), collider='box', mass=1) # 会掉下来的箱子
hit = raycast(player.position, (0, -1, 0), distance=10) # 射线检测,可用来瞄准
联机
host(public=False, port=5555) # False = 局域网联机;True = 公网联机
connect("192.168.1.100") # 加入别人的房间
补间动画
box.animate('position', (5, 2, 0), duration=1.0, curve='ease_in_out')
box.animate_rotation((0, 360, 0), duration=4, loop=True)
animate_color(box, color.red, duration=0.5)
粒子
sparks = Particles(texture='particle_spark', num_particles=60, speed=6, gravity=(0, -8, 0))
sparks.burst(player.position) # 炸一把
sparks.start(follow=player) # 持续跟随发射
音效(不需要素材也能响)
jump = Audio('sounds/jump.ogg') # 用音频文件
jump.play()
beep(660, 0.12) # 纯代码合成提示音
bgm = Music('sounds/bgm.ogg', volume=0.4); bgm.play()
触发区
on_enter((0, 1, 10), (4, 4, 4), lambda: print("过关!"))
存档 / 读档
save("save1.json", data={"score": 120, "level": 3}) # 存下全场景位置+进度数据
payload = load("save1.json") # 读回来
print(payload["data"]["score"]) # 120
save_slot(1) # 存到第 1 个槽位(saves/1.json)
load_slot(1) # 读第 1 个槽位
list_saves() # 看看有哪些存档
内置贴图(53 种,比 Ursina 更多)
- 自然:
grassdirtstonerockcliffsandsnowlavawatermudgravelmoss - 建筑:
brickconcretetilemarbleroadpathgrid - 材质:
woodmetalleatherfabriccarpetdiamond_platecracked_glass - 颜色:
redgreenblueyellowcyanmagentagraywhiteblack - 天空与渐变:
skycloudsgradientradial_gradientclouds - 噪声:
noiseperlin - UI:
buttonbutton_hoverbutton_pressedpanelbordercircle - 粒子:
particle_circleparticle_smokeparticle_sparkparticle_star - 其他:
white_cubecheckerboard
内置模型
cube、plane、quad、cylinder、cone,另外 load_model() 可加载外部的 .egg/.bam/.gltf 模型。
许可
MIT License
Metadata
Release files for Three-dimensional-Games 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| three_dimensional_games-0.3.0.tar.gz | 67.3 kB | Without provenance | Details for three_dimensional_games-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| three_dimensional_games-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for three_dimensional_games-0.3.0-py3-none-any.whl |
Total release size: 146.7 kB
Release files / three_dimensional_games-0.3.0.tar.gz
| Download URL | three_dimensional_games-0.3.0.tar.gz |
|---|---|
| Size | 67.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f645058da9b8f00e6399efb744e7adba925e95fd7f9aa3e3cb6ea43d3f918fda
|
|
BLAKE2b-256 checksum How to use checksums |
9f8413bf8fcda94d4a505a398c068deea39858e363d0f322068d8890c7c4153a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / three_dimensional_games-0.3.0-py3-none-any.whl
| Download URL | three_dimensional_games-0.3.0-py3-none-any.whl |
|---|---|
| Size | 79.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0cd99a09a0ba54d98a3a849e05ff3df79283e9e975d029978c8fda8e2782a66
|
|
BLAKE2b-256 checksum How to use checksums |
0c891c0ca861efa6bb84de017a2244b9af3c2269f14d577f8a4eee36fa1f3af3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for Three-dimensional-Games 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.