# Get a value of variable inside Console

**URL:** https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780
**Category:** Questions
**Created:** [March 8, 2019, 4:43pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780 "2019-03-08T16:43:32Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 4:43pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/1 "2019-03-08T16:43:32Z")

</div>

Hello guys , please i need to get the value of the position of the camera ( the x axis) , but when i put “scene.camera.position.x” in the console i get “is not defined” , how i can acces to this variable ?

this the js code i use :

window.addEventListener(“DOMContentLoaded”, function() {

var canvas = document.getElementById(‘renderCanvas’);  
var engine = new BABYLON.Engine(canvas, true);  
var createScene = function() {  
var scene = new BABYLON.Scene(engine);

var camera1 = new BABYLON.ArcRotateCamera(“Camera”, 0, 0, 0, new BABYLON.Vector3(100, 40, 0), scene);

```
 return scene;

```

};

var scene = createScene();

engine.runRenderLoop(function() {  
scene.render();  
});

window.addEventListener(“resize”, function() {  
engine.resize();  
});

});

thanks

---

<div class="post-metadata">

### Author: ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)
#### Post date: [March 8, 2019, 4:55pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/2 "2019-03-08T16:55:25Z")

</div>

Try with `scene.activeCamera` ?

---

<div class="post-metadata">

### Author: ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)
#### Post date: [March 8, 2019, 4:56pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/3 "2019-03-08T16:56:31Z")

</div>

> [@mixofo](#):
>
> var camera1 = new BABYLON.ArcRotateCamera(“Camera”, 0, 0, 0, new BABYLON.Vector3(100, 40, 0), scene);

Your camera has a 0 radius, an arcRotateCamera must have a radius so try var camera1 = new BABYLON.ArcRotateCamera(“Camera”, 0, 0, 5, new BABYLON.Vector3(100, 40, 0), scene);

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#W334GC)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

[https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera](https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera)

---

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 4:56pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/4 "2019-03-08T16:56:59Z")

</div>

thanks , but i get ReferenceError: scene is not defined

---

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 4:57pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/5 "2019-03-08T16:57:40Z")

</div>

thanks for response , but it is not my question , i just need to get any variable inside the scene i created, but i get ReferenceError: scene is not defined

---

<div class="post-metadata">

### Author: ![PirateJC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piratejc/32/1003_2.png) [@PirateJC](https://forum.babylonjs.com/u/PirateJC)
#### Post date: [March 8, 2019, 4:58pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/6 "2019-03-08T16:58:39Z")

</div>

@mixofo - you’ve named your variable “camera1” but you mention that you’re using:

scene.camera.position.x

In this case try using camera1 instead of camera as you should be accessing the variable name.

Here’s some more info on the arcRotateCamera and how you can also override it’s behavior and position it if you need to.

[https://doc.babylonjs.com/babylon101/cameras](https://doc.babylonjs.com/babylon101/cameras)

---

<div class="post-metadata">

### Author: ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)
#### Post date: [March 8, 2019, 5:01pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/7 "2019-03-08T17:01:27Z")

</div>

> [@mixofo](#):
>
> thanks for response , but it is not my question , i just need to get any variable inside the scene i created, but i get ReferenceError: scene is not defined

You question

> [@mixofo](#):
>
> Hello guys , please i need to get the value of the position of the camera ( the x axis) , but when i put “scene.camera.position.x” in the console i get “is not defined” , how i can acces to this variable

???

---

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 5:02pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/8 "2019-03-08T17:02:47Z")

</div>

thanks , but it is changed nothing , maybe i need to rexplain my real problem , imagine if i create a variable " my\_var" inside the windows.addeventListner function , and if i need to get the value of this variable inside the console , normaly i think scene.my\_var should work , but it is give me "scene it is not defined "

---

<div class="post-metadata">

### Author: ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)
#### Post date: [March 8, 2019, 5:07pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/9 "2019-03-08T17:07:46Z")

</div>

Is this a Babylon.js question or a Javascript question? As far as I know a Babylon.js scene does not keep a list of variables. Can you make a playground or edit the one I gave to show your problem.

---

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 5:11pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/10 "2019-03-08T17:11:59Z")

</div>

I think it is a Javascript question , but i test everything to get it , and nothing itisn’t working .  
I cant make a playground , because i use a separe JS file, with windows.addeventListner method.

thanks for everything

---

<div class="post-metadata">

### Author: ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)
#### Post date: [March 8, 2019, 5:44pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/11 "2019-03-08T17:44:46Z")

</div>

The scene variable is inside the listener’s scope, so you either have to remove the ‘var’, or you have to put ‘var scene’ before the listener and do ‘scene = new BABYLON.Scene(engine)’ in the listener. See: [JavaScript Scope](https://www.w3schools.com/js/js_scope.asp)

---

<div class="post-metadata">

### Author: ![mixofo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mixofo/32/7947_2.png) [@mixofo](https://forum.babylonjs.com/u/mixofo)
#### Post date: [March 8, 2019, 5:50pm UTC](https://forum.babylonjs.com/t/get-a-value-of-variable-inside-console/1780/12 "2019-03-08T17:50:18Z")

</div>

thanks it is working !
