Camera
getCameraRotation
getCameraRotation(callback: Function)
Gets the camera rotation (in radians).
api.getCameraRotation(function(rotation){
console.log(rotation); // Result: [x, y, z]
});
2
3
setCameraRotation
setCameraRotation(rotation: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera rotation (in radians). The duration is the time for the transition from the current rotation to the new rotation (a number in seconds; defaults to 2).
api.setCameraRotation([0, Math.PI, 0], 2.5, function(camera){
console.log('Camera rotation changed');
});
2
3
getCameraPosition
getCameraPosition(callback: Function)
Gets the camera position.
api.getCameraPosition(function(position){
console.log(position); // Result: [x, y, z]
});
2
3
setCameraPosition
setCameraPosition(position: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera position. The duration is the time for the transition from the current position to the new position (a number in seconds; defaults to 2).
api.setCameraPosition([5, 5, 5], 2.5, function(camera){
console.log('Camera position changed');
});
2
3
getCameraOrientation
getCameraOrientation(callback: Function)
Returns the current camera position and rotation (radians).
api.getCameraOrientation(function(camera){
console.log(camera.position); // Result: [x, y, z]
console.log(camera.rotation); // Result: [x, y, z]
});
2
3
4
setCameraOrientation
setCameraOrientation(position: [x: number, y: number, z: number], rotation: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera position and rotation (radians). The duration is the time of the move from the current camera to the new camera (a number, in seconds; 2 by default)
api.setCameraOrientation([0, 10, 0], [0, Math.PI, 0], 2.5, function(camera){
console.log('Camera moved');
});
2
3
switchCameraType
switchCameraType(type: 'walk' | 'birdseye' | 'vr' | 'cardboard' | 'anaglyph' | 'topdown' | 'virtual-joysticks' | 'device-orientation', [callback: Function])
Switch the camera type.
api.switchCameraType('birdseye', function(){
console.log('Camera type switched');
});
2
3
setCameraZoom
setCameraZoom(radius: number, [duration=0], [callback: Function])
Sets the birdseye camera radius. The duration is the time of the move from the current camera radius to the new camera radius (a number, in seconds; 0 by default)
api.setCameraZoom(30, 5, function(){
console.log('Camera radius changed');
});
2
3
getCameraZoom
getCameraZoom(callback: Function)
Gets the birdseye camera radius.
api.getCameraZoom(function (radius) {
console.log(radius); // Result: number
});
2
3
getCameraTarget
getCameraTarget(callback: Function)
Gets the camera target position.
api.getCameraTarget(function(target){
console.log(target); // Result: [x, y, z]
});
2
3
setCameraTarget
setCameraTarget(target: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera target position. The duration is the time of the move from the current target to the new target (a number, in seconds; 2 by default)
api.setCameraTarget([0, 0, 0], 2.5, function(){
console.log('Camera target changed');
});
2
3
getFov
getFov(callback: Function)
Returns the camera's current field of view (FoV) in degrees.
api.getFov(function(fov){
console.log('Camera Fov is', fov); // Result: 80
});
2
3
setFov
setFov(angle: number, [callback: Function])
Defines the camera field of view (FoV). The angle is a number, in degrees, between 1 and 179.
api.setFov(80, function(){
console.log('Camera Fov changed');
});
2
3
getFov
getFov(callback: Function)
Gets the current camera field of view (FoV) in degrees.
api.getFov(function(fov){
console.log(fov); // Result: 45
});
2
3
getCameraTarget
getCameraTarget(callback: Function)
Gets the current camera target position.
api.getCameraTarget(function(target){
console.log(target); // Result: [x, y, z]
});
2
3
setCameraTarget
setCameraTarget(target: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera target position. The duration is the time for the transition from the current target to the new target (a number in seconds; defaults to 2).
api.setCameraTarget([0, 0, 0], 2.5, function(){
console.log('Camera target changed');
});
2
3