You know the quality of my dev skills (I actually should start all my posts with this )…
For a small project I’m about to finalize, I needed this feature where I can (simply) save a number of properties by writing them to a json file, download the file and next allow the user to upload this file as ‘presets’ and apply it to the scene.
I had a few bits here or there and was trying to fill-in the missing parts from this forum… and next from other forums… and ended-up with ChatGPT… which I have proven wrong on some parts after identifying other bits.
So, I decided I would make a PG that I can later share here with an explicit name so that others who’d likely face the same situation would be able to have at least this source.
I believe the logic and method to be correct (and it works)… but I do have a small issue with it.
I’m uploading and applying properties for the active camera. They all do load correctly, but - for the active camera only (camera1 in this PG), they ALL apply only if I load the file twice… for some unknown reason. On the first pass, it looks like some are ‘ignored’. So, I tried detaching, re-attaching the camera, re-instruct scene.activeCameras, make another scene.render… nothing seems to do the trick?
Anyone of yours experts have a quick look at this PG and tell me where I messed it up?
Also feel free to improve the script for write to json, export/download, import, parse, apply (if not the best). I’d like to keep it ‘explicit’ and ‘simple’ but I don’t want to share something that’s not 100% ‘recommendable’.
The file upload ‘twist’ to also work in the Playground and using only the BJS GUI I tweaked (for JSON) from this source from @Evgeni_Popov (while ChatGPT was first saying it is not possible, lol ) BTW ChatGPT v4 is thanking @Evgeni_Popov for his outstanding contribution
Did you try change all properties. Including target (panning) and the camera fov? That’s how I eventually encounter the issue. Could be because of the target. May be should use setTarget first … 'need to investigate… Anyways, thx for having a look at it and have a great day
Don’t know how I got it in the first place I can assure you I didn’t bribe for it I’m just hoping I will never have to face a dark lord - or he’ll slice me with a single line of saber code
That’s probably just ‘incidental’. Like most of the things I do … As said above, I will have to check back on this… Thanks for taking the time to have a look at it and have a great day
very close to the og position but not quite : )
can you try the steps listed, if it still doesn’t happen for you it might be a platform thing : O
I’m on firefox linux
Yes, of course ‘position’. Stupid me completely forgot about it. Huh? Did I? I’m not sure; The position of the arc cam should be from the target (orbital) using alpha, beta and radius. … and I thought I had a perfect understanding of cameras As I said, need to check on this…
Well, the answer may be in my last question. If it is ‘from the target’ may be just need to set the target first That could explain why it works when you upload a second time…
Edit: typed and didn’t see your post
That might be it. I’ll just quickly check on that. There’s a fair chance that would be it… don’t waste more time on this. I’ll sure let you know if it isn’t
OK Guys,
Thanks again and sorry for wasting your precious time .
The above looks like the solution: Set the target first.
Here’s an updated playground that should work (does it? )
Edit: Updated PG link. Uses ‘pointerUp’ observable to load the file which prevents from having to click twice (since the hidden DOM element is created dynamically).