Using setExtras() on gltf-transform CLI #1177
-
Hi,
to set additional meta data? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I support this (would be very handy for https://xrfragment.org glTF's too). |
Beta Was this translation helpful? Give feedback.
-
Hi @Utopiah and @coderofsalvation! The CLI doesn't provide any way to assign custom "extras" metadata today, unless you use a custom config. Are you hoping to assign extras on the root of the glTF file, or to specific objects/meshes/materials/etc within the file? Different options might be easier depending on the purpose. Do you have a preference on how you'd want to do this? It is definitely possible to use the scripting interface as well... would be something like: import { NodeIO } from '@gltf-transform/core';
import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
const io = new NodeIO().registerExtensions(ALL_EXTENSIONS);
const document = await io.read('path/to/model.glb');
const node = document.getRoot().listNodes()
.find((node) => node.getName() === 'MyNode');
node.setExtras({test: true});
await io.write('path/to/output.glb', document); You might need a bit more configuration in there if you're also using Draco or Meshopt compression, or non-standard extensions, but that's general idea. |
Beta Was this translation helpful? Give feedback.
Hi @Utopiah and @coderofsalvation! The CLI doesn't provide any way to assign custom "extras" metadata today, unless you use a custom config.
Are you hoping to assign extras on the root of the glTF file, or to specific objects/meshes/materials/etc within the file? Different options might be easier depending on the purpose. Do you have a preference on how you'd want to do this?
It is definitely possible to use the scripting interface as well... would be something like: