Convert FBX to JSON by code at runtime?

Is it possible to convert a FBX to JSON by code? I know Playcanvas can do that in the editor but I want to do that at runtime.

For context , what I want to do is,

  1. Importing a FBX file through a form;
  2. Convert this FBX to JSON,
  3. Load it dynamically
  4. Show it.

I just want the JSON about the 3D meshs but if it gives the materials and textures at the same time, I’ll take them too.

So when you launch the game you want the fbx to convert to json?

Not directly when I launch the application, but when it’s running, yes. The application ask to import the FBX files.

1 Like

So you mean after the game has loaded them? Well what i can suggest is im not sure if you can do exactlly that but i can suggest disabling the json and the enable it at runtime

Here a similar question about that request: Programatically convert fbx to json for playcavas

But from my point of view, it’s a bit too complex (convert FBX to GLTF, GLTF to JSON). I’m sure there is an easiest way to do that, since the editor can handle that very fast.

1 Like

The editor does the FBX to JSON on the backend server (you upload the FBX, the server gets a request to convert which uses a commandline tool most likely and adds the JSON to the project). It doesn’t do the conversion in the browser which seems to be what you are asking?

Isnt there a way to convert it yourself though? even after uploading the fbx to the project?

It is possible to do yourself and probably in the browser (despite being slow) but you would have to write the convertor yourself. It isn’t an off the shelf solution.

1 Like

Side note: There’s a library to load GLTF natively. It doesn’t get converted to the PlayCanvas JSON format. https://github.com/playcanvas/playcanvas-gltf

yaustar:
The editor does the FBX to JSON on the backend server.

Is there a way to send a request to this backend without the editor (with HTTP request?) and receive the JSON as a response?

When I use the editor to convert a file, I can see a response from (https://playcanvas.com/api/assets). Maybe there’s an API available?

Not without going through the editor.

Maybe? I would expect it to need an auto token? I would also doubt it do a JSON asset response. It is more likely to upload it to the server where the editor can access it.

You be better off going from FBX to GLTF to be honest. More convertors available freely online and it handles all the texturing too.

I figured out how to POST a request to the server to get the conversion but I received an Unauthorized access. So the tool is there but not publicly available.

20x20 yaustar:
You be better off going from FBX to GLTF to be honest. More convertors available freely online and it handles all the texturing too.

Do this mean that we can show/use directly GLTF model without any conversion to a JSON format? If yes, maybe I can ask my 3D artist to export directly in that format, removing completely my need to create/use a converter tool.

Yes, as mentioned before, there’s a library that loads GLTF natively. I’m not sure where the idea that it gets converted to JSON is from?