Tutorial: Scene Toys
|By dcantor . July 20, 2012 . tutorials.|
Each Voxelent scene has some special actors that allows us to orient ourselves. These actors are:
Before getting into detail, let’s see how we can access these objects
If you have set up a view you can use the view variable to get a reference to the scene toys like this:
var view = vxl.api.setup("dom-canvas-id"); var toys = view.scene.toys
If you have only one scene in your page, then the current scene variable would be set up for you and then you could access the toys using it like this:
var toys = vxl.c.scene.toys
Now let’s take a look at our first toy.
The bounding box contains all the actors in a given scene.
There are some scenarios where using a bounding box is useful. For instance, when we want to position our camera in a way that all the objects are visible. The bounding box allows us to do such calculation. Luckily, you don’t have to do it. You just need to call the
To make visible the scene’s bounding box you can do this:
Also, you could do this through the public API by writing:
If you want to hide the bounding box, you can use:
Or through the
The axis shows the centre of the bounding box. You can access the axis through a
toys context like this:
Or through the api like this:
The axis will always point to the centre of the scene.
The floor allows us to visually inspect the location of objects (near, far) and also enables us to tell which objects are up and down. In many cases the floor is a good method of visual inspection to make sure that the objects int the scene are where we expect them to be.
The floor can be accessed through a toys context:
however if you execute this command you won’t see anything. This is due to the fact that we need to specify two parameters: the dimension of the floor and the grid spacing. We do so by invoking:
This method will automatically make the floor visible.
Similarly to the previous cases, these commands have an API equivalent that will affect the current scene set in
vxl.api.floorON(dimension, spacing); vxl.api.floorOFF();
If floorON is invoked without setting the dimension and spacing parameters the floor will be visualized with the last parameters that were set. If no parameters have been set, the floor will not appear.
1. Click on the image above to open the interactive demo
3. Let’s hide the bounding box and show the floor. For that you should write: