Skip to content
cjcliffe edited this page Oct 24, 2011 · 1 revision

CubicVR.addResizeable function

When using CubicVR.start or CubicVR.init it will provide a canvas that's resized automatically. In order for other elements such as scenes or cameras to correctly receive update events in correlation to the browser resize the global-resize list is provided.

When you add an object to the global-resize list via CubicVR.addResizeable(object) it assumes that object has a method of .resize(x,y). Most relevant objects such as Scene, Layout, Camera, PostProcessingChain and more already support being added to the global-resize list.

CubicVR.addResizeable( object )

Parameters:

  • object : An object containg a method in the format: function(x, y) which will be passed the X and Y dimensions of the browser in pixels upon resize. Some DOM elements are also acceptable passed directly and will be repositioned using absolute CSS values.

Typical usage:

// Adding a scene to the resize list
var myScene = new CubicVR.Scene();
CubicVR.addResizeable(myScene);

// Adding a camera to the resize list (not needed if using scene)
var myCamera = new CubicVR.Camera();
CubicVR.addResizeable(myCamera);

// Adding a layout to the resize list
var myLayout = new CubicVR.Layout();
CubicVR.addResizeable(myLayout);

...and many more...

// Adding a custom-callback to resize
var myScene = new CubicVR.Scene();
CubicVR.addResizeable({
    resize: function(width, height) {
        // do something with width and height.
    }
});

Returns:

none.

Clone this wiki locally