Metadata-Version: 2.4
Name: mini3d
Version: 0.2.0
Summary: 纯 Python 实现的迷你 3D 模型工具箱：几何体生成、网格编辑组合、网格分析、几何变换、STL/OBJ/PLY/glTF 读写，零第三方依赖
Author: 阿R
License: MIT
Keywords: 3d,mesh,stl,obj,ply,gltf,geometry,trimesh
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# mini3d

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

## 功能

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

## 安装

发布到 PyPI 后：

```bash
python3 -m pip install mini3d
```

从源码本地安装（在本目录下）：

```bash
# 开发模式安装（改源码后立即生效，无需重装）
python3 -m pip install --user -e .

# 或普通安装（把代码复制进站点目录，与源码目录脱离）
python3 -m pip install --user .
```

## 快速上手

```python
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")
```

## 几何体示例

```python
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)
```

## 编辑组合与分析

```python
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))            # 顶点/面/边统计
```

## 读取已有模型

```python
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](LICENSE)。
