Light

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

LightEntity 3Dシーンに光源を追加するものです。例えば Camera,、それはに取り付けられます Node 位置と方向を制御するために。.

class Light(Camera):

Methods

A3DObjectSceneObjectEntityCameraLight

LightCamera.。 現行リリースでは、 Light クラス自体は、継承元から継承されたもの以外に追加のプロパティを公開していません CameraEntity.。 LightType 列挙型はライトのカテゴリ分けのために存在しますが、 light_type プロパティは Light クラス。.


Methods

Light(name: str = None)
MethodsMethodsMethodsMethods
name`strNone`None

Methods

MethodsMethodsMethods
namestrライトオブジェクトの名前(継承元は A3DObject).

Light もすべて継承します Camera プロパティ(near_plane, far_plane,など)、ただしこれらはライトオブジェクトにとって意味がありません。注: Light クラスは a を公開していません light_type 現在の API の表層にあるプロパティ。.


LightType の値

from aspose.threed.entities import LightType
MethodsMethodsMethods
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)

関連項目

 日本語