I’ve made a model data compression tool with decompression library for PlayCanvas (~4.50 mb json model compressed into ~800 kb binary model (gzipped goes down to 600kb, more than 2 times less file size than just gzipped json model)) and i’ve hit the wall:
PlayCanvas Online editor cannot upload custom files (which by the way should be allowed for developer to extend loader by custom assets handlers) - is there any other way to upload custom files to project assets directory (they don’t have to be processed by Editor, they should just exists in project assets directory and should be available for Launch mode).
I hope that i will not have to add custom files only in downloaded html distribution package to be available to handle those compressed models
There isn’t any way to upload custom file. We currently only accept files that are processed by our asset pipeline.
We’re in the process of updating the asset pipeline, one of the main features will be the ability to use files directly as uploaded and not processed by the pipeline. We’ll look into allowing custom file types as that sounds like it would be useful for users.
ok @dave, i know that it will be not tomorrow or near future, so please tell me if it could fix problem for me:
if i will create script library with new model handler that extends built-in ModelHandler by accepting my custom model format (it will check downloaded file header and then choose if have to use decompressed model handler or playcanvas model handler), then this will also accept .lwm file extensions as playcanvas model asset in Editor? if yes, can you tell me where can find code in engine that checks what file extension is assigned to what type of asset resources (or is it only on editor code side?)?
Please, i very need to achieve solution for that problem as quick as it is possible. it’s very important for me right now, so any advise will be helpful.
Take a look in pc.ModelHandler#open in resources_model.js. This method uses the parser_jsonmodel.js to convert the received data into a pc.Model. You should create a similar parser for your model format.
There should be a way to register parsers to a file extension with the model resource handler. Then you can write your own parser and register it. If you load a model with your file extension it will use your parser. This isn’t written yet… but isn’t much work to do.
I encountered the same issue as Psichi when I tried to create voxel mesh from “.vox” binary file format which is used by MagicaVoxel editor. (Please refer #magicavoxel to find out awesome arts with this tool. https://twitter.com/search?src=typd&q=%23magicavoxel)
If it is possible to treat “.bin” file as a binary file and I can access the binary data via asset.resource Uint8Array, that would be very helpful to dig into this area.
I’m glad that you think binary file access is useful. FYI, When I tried to upload a vox file as a “.txt” file, it seems the file itself is uploaded intact. But when I tried to access the data via asset.resource, the data is stored as String rather than as TypedArray/DataView object which is optimal for binary access. (And I couldn’t find a way to convert String to TypedArray without damaging the data)
So currently you would have to do as above and base64 encode, upload as a txt file and then decode when you’ve loaded it in engine. That is a pain and not very efficient.
Another way is to put the file on another remote server that is generally accessible and load it using the standard XmlHttpRequest or pc.http.get(). If you have access to a server that should be relatively easy. Give me a shout if you need a hand with the loading code.
I’ll look again at what is required to allow general purpose uploading text or binary files.