Browse Source

Merge pull request #5137 from sebavan/master

Camera doc
sebavan 7 years ago
parent
commit
cba34dbc72

+ 14 - 0
src/Behaviors/Cameras/babylon.bouncingBehavior.ts

@@ -1,8 +1,12 @@
 module BABYLON {
     /**
      * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
+     * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
      */
     export class BouncingBehavior implements Behavior<ArcRotateCamera> {
+        /**
+         * Gets the name of the behavior.
+         */
         public get name(): string {
             return "Bouncing";
         }
@@ -79,10 +83,17 @@ module BABYLON {
         private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;
         private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;
 
+        /**
+         * Initializes the behavior.
+         */
         public init(): void {
             // Do notihng
         }
 
+        /**
+         * Attaches the behavior to its arc rotate camera.
+         * @param camera Defines the camera to attach the behavior to
+         */
         public attach(camera: ArcRotateCamera): void {
             this._attachedCamera = camera;
             this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {
@@ -102,6 +113,9 @@ module BABYLON {
             });
         }
 
+        /**
+         * Detaches the behavior from its current arc rotate camera.
+         */
         public detach(): void {
             if (!this._attachedCamera) {
                 return;

+ 17 - 0
src/Behaviors/Cameras/babylon.framingBehavior.ts

@@ -1,5 +1,12 @@
 module BABYLON {
+    /**
+     * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
+     * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
+     */
     export class FramingBehavior implements Behavior<ArcRotateCamera> {
+        /**
+         * Gets the name of the behavior.
+         */
         public get name(): string {
             return "Framing";
         }
@@ -147,10 +154,17 @@ module BABYLON {
         private _isPointerDown = false;
         private _lastInteractionTime = -Infinity;
 
+        /**
+         * Initializes the behavior.
+         */
         public init(): void {
             // Do notihng
         }
 
+        /**
+         * Attaches the behavior to its arc rotate camera.
+         * @param camera Defines the camera to attach the behavior to
+         */
         public attach(camera: ArcRotateCamera): void {
             this._attachedCamera = camera;
             let scene = this._attachedCamera.getScene();
@@ -184,6 +198,9 @@ module BABYLON {
             });
         }
 
+        /**
+         * Detaches the behavior from its current arc rotate camera.
+         */
         public detach(): void {
             if (!this._attachedCamera) {
                 return;

+ 2 - 1
src/Cameras/Stereoscopic/babylon.anaglyphArcRotateCamera.ts

@@ -5,7 +5,8 @@ module BABYLON {
 
     /**
      * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
-     */    
+     * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
+     */
     export class AnaglyphArcRotateCamera extends ArcRotateCamera {
 
         /**

+ 1 - 0
src/Cameras/Stereoscopic/babylon.anaglyphFreeCamera.ts

@@ -5,6 +5,7 @@ module BABYLON {
 
     /**
      * Camera used to simulate anaglyphic rendering (based on FreeCamera)
+     * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
      */
     export class AnaglyphFreeCamera extends FreeCamera {
         /**

+ 1 - 0
src/Cameras/Stereoscopic/babylon.anaglyphGamepadCamera.ts

@@ -5,6 +5,7 @@ module BABYLON {
 
     /**
      * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
+     * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
      */       
     export class AnaglyphGamepadCamera extends GamepadCamera {
         /**

+ 1 - 0
src/Cameras/Stereoscopic/babylon.anaglyphUniversalCamera.ts

@@ -5,6 +5,7 @@ module BABYLON {
 
     /**
      * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
+     * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
      */        
     export class AnaglyphUniversalCamera extends UniversalCamera {
         /**

+ 2 - 1
src/Cameras/Stereoscopic/babylon.stereoscopicArcRotateCamera.ts

@@ -5,7 +5,8 @@ module BABYLON {
 
     /**
      * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
-     */      
+     * @see http://doc.babylonjs.com/features/cameras
+     */
     export class StereoscopicArcRotateCamera extends ArcRotateCamera {
         /**
          * Creates a new StereoscopicArcRotateCamera

+ 1 - 0
src/Cameras/Stereoscopic/babylon.stereoscopicFreeCamera.ts

@@ -5,6 +5,7 @@ module BABYLON {
 
     /**
      * Camera used to simulate stereoscopic rendering (based on FreeCamera)
+     * @see http://doc.babylonjs.com/features/cameras
      */    
     export class StereoscopicFreeCamera extends FreeCamera {
         /**

+ 1 - 0
src/Cameras/Stereoscopic/babylon.stereoscopicGamepadCamera.ts

@@ -5,6 +5,7 @@ module BABYLON {
 
     /**
      * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
+     * @see http://doc.babylonjs.com/features/cameras
      */      
     export class StereoscopicGamepadCamera extends GamepadCamera {
         /**

+ 1 - 0
src/Cameras/Stereoscopic/babylon.stereoscopicUniversalCamera.ts

@@ -4,6 +4,7 @@ module BABYLON {
     });    
     /**
      * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
+     * @see http://doc.babylonjs.com/features/cameras
      */      
     export class StereoscopicUniversalCamera extends UniversalCamera {
         /**

+ 67 - 0
src/Cameras/VR/babylon.vrCameraMetrics.ts

@@ -1,27 +1,81 @@
 module BABYLON {
+    /**
+     * This represents all the required metrics to create a VR camera.
+     * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
+     */
     export class VRCameraMetrics {
+        /**
+         * Define the horizontal resolution off the screen.
+         */
         public hResolution: number;
+        /**
+         * Define the vertical resolution off the screen.
+         */
         public vResolution: number;
+        /**
+         * Define the horizontal screen size.
+         */
         public hScreenSize: number;
+        /**
+         * Define the vertical screen size.
+         */
         public vScreenSize: number;
+        /**
+         * Define the vertical screen center position.
+         */
         public vScreenCenter: number;
+        /**
+         * Define the distance of the eyes to the screen.
+         */
         public eyeToScreenDistance: number;
+        /**
+         * Define the distance between both lenses
+         */
         public lensSeparationDistance: number;
+        /**
+         * Define the distance between both viewer's eyes.
+         */
         public interpupillaryDistance: number;
+        /**
+         * Define the distortion factor of the VR postprocess.
+         * Please, touch with care.
+         */
         public distortionK: number[];
+        /**
+         * Define the chromatic aberration correction factors for the VR post process.
+         */
         public chromaAbCorrection: number[];
+        /**
+         * Define the scale factor of the post process.
+         * The smaller the better but the slower.
+         */
         public postProcessScaleFactor: number;
+        /**
+         * Define an offset for the lens center.
+         */
         public lensCenterOffset: number;
+        /**
+         * Define if the current vr camera should compensate the distortion of the lense or not.
+         */
         public compensateDistortion = true;
 
+        /**
+         * Gets the rendering aspect ratio based on the provided resolutions.
+         */
         public get aspectRatio(): number {
             return this.hResolution / (2 * this.vResolution);
         }
 
+        /**
+         * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
+         */
         public get aspectRatioFov(): number {
             return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
         }
 
+        /**
+         * @hidden
+         */
         public get leftHMatrix(): Matrix {
             var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
             var h = (4 * meters) / this.hScreenSize;
@@ -29,6 +83,9 @@
             return Matrix.Translation(h, 0, 0);
         }
 
+        /**
+         * @hidden
+         */
         public get rightHMatrix(): Matrix {
             var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
             var h = (4 * meters) / this.hScreenSize;
@@ -36,14 +93,24 @@
             return Matrix.Translation(-h, 0, 0);
         }
 
+        /**
+         * @hidden
+         */
         public get leftPreViewMatrix(): Matrix {
             return Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);
         }
 
+        /**
+         * @hidden
+         */
         public get rightPreViewMatrix(): Matrix {
             return Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
         }
 
+        /**
+         * Get the default VRMetrics based on the most generic setup.
+         * @returns the default vr metrics
+         */
         public static GetDefault(): VRCameraMetrics {
             var result = new VRCameraMetrics();
 

+ 19 - 0
src/Cameras/VR/babylon.vrDeviceOrientationArcRotateCamera.ts

@@ -3,8 +3,23 @@ module BABYLON {
         return () => new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, Vector3.Zero(), scene);
     });
 
+    /**
+     * Camera used to simulate VR rendering (based on ArcRotateCamera)
+     * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
+     */
     export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
 
+        /**
+         * Creates a new VRDeviceOrientationArcRotateCamera
+         * @param name defines camera name
+         * @param alpha defines the camera rotation along the logitudinal axis
+         * @param beta defines the camera rotation along the latitudinal axis
+         * @param radius defines the camera distance from its target
+         * @param target defines the camera target
+         * @param scene defines the scene the camera belongs to
+         * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
+         * @param vrCameraMetrics defines the vr metrics associated to the camera
+         */
         constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion = true, vrCameraMetrics: VRCameraMetrics = VRCameraMetrics.GetDefault()) {
             super(name, alpha, beta, radius, target, scene);
 
@@ -14,6 +29,10 @@ module BABYLON {
             this.inputs.addVRDeviceOrientation();
         }
 
+        /**
+         * Gets camera class name
+         * @returns VRDeviceOrientationArcRotateCamera
+         */
         public getClassName(): string {
             return "VRDeviceOrientationArcRotateCamera";
         }

+ 16 - 1
src/Cameras/VR/babylon.vrDeviceOrientationFreeCamera.ts

@@ -3,8 +3,20 @@ module BABYLON {
         return () => new VRDeviceOrientationFreeCamera(name, Vector3.Zero(), scene);
     });
 
+    /**
+     * Camera used to simulate VR rendering (based on FreeCamera)
+     * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
+     */
     export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
 
+        /**
+         * 
+         * @param name 
+         * @param position 
+         * @param scene 
+         * @param compensateDistortion 
+         * @param vrCameraMetrics 
+         */
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true, vrCameraMetrics: VRCameraMetrics = VRCameraMetrics.GetDefault()) {
             super(name, position, scene);
 
@@ -12,7 +24,10 @@ module BABYLON {
             this.setCameraRigMode(Camera.RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
         }
 
-
+        /**
+         * Gets camera class name
+         * @returns VRDeviceOrientationFreeCamera
+         */
         public getClassName(): string {
             return "VRDeviceOrientationFreeCamera";
         }

+ 16 - 0
src/Cameras/VR/babylon.vrDeviceOrientationGamepadCamera.ts

@@ -3,14 +3,30 @@ module BABYLON {
         return () => new VRDeviceOrientationGamepadCamera(name, Vector3.Zero(), scene);
     });
 
+    /**
+     * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
+     * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
+     */
     export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
 
+        /**
+         * 
+         * @param name 
+         * @param position 
+         * @param scene 
+         * @param compensateDistortion 
+         * @param vrCameraMetrics 
+         */
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true, vrCameraMetrics: VRCameraMetrics = VRCameraMetrics.GetDefault()) {
             super(name, position, scene, compensateDistortion, vrCameraMetrics);
             
             this.inputs.addGamepad();
         }
 
+        /**
+         * Gets camera class name
+         * @returns VRDeviceOrientationGamepadCamera
+         */
         public getClassName(): string {
             return "VRDeviceOrientationGamepadCamera";
         }