Skip to main content

mini3d

纯 Python(仅标准库,零第三方依赖)实现的迷你 3D 模型工具箱。

功能

  • 几何体生成:立方体、长方体、球体、半球、圆柱、圆锥台、圆锥、正棱柱、棱锥、平面、圆环面、螺旋弹簧、多边形挤出、五角星柱
  • 几何变换:平移、绕 X/Y/Z 轴旋转、缩放
  • 网格编辑组合:多网格合并、镜像、三角面四分细分、重复顶点合并、孤立顶点清理
  • 网格分析:体积、表面积、顶点平均质心、体积加权质心、顶点/面/边统计、包围球
  • 基础数学:三维向量、4×4 变换矩阵、四元数、网格法线、包围盒
  • 文件读写:STL(二进制 + ASCII)、OBJ、PLY(含顶点颜色)、glTF 导出

安装

发布到 PyPI 后:

python3 -m pip install mini3d

从源码本地安装(在本目录下):

# 开发模式安装(改源码后立即生效,无需重装)
python3 -m pip install --user -e .

# 或普通安装(把代码复制进站点目录,与源码目录脱离)
python3 -m pip install --user .

快速上手

from mini3d import box, rotate_z, translate, write_stl, write_obj, write_ply

m = box(width=2, height=2, depth=2)
rotate_z(m, 45)
translate(m, 0, 2, 0)

write_stl(m, "out.stl")
write_obj(m, "out.obj")
write_ply(m, "out.ply")

几何体示例

from mini3d import sphere, frustum, prism, pyramid, helix, star_prism

sphere(radius=1.0, segments=32, rings=16)
frustum(bottom_radius=1.0, top_radius=0.5, height=2.0)
prism(n_sides=6, radius=1.0, height=2.0)
pyramid(n_sides=4, radius=1.0, height=2.0)
helix(radius=1.0, height=2.0, turns=3.0, tube_radius=0.1)
star_prism(outer_radius=1.0, inner_radius=0.45, points=5, height=1.0)

编辑组合与分析

from mini3d import cube, merge, mirror, subdivide, volume, surface_area, stats

a = cube(size=1)
b = cube(size=1)
scene = merge([a, b])          # 合并多个网格
mirror(scene, "x")             # 沿 X 轴镜像
smooth = subdivide(cube(size=1))  # 三角面细分

print(volume(scene))           # 体积
print(surface_area(scene))     # 表面积
print(stats(scene))            # 顶点/面/边统计

读取已有模型

from mini3d import read_stl, read_obj, read_ply

mesh = read_stl("some_model.stl")
print(mesh)  # Mesh(vertices=..., faces=...)

目录结构

mini3d/
├── core/      # Vector3、Matrix4x4、Quaternion、Mesh
├── geometry/  # 基本几何体生成器
├── ops/       # 变换 / 合并镜像 / 细分与清理
├── analysis/  # 体积、表面积、质心、统计、包围球
└── io/        # STL / OBJ / PLY / glTF 读写

许可证

MIT License,见 LICENSE。

Metadata

Release files for mini3d 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mini3d 0.2.0
File Size Uploaded Provenance Actions
mini3d-0.2.0.tar.gz 20.0 kB Without provenance Details for mini3d-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mini3d 0.2.0
File Interpreter ABI Platform Actions
mini3d-0.2.0-py3-none-any.whl Python 3 none any Details for mini3d-0.2.0-py3-none-any.whl

Total release size: 48.2 kB

Release files / mini3d-0.2.0.tar.gz

Download URL mini3d-0.2.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
82a08849dad2da14660e78d53bde8018e28f82e7555e73fabdadca057287e559
BLAKE2b-256 checksum
How to use checksums
ccfda021ea6140f7ed99defef18005be74fd6f9ebc47d3fbeb2401f3b283968e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / mini3d-0.2.0-py3-none-any.whl

Download URL mini3d-0.2.0-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c9f50408db459f015198e988743ac41fea8253627f31d57b8b77d9fa5ec947d
BLAKE2b-256 checksum
How to use checksums
7e732c5ffcb2a5e119ff535e7fc56ee2b1ef2bfac9483f9be0fecf73e21e5b9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for mini3d 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page