# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Module containing an example UsdSuperLayer Content Layer.
"""

import usg
from Katana import NodegraphAPI

light_types = [
    "CylinderLight",
    "DiskLight",
    "DistantLight",
    "DomeLight",
    "DomeLight_1",
    "GeometryLight",
    "MeshLight",
    "PortalLight",
    "RectLight",
    "SphereLight",
    "VolumeLight",
]

super_tool = NodegraphAPI.CreateNode("UsdSuperLayer", NodegraphAPI.GetRootNode())
controller = super_tool.getStageSubtreeController()

# Check if the super_tool is a UsdSuperLayer and create the Material prim
if super_tool.getType() == "UsdSuperLayer":
    controller.createPrim("Material", "Material", usg.PrimSpecifier.Def)

for light in light_types:
    if light == "MeshLight":
        prim = controller.createPrim(f"{light}_{light}", "Cube", usg.PrimSpecifier.Def)
        prim.addAppliedSchema("MeshLightAPI", usg.ListPosition.PrependFront)

    elif light == "VolumeLight":
        prim = controller.createPrim(f"{light}_{light}", "Sphere", usg.PrimSpecifier.Def)
        prim.addAppliedSchema("VolumeLightAPI", usg.ListPosition.PrependFront)

    else:
        controller.createPrim(f"{light}_{light}", light, usg.PrimSpecifier.Def)

super_tool.syncLayerAndParameters()
