1 /** 2 * @class camera 3 * @extends entity 4 * @description 5 * A rendering target and manipulation object. 6 * 7 * The camera is the symbolic viewing port for sandboxe. 8 * It acts as the bridge between the rendered scene and the viewer. 9 * Any number of cameras can be maintained, but only one may be used at a time. 10 * See {@link sandboxe.graphics.setCamera2d} 11 * ,{@link sandboxe.graphics.setCamera3d} 12 * ,{@link sandboxe.graphics.setRenderCamera} 13 * 14 * 15 */ 16 function camera() { 17 18 /** 19 * Forces clearing of the results of drawing stored within the Camera. 20 */ 21 this.refresh = function(){}; 22 23 24 /** 25 * Sets the camera's facing target. When called, the camera will orient itseld 26 * so that the center of its view "looks" at the given position. 27 * @param {vector} pos Position to look at 28 */ 29 this.setTarget = function(pos){}; 30 31 32 /** 33 * Sets the width and height of the camer'as internal framebuffer. The frameuffer 34 * is effectively the image representing the results of drawing operations. 35 * @param {Number} width The new width in device units. 36 * @param {Number} height The new height in device units. 37 */ 38 this.setRenderResolution = function(width, height){}; 39 40 41 /** 42 * Converts a point representing a pixel on a display to 43 * a point in world space.. 44 * 45 * @param {vector} pointScreen The point to convert. 46 * @param {Number} disance The distance to project the Vector to. In the case of a 3D perspective camera: Since the source is 2D, the 47 * Z value is ignored. However, when projecting, since there is no source Z value, 48 * The actual depth from the Camera's point of view is undefined when projecting, 49 * so a distance from the viewpoint is needed. 50 */ 51 this.transformScreenToWorld = function(pointScreen, distance){}; 52 53 /** 54 * Converts a point in transformed space to a pixel position on the camera's framebuffer. 55 * 56 * @param {vector} point The source point to project onto the camera. 57 */ 58 this.transformWorldToScreen = function(point){}; 59 60 /** 61 * Copies the current front visual of the camera as an image asset. 62 * In a double-buffered environment, the front buffer is usually the currently incomplete 63 * frame that is painted to as the scene is drawn. 64 * Note that when done, the asset should be removed. See {@link sandboxe.assets} 65 * @returns {asset} The image asset of the front visual. 66 */ 67 this.copyFrontVisual = function(){}; 68 69 70 /** 71 * Copies the current back visual of the camera as an image asset. 72 * In a double-buffered environment, the back buffer is usually the previous complete 73 * frame that is currently visible on the screen. 74 * Note that when done, the asset should be removed. See {@link sandboxe.assets} 75 * @returns {asset} The image asset of the back visual. 76 */ 77 this.copyBackVisual = function(){}; 78 79 80 81 82 /** 83 * Width of the camera's output framebuffer 84 * @type {Number} 85 */ 86 this.width = 0; 87 88 89 /** 90 * Height of the camera's output framebuffer 91 * @type {Number} 92 */ 93 this.height = 0; 94 95 /** 96 * Type of the camera. See {@link sandboxe.camera.type}. 97 * @type {Number} 98 */ 99 this.type = 0; 100 101 102 /** 103 * Whether the engine should handle clearing the framebuffer for you when 104 * using this camer as a render target. Unless you're doing something very special, 105 * the default of 'true' is good. 106 * @type {Boolean} 107 */ 108 this.autoRefresh = 0; 109 110 111 112 return this; 113 } 114