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

Comments #10

Closed
cecilemuller opened this issue Dec 21, 2015 · 2 comments
Closed

Comments #10

cecilemuller opened this issue Dec 21, 2015 · 2 comments
Labels

Comments

@cecilemuller
Copy link
Member

A question have been recurring:

How to handle comments?

@cecilemuller
Copy link
Member Author

Two ways are possible, depending on whether the comments need to be part of the scenegraph or not.


When comments don't need to be part of the scenegraph

They are the same as VRML comments.

You can use a JSON5 parser (for example, the json5 module has 1 million downloads per month) to support familiar Javascript-style comments in JSON:

{
    "$": "Shape",

    // This line is a comment.
    "geometry": {
        "$": "Sphere"
    },

    "appearance": {
        "$": "Appearance",
        "material": {
            "$": "Material",
            "diffuseColor": [0, 1, 0]
        }
    }
}

Example in node.js


When comments must be part of the scenegraph:

Use Metadata nodes, for example:

{
    "$": "MetadataString",
    "name": "mydata",
    "value": ["one", "two", "three"]
}

@cecilemuller
Copy link
Member Author

Although, if comments don't need to be in the scenegraph, I would advise to simply not include them to avoid having to use a JSON5 parser.

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