KhronosGroup / gltf-asset-auditor

Check glTF file attributes against commerce application use case requirements
Apache License 2.0
20 stars 3 forks source link

Doubt related to load model #4

Open deep9888 opened 1 year ago

deep9888 commented 1 year ago

Hey Mike, I am facing one issue, like using ThreeJs in my project to load the model. Is three js compatible with gltf-asset-auditor? and I used it directly by dragging and dropping GLB with Babylon.js-

function createDropzone1() {
    const drpCntrl = new SimpleDropzone(dropArea, input1);
    drpCntrl.on('drop', ({files}) => {

      files.forEach((value, key) => {
        const blob = new Blob([value], { type: 'model/gltf-binary' });
        const file = new File([blob], key);
        fileArray.push(file);
      });
      console.log("file array ===",fileArray);
      const auditor = new Auditor();
      auditor.model.loadFromFileInput(fileArray);
      console.log('auditor loaded successfully', auditor);
      console.log('auditor.model.loaded',auditor.model.loaded)});
}

With the above code, the GLB file is not loaded properly. It gives me an error- error7

And one thing I want to know is whether it is compulsory to load the model with auditor.model.loadFromFileInput(Array.from(input.files));, Do I use other functions without loading the model? Or I can use it.

deep9888 commented 1 year ago

I tried this approach also, which you have used in web-example

const inp = document.getElementById("file-input") as HTMLInputElement;
inp.addEventListener('change',  async (event) => {
  const auditor = new Auditor();
  const files = inp.files;
  console.log(files);
  await auditor.model.loadFromFileInput(Array.from(inp.files));
  console.log('auditor.model.loaded',auditor.model.loaded);
  // Do something with the selected files
});

but still giving me this error- error8

Will you guide me in this? Thanks for your time

MikeFesta commented 1 year ago

It looks like you are running into an issue related to https://github.com/KhronosGroup/gltf-asset-auditor/issues/2, where models with Draco compression cannot be loaded. Can you try loading a gltf without compression? There are some in the test folder of the repo. Draco support may be dependent on a feature request for Babylon.js, although I am trying to come up with a solution.

To answer your other questions:

deep9888 commented 1 year ago

I want to know if there is any way I can pass buffer data to auditor.model.loadFromInput(), like I am loading the glb model with three js. If I pass the buffer data for generating the audit report without calling this function auditor.model.loadFromInput(). Because with this function, Babylon.js gives me the above errors.

MikeFesta commented 1 year ago

Sorry, it's not currently possible to load the buffer data directly. Babylon.js is used to compute all of the model attributes that can be audited, most of which are not in the glTF file itself.

Currently there is an issue with loading draco compressed models that is most likely causing the errors you are seeing. Trying getting your code to work with non-draco models first. I'm hoping to get the draco issue resolved next week.

deep9888 commented 1 year ago

Ok, and one more thing, will you also add an audit report for FBX and OBJ files?

deep9888 commented 1 year ago

I tested my GLB model on your web example. It works fine, but if I run it locally, that gives me the above errors.

deep9888 commented 1 year ago

Today, I cloned your GitHub repo and ran that locally, still it not working. I loaded the same model on web-example https://www.khronos.org/gltf/gltf-asset-auditor/ that is working; I don't know where the bug is-

I run Locally error9

I run on deployed web example The same model I loaded in an online web example that is working- error10

deep9888 commented 1 year ago

What is the use of this line in the src folder -> Model.ts?

await SceneLoader.AppendAsync('', glb.getBase64String(), this.scene, () => {}, 'KHR_draco_mesh_compression');

Like babylon.js does not support KHR-Draco-Mesh GLB

MikeFesta commented 1 year ago

Ah, I see what is happening, this line of code, also reported here: https://github.com/KhronosGroup/gltf-asset-auditor/issues/5, accidentally made it into the NPM repo, but not the git repo. It was only in there as an experiment trying to resolve the issue of loading Draco compressed models. I'll push out a version 1.0.2 to NPM that will fix that line.