Having an airhead moment. I want to call api methods from the global space, not inside the client init scope. In the cameraUpdate function below, api is obviously undefined. How do I get a handle to it? Copying it somewhere global causes "object cannot be cloned" error.
var urlid = '7w7pAfrCfjovwykkEeRFLGw5SXS';
client.init( urlid, {
success: function onSuccess( api ){
api.start();
api.addEventListener( 'viewerready', function() {
//API is ready to use
console.log( 'Viewer is ready' );
} );
},
error: function onError() {
console.log( 'Viewer error' );
}
} );
function cameraUpdate(camera) {
api.lookat(
camera.position,
camera.target,
1
);
}