How to add prefix to baseColor_xx.jpg? #1353
-
After using the write method, there will be three files exported: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ringcrl! It sounds like you are using the scripting API and For example: import { ImageUtils } from '@gltf-transform/core';
import { listTextureSlots } from '@gltf-transform/functions';
const io = new NodeIO();
const document = await io.read('path/to/modelName.glb');
const prefix = 'modelName';
for (const texture of document.getRoot().listTextures()) {
const slot = listTextureSlots(texture)[0] || 'unused';
const extension = ImageUtils.mimeTypeToExtension(texture.getMimeType());
texture.setURI(`${myPrefix}.${slot}.${extension}`);
}
await io.write('path/to/modelName.gltf', document); If you prefer to put images into folders, you can also prefix the path with the name of a folder. |
Beta Was this translation helpful? Give feedback.
Hi @ringcrl! It sounds like you are using the scripting API and
NodeIO
to read/write? If that's not the case and you're using the CLI instead, I think you'll need to use the scripting API. The names of textures are configured by theTexture#setURI
method; if unspecified, defaults are chosen.For example: