Is there a way to determine the users platform?

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)

2 Likes

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.

2 Likes

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 :slight_smile:
I will try both.

1 Like

Try this library: bowserjs

1 Like

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.

1 Like

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.

2 Likes

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.

2 Likes