API

Interface IGLTFToFlowGraphMapping

Description of how a KHR_interactivity declaration (op such as pointer/get, event/onSelect, math/add) maps to one or more FlowGraph blocks. Used by InteractivityGraphToFlowGraphParser to translate the source glTF graph into the serialized FlowGraph form.

interface IGLTFToFlowGraphMapping {
    blocks: any[];
    configuration?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    declarationSchema?: {
        inputValueSockets: Record<
            string,
            | "bool"
            | "float"
            | "float2"
            | "float3"
            | "float4"
            | "float2x2"
            | "float3x3"
            | "float4x4"
            | "int"
            | "ref"
            | "custom",
        >;
        outputValueSockets: Record<
            string,
            | "bool"
            | "float"
            | "float2"
            | "float3"
            | "float4"
            | "float2x2"
            | "float3x3"
            | "float4x4"
            | "int"
            | "ref"
            | "custom",
        >;
    };
    extraProcessor?: (
        gltfBlock: IKHRInteractivity_Node,
        declaration: IKHRInteractivity_Declaration,
        mapping: IGLTFToFlowGraphMapping,
        parser: InteractivityGraphToFlowGraphParser,
        serializedObjects: ISerializedFlowGraphBlock[],
        context: ISerializedFlowGraphContext,
        globalGLTF?: IGLTF,
    ) => ISerializedFlowGraphBlock[];
    inputs?: {
        flows?: { [originName: string]: IGLTFToFlowGraphMappingObject };
        values?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    };
    interBlockConnectors?: {
        input: string;
        inputBlockIndex: number;
        isVariable?: boolean;
        output: string;
        outputBlockIndex: number;
    }[];
    outputs?: {
        flows?: { [originName: string]: IGLTFToFlowGraphMappingObject };
        values?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    };
    typeToTypeMapping?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    validation?: (
        gltfBlock: IKHRInteractivity_Node,
        interactivityGraph: IKHRInteractivity_Graph,
        glTFObject?: IGLTF,
    ) => { error?: string; valid: boolean };
}
Index
blocks: any[]

The type of the FlowGraph block(s). Typically will be a single element in an array. When adding blocks defined in this module use the KHR_interactivity prefix.

configuration?: { [originName: string]: IGLTFToFlowGraphMappingObject }

The configuration of the glTF node mapped to the FlowGraph block. This information is usually passed to the constructor of the block.

declarationSchema?: {
    inputValueSockets: Record<
        string,
        | "bool"
        | "float"
        | "float2"
        | "float3"
        | "float4"
        | "float2x2"
        | "float3x3"
        | "float4x4"
        | "int"
        | "ref"
        | "custom",
    >;
    outputValueSockets: Record<
        string,
        | "bool"
        | "float"
        | "float2"
        | "float3"
        | "float4"
        | "float2x2"
        | "float3x3"
        | "float4x4"
        | "int"
        | "ref"
        | "custom",
    >;
}

Exact value socket contract for an operation supplied by another extension.

extraProcessor?: (
    gltfBlock: IKHRInteractivity_Node,
    declaration: IKHRInteractivity_Declaration,
    mapping: IGLTFToFlowGraphMapping,
    parser: InteractivityGraphToFlowGraphParser,
    serializedObjects: ISerializedFlowGraphBlock[],
    context: ISerializedFlowGraphContext,
    globalGLTF?: IGLTF,
) => ISerializedFlowGraphBlock[]

This is used if we need extra information for the constructor/options that is not provided directly by the glTF node. This function can return more than one node, if extra nodes are needed for this block to function correctly. Returning more than one block will usually happen when a json pointer was provided.

Type Declaration

    • (
          gltfBlock: IKHRInteractivity_Node,
          declaration: IKHRInteractivity_Declaration,
          mapping: IGLTFToFlowGraphMapping,
          parser: InteractivityGraphToFlowGraphParser,
          serializedObjects: ISerializedFlowGraphBlock[],
          context: ISerializedFlowGraphContext,
          globalGLTF?: IGLTF,
      ): ISerializedFlowGraphBlock[]
    • Parameters

      • gltfBlock: IKHRInteractivity_Node

        the glTF node

      • declaration: IKHRInteractivity_Declaration

        the declaration object

      • mapping: IGLTFToFlowGraphMapping

        the mapping object

      • parser: InteractivityGraphToFlowGraphParser

        the interactivity graph parser

      • serializedObjects: ISerializedFlowGraphBlock[]

        the serialized objects

      • context: ISerializedFlowGraphContext

        the serialized flow graph context

      • OptionalglobalGLTF: IGLTF

        the global gltf object

      Returns ISerializedFlowGraphBlock[]

      an array of serialized nodes that will be added to the graph.

inputs?: {
    flows?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    values?: { [originName: string]: IGLTFToFlowGraphMappingObject };
}

The inputs of the glTF node mapped to the FlowGraph block.

Type Declaration

interBlockConnectors?: {
    input: string;
    inputBlockIndex: number;
    isVariable?: boolean;
    output: string;
    outputBlockIndex: number;
}[]

The connections between two or more blocks. This is used to connect the blocks in the graph

Type Declaration

  • input: string

    The name of the input connection in the first block.

  • inputBlockIndex: number

    The index of the block in the array of blocks that corresponds to the input.

  • OptionalisVariable?: boolean

    If the connection is a variable connection or a flow connection.

  • output: string

    The name of the output connection in the second block.

  • outputBlockIndex: number

    The index of the block in the array of blocks that corresponds to the output.

outputs?: {
    flows?: { [originName: string]: IGLTFToFlowGraphMappingObject };
    values?: { [originName: string]: IGLTFToFlowGraphMappingObject };
}

The outputs of the glTF node mapped to the FlowGraph block.

Type Declaration

typeToTypeMapping?: { [originName: string]: IGLTFToFlowGraphMappingObject }

If we generate more than one block for a single glTF node, this mapping will be used to map between the flowGraph classes.

validation?: (
    gltfBlock: IKHRInteractivity_Node,
    interactivityGraph: IKHRInteractivity_Graph,
    glTFObject?: IGLTF,
) => { error?: string; valid: boolean }

This optional function will allow to validate the node, according to the glTF specs. For example, if a node has a configuration object, it must be present and correct. This is a basic node-based validation. This function is expected to return false and log the error if the node is not valid. Note that this function can also modify the node, if needed.

Type Declaration

    • (
          gltfBlock: IKHRInteractivity_Node,
          interactivityGraph: IKHRInteractivity_Graph,
          glTFObject?: IGLTF,
      ): { error?: string; valid: boolean }
    • Parameters

      • gltfBlock: IKHRInteractivity_Node

        the glTF node to validate

      • interactivityGraph: IKHRInteractivity_Graph

        the interactivity graph

      • OptionalglTFObject: IGLTF

        the glTF object

      Returns { error?: string; valid: boolean }

      true if validated, false if not.