Skip to content

How to add prefix to baseColor_xx.jpg? #1353

Answered by donmccurdy
ringcrl asked this question in Q&A
Discussion options

You must be logged in to vote

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 the Texture#setURI method; if unspecified, defaults are chosen.

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(t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ringcrl
Comment options

Answer selected by ringcrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #1352 on April 11, 2024 13:38.