KhronosGroup / glTF-InteractivityGraph-AuthoringTool

A React based DCC for viewing and authoring KHR_interactivity models
17 stars 3 forks source link

Bug: exception when loading graph #10

Closed hybridherbst closed 1 month ago

hybridherbst commented 1 month ago

I created this graph in another experimental authoring tool, but can't load it:

{
    "types": [
        { "signature": "bool" },
        { "signature": "int" },
        { "signature": "float" },
        { "signature": "float2" },
        { "signature": "float3" },
        { "signature": "float4" },
        { "signature": "float4x4" },
        {
            "signature": "custom",
            "extensions": {
                "AMZN_interactivity_string": {}
            }
        }
    ],
    "variables": [],
    "customEvents": [],
    "nodes": [
        {
            "type": "node/onSelect",
            "index": 0,
            "configuration": [
                {
                    "id": "nodeIndex",
                    "type": 1,
                    "value": 0
                },
                {
                    "id": "stopPropagation",
                    "type": 0,
                    "value": false
                }
            ],
            "flows": [
                {
                    "id": "out",
                    "node": 1,
                    "socket": "in"
                }
            ]
        },
        {
            "type": "world/startAnimation",
            "index": 1,
            "values": [
                {
                    "id": "animation",
                    "type": 1,
                    "value": 0
                },
                {
                    "id": "speed",
                    "type": 2,
                    "value": 1
                },
                {
                    "id": "startTime",
                    "type": 2,
                    "value": 0
                },
                {
                    "id": "endTime",
                    "type": 2,
                    "value": 7.5
                }
            ]
        }
    ]
}

When I try to load this graph via "Load JSON", I get an exception which I don't understand: image

When manually creating the same graph in the UI, it looks like this:

{
    "nodes": [
        {
            "type": "node/OnSelect",
            "values": [],
            "configuration": [
                {
                    "id": "nodeIndex",
                    "value": [
                        0
                    ]
                },
                {
                    "id": "stopPropagation",
                    "value": [
                        false
                    ]
                }
            ],
            "flows": [
                {
                    "id": "out",
                    "node": 1,
                    "socket": "in"
                }
            ],
            "metadata": {
                "positionX": "1217.59375",
                "positionY": "237.609375"
            }
        },
        {
            "type": "animation/start",
            "values": [
                {
                    "id": "animation",
                    "value": [
                        0
                    ],
                    "type": 1
                },
                {
                    "id": "speed",
                    "value": [
                        1
                    ],
                    "type": 2
                },
                {
                    "id": "startTime",
                    "value": [
                        0
                    ],
                    "type": 2
                },
                {
                    "id": "endTime",
                    "value": [
                        7.5
                    ],
                    "type": 2
                }
            ],
            "configuration": [],
            "flows": [],
            "metadata": {
                "positionX": "1797.59375",
                "positionY": "131.609375"
            }
        }
    ],
    "variables": [],
    "customEvents": [],
    "types": [
        {
            "signature": "bool"
        },
        {
            "signature": "int"
        },
        {
            "signature": "float"
        },
        {
            "signature": "float2"
        },
        {
            "signature": "float3"
        },
        {
            "signature": "float4"
        },
        {
            "signature": "float4x4"
        },
        {
            "signature": "custom",
            "extensions": {
                "AMZN_interactivity_string": {}
            }
        }
    ]
}

When comparing these two, the main difference I can find is that the former example uses world/animationStart while the latter uses animation/start, with the latter probably correct as per the spec.

If that is the actual issue in the file, it would be great if the UI tells me so – Cannot read properties of undefined (reading 'configuration') sounds like a different problem.

hybridherbst commented 1 month ago

I tried if the first graph loads when changing to animation/start, but that doesn't seem to be the problem.

After digging a bit deeper, there is a second problem: this repository implements node/OnSelect while the JSON contains node/onSelect. I'm not able to figure out which one is correct – is there a specification for that somewhere that I can read?

Other events seem to start with a lowercase letter, while the screenshot here contains node/OnSelect with uppercase O as well.

I think instead of crashing the viewer should tell me that a set of nodes is not known and thus the file can't load.

hybridherbst commented 1 month ago

I found the spec for KHR_node_selectability and the event is officially called node/onSelect. Would be great if this tool could be updated to reflect that.

mattmacf98 commented 1 month ago

Better_Error

hybridherbst commented 1 month ago

Awesome, thanks!