Coder Social home page Coder Social logo

Comments (2)

donmccurdy avatar donmccurdy commented on August 16, 2024 2

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

from gltf-tutorials.

javagl avatar javagl commented on August 16, 2024 1

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...");
    ...

from gltf-tutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.