Camera
Methods: aspose.threed.entities (aspose-3d-foss)
Camera on Entity joka määrittelee näkökulman 3D‑kohtauksessa. Se ohjaa, miten kohtaus projisoidaan 2D‑kuvapinnalle. Kamera on kiinnitetty Node sijaintimaan ja suuntaamaan sen kohtauksessa.
class Camera(Entity):Methods
A3DObject → SceneObject → Entity → Camera
Toteutuksen huomautukset
Tässä aspose-3d-foss -versiossa, Camera luokka on ilmoituspohja. projection_type ja name ovat toiminnallisesti tallennettuja ja haettavissa. Kaikki muut ominaisuudet (near_plane, far_plane, field_of_view, aspect_ratio, jne.) sisältävät asettajat, jotka eivät tee mitään; asetetut arvot eivät säily. Näiden ominaisuuksien takaisinlukeminen palauttaa luokan oletusarvon riippumatta siitä, mitä on asetettu.
Kun tuodaan kameratietoja 3D‑tiedostosta (glTF, FBX), projection_type jäsennetään oikein. Muita kameran attribuutteja on saatavilla, jos formaatti tallentaa ne kohtausgrafiikan metatietoina.
Methods
Camera(name: str = None, projection_type: str = "PERSPECTIVE")| Methods | Methods | Methods | Methods |
|---|---|---|---|
name | `str | None` | None |
projection_type | str | "PERSPECTIVE" | Alkuperäinen projektiotyyppi. Käytä ProjectionType.PERSPECTIVE tai ProjectionType.ORTHOGRAPHIC. |
Methods
| Methods | Methods | Methods |
|---|---|---|
projection_type | str | Projektio-tila: "PERSPECTIVE" tai "ORTHOGRAPHIC". Aseta ProjectionType vakioita. |
near_plane | float | Etäisyys lähimmälle leikkausplanelle. Geometria, joka on tätä lähempänä, ei renderöidy. Oletus 0.1. |
far_plane | float | Etäisyys kauimmalle leikkausplanelle. Geometria, joka on tätä kauempana, ei renderöidy. Oletus 1000.0. |
field_of_view | float | Pystysuuntainen näkökenttä asteina (vain perspektiivikamerat). Oletus 0.0. |
field_of_view_x | float | Vaakasuuntainen näkökenttä asteina. Oletus 0.0. |
field_of_view_y | float | Pystysuuntainen näkökenttä asteina (sama kuin field_of_view). Oletus 0.0. |
aspect_ratio | float | Leveyden ja korkeuden suhde tuloskuvalle. Oletus 1.0. |
ortho_height | float | Ortografisen näkymätilavuuden korkeus maailman yksiköissä (vain ortografiset kamerat). Oletus 100.0. |
name | str | Kameran objektin nimi. |
Käyttöesimerkit
Methods: Tässä versiossa, vain projection_type on toiminnallisesti tallennettu. Ominaisuuksien asettaminen kohteelle near_plane, far_plane, field_of_view, ja aspect_ratio hyväksytään ilman virhettä, mutta eivät säily.
Perspektiivinen kamera
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")Ortografinen kamera
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)Kameran lukeminen tuonnin jälkeen
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}")