Python에서 3D로 시작하는 방법

Python에서 3D로 시작하는 방법

원칙들

  • Python 3.7 또는 그 이후의 경우
  • PIP 패키지 관리자

단계 1 - 패키지를 설치합니다.

PyPI에서 Aspose.3D FOSS를 설치하십시오 :

pip install aspose-3d-foss

설치를 확인하십시오 :

import aspose.threed as a3d
scene = a3d.Scene()
print("Aspose.3D FOSS is working, version:", a3d.Scene.VERSION)

단계 2 - 첫 번째 3D 장면을 만드십시오.

A 는 Scene 모든 3D 개체에 대한 뿌리 컨테이너입니다.Constructor는 선택적 인 것을 받아 들일 수 있습니다. 본인, 부모의 장면 및 이름:

import aspose.threed as a3d

# Create an empty scene (CLM-3d-35d727)
scene = a3d.Scene()

# Access the root node of the scene (CLM-3d-859ac2)
root = scene.root_node  # root_node is a property, not a method — no ()
print("Root node:", root)

단계 3 - 무대에 메시지를 추가하십시오.

Mesh 폴리곤 지질학을 나타냅니다. Node 장면 그라프에 단체를 추가 :

import aspose.threed as a3d

scene = a3d.Scene()

# Create a named mesh (CLM-3d-529c11)
mesh = a3d.Mesh("my_mesh")

# Create a node and attach the mesh (CLM-3d-0edae8)
node = a3d.Node("my_node", mesh)

# Add the node as a child of the root (CLM-3d-a403f5)
scene.root_node.add_child_node(node)  # root_node is a property, not a method — no ()

단계 4 - 기존 3D 파일을 다운로드합니다.

Scene.open() 디스크 또는 스트림에서 3D 파일을 업로드합니다.그것은 경로를 받아들이고 선택적입니다. 로드 옵션 :

import aspose.threed as a3d

# Load an OBJ file (CLM-3d-d84964)
scene = a3d.Scene()
scene.open("model.obj")

# Inspect the loaded scene
root = scene.root_node  # root_node is a property, not a method — no ()
print("Child nodes:", len(root.child_nodes))  # child_nodes is a property, not a method — no ()

다운로드하기 전에 파일 형식을 확인하려면:

import aspose.threed as a3d

# Detect the format from a file name (CLM-3d-d2de62)
fmt = a3d.FileFormat.detect(None, "model.fbx")
if fmt:
    print("Detected format:", fmt.extension)  # extension is a property, not a method — no ()

단계 5 - 파일에 출력 저장

Scene.save() 모든 지원되는 형식으로 시나리오를 수출합니다.이 권장 접근 방식은 확장 기반 자동 탐지: Aspose.3D는 파일 확장에서 형식을 인프라합니다. (CLM-3d-8051bd, CLM 3d-b28d7a, 클로마-3D-de8e1a) :

import aspose.threed as a3d

scene = a3d.Scene()
# ... populate scene ...

# Save as Wavefront OBJ — extension auto-detects the format
scene.save("output.obj")

# Save as glTF 2.0 binary — .glb extension triggers binary GLB output
scene.save("output.glb")

또한 공장 방법을 사용하여 명확한 형식을 통과 할 수 있습니다. FileFormat.WAVEFRONT_OBJ() 또는 FileFormat.GLTF2(), 하지만 확장 자동 탐지은 더 간단하고 더 휴대합니다.

다음 단계

 한국어