-
I would like to edit USD(A/C) files in JavaScript. I don't need (or want) to resolve compositional arcs, I want to edit a USD file directly. (Other code will then process the USD files using a full USD implementation.) I was thinking of a USD <--> JSON tool, so I can modify the JSON in JavaScript, but that is not mandatory. I notice there were WASM etc builds. Has anyone tried to read a USD file, make changes, and write back to the file from JavaScript? Words of wisdom greatly appreciated! At the moment I only support export to USDA (print statements!), so was wondering how to make the next step of being able to read, modify, write USD files. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At the moment, most of TinyUSDZ users use C++. If you want to do read/modify USD file in JavaScript, as you thinking of, having JSON representation of USD(USDJ or USDJPY(USD Json rePresentation, Yay!)) should fit your requirements. There is a very early prototype of USD to JSON conversion in TinyUSDZ https://github.com/syoyo/tinyusdz/blob/dev/src/usd-to-json.cc . Once this is implemented, you can read USD and convert it to JSON on JavaScript. const tinyusdz = require('tinyusdz') // wasm build of tinyusdz
usd = tinyusdz.loadUSD(file_or_uri)
// j = JSON
j = tinyusdz.ToJSON(usd)
// edit j
// optionally, validate JSON with JSON Schema
// Construct USD(Stage) from JSON
usd2 = tinyusdz.FromJSON(j)
tinyusdz.WriteAsUSDA(usd2) Currently the priority of implementing USD <-> JSON conversion functionality is low, but the implementation should be rather straightforward. |
Beta Was this translation helpful? Give feedback.
At the moment, most of TinyUSDZ users use C++. If you want to do read/modify USD file in JavaScript, as you thinking of, having JSON representation of USD(USDJ or USDJPY(USD Json rePresentation, Yay!)) should fit your requirements.
#69
There is a very early prototype of USD to JSON conversion in TinyUSDZ https://github.com/syoyo/tinyusdz/blob/dev/src/usd-to-json.cc . Once this is implemented, you can read USD and convert it to JSON on JavaScript.