Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

"_children":"Shape"` vs Array of {"$":"Shape"} #4

Closed
cecilemuller opened this issue Oct 17, 2014 · 1 comment
Closed

"_children":"Shape"` vs Array of {"$":"Shape"} #4

cecilemuller opened this issue Oct 17, 2014 · 1 comment
Labels

Comments

@cecilemuller
Copy link
Member

A question from the X3D mailing-list referencing #1 :

[...] wondering then whether this slight variation using field name (containerField) is an alternative option:

    "_children": "Shape"
    ...
},
{
    "_children": "Transform"
    ...
},
{
    "_children": "Shape"
@cecilemuller
Copy link
Member Author

Let's imagine a SFNode of type SpecialGroup that has two MFNode fields someChildren and otherChildren.

In VRML, it would be:

SpecialGroup {
    ...
    someChildren [
        Shape {
            ...
        }           
        Transform {
            ...
        }           
        Shape {
            ...
        }           
    ]
    otherChildren [
        Shape {
            ...
        }           
        Transform {
            ...
        }           
        Shape {
            ...
        }           
    ]
}

_children

The downsides would be:

  • one can't know if/how many/which nodes a specific MFNode field contains unless iterating the big array to extract the nodes of that field
  • the name of the type isn't always stored in the same property (sometimes it's in _children, sometimes _someChildren, sometimes _otherChildren), so SFNode gets written a different way depending on where it is in the scenegraph
{
    "_children": "SpecialGroup",
    ...
    "WHAT_PROPERTY_ID_HERE": [
        {
            "_someChildren": "Shape"
            ...
        },
        {
            "_someChildren": "Transform"
            ...
        },
        {
            "_someChildren": "Shape"
            ...
        },
        {
            "_otherChildren": "Shape"
            ...
        },
        {
            "_otherChildren": "Transform"
            ...
        },
        {
            "_otherChildren": "Shape"
            ...
        }
    ]
}

$

Using $ instead:

  • no need to guess which property stores the type name
  • each MFNode field is explicit about the list of nodes it contains
  • each SFNode is consistently structured the same way regardless of where it is in the scenegraph
[
    {
        "$": "SpecialGroup",
        "someChildren": [
            {
                "$": "Shape"
                ...
            },
            {
                "$": "Transform"
                ...
            },
            {
                "$": "Shape"
                ...
            }
        ],
        "otherChildren": [
            {
                "$": "Shape"
                ...
            },
            {
                "$": "Transform"
                ...
            },
            {
                "$": "Shape"
                ...
            }
        ]
    }
]

@cecilemuller cecilemuller changed the title _children instead of _type "_children": "Shape"+ no _type vs Array of {"_type":"Shape"} Feb 19, 2015
@cecilemuller cecilemuller changed the title "_children": "Shape"+ no _type vs Array of {"_type":"Shape"} "_children":"Shape"+ no _type` vs Array of {"_type":"Shape"} Feb 19, 2015
@cecilemuller cecilemuller changed the title "_children":"Shape"+ no _type` vs Array of {"_type":"Shape"} "_children":"Shape"` vs Array of {"@":"Shape"} Dec 21, 2015
@cecilemuller cecilemuller changed the title "_children":"Shape"` vs Array of {"@":"Shape"} "_children":"Shape"` vs Array of {"$":"Shape"} Dec 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant