From a client:
We have hundreds of FBXs to update, is there an easy way to do this without doing this one by one?
There are a couple of ways I can think of doing this and due to state of the project where the FBX source assets have been deleted, only one of these is viable.
(Side note: Source assets don’t need to be deleted as they won’t be included in the build)
I was originally going to recommend using the asset update REST API to upload and update the existing FBX source assets which will in turn update the models and materials that were generated from the FBX.
In this case where you only have the Model GLB assets, this is what I would do instead assuming that the filenames of the FBX also matches the GLB in the project.
Step 1 - Generate the GLBs
-
Create a new project
-
Uploaded all the FBXs into that project and wait for all the GLBs to be generated
-
Download a build of the project
-
Unzip the build
-
Filter the folder by GLB
-
Select all the GLBs and copy into a new folder
Step 2 - Get the asset registry config
-
If your master branch is up to date, go to your project dashboard and Export your project
-
If the branch you are working is not master, you will need to use the REST API to export the project with the correct branch. This can be done via cURL Projects - Archive project | Learn PlayCanvas or you can use our REST API tools to make this a little easier: GitHub - playcanvas/playcanvas-rest-api-tools: A set of tools to use with the PlayCanvas REST API for common jobs such as downloading a build and archiving a project
-
Unzip the zip and there will be some files
-
The important file here is assets.json. If we open that (and format), we can search by name and find the asset data and with it, the asset id.
Step 3 - Mass update the GLB assets
I’ve done this with a single file but in theory this should work.
- Write a script that loads the JSON file assets.json from Step 2 and also finds the GLBs files in the folder from Step 1
- Use the REST API endpoint Assets - Update asset | Learn PlayCanvas to update each GLB from Step 1 using the asset id found in Step 2.The end point is strict rate limited which is 5 calls per minute. Please write the script with this in mind and I would do this operation in a branch, not master.