BritneyWatch Posted November 30, 2018 Share Posted November 30, 2018 <!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 ? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 30, 2018 Share Posted November 30, 2018 It is normal as it is intented to follow stuff and not to be controlled by the user. You can remove the line if you wish. Quote Link to comment Share on other sites More sharing options...
BritneyWatch Posted November 30, 2018 Author Share Posted November 30, 2018 Thank you ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.