Jump to content

move camera outside createScene


Recommended Posts

i got stuck with my project, the file is pretty complex now

i need to access camera control outside createScene function

all my code is inside createScene, camera is created inside that function, i also have  a function that i found in some post

function ArcAnimation(camera, toAlpha, toBeta, toRadius, position, animSpeed) 

this function moves the camera 

i just moved this function outside createScene, because i need to trigger the first camera animation from an HTML element, but camera is not defined outside createScene

i try to access camere with scene.camera

since i initialize the scene with var scene = createScene();

but doesn't work



Link to comment
Share on other sites

As adam mentioned scene.activeCamera should work. but you can also do this:

var camera;

//createScene function


camera = new BABYLON.camera...


//end of createScene

//do whatever you want to do 

function moveCamera(){
  if(!camera) return;
  camera.position.x += 10;
  camera.position.z += 10;


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.

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.


  • Recently Browsing   0 members

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