Skip to content

Holoplay.js Reference

Functions

HoloPlay(scene, camera, renderer, focalPointVector, constantCenter, hiResRender)

Returns: HoloPlay object

Constructs a HoloPlay object.

Parameters:

  • scene: the scene we want to have 3D logic applied to
  • camera: the camera to take control of and render
  • renderer: the renderer to take over and do 3D rendering with
  • focalPointVector (optional): the focal point of the HoloPlay object, where the image will be sharpest; can be either a THREE.Vector3 or an array with three elements for x, y, z; default is (0,0,0)
  • constantCenter (optional): a boolean that determines whether the center moves as the camera does or stays fixed; use true when using orbit controls and false for first-person controls; default is true
  • hiResRender (optional): determines if the rendering will be 32 views or 45; default is true
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(12.5, width / height, 1, 1000);

camera.position.set(0,0,20);

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var holoplay = new HoloPlay(camera, scene, renderer);

HoloPlay.render(scene, camera, renderer)

Returns: void

The render loop for the HoloPlay object. Use this instead of the WebGL render function.

This function also handles button press updates.

Parameters:

  • scene (optional): the scene to render, by default the one passed into constructor
  • camera (optional): the camera to render, by default the one passed into constructor
  • renderer (optional): the WebGL renderer, by default the one passed into constructor
// Game loop
function RunApp(){
  requestAnimationFrame(RunApp);
  holoplay.render();
}

HoloPlay.lookAt(target, camera)

Returns: void

Refocuses the HoloPlay object on a particular point or object.

Parameters:

  • target: the target to look at, either a THREE.Object3D or a THREE.Vector3
  • camera (optional): the camera to focus on the target, by default the camera given to the HoloPlay object in its constructor
holoplay.lookAt(new THREE.Vector3(0,1,0));

Events

buttonDown

Fires whenever a Looking Glass button is first pressed.

Properties:

  • name: the name of the button pressed: "square," "left," "right," and "circle"
  • index: the index of the button pressed (square = 0, left = 1, right = 2, circle = 3)
document.addEventListener('buttonDown', function(e){
  console.log("Button name: " + e.name + " Button index: " + e.index);
});

buttonPressed

An event that fires every loop a Looking Glass button is held down.

Properties:

  • name: the name of the button pressed: "square," "left," "right," and "circle"
  • index: the index of the button pressed (square = 0, left = 1, right = 2, circle = 3)
document.addEventListener('buttonPressed', function(e){
  console.log("Button name: " + e.name + " Button index: " + e.index);
});

buttonUp

An event that fires when a Looking Glass button is let go.

Properties:

  • name: the name of the button pressed: "square," "left," "right," and "circle"
  • index: the index of the button pressed (square = 0, left = 1, right = 2, circle = 3)
document.addEventListener('buttonUp', function(e){
  console.log("Button name: " + e.name + " Button index: " + e.index);
});

Properties

useButtons

Type: bool

If true (default), buttons can be used and will be queried each frame for state changes.