Light

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

Light yra Entity kuris prideda šviesos šaltinį į 3D sceną. Kaip Camera, jis yra prijungtas prie Node kad kontroliuotų jo padėtį ir kryptį.

class Light(Camera):

Methods

A3DObjectSceneObjectEntityCameraLight

Light paveldi iš Camera. Dabartinėje versijoje, Light klasė pati neatskleidžia papildomų savybių, išskyrus tas, kurios paveldimos iš Camera ir Entity. Ši LightType enum egzistuoja šviesų kategorizavimui, tačiau nėra light_type savybės ant Light klasės.


Methods

Light(name: str = None)
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, light_type)
move_forward(distance: float)
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)
get_property(property: str)
set_property(property: str, value)Sets the property value.
find_property(property: str)

Light taip pat paveldi visus Camera savybės (near_plane, far_plane, ir t.t.), nors šios nėra prasmingos šviesos objektams. Pastaba: the Light klasė neatskleidžia light_type savybės dabartinėje API sąsajoje.


LightType reikšmės

from aspose.threed.entities import LightType
MethodsMethodsMethods
LightType.POINT"POINT"Skleidžia šviesą vienodai visomis kryptimis iš vieno taško.
LightType.DIRECTIONAL"DIRECTIONAL"Lygiagrečios spinduliai iš begalinio atstumo šaltinio (pvz., saulės šviesos).
LightType.SPOT"SPOT"Kūgio formos spindulys; svarbūs padėtis ir kryptis.
LightType.AREA"AREA"Šviesa, išskleidžiama iš stačiakampės srities.
LightType.VOLUME"VOLUME"Tūrinė / globali apšvietimo šviesa.

Naudojimo pavyzdžiai

Taškinė šviesa

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)

Kryptinė šviesa

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

Pridėti tiek Camera, tiek Light

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)

Išvardinti Light objektus importuotoje scenoje

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)

Žr. taip pat

 Lietuvių