Jump to content

attachControl have no effect on BABYLON.FollowCamera.


BritneyWatch
 Share

Recommended Posts

<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<title>Babylon.js Bare Minimum Setup</title>
<style type="text/css">
html, body
{
	margin:0;
	padding:0;
	width:100%;
	height:100%;
	overflow:hidden;
	background-color: #000000;
}

#my_canvas
{
	width:100%;
	height:100%;
	touch-action:none;
}
</style>

<script src="babylon.js"></script>

<script>
var canvas_id; var engine; var scene; var camera; var light; var sphere;

function init()
{
	setup_Babylon_Scene();
	addEventListener("keydown", onKeyDown, false);
}

function onKeyDown(event)
{
	scene.getMeshByName("Sphere1").position.z += 0.1;
}

function setup_Babylon_Scene()
{
	canvas_id = document.getElementById("my_canvas");
	engine = new BABYLON.Engine(canvas_id);
	scene = new BABYLON.Scene(engine);
	scene.clearColor = new BABYLON.Color3.White();

	light = new BABYLON.PointLight("Light1", new BABYLON.Vector3(0,30,10),scene);
	
	sphere = BABYLON.Mesh.CreateSphere("Sphere1",16,6,scene); //Segments, Radius;
	var mat = new BABYLON.StandardMaterial("Material1", scene);
	mat.diffuseTexture = new BABYLON.Texture("Diffuse.png", scene);
	sphere.material = mat;

	var sphere1 = BABYLON.Mesh.CreateSphere("Sphere2",16,6,scene);
	var mat2 = new BABYLON.StandardMaterial("WireMaterial1", scene);
	mat2.wireframe = true;
	sphere1.material = mat2;
	sphere1.position.x = 10;

	camera = new BABYLON.FollowCamera("FollowCamera1",BABYLON.Vector3.Zero(), scene);
	camera.lockedTarget = sphere;
	camera.radius = 10; 
	camera.heightOffset = 10;
	camera.attachControl(canvas_id); //Default controls enabled.

	engine.runRenderLoop(onEnterFrame);
	window.addEventListener("resize",function(){engine.resize();});
}

function onEnterFrame()
{
	scene.render();
}
</script>
</head>
<body onLoad="init()">
<canvas id="my_canvas"></canvas>
</body>
</html>

That last line "camera.attachControl(canvas_id);" , whether I add it in or not, it makes no difference, the mouse have no effect on it whatsoever.
Works for ArcRotateCamera and Free Camera but not FollowCamera, should I even bother to put in that last line for FollowCamera at all or is it a bug ?

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