Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glTF/GLB model size - is there any tool for checking it? #58

Closed
JMAR09 opened this issue Sep 24, 2021 · 2 comments
Closed

glTF/GLB model size - is there any tool for checking it? #58

JMAR09 opened this issue Sep 24, 2021 · 2 comments

Comments

@JMAR09
Copy link

JMAR09 commented Sep 24, 2021

Hi guys, is there any tool, where I can check actual size (dimmensions) of glTF/GLB model?

Imagine that we got some 3D models of TV, we would like to use them for AR presentation, but before we would like to be sure, if dimmension of those models is correct.

Hope, that my question is clear.

Thank you in advance

Jan :)

@javagl
Copy link
Contributor

javagl commented Sep 24, 2021

First, a small aside: This repository here is for the glTF Tutorials - so this issue does not really belong here. Questions like this could probably better fit into the forum at https://community.khronos.org/c/gltf-general/45


However, in general, glTF models SHOULD always have "the right size", and this size should always be given in meters. A strongly related question has been brought up recently, at KhronosGroup/glTF-Sample-Assets#63 .

But of course, it can make sense to check that, because ... you never know what that GLB might contain. According to what Don said in that other issue, the https://github.com/donmccurdy/glTF-Transform tools already offer that functionality, namely computing the bounds of a whole scene or node. The relevant function is https://github.com/donmccurdy/glTF-Transform/blob/main/packages/core/src/utils/bounds.ts

Some rough draft of how you could do this would be

import { NodeIO } from '@gltf-transform/core';
import { bounds } from '@gltf-transform/core';
...
    const document = io.read('C:/yourFile.glb');
    const {min, max} = bounds(document.getRoot().listScenes()[0])    
    const sizeX = max[0] - min[0];
    const sizeY = max[1] - min[1];
    const sizeZ = max[2] - min[2];

    if (sizeX > ...) console.log("Nope, that's too large...");
    ...

@donmccurdy
Copy link

donmccurdy commented Sep 24, 2021

The bounds can also be found by CLI or on a website if that's easier:

(1) CLI

npm install --global @gltf-transform/cli
gltf-transform inspect input.glb

(2) https://gltf.report/
Screen Shot 2021-09-24 at 12 04 16 PM

@emackey emackey closed this as completed Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants