Camera

Methods: aspose.threed.entities (aspose-3d-foss)

Camera یک Entity که یک نقطه‌نظر را در یک صحنهٔ سه‌بعدی تعریف می‌کند. این کنترل می‌کند که صحنه چگونه بر روی صفحهٔ تصویر دو‌بعدی پروجکت شود. یک دوربین به یک Node برای موقعیت‌یابی و جهت‌دهی آن در صحنه.

class Camera(Entity):

Methods

A3DObjectSceneObjectEntityCamera


نکات پیاده‌سازی

در این نسخه از aspose-3d-foss، Camera کلاس یک قالب اعلان. فقط projection_type و name به‌صورت عملکردی ذخیره شده و قابل بازیابی هستند. تمام ویژگی‌های دیگر ( «<SEG_2»> ، و غیره) setterهایی دارند که هیچ کاری انجام نمی‌دهند؛ مقادیر اختصاص داده شده حفظ نمی‌شوند. خواندن مجدد این ویژگی‌ها مقدار پیش‌فرض کلاس را برمی‌گرداند، صرف‌نظر از آنچه اختصاص داده شده بود.near_plane, far_plane, field_of_view, aspect_ratio, و غیره) setterهایی دارند که هیچ کاری انجام نمی‌دهند؛ مقادیر اختصاص داده شده حفظ نمی‌شوند. خواندن مجدد این ویژگی‌ها مقدار پیش‌فرض کلاس را برمی‌گرداند، صرف‌نظر از آنچه اختصاص داده شده بود.

هنگام وارد کردن داده‌های دوربین از یک فایل سه‌بعدی (glTF، FBX)، projection_type به‌درستی تجزیه می‌شود. سایر ویژگی‌های دوربین در دسترس هستند اگر فرمت آن‌ها را به‌عنوان متادیتای گراف صحنه ذخیره کند.


Methods

Camera(name: str = None, projection_type: str = "PERSPECTIVE")
NameTypeAccessDescription
namestrRead/WriteGets or sets the name.
parent_nodes``ReadGets the parent nodes.
excludedboolRead/WriteGets or sets the excluded.
parent_node``Read/WriteGets or sets the parent node.
rotation_mode``Read/WriteGets or sets the rotation mode.
near_planefloatRead/WriteGets or sets the near plane.
far_planefloatRead/WriteGets or sets the far plane.
aspectfloatRead/WriteGets or sets the aspect.
ortho_heightfloatRead/WriteGets or sets the ortho height.
up``Read/WriteGets or sets the up.
look_at``Read/WriteGets or sets the look at.
direction``Read/WriteGets or sets the direction.
target``Read/WriteGets or sets the target.
aperture_mode``Read/WriteGets or sets the aperture mode.
field_of_viewfloatRead/WriteGets or sets the field of view.
field_of_view_xfloatRead/WriteGets or sets the field of view x.
field_of_view_yfloatRead/WriteGets or sets the field of view y.
widthfloatRead/WriteGets or sets the width.
heightfloatRead/WriteGets or sets the height.
aspect_ratiofloatRead/WriteGets or sets the aspect ratio.
magnification``Read/WriteGets or sets the magnification.
projection_typestrRead/WriteGets or sets the projection type.
scene``Read/WriteGets or sets the scene.
propertiesPropertyCollectionReadGets the properties.

Methods

SignatureDescription
__init__(name: str, projection_type)
move_forward(distance: float)Moves the camera forward by the specified distance
get_bounding_box()Returns the bounding box.
get_entity_renderer_key()Not implemented in the FOSS edition — throws at runtime. Returns the entity renderer key.
remove_property(property)Removes a custom property identified by the given property object
remove_property(property_name: str)
get_property(property: str)Retrieves the value of a custom property by its identifier
set_property(property: str, value)Sets the property value.
find_property(property: str)Searches for a custom property and returns it if found

مثال‌های استفاده

Methods: در این نسخه، فقط projection_type به‌صورت عملکردی ذخیره می‌شود. تخصیص‌های ویژگی برای near_plane, far_plane, field_of_view,، و aspect_ratio پذیرفته می‌شوند بدون خطا اما ذخیره نمی‌شوند.

دوربین پرسپکتیو

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

دوربین ارتوگرافیک

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)

خواندن دوربین پس از وارد کردن

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}")

موارد مرتبط

 فارسی