linker.connectΒΆ

nil linker.connect ( Node left , Node right , types.bool connect , string|table mode , string|nil submode )

Manage the connection between 2 objects in a specified mode

This function handles the connection between 2 objects, such as light linking, trace linking, etc.

It takes 2 nodes to connect/disconnect, a flag that tells if the nodes must be connected or disconnected, a mode that indicates which kind of connection must be handled and an optional submode if the connection mode has submodes.

The passed mode can be either a string for built-in linker modes, or a custom table for alternative linking mode. Available built-in linker modes are:

The left and right nodes classes to connect are expected to be compatible with the mode's LeftClasses and RightClasses attributes. For instance:

linker.connect (myPrimitive, myMaterial, true"MaterialLinking")
-- Correct, connect myPrimitive Primitive to myMaterial Material

linker.connect (myLight, myPrimitive, true"LightLinking")
-- Wrong, left is expected to be a SceneGraphNodeor a LayerOut
-- and right is expected to be a Light or a ShaderNodeShadow

linker.connect (myPrimitive, myLight, true"LightLinking")
-- Correct, myPrimitive is connected to myLight
-- No submode assumes default connections, that is Lit and Shadow

The mode argument can be a custom linker mode, as a table:

local LeftStereoLinking = 
{
    -- The name to be displayed as linking mode in the linker
    Name = "Left Camera",
    -- Filter to use in the left tree
    LeftLabels = "Stereo Camera",
    LeftClasses = {"Camera"},
    -- Filter to use in the right tree
    RightLabels = "Left Camera",
    RightClasses = {"Camera"},
    -- Dependencies
    Dependencies =
    {
        {
            {
                "LeftCam",        -- Plug to connect in the left object
                "CameraParams",    -- Plug to connect in the right object
                true,            -- true : left depends on right, false : right depends on left
                false,            -- true : enable multiple connections, false : only one connection
            },
        },
    }
}
Arguments:

  • left The left node to connect
  • right The right node to connect
  • connect Connect or disconnect
  • mode The connection mode
  • submode The connection submode