Camera
Methods: aspose.threed.entities (aspose-3d-foss)
Camera là một Entity định nghĩa một góc nhìn trong một cảnh 3D. Nó kiểm soát cách cảnh được chiếu lên mặt phẳng ảnh 2D. Một camera được gắn vào một Node để định vị và định hướng nó trong cảnh.
class Camera(Entity):Methods
A3DObject → SceneObject → Entity → Camera
Ghi chú triển khai
Trong phiên bản này của aspose-3d-foss, Camera lớp là một đầu mối khai báo. Chỉ projection_type và name được lưu trữ và có thể truy xuất một cách chức năng. Tất cả các thuộc tính khác (near_plane, far_plane, field_of_view, aspect_ratio, v.v.) có các setter không thực hiện gì; các giá trị được gán không được giữ lại. Khi đọc lại các thuộc tính này, giá trị trả về là giá trị mặc định của lớp bất kể giá trị nào đã được gán.
Khi nhập dữ liệu máy ảnh từ tệp 3D (glTF, FBX), the projection_type được phân tích đúng cách. Các thuộc tính máy ảnh khác có sẵn nếu định dạng lưu chúng dưới dạng siêu dữ liệu đồ thị cảnh.
Methods
Camera(name: str = None, projection_type: str = "PERSPECTIVE")| Methods | Methods | Methods | Methods |
|---|---|---|---|
name | `str | None` | None |
projection_type | str | "PERSPECTIVE" | Kiểu chiếu ban đầu. Sử dụng ProjectionType.PERSPECTIVE hoặc ProjectionType.ORTHOGRAPHIC. |
Methods
| Methods | Methods | Methods |
|---|---|---|
projection_type | str | Chế độ chiếu: "PERSPECTIVE" hoặc "ORTHOGRAPHIC". Đặt bằng ProjectionType các hằng số. |
near_plane | float | Khoảng cách tới mặt phẳng cắt gần. Đối tượng gần hơn so với này sẽ không được vẽ. Mặc định 0.1. |
far_plane | float | Khoảng cách tới mặt phẳng cắt xa. Đối tượng xa hơn so với này sẽ không được vẽ. Mặc định 1000.0. |
field_of_view | float | Trường nhìn dọc tính bằng độ (chỉ áp dụng cho máy ảnh phối cảnh). Mặc định 0.0. |
field_of_view_x | float | Trường nhìn ngang tính bằng độ. Mặc định 0.0. |
field_of_view_y | float | Trường nhìn theo chiều dọc tính bằng độ (giống như field_of_view). Mặc định 0.0. |
aspect_ratio | float | Tỷ lệ chiều rộng trên chiều cao của ảnh đầu ra. Mặc định 1.0. |
ortho_height | float | Chiều cao của thể tích góc nhìn trực giao tính bằng đơn vị thế giới (chỉ dành cho camera trực giao). Mặc định 100.0. |
name | str | Tên của đối tượng camera. |
Ví dụ sử dụng
Methods: Trong phiên bản này, chỉ projection_type được lưu trữ một cách chức năng. Các phép gán thuộc tính cho near_plane, far_plane, field_of_view, và aspect_ratio được chấp nhận mà không có lỗi nhưng không được duy trì.
Camera phối cảnh
from aspose.threed import Scene
from aspose.threed.entities import Camera
from aspose.threed.entities import ProjectionType
scene = Scene()
# projection_type is stored and saved
cam = Camera("MainCamera", ProjectionType.PERSPECTIVE)
node = scene.root_node.create_child_node("camera", cam)
# Position the camera using node transform (this does persist)
node.transform.set_translation(0.0, 5.0, 20.0)
scene.save("scene-with-camera.glb")Camera trực giao
from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Camera, ProjectionType
scene = Scene()
# Only projection_type is retained; other property assignments are no-ops
cam = Camera("OrthoCamera", ProjectionType.ORTHOGRAPHIC)
scene.root_node.create_child_node("ortho_cam", cam)
scene.save("ortho-scene.glb", FileFormat.GLTF)Đọc Camera sau khi nhập
from aspose.threed import Scene
from aspose.threed.entities import Camera
scene = Scene()
scene.open("model.glb")
for node in scene.root_node.child_nodes:
if isinstance(node.entity, Camera):
cam = node.entity
# projection_type is reliably populated; other numeric properties
# return default values (0.0 / 1.0) regardless of file content
print(f"Camera '{cam.name}': {cam.projection_type}")