Light
Methods: aspose.threed.entities (aspose-3d-foss)
Light הוא Entity שמוסיף מקור אור לסצנה תלת‑ממדית. כמו Camera, הוא מצורף ל‑ Node כדי לשלוט במיקומו ובכיוונו.
class Light(Camera):Methods
A3DObject → SceneObject → Entity → Camera → Light
Light יורש מ Camera. בגרסה הנוכחית, ה Light המחלקה עצמה אינה חושפת תכונות נוספות מעבר לאלה שהורשו מ Camera ו Entity. ה LightType ה‑enum קיים למיון אורות אך אין light_type מאפיין ב‑ Light המחלקה.
Methods
Light(name: str = None)| Methods | Methods | Methods | Methods |
|---|---|---|---|
name | `str | None` | None |
Methods
| Methods | Methods | Methods |
|---|---|---|
name | str | שם של אובייקט האור (יורש מ A3DObject). |
Light גם יורש את כל Camera מאפיינים (near_plane, far_plane, וכו’), למרות שאלו אינם משמעותיים עבור אובייקטים של אור. שים לב: ה Light המחלקה אינה חושפת a light_type מאפיין במשטח ה-API הנוכחי.
ערכי LightType
from aspose.threed.entities import LightType| Methods | Methods | Methods |
|---|---|---|
LightType.POINT | "POINT" | פולט אור באופן שווה בכל הכיוונים מנקודה אחת. |
LightType.DIRECTIONAL | "DIRECTIONAL" | קרניים מקבילות ממקור אינסופי מרוחק (כמו אור השמש). |
LightType.SPOT | "SPOT" | קרן בצורת קונוס; המיקום והכיוון חשובים. |
LightType.AREA | "AREA" | אור הפולט מאזור מלבני. |
LightType.VOLUME | "VOLUME" | אור תלת-ממדי/הארה גלובלית. |
דוגמאות שימוש
אור נקודתי
from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Light, LightType
scene = Scene()
light = Light("PointLight")
node = scene.root_node.create_child_node("light", light)
node.transform.set_translation(0.0, 10.0, 0.0)
scene.save("lit-scene.glb", FileFormat.GLTF)אור כיווני
from aspose.threed import Scene
from aspose.threed.entities import Light, LightType
scene = Scene()
sun = Light("Sun")
node = scene.root_node.create_child_node("sun", sun)
# Direction is controlled by the node's rotation
node.transform.set_euler_angles(-45.0, 30.0, 0.0) # degrees
scene.save("directional-light.glb")הוסף גם מצלמה וגם אור
from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Camera, Light, LightType, ProjectionType
scene = Scene()
# Camera
cam = Camera("Cam", ProjectionType.PERSPECTIVE)
cam.field_of_view = 60.0
cam_node = scene.root_node.create_child_node("camera", cam)
cam_node.transform.set_translation(0.0, 5.0, 15.0)
# Directional light
light = Light("DirLight")
light_node = scene.root_node.create_child_node("light", light)
light_node.transform.set_euler_angles(-30.0, 45.0, 0.0)
scene.save("camera-and-light.glb", FileFormat.GLTF)רשימת האורות בסצנה מיובאת
from aspose.threed import Scene
from aspose.threed.entities import Light
scene = Scene()
scene.open("model.glb")
def find_lights(node, depth=0):
if isinstance(node.entity, Light):
print(f"{' ' * depth}Light: {node.name}")
for child in node.child_nodes:
find_lights(child, depth + 1)
find_lights(scene.root_node)