Camera
getCameraTarget
getCameraTarget(callback: Function)
Gets the camera target.
api.getCameraTarget(function(target){
console.log(target); // Result: [x, y, z]
});
setCameraTarget
setCameraTarget(target: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera target. 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(camera){
console.log('Camera target changed');
});
getCameraPosition
getCameraPosition(callback: Function)
Gets the camera position.
api.getCameraPosition(function(position){
console.log(position); // Result: [x, y, z]
});
setCameraPosition
setCameraPosition(position: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera position. The duration is the time of the move from the current position to the new position (a number, in seconds; 2 by default)
api.setCameraPosition([5, 5, 5], 2.5, function(camera){
console.log('Camera position changed');
});
getCameraLookAt
getCameraLookAt(callback: Function)
Returns the current camera position and target.
api.getCameraLookAt(function(camera){
console.log(camera.position); // Result: [x, y, z]
console.log(camera.target); // Result: [x, y, z]
});
setCameraLookAt
setCameraLookAt(position: [x: number, y: number, z: number], target: [x: number, y: number, z: number], [duration: number], [callback: Function])
Sets the camera position and target. The duration is the time of the move from the current camera to the new camera (a number, in seconds; 2 by default)
api.setCameraLookAt([0, 10, 0], [0, 0 ,0], 2.5, function(camera){
console.log('Camera moved');
});
startRotateCamera
startRotateCamera(direction: 1 | -1, [callback: Function])
Start the rotation of the camera around the target on the objects x-axis. Set the direction +1 (clockwise) or -1 (counterclockwise).
api.startRotateCamera(1, function(){
console.log('Camera rotation started');
});
stopRotateCamera
stopRotateCamera(callback: Function)
Stop the rotation or the camera.
api.stopRotateCamera(function(){
console.log('Camera rotation stopped');
});
recenterCamera
recenterCamera([callback: Function])
Centers the camera around the objects bounding box, taking portrait/landscape mode into account.
api.recenterCamera(function(){
console.log('Camera recentered');
});
focusOnVisibleGeometries
focusOnVisibleGeometries()
Centers the camera around the objects visible geometries, taking portrait/landscape mode into account.
api.focusOnVisibleGeometries(function(){
console.log('Camera Recentered');
});
setFov
setFov(angle, [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');
});
getFov
getFov([callback: Function])
Returns the cameras current field of view (FoV) in degrees.
api.getFov(function(fov){
console.log('Camera Fov is', fov); // Result: 80
});