I try to host my own json model file to be used in the playcanvas script.
I have tried hosting both in AWS S3 bucket as well as a simple local python server. But in both cases I get
“Uncaught SyntaxError: Unexpected end of JSON input”.
I can download the json file just fine with all the content in a browser. See my hosting below. https://s3-us-west-1.amazonaws.com/exkuisite-floorplans/Gas+Station.json
Your project link is broken. I guess we have to access to this scene.
I tested your json and it’s valid.
However, I tested it like pc.app.assets.loadFromUrl("https://s3-us-west-1.amazonaws.com/exkuisite-floorplans/Gas+Station.json", "model", function(result) {console.log(result)});
Thanks for checking @mikefinch
AWS S3 hosting doesn’t add CORS header allow all by default, so it was throwing when accessed via API !
After seeing your code i realized i could actually debug using “console.log” in play canvas, haha.
This is going to be soo convenient going forward to debug stuff.
Saved my day <3
Oh that explains why it isn’t loading any colors when i load from my url. I thought all I need to host is the json file to load a model with material and colors. I guess not ?
I do see when i load the json from github link, browser also downloads some images and a .mapping json file and what appears to be a material json file !
As a newbie, this is pretty confusing.
Right now I get my models from a designer in fbx file, and then
I use the playcanvas editor to convert it to json.(drag drop)
Host that json file that editor created
I thought these 2 steps are enough to use that fbx model in playcanvase. But i guess not.
What’s the best way to convert these fbx files to be able to load dynamically ?
As a side question, is there a reason you want to self host the assets on your servers instead of it being in the project?
PS when you download the model json file from the editor, it should package the mappings, textures etc as a zip which all need to be upload to your server as is (unless you are willing to edit the files and change the files paths)
Thanks @mikefinch@yaustar
Yes, For following reasons I’m thinking to self host:
I’m building a website where people can view there floor plans and add furniture and design their home. So there are going to be lots of 3d floor plan models coming soon and hundreds of furniture models being added. And the website has to show them as options as and when new models arrive. It seems easy to give someone access to a S3 bucket and ask them to upload models than give them permission to the editor, where they can fuck something up.
These model files can potentially go beyond the size limit that I have on my paid account.
I want to load these models dynamically and only load models that the customer tries out in the website. Thereby also reducing page load time.
It doesn’t seem too convenient to manage 100s of assets in editor. (I may be wrong ?) Also will the editor get too slow if i have so many models in there perhaps ?
Seems to be more of a workflow issue where the lack of version control in PlayCanvas doesn’t help. That said, the Organisation plans does have upload/download of projects so you can backup revisions of the project. (I use a Python script which can be used to automate the process with CI systems). Using S3/external server is valid and not a bad way to go. The downside is that you can’t preload any of the assets or will need a custom loading script to do the preload.
That’s fair. Just be cautious of the individual size of the files in terms of time for the end user to download and view the asset.
It’s doable and IIRC, there is some lazy loading in the assets view so performance shouldn’t be a problem.
TL;DR: Your approach is fine and builds will be faster as the data is external. The downside is that the standard download of the assets from the editor don’t include the DXT, ETC1 and PVR textures which really help with VRAM usage, especially in your case.The only way I’ve seen to get them is either through a web publish or exporting the project which is a little cumbersome.
I think another user has done offline conversions of the texture files but offhand, I can’t remember how the mappings work.