Unity Toolkit - remote .glb load works - local path .glb does not - Suggestions?

Remote .glb works:

BABYLON.SceneLoader.ImportMesh("",
                "https://raw.githubusercontent.com/pavankulkarni11/3D_Meshes/main/",
                "Pillow.glb", this.scene, function (newMeshes) {
                })

Local .glb does not work

BABYLON.SceneLoader.ImportMesh("",
                "/Assets/Folder1/Folder2/",
                "Pillow.glb", this.scene, function (newMeshes) {
                })

It gives back a 404 error. File Not Found. Seems the local path is not correct. I’ve tried …/, …/…/, ./, even …/…/…/. This feels like a simple fix.

Anyone have an idea? We need this for quicker debug sessions, change checks.

Adding @MackeyK24 the daddy of the toolkit :slight_smile:

1 Like

Thank you @sebavan.

First of all. BABYLON.SceneLoader is a regular BJS API call.

I would suggest you use the whole path. For local server you can just format a string and combine your root url the scene was loaded from and the local path.

I might have a BABYLON.SceneManager.GetRootUrl or something like that in my scene manager library. Not sure what version you are rocking

I have your Github latest version of the Toolkit.

Basically pillow.glb should be under the project export folder

Is there a BABYLON.SceneManager.GetRootUrl function in the version you have

I’ll check. But I did try the Windows full path version. “not allowed to load local resource…” was what I got back. I’ll try the GetRootUrl next.

You need to use export path, not window local path…

So if your pillow.glb is in the export folder

Your path would be:
http://localhost:8888/scenes/pillow.glb

You might be able to get away with a relative path was well. It would just be:
scenes/pillow.glb

I did get this back on a console.log(…), “function(e){return null!=e._rootUrl&&”“!==e._rootUrl?e._rootUrl:”/“}”.

Okay, I have to take a call but I’m going to test this all out. Thanks Mackey.

Manually dropping the .glb in …\Export\scenes path got this to work, but no shadows seen. If I add a Unity cube in the scene, that shows the shadows.

The code used for testing purposes:

BABYLON.SceneLoader.ImportMesh("",
                "http://localhost:8888/scenes/",
                "pillow.glb", this.scene, function (newMeshes) {
                })

Where did pillow.glb come from… If it came from my toolkit it should have metadata in the gltf json that has info about shadows.

If it does not have the Unity Toolkit Metadata in it. You will have to add the mesh to the light’s shadow caster list in code after you load mesh with ImportMesh.

I think its something like:

light.addShadowCaster()
2 Likes

Okay. I’ll try that tonight. Thanks Mackey. I export from Blender with .glTF.

UPDATE:
I’ll get to this soon. I’m now knee deep in something else. Thanks again @MackeyK24.