How to load local .json(converted from pc editor) file with engine

As we know,loadFromUrl() needs a parameter which is a remote url,now my code works well:

// remoteUrl = 'https:..'; // this file was downloaded from editor
app.assets.loadFromUrl(remoteUrl, "model", function (err, asset) {...}

this file from remoteUrl is large,so I want to compress this file to reduce the network request time. so ,there are 4 steps:
1:compress this file
2:puts it on my server
3:download it
4:use this file
my problem is fourth step,after I download this file ,it is a compressed file ,I decompress it,the question is I got this decompressed file,how to load it into my scene

Hi @fengyu,

So you should extract the contents of the archive you got and then:

  1. Load the model (.glb or .json legacy model) with a single loadFromUrl() request.
  2. Load each model material from the subfolders that were created using additional loadFromUrl() requests.
  3. If textures were included with this model, load any texture found in the material subfolders in the same way.

To help automate this, you will get a .mapping.json file as well, which contains a full list of what you need to load together with this model.

Thank you for your reply.
I didn’t make it clear,for example,I downloaded a model file from editor ,then I got a folder(it containes .json file and other textures) ,I just compressed this folder to put it on my company server.when I dowloaded this .zip file,I decompress it,it is a local file now,then I don’t know what is the url which is a parameter for the loadFromUrl() function,I get confused

So, for PlayCanvas to load the file that needs to be served from a local or web server.

Where do you execute your PlayCanvas engine only app? From there you should find the running url and the assets url.

Thank you. I’m a newer. I think this may be related to the file system.

In order to reduce the time of network requests, I think of compressing the resources on the server, which are still in the verification stage. Do you have any good suggestions

Are you looking to download the zip to the client with multiple files in it?

Yes,Do you have any good suggestions

Have you enabled GZIP compression on the server (which is what PlayCanvas does it’s hosting servers)?

This compresses the files so when they are transferred to the client, they are compressed (eg the engine file which goes from 1.2MB to 120KB) and the client uncompressed in the browser.

https://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

This doesn’t put all the files into a single zip/compressed archive but can greatly reduce the size of files on transport.

Wow,nice,that’s what I think,I need to learn these usages.
Thank you!