@kroxilon/usda-parser
v0.0.4
Published
Allows parsing of USDA files - see https://www.openusd.org
Downloads
2,614
Maintainers
Readme
Allows parsing of USDA files in NodeJS and the browser.
yarn install @kroxilon/usda-parser
Getting Started
import {parse} from "@kroxilon/usda-parser";
const file = `#usda 1.0
(
defaultPrim = "hello"
)
def Xform "hello"
{
custom double3 xformOp:translate = (4, 5, 6)
uniform token[] xformOpOrder = ["xformOp:translate"]
def Sphere "world"
{
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
color3f[] primvars:displayColor = [(0, 0, 1)]
double radius = 2
}
}`;
const parseResult = parse(inputFile);
console.log(parsedResult, null, ' ');
{
"version": 1,
"descriptor": {
"description": null,
"assignments": [
{
"type": "assignment",
"keyword": null,
"identifier": "defaultPrim",
"value": "hello"
}
]
},
"statements": [
{
"type": "definition",
"subType": "def",
"defType": "Xform",
"name": "hello",
"args": [],
"statements": [
{
"type": "declaration",
"keyword": "custom",
"defineType": "double3",
"reference": "xformOp:translate",
"value": [
4,
5,
6
],
"descriptor": null
},
{
"type": "declaration",
"keyword": "uniform",
"defineType": "token[]",
"reference": "xformOpOrder",
"value": [
"xformOp:translate"
],
"descriptor": null
},
{
"type": "definition",
"subType": "def",
"defType": "Sphere",
"name": "world",
"args": [],
"statements": [
{
"type": "declaration",
"keyword": null,
"defineType": "float3[]",
"reference": "extent",
"value": [
[
-2,
-2,
-2
],
[
2,
2,
2
]
],
"descriptor": null
},
{
"type": "declaration",
"keyword": null,
"defineType": "color3f[]",
"reference": "primvars:displayColor",
"value": [
[
0,
0,
1
]
],
"descriptor": null
},
{
"type": "declaration",
"keyword": null,
"defineType": "double",
"reference": "radius",
"value": 2,
"descriptor": null
}
]
}
]
}
]
}