ユースケース
概要
Aspose.3D は、Python 用のオープンソース 3D ファイル形式ライブラリで、開発者がプログラムで 3D シーンやモデルを作成、操作、変換できるようにします。堅牢なファイル I/O とシーングラフ処理を提供することで、最新の 3D ワークフローをサポートします。
このライブラリは、PBRマテリアルサポートを備えたglTF(GL Transmission Format)をフルサポートし、Webおよびリアルタイムレンダリングパイプラインに適しています。その階層的なノード構造により、ノード間の親子関係を使用した3Dシーンの直感的な整理が可能となり、複雑なモデルのスケーラブルなシーン管理を実現します。
仕組み
Aspose.3D for Python は、Scene、Node、Entity を中心とした構造化オブジェクトモデルを通じて、3D シーンとモデルをプログラムで制御できるようにします。開発者は、STL(3D プリントで広く使用されている)などの既存フォーマットをロードしたり、Mesh のようなコアプリミティブを使用してゼロからシーンを構築したりできます。このライブラリはメッシュとエンティティの管理をサポートし、シーン階層内の頂点データ、ポリゴントポロジー、および空間関係の検査と変更を可能にします。
from aspose.threed import Scene
from aspose.threed.entities import Mesh
# Create a Mesh instance
mesh = Mesh()
# Access mesh data (control_points and edges are properties, not method calls)
vertices = mesh.control_points
edges = mesh.edgesコード例
この例では、ロードオプションを使用してOBJファイルから3Dモデルを読み込み、シーングラフを走査してメッシュジオメトリを検査します。Scene.from_file()はファイルパスのみを受け付けます。ロードオプションを渡すにはscene.open()を使用してください。
from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.formats import ObjLoadOptions
# Import an OBJ file with load options
# Note: Scene.from_file() takes only a file path argument.
# To pass options, use scene.open() instead.
options = ObjLoadOptions()
options.enable_materials = True
options.flip_coordinate_system = False
scene = Scene()
scene.open("model.obj", options)
# Access imported data
for node in scene.root_node.child_nodes:
if node.entity and isinstance(node.entity, Mesh):
mesh = node.entity
print(f"Mesh: {node.name}")
print(f" Vertices: {len(mesh.control_points)}")
print(f" Polygons: {mesh.polygon_count}")参照
Aspose.3D は、可視化ツールやインタラクティブ アプリケーション向けの堅牢な 3D Python 開発を可能にします。開発者は 3D シーンを作成および操作し、ObjLoadOptions.enable_materials を使用したマテリアル読み込みで OBJ ファイルをインポートし、ObjExporter を使用して OBJ ファイルをエクスポートし、Vector4 や Matrix4 のような組み込み型を使用して低レベルのベクトル演算を実行できます。