Is there a way to directly edit the size parameters in a gltf file?

First, I would like to apologize if there are any existing topics with similar content.

Context: I am using THREE.js to display 3D objects from a gltf file (v2.0) in the browser.

I have .gltf files exported from the Spline editor. The geometric sizes in these gltf files are 100 times larger than I expect, and the position parameters are also 100 times larger.

I believe there is a way to directly modify the contents of these .gltf files to reduce the geometric sizes by 100 times. I have been exploring this approach and have tried using NodeJS to modify the contents of the .gltf file.
I have a SCALE_FACTOR = 0.01
I loop through gltf.nodes and adjust the corresponding buffer along with mesh.width, mesh.height, and mesh.depth.

I think the idea is correct but my implementation is not. I get results that are not as expected.
I am new to these technologies, so my knowledge is limited. I would be very grateful if someone could provide a solution to this problem.

When you say “larger”, are you talking about the file size, the number of vertices, or the sizes of the meshes when rendered?

If you’re loading the model in three.js, probably the important thing to know is that the results returned by THREE.GLTFLoader are three.js objects, with the gltf.scene root object being a THREE.Group and everything else nested under that.

Because nodes inherit transforms from their parents, iterating over the entire list of nodes will apply compounding transforms to nested nodes. Instead it would be most common just to scale the root object:

const gltf = await loader.loadAsync('path/to/scene.glb');
const model = gltf.scene;
model.scale.set(0.01, 0.01, 0.01);
scene.add(model);

While you could do this offline in a script, it’s probably easier just to do so at runtime in the browser.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.