I am sure there must be but I can’t seem to find it. My issue is that I am having performance problems with procedural textures on macOS so I want to turn them off if the user is on a mac.
You can sniff the useragent (even though this is bad ;)): Browser detection using the user agent - HTTP | MDN (mozilla.org)
You might be able to also use navigator.platform
as well. For MacOS, I believe it’ll return MacIntel but you might want to verify beforehand.
Thanks, yeah i was looking at userAgent wondering if that would be the best bet. I guess BJS cant do anything magic in that regard
I will try both.
You can also try using the Babylon scene optimizer.
This has an event that fires if a certain framerate isn’t hit. You can use this to turn off features based on framerate instead of a specific browser or OS.
Thanks Alex. I do have the optimizer active in the scene but didn’t realise i could get an event that i could respond to. That might indeed be worth a try.
Ok, I finally got back to this. I was able to acheive what I wanted by using the Optimizer. I tried using the onFailureObservable but it was never getting fired. I think this was due to a bug (?) in the optimizer where it was crashing and stopping while attempting MergeMeshes. The solution for me was to setup a custom optimazation as described here
to disable MergeMeshesOptimization and to which I added a first step, ie priority 0, before doing anything else
result.addCustomOptimization(
() => {
console.log("Optimizer: Stopping procedural textures, floor reflections");
// My optimization code
return true;
},
() => {
return "Optimizing...reflections, procedural textures...";
},
priority
);
A nice clean, general solution without needed to check the user browser/platform.
Thanks for the pointers.