Skip to content

Scaling asset up/down? #1006

Answered by donmccurdy
bigrig2212 asked this question in Q&A
Jun 30, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @bigrig2212! If you mean to rescale all or part of the scene (as opposed to textures) then no, the CLI does not provide commands for that. However, this can be done in a script. Related functions:

A basic example, scaling scenes up by 2x, would look something like this:

import { NodeIO } from '@gltf-transform/core';

const io = new NodeIO();
const document = await io.read('path/to/model.glb');

for (const scene of document.getRoot().listScenes()) {
  for (const node of scene.listChildren()) {
    const scale = node.getScale();
    scale[0] *= 2;
    scale[1] *= 2;
    scale[2] *= 2;
    node.setScale(scale);
  }
}

await io.write('path/t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by bigrig2212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants