dbhvk

Manually adding FilesToLoad

Recommended Posts

I'm trying to load the following GLTF (https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.filesInput.ts#L161) in a sandbox-like manner but without using the drop monitor or an standard file input.

I do have the file instance for each file, and when I manually set the lowercased-name of the file + the file instance on the FilesToLoad object, the GLTF will fail to load with the following error:

n {cameras: Array(0), lights: Array(0), meshes: Array(2), skeletons: Array(0), particleSystems: Array(0), …} "Unable to load from blob:http://localhost:3000/2a140a19-0e8d-47a6-bad0-d4d8b2e0c1c7: #/bufferViews/6: Invalid typed array length: 288" Error: #/bufferViews/6: Invalid typed array length: 288
    at preview.js:36
preview.js:36 Uncaught (in promise) Error: #/bufferViews/6: Invalid typed array length: 288
    at preview.js:36
[...]
bundle.js:162382 BJS - [09:58:31]: Error while trying to load image: [object Blob]

I've been trying to load GLTFs and GLBs with texture dependencies (with no luck). The error while loading a blob is common as well. Any ideas on where to start to debug this?

The scene is loading with the standard scene loader pointing to an object url with the file extension correctly forced. It works for any gltf/glb with bundled base64 materials.

Update (relevant gltf parts):

      {
         "bufferView" : 6,
         "byteOffset" : 0,
         "componentType" : 5126,
         "count" : 36,
         "max" : [
            1.000000,
            1.000000
         ],
         "min" : [
            -1.000000,
            -1.000000
         ],
         "type" : "VEC2"
      }

[...]

      {
         "buffer" : 0,
         "byteLength" : 288,
         "byteOffset" : 1572,
         "target" : 34962
      }


 

Share this post


Link to post
Share on other sites

Hmm, works in the playground, but ported it to codepen so I can initialize stuff myself and get a different error (but still an error), can you check please?
https://codepen.io/belohlavek/pen/ZqOWWW

The error should be:

babylon.js:1 Uncaught (in promise) Error: #/images/1/uri: Failed to load 'AnimatedCube_MetallicRoughness.png': 404 

I'm fine with that one (that's what I get on the Playground btw), means that I need to add more files to the FilesToLoad list.

Share this post


Link to post
Share on other sites

If you want to use "file:" to load files, all the files that are referenced by the glTF must be included in the files. In this case, the glTF is inlined, but the images that it references are not present in the list.

Share this post


Link to post
Share on other sites

Yep, the thing is that's not the error I get on codepen.

If you run the code on the playground, the error will inform that images cannot be found, that's fine.

For codepen and my codebase I get two different errors for the same babylon version. So just to clarify:

BJS - [21:11:46]: Unable to load from file:simon_scene.gltf: loadAssets of unknown

👆that's the codepen error and it's not the expected one

Share this post


Link to post
Share on other sites

I'm not getting the error you are getting for the codepen link you sent.

There are a couple of issues with the codepen page:

  1. In order to load glTF files, you need to include loaders/babylon.glTFFileLoader.js (for example from here: https://cdn.babylonjs.com/loaders/babylon.glTFFileLoader.js) see http://doc.babylonjs.com/how_to/gltf#setup
  2. Codepen appears to stop execution when any exception is thrown. There is an exception that is being thrown by Babylon because it is trying to check if there is a manifest. You can disable this by calling "engine.enableOfflineSupport = false" after creating the engine.

After fixing these two, I get the reference errors for the external files.

Share this post


Link to post
Share on other sites

You are right, that generates the expected errors on codepen!

There's still my inicial issue that I can't replicate elsewhere, so I'll beat my head against the wall a bit during the weekend a report back if I can reproduce it

Cheers

Share this post


Link to post
Share on other sites

Ah, yes. That's a good observation. You need to put "file:" as the first parameter rootUrl instead of putting it as part of the second parameter sceneFilename. The rootUrl will be prepended to the uris of the glTF file.

Share this post


Link to post
Share on other sites
On 10/4/2018 at 3:19 PM, bghgary said:

If you want to use "file:" to load files, all the files that are referenced by the glTF must be included in the files. In this case, the glTF is inlined, but the images that it references are not present in the list.

So can you disregard or ignore a material asset file for a 3d file defined in the gltf or obj spec any way to ignore errors and continue to load asset without materials

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.