Jump to content

Detection of "Mobile"


JCPalmer
 Share

Recommended Posts

Hi Jeff, here is a piece of code that I have been experimenting with - not for loading different assets but for deciding on what camera to use.

var isMobile = {                    Android: function() {                        return navigator.userAgent.match(/Android/i);                    },                    BlackBerry: function() {                        return navigator.userAgent.match(/BlackBerry/i);                    },                    iOS: function() {                        return navigator.userAgent.match(/iPhone|iPad|iPod/i);                    },                    Opera: function() {                        return navigator.userAgent.match(/Opera Mini/i);                    },                    Windows: function() {                        return navigator.userAgent.match(/IEMobile/i);                    },                    any: function() {                        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());                    }                };

Then once I load the scene I have this code to decide a camera:

if( isMobile.any() ){                    //alert('Mobile');                    //Create a TouchCamera                    }                    else {                    //Load a FreeCamera from the babylon file                    }

Not my script - from here

 

cheers, gryff :)

 

 

Link to comment
Share on other sites

Thanks.  I knew this had to have been solved somewhere.  Think I will primarily be using this for materials.  The MakeHuman textures are way too big for mobile, 2048x2048.

 

I tried to work in changing resolution of textures in exporter, but gave up.  Fortunately, back in 2000, I did a little hobby project to digitize family photos & 35mm slides.  Made a small Java app to search & display them, but also made a command line Java app to go through a directory and make thumb nail files.  That thumb nail maker is going to get a dusting off after I get Blender actions done.

Link to comment
Share on other sites

I think detecting "mobile" vs. "desktop" is rather wrong.

A lot of reasons, one of them is this - http://www.stucox.com/blog/you-cant-detect-a-touchscreen/ . It is impossible to 100% detect a touchscreen (would be great to find a method that actually does it correctly).

The web is going responsive. and I believe this is the best way to go here - check the screen resolution, and you would know what resources should be sent to the target client. Check (for a second or two) the FPS on the user's device, and you will know if it is strong or not. Some iPhones are stronger than some laptops I know :)

The only problem occurs when you try to target the camera - which one should be used? touch camera? follow camera? I tried implementing an auto-camera picker in an old project, and the article above kind'a explained my bad experience. Try detecting mobile, ask the user to approve he is on mobile, and set him up with a touch camera.

Link to comment
Share on other sites

Raanan,

I thought Gryff's use for Camera, while fine for him, might be better implemented using Hand.

Fast vs wimpy is really what I am after to know to drop the texture size. Screen resolution is not always perfect either. When I pass a 2K texture to a 10" iPad it really affects things.  Maybe an evaluation of GPU capabilities is also a way to go.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...