Scaling asset up/down? #1006
-
Haven't seen an api for Scaling. Assuming there's no api for that? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Oh, actually i see: https://github.com/donmccurdy/glTF-Transform/blob/main/packages/core/src/properties/node.ts |
Beta Was this translation helpful? Give feedback.
-
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/to/model.glb', document); |
Beta Was this translation helpful? Give feedback.
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:
Node#setScale
transformMesh
transformPrimitive
A basic example, scaling scenes up by 2x, would look something like this: