Jump to content

ArcRotateCamera not working in mobile browser


tranlong021988
 Share

Recommended Posts

Sorry, I don't have PG for this case because I see every sample work perfectly on even mobile browser.

Please check http://appsbymekong.com/flashdemo/test/ 

It's just a simple scene with a ground. On PC, ArcRotateCamara work perfectly. But on mobile browser (my Google Nexus 6), when I slide the screen, it's just move a little bit and sometime display wrong behavior. 

I think that I miss something but don't know what exactly it is.

Sorry for my poor English.

Here my code (useless code removed):


<!doctype html>
<html>
<head>
    <title>Porfolio</title>
    <meta name="viewport" content="width=device-width">
    <style type='text/css'>
		html, body,canvas{
			padding: 0;
            margin: 0;
            overflow: hidden;
			width: 100%;
            height: 100%;
		}
    </style>
    <script src="https://code.jquery.com/pep/0.4.1/pep.js"></script>
    <script src='http://cdn.babylonjs.com/2-5/babylon.js'></script>
    
</head>

<body>
    <canvas id='canvas'></canvas>
    
    <script type='text/javascript'>
        var canvas = document.getElementById('canvas');
        var engine = new BABYLON.Engine(canvas, false);
		var scene = createScene();
		function createScene(){
			var scene = new BABYLON.Scene(engine);
			var rayMesh;
			var ambientLight = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
			var light;
			var cam = new BABYLON.ArcRotateCamera("ArcRotateCamera", 1, 0.8, 180, new BABYLON.Vector3(0, 0, 0), scene);
			cam.upperBetaLimit = 2.0; 
			cam.attachControl(canvas,false);
			scene.activeCamera = cam ;
			
			var ground = BABYLON.Mesh.CreateGround("ground1", 50, 50, 2, scene);
			
			return scene;
     
			}
			
 
  
		scene.registerBeforeRender(function(){
				//cam.alpha+=0.01;
		});
        engine.runRenderLoop(function() {
				
                scene.render();
        });
		 window.addEventListener("resize", function () {
			engine.resize();
		  });
         
		
    </script>
</body>
</html>

 

Link to comment
Share on other sites

  • 6 months later...
On 12/15/2016 at 9:24 PM, Deltakosh said:

I guess you forgot to add css property to the canvas: "touch-action: none"

I think, someone has to capture this in the documentation for the Cameras, where you say that we need to add the css property to the canvas:"touch-action:none"

it will be very helpful then for newbies like me.

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...