Selaa lähdekoodia

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 vuotta sitten
vanhempi
commit
e57392383e

+ 5 - 1
Viewer/src/configuration/configuration.ts

@@ -9,7 +9,8 @@ export interface ViewerConfiguration {
     pageUrl?: string; // will be used for sharing and other fun stuff. This is the page showing the model (not the model's url!)
 
     configuration?: string | {
-        url: string;
+        url?: string;
+        payload?: any;
         mapper?: string; // json (default), html, yaml, xml, etc'. if not provided, file extension will be used.
     };
 
@@ -123,6 +124,9 @@ export interface ViewerConfiguration {
     // engine configuration. optional!
     engine?: {
         antialiasing?: boolean;
+        disableResize?: boolean;
+        engineOptions?: { [key: string]: any };
+        adaptiveQuality?: boolean;
     },
     //templateStructure?: ITemplateStructure,
     templates?: {

+ 20 - 13
Viewer/src/configuration/loader.ts

@@ -23,20 +23,27 @@ export class ConfigurationLoader {
         if (loadedConfig.configuration) {
 
             let mapperType = "json";
-            let url = loadedConfig.configuration;
-
-            // if configuration is an object
-            if (loadedConfig.configuration.url) {
-                url = loadedConfig.configuration.url;
-                mapperType = loadedConfig.configuration.mapper;
-                if (!mapperType) {
-                    // load mapper type from filename / url
-                    mapperType = loadedConfig.configuration.url.split('.').pop();
+            return Promise.resolve().then(() => {
+                if (typeof loadedConfig.configuration === "string" || loadedConfig.configuration.url) {
+                    // a file to load
+                    let url = loadedConfig.configuration;
+
+                    // if configuration is an object
+                    if (loadedConfig.configuration.url) {
+                        url = loadedConfig.configuration.url;
+                        mapperType = loadedConfig.configuration.mapper;
+                        if (!mapperType) {
+                            // load mapper type from filename / url
+                            mapperType = loadedConfig.configuration.url.split('.').pop();
+                        }
+                    }
+                    return this.loadFile(url);
+                } else {
+                    mapperType = loadedConfig.configuration.mapper || mapperType;
+                    return loadedConfig.configuration.payload || {};
                 }
-            }
-
-            let mapper = mapperManager.getMapper(mapperType);
-            return this.loadFile(url).then((data: any) => {
+            }).then((data: any) => {
+                let mapper = mapperManager.getMapper(mapperType);
                 let parsed = mapper.map(data);
                 return deepmerge(loadedConfig, parsed);
             });

+ 11 - 5
Viewer/src/templateManager.ts

@@ -89,8 +89,13 @@ export class TemplateManager {
         }
 
         //build the html tree
-        this.buildHTMLTree(templates).then(htmlTree => {
-            internalInit(htmlTree, 'main');
+        return this.buildHTMLTree(templates).then(htmlTree => {
+            if (this.templates['main']) {
+                internalInit(htmlTree, 'main');
+            } else {
+                this.checkLoadedState();
+            }
+            return;
         });
     }
 
@@ -123,8 +128,9 @@ export class TemplateManager {
                     buildTree(parentObject[element], element);
                 });
             }
-
-            buildTree(templateStructure, "main");
+            if (this.templates['main']) {
+                buildTree(templateStructure, "main");
+            }
             return templateStructure;
         });
     }
@@ -139,7 +145,7 @@ export class TemplateManager {
     }
 
     private checkLoadedState() {
-        let done = Object.keys(this.templates).every((key) => {
+        let done = Object.keys(this.templates).length === 0 || Object.keys(this.templates).every((key) => {
             return this.templates[key].isLoaded && !!this.templates[key].parent;
         });
 

+ 46 - 10
Viewer/src/viewer/viewer.ts

@@ -20,6 +20,8 @@ export abstract class AbstractViewer {
     public onEngineInitObservable: PromiseObservable<Engine>;
     public onModelLoadedObservable: PromiseObservable<AbstractMesh[]>;
 
+    private canvas: HTMLCanvasElement;
+
     constructor(public containerElement: HTMLElement, initialConfiguration: ViewerConfiguration = {}) {
         // if exists, use the container id. otherwise, generate a random string.
         if (containerElement.id) {
@@ -62,6 +64,10 @@ export abstract class AbstractViewer {
             this.templateManager.initTemplate(templateConfiguration);
             // when done, execute onTemplatesLoaded()
             this.templateManager.onAllLoaded.add(() => {
+                let canvas = this.templateManager.getCanvas();
+                if (canvas) {
+                    this.canvas = canvas;
+                }
                 this.onTemplatesLoaded();
             });
         });
@@ -72,6 +78,31 @@ export abstract class AbstractViewer {
         return this.baseId;
     }
 
+    public isCanvasInDOM(): boolean {
+        return !!this.canvas && !!this.canvas.parentElement;
+    }
+
+    protected resize = (): void => {
+        // Only resize if Canvas is in the DOM
+        if (!this.isCanvasInDOM()) {
+            return;
+        }
+
+        if (this.canvas.clientWidth <= 0 || this.canvas.clientHeight <= 0) {
+            return;
+        }
+
+        this.engine.resize();
+    }
+
+    protected render = (): void => {
+        this.scene && this.scene.render();
+    }
+
+    public dispose() {
+        window.removeEventListener('resize', this.resize);
+    }
+
     protected abstract prepareContainerElement();
 
     /**
@@ -84,7 +115,11 @@ export abstract class AbstractViewer {
      */
     protected onTemplatesLoaded(): Promise<AbstractViewer> {
         return this.initEngine().then(() => {
-            return this.loadModel();
+            if (this.configuration.model) {
+                return this.loadModel();
+            } else {
+                return this.scene;
+            }
         }).then(() => {
             return this;
         });
@@ -104,21 +139,22 @@ export abstract class AbstractViewer {
         }
         let config = this.configuration.engine || {};
         // TDO enable further configuration
-        this.engine = new Engine(canvasElement, !!config.antialiasing);
+        this.engine = new Engine(canvasElement, !!config.antialiasing, config.engineOptions);
 
         // Disable manifest checking
         Database.IDBStorageEnabled = false;
 
-        window.addEventListener('resize', () => {
-            this.engine.resize();
-        });
+        if (!config.disableResize) {
+            window.addEventListener('resize', this.resize);
+        }
 
-        this.engine.runRenderLoop(() => {
-            this.scene && this.scene.render();
-        });
 
-        var scale = Math.max(0.5, 1 / (window.devicePixelRatio || 2));
-        this.engine.setHardwareScalingLevel(scale);
+        this.engine.runRenderLoop(this.render);
+
+        if (this.configuration.engine && this.configuration.engine.adaptiveQuality) {
+            var scale = Math.max(0.5, 1 / (window.devicePixelRatio || 2));
+            this.engine.setHardwareScalingLevel(scale);
+        }
 
         return this.onEngineInitObservable.notifyWithPromise(this.engine).then(() => {
             return this.engine;

+ 0 - 439
dist/preview release/typedocValidationBaseline.json

@@ -41496,156 +41496,6 @@
         }
       }
     },
-    "VRExperienceHelper": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new VRExperienceHelper": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "webVROptions": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "currentVRCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceOrientationCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "displayGaze": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "displayLaserPointer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "teleportationTarget": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "vrDeviceOrientationCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "webVRCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "webVROptions": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "addFloorMesh": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "floorMesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "changeGazeColor": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "color": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "changeLaserColor": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "color": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "dispose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "enableInteractions": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "enableTeleportation": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "vrTeleportationOptions": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "getClassName": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "removeFloorMesh": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "floorMesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "ValueCondition": {
       "Class": {
         "Comments": {
@@ -45672,116 +45522,6 @@
         }
       }
     },
-    "WebVRFreeCamera": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "_vrDevice": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "controllers": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceDistanceToRoomGround": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "devicePosition": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceRotationQuaternion": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceScaleFactor": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "leftController": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onControllerMeshLoadedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onControllersAttachedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rawPose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rigParenting": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rightController": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "useStandingMatrix": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "getControllerByName": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "name": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "initControllers": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "resetToCurrentRotation": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "updateFromDevice": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "poseData": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "WindowsMotionController": {
       "Class": {
         "Comments": {
@@ -46542,40 +46282,6 @@
         }
       }
     },
-    "DevicePose": {
-      "Property": {
-        "angularAcceleration": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "angularVelocity": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "linearAcceleration": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "linearVelocity": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "orientation": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "DistanceJointData": {
       "Interface": {
         "Comments": {
@@ -48747,59 +48453,6 @@
         }
       }
     },
-    "PoseControlled": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "devicePosition": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceRotationQuaternion": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceScaleFactor": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rawPose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rotationQuaternion": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "updateFromDevice": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "poseData": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "SerializedColliderToWorker": {
       "Interface": {
         "Comments": {
@@ -49000,98 +48653,6 @@
         }
       }
     },
-    "VRExperienceHelperOptions": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "createDeviceOrientationCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "createFallbackVRDeviceOrientationFreeCamera": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
-    "VRTeleportationOptions": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "floorMeshName": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "floorMeshes": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
-    "WebVROptions": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "controllerMeshes": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "customVRButton": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "defaultHeight": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "defaultLightingOnControllers": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "displayName": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "positionScale": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rayLength": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "trackPosition": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "useCustomVRButton": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "WorkerReply": {
       "Interface": {
         "Comments": {

+ 2 - 1
dist/preview release/what's new.md

@@ -23,7 +23,8 @@
    ([carloslanderas](https://github.com/carloslanderas))
 - VRHelper now exposes onNewMeshPicked observable that will notify a PickingInfo object after meshSelectionPredicate evaluation
    ([carloslanderas](https://github.com/carloslanderas))
-- `AssetsManager` will now clear its `tasks` lsit from all successfully loaded tasks ([deltakosh](https://github.com/deltakosh))
+- `AssetsManager` will now clear its `tasks` list from all successfully loaded tasks ([deltakosh](https://github.com/deltakosh))
+- Added documentation to WebVRCamera and VRExperienceHelper ([trevordev](https://github.com/trevordev))
 
 ## Bug fixes
 

+ 98 - 5
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -1,14 +1,36 @@
 module BABYLON {
+    /**
+     * Options to modify the vr teleportation behavior.
+     */
     export interface VRTeleportationOptions {
-        floorMeshName?: string; // If you'd like to provide a mesh acting as the floor
+        /**
+         * The name of the mesh which should be used as the teleportation floor. (default: null)
+         */
+        floorMeshName?: string;
+        /**
+         * A list of meshes to be used as the teleportation floor. (default: empty)
+         */
         floorMeshes?: Mesh[];
     }
 
+    /**
+     * Options to modify the vr experience helper's behavior.
+     */
     export interface VRExperienceHelperOptions extends WebVROptions {
-        createDeviceOrientationCamera?: boolean; // Create a DeviceOrientationCamera to be used as your out of vr camera.
-        createFallbackVRDeviceOrientationFreeCamera?: boolean; // Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found
+        /**
+         * Create a DeviceOrientationCamera to be used as your out of vr camera.
+         */
+        createDeviceOrientationCamera?: boolean;
+        /**
+         * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
+         */
+        createFallbackVRDeviceOrientationFreeCamera?: boolean;
     }
 
+    /**
+     * Helps to quickly add VR support to an existing scene.
+     * See http://doc.babylonjs.com/how_to/webvr_helper
+     */
     export class VRExperienceHelper {
         private _scene: Scene;
         private _position: Vector3;
@@ -166,10 +188,16 @@ module BABYLON {
 
         private _dpadPressed = true;
 
+        /**
+         * The mesh used to display where the user is going to teleport.
+         */
         public get teleportationTarget(): Mesh {
             return this._teleportationTarget;
         }
 
+        /**
+         * Sets the mesh to be used to display where the user is going to teleport.
+         */
         public set teleportationTarget(value: Mesh) {
             if (value) {
                 value.name = "teleportationTarget";
@@ -178,10 +206,16 @@ module BABYLON {
             }
         }
 
+        /**
+         * If the ray of the gaze should be displayed.
+         */
         public get displayGaze(): boolean {
             return this._displayGaze;
         }
 
+        /**
+         * Sets if the ray of the gaze should be displayed.
+         */
         public set displayGaze(value: boolean) {
             this._displayGaze = value;
             if (!value) {
@@ -189,10 +223,16 @@ module BABYLON {
             }
         }
 
+        /**
+         * If the ray of the LaserPointer should be displayed.
+         */
         public get displayLaserPointer(): boolean {
             return this._displayLaserPointer;
         }
 
+        /**
+         * Sets if the ray of the LaserPointer should be displayed.
+         */
         public set displayLaserPointer(value: boolean) {
             this._displayLaserPointer = value;
             if (!value) {
@@ -213,11 +253,16 @@ module BABYLON {
             }
         }
 
+        /**
+         * The deviceOrientationCamera used as the camera when not in VR.
+         */
         public get deviceOrientationCamera(): Nullable<DeviceOrientationCamera> {
             return this._deviceOrientationCamera;
         }
 
-        // Based on the current WebVR support, returns the current VR camera used
+        /**
+         * Based on the current WebVR support, returns the current VR camera used.
+         */
         public get currentVRCamera(): Nullable<Camera> {
             if (this._webVRready) {
                 return this._webVRCamera;
@@ -227,15 +272,27 @@ module BABYLON {
             }
         }
 
+        /**
+         * The webVRCamera which is used when in VR.
+         */
         public get webVRCamera(): WebVRFreeCamera {
             return this._webVRCamera;
         }
 
+        /**
+         * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
+         */
         public get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera> {
             return this._vrDeviceOrientationCamera;
         }
 
-        constructor(scene: Scene, public webVROptions: VRExperienceHelperOptions = {}) {
+        /**
+         * Instantiates a VRExperienceHelper.
+         * Helps to quickly add VR support to an existing scene.
+         * @param scene The scene the VRExperienceHelper belongs to.
+         * @param webVROptions Options to modify the vr experience helper's behavior.
+         */
+        constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */public webVROptions: VRExperienceHelperOptions = {}) {
             this._scene = scene;
             this._canvas = scene.getEngine().getRenderingCanvas();
 
@@ -581,10 +638,16 @@ module BABYLON {
             }
         }
 
+        /**
+         * The position of the vr experience helper.
+         */
         public get position(): Vector3 {
             return this._position;
         }
 
+        /**
+         * Sets the position of the vr experience helper.
+         */
         public set position(value: Vector3) {
             this._position = value;
 
@@ -593,6 +656,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Enables controllers and user interactions suck as selecting and object or clicking on an object.
+         */
         public enableInteractions() {
             if (!this._interactionsEnabled) {
                 this._interactionsRequested = true;
@@ -644,6 +710,10 @@ module BABYLON {
             return false;
         }
 
+        /**
+         * Adds a floor mesh to be used for teleportation.
+         * @param floorMesh the mesh to be used for teleportation.
+         */
         public addFloorMesh(floorMesh: Mesh): void {
             if (!this._floorMeshesCollection) {
                 return;
@@ -656,6 +726,10 @@ module BABYLON {
             this._floorMeshesCollection.push(floorMesh);
         }
 
+        /**
+         * Removes a floor mesh from being used for teleportation.
+         * @param floorMesh the mesh to be removed.
+         */
         public removeFloorMesh(floorMesh: Mesh): void {
             if (!this._floorMeshesCollection) {
                 return
@@ -667,6 +741,10 @@ module BABYLON {
             }
         }
 
+        /**
+         * Enables interactions and teleportation using the VR controllers and gaze.
+         * @param vrTeleportationOptions options to modify teleportation behavior.
+         */
         public enableTeleportation(vrTeleportationOptions: VRTeleportationOptions = {}) {
             if (!this._teleportationInitialized) {
                 this._teleportationRequested = true;
@@ -1463,6 +1541,10 @@ module BABYLON {
             }
         }
 
+        /**
+         * Sets the color of the laser ray from the vr controllers.
+         * @param color new color for the ray.
+         */
         public changeLaserColor(color: Color3) {
             if (this._leftLaserPointer && this._leftLaserPointer.material) {
                 (<StandardMaterial>this._leftLaserPointer.material).emissiveColor = color;
@@ -1472,12 +1554,19 @@ module BABYLON {
             }
         }
 
+        /**
+         * Sets the color of the ray from the vr headsets gaze.
+         * @param color new color for the ray.
+         */
         public changeGazeColor(color: Color3) {
             if (this._gazeTracker.material) {
                 (<StandardMaterial>this._gazeTracker.material).emissiveColor = color;
             }
         }
 
+        /**
+         * Exits VR and disposes of the vr experience helper
+         */
         public dispose() {
             if (this.isInVRMode) {
                 this.exitVR();
@@ -1535,6 +1624,10 @@ module BABYLON {
             this._scene.unregisterBeforeRender(this.beforeRender);
         }
 
+        /**
+         * Gets the name of the VRExperienceHelper class
+         * @returns "VRExperienceHelper"
+         */
         public getClassName(): string {
             return "VRExperienceHelper";
         }

+ 200 - 22
src/Cameras/VR/babylon.webVRCamera.ts

@@ -4,45 +4,135 @@ declare var VRFrameData: any;
 
 module BABYLON {
     /**
-     * This is a copy of VRPose.
+     * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
      * IMPORTANT!! The data is right-hand data.
      * @export
      * @interface DevicePose
      */
     export interface DevicePose {
+        /**
+         * The position of the device, values in array are [x,y,z].
+         */
         readonly position?: Float32Array;
+        /**
+         * The linearVelocity of the device, values in array are [x,y,z].
+         */
         readonly linearVelocity?: Float32Array;
+        /**
+         * The linearAcceleration of the device, values in array are [x,y,z].
+         */
         readonly linearAcceleration?: Float32Array;
 
+        /**
+         * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
+         */
         readonly orientation?: Float32Array;
+        /**
+         * The angularVelocity of the device, values in array are [x,y,z].
+         */
         readonly angularVelocity?: Float32Array;
+        /**
+         * The angularAcceleration of the device, values in array are [x,y,z].
+         */
         readonly angularAcceleration?: Float32Array;
     }
 
+     /**
+     * Interface representing a pose controlled object in Babylon.
+     * A pose controlled object has both regular pose values as well as pose values 
+     * from an external device such as a VR head mounted display
+     */
     export interface PoseControlled {
+        /**
+         * The position of the object in babylon space.
+         */
         position: Vector3;
+        /**
+         * The rotation quaternion of the object in babylon space.
+         */
         rotationQuaternion: Quaternion;
+        /**
+         * The position of the device in babylon space.
+         */
         devicePosition?: Vector3;
+        /**
+         * The rotation quaternion of the device in babylon space.
+         */
         deviceRotationQuaternion: Quaternion;
+        /**
+         * The raw pose coming from the device.
+         */
         rawPose: Nullable<DevicePose>;
+        /**
+         * The scale of the device to be used when translating from device space to babylon space.
+         */
         deviceScaleFactor: number;
+        /**
+         * Updates the poseControlled values based on the input device pose.
+         * @param poseData the pose data to update the object with
+         */
         updateFromDevice(poseData: DevicePose): void;
     }
 
+    /**
+     * Set of options to customize the webVRCamera
+     */
     export interface WebVROptions {
-        trackPosition?: boolean; //for the sake of your users - set it to true.
+        /**
+         * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
+         */
+        trackPosition?: boolean;
+        /**
+         * Sets the scale of the vrDevice in babylon space. (default: 1)
+         */
         positionScale?: number;
-        displayName?: string; //if there are more than one VRDisplays.
-        controllerMeshes?: boolean; // should the native controller meshes be initialized
-        defaultLightingOnControllers?: boolean; // creating a default HemiLight only on controllers
-        useCustomVRButton?: boolean; // if you don't want to use the default VR button of the helper
-        customVRButton?: HTMLButtonElement; //if you'd like to provide your own button to the VRHelper
-        rayLength?: number; // to change the length of the ray for gaze/controllers.
-        defaultHeight?: number; // to change the default offset from the ground to account for user's height
+        /**
+         * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
+         */
+        displayName?: string;
+        /**
+         * Should the native controller meshes be initialized. (default: true)
+         */
+        controllerMeshes?: boolean;
+        /**
+         * Creating a default HemiLight only on controllers. (default: true)
+         */
+        defaultLightingOnControllers?: boolean;
+        /**
+         * If you don't want to use the default VR button of the helper. (default: false)
+         */
+        useCustomVRButton?: boolean;
+
+        /**
+         * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
+         */
+        customVRButton?: HTMLButtonElement;
+
+        /**
+         * To change the length of the ray for gaze/controllers. (default: 100)
+         */
+        rayLength?: number;
+
+        /**
+         * To change the default offset from the ground to account for user's height. (default: 1.7)
+         */
+        defaultHeight?: number;
+
     }
 
+    /**
+     * This represents a WebVR camera.
+     * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
+     * @example http://doc.babylonjs.com/how_to/webvr_camera
+     */
     export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
+        /**
+         * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
+         */
         public _vrDevice: any = null;
+        /**
+         * The rawPose of the vrDevice.
+         */
         public rawPose: Nullable<DevicePose> = null;
         private _onVREnabled: (success: boolean) => void;
         private _specsVersion: string = "1.1";
@@ -58,24 +148,51 @@ module BABYLON {
 
         private _standingMatrix: Nullable<Matrix> = null;
 
-        // Represents device position and rotation in babylon space
+        /**
+         * Represents device position in babylon space.
+         */
         public devicePosition = Vector3.Zero();
+        /**
+         * Represents device rotation in babylon space.
+         */
         public deviceRotationQuaternion = Quaternion.Identity();
 
+        /**
+         * The scale of the device to be used when translating from device space to babylon space.
+         */
         public deviceScaleFactor: number = 1;
 
         private _deviceToWorld = Matrix.Identity();
         private _worldToDevice = Matrix.Identity();
 
+        /**
+         * References to the webVR controllers for the vrDevice.
+         */
         public controllers: Array<WebVRController> = [];
+        /**
+         * Emits an event when a controller is attached.
+         */
         public onControllersAttachedObservable = new Observable<Array<WebVRController>>();
+        /**
+         * Emits an event when a controller's mesh has been loaded;
+         */
         public onControllerMeshLoadedObservable = new Observable<WebVRController>();
-
-        public rigParenting: boolean = true; // should the rig cameras be used as parent instead of this camera.
+        /**
+         * If the rig cameras be used as parent instead of this camera.
+         */
+        public rigParenting: boolean = true;
 
         private _lightOnControllers: HemisphericLight;
 
         private _defaultHeight?: number = undefined;
+
+        /**
+         * Instantiates a WebVRFreeCamera.
+         * @param name The name of the WebVRFreeCamera
+         * @param position The starting anchor position for the camera
+         * @param scene The scene the camera belongs to
+         * @param webVROptions a set of customizable options for the webVRCamera
+         */
         constructor(name: string, position: Vector3, scene: Scene, private webVROptions: WebVROptions = {}) {
             super(name, position, scene);
             this._cache.position = Vector3.Zero();
@@ -164,7 +281,11 @@ module BABYLON {
             });
         }
 
-        public deviceDistanceToRoomGround = () => {
+        /**
+         * Gets the device distance from the ground.
+         * @returns the distance from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
+         */
+        public deviceDistanceToRoomGround(): number {
             if (this._standingMatrix && this._defaultHeight === undefined) {
                 // Add standing matrix offset to get real offset from ground in room
                 this._standingMatrix.getTranslationToRef(this._workingVector);
@@ -174,8 +295,12 @@ module BABYLON {
             return this._defaultHeight || 0;            
         }
 
-        public useStandingMatrix = (callback = (bool: boolean) => { }) => {
-            // Use standing matrix if availible
+        /**
+         * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
+         * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
+         */
+        public useStandingMatrix(callback = (bool: boolean) => { }) {
+            // Use standing matrix if available
             if (!navigator || !navigator.getVRDisplays) {
                 callback(false);
             } else {
@@ -192,17 +317,25 @@ module BABYLON {
                                 }
                             });
                         }
-                        callback(true)
+                        callback(true);
                     }
-                })
+                });
             }
         }
 
+        /**
+         * Disposes the camera
+         */
         public dispose(): void {
             this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
             super.dispose();
         }
 
+        /**
+         * Gets a vrController by name.
+         * @param name The name of the controller to retreive
+         * @returns the controller matching the name specified or null if not found
+         */
         public getControllerByName(name: string): Nullable<WebVRController> {
             for (var gp of this.controllers) {
                 if (gp.hand === name) {
@@ -214,6 +347,9 @@ module BABYLON {
         }
 
         private _leftController: Nullable<WebVRController>;
+        /**
+         * The controller corrisponding to the users left hand.
+         */
         public get leftController(): Nullable<WebVRController> {
             if (!this._leftController) {
                 this._leftController = this.getControllerByName("left");
@@ -223,6 +359,9 @@ module BABYLON {
         };
 
         private _rightController: Nullable<WebVRController>;
+        /**
+         * The controller corrisponding to the users right hand.
+         */
         public get rightController(): Nullable<WebVRController> {
             if (!this._rightController) {
                 this._rightController = this.getControllerByName("right");
@@ -232,7 +371,11 @@ module BABYLON {
         };
 
 
-
+        /**
+         * Casts a ray forward from the vrCamera's gaze.
+         * @param length Length of the ray (default: 100)
+         * @returns the ray corrisponding to the gaze
+         */
         public getForwardRay(length = 100): Ray {
             if (this.leftCamera) {
                 // Use left eye to avoid computation to compute center on every call
@@ -243,6 +386,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Updates the camera based on device's frame data
+         */
         public _checkInputs(): void {
             if (this._vrDevice && this._vrDevice.isPresenting) {
                 this._vrDevice.getFrameData(this._frameData);
@@ -253,6 +399,10 @@ module BABYLON {
             super._checkInputs();
         }
 
+        /**
+         * Updates the poseControlled values based on the input device pose.
+         * @param poseData Pose coming from the device
+         */
         updateFromDevice(poseData: DevicePose) {
             if (poseData && poseData.orientation) {
                 this.rawPose = poseData;
@@ -277,10 +427,8 @@ module BABYLON {
          * within a user-interaction callback. Example:
          * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
          * 
-         * @param {HTMLElement} element 
-         * @param {boolean} [noPreventDefault] 
-         * 
-         * @memberOf WebVRFreeCamera
+         * @param element html element to attach the vrDevice to
+         * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
          */
         public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
             super.attachControl(element, noPreventDefault);
@@ -293,6 +441,11 @@ module BABYLON {
             }
         }
 
+        /**
+         * Detaches the camera from the html element and disables VR
+         * 
+         * @param element html element to detach from
+         */
         public detachControl(element: HTMLElement): void {
             this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
             this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
@@ -302,16 +455,26 @@ module BABYLON {
             this.getEngine().disableVR();
         }
 
+        /**
+         * @returns the name of this class
+         */
         public getClassName(): string {
             return "WebVRFreeCamera";
         }
 
+        /**
+         * Calls resetPose on the vrDisplay
+         * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
+         */
         public resetToCurrentRotation() {
             //uses the vrDisplay's "resetPose()".
             //pitch and roll won't be affected.
             this._vrDevice.resetPose();
         }
 
+        /**
+         * Updates the rig cameras (left and right eye)
+         */
         public _updateRigCameras() {
             var camLeft = <TargetCamera>this._rigCameras[0];
             var camRight = <TargetCamera>this._rigCameras[1];
@@ -328,6 +491,10 @@ module BABYLON {
 
         private updateCacheCalled: boolean;
 
+        /**
+         * Updates the cached values of the camera
+         * @param ignoreParentClass ignores updating the parent class's cache (default: false)
+         */
         public _updateCache(ignoreParentClass?: boolean): void {
             if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
                 // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
@@ -367,6 +534,9 @@ module BABYLON {
             this.updateCacheCalled = false;
         }
 
+        /**
+         * Updates the current device position and rotation in the babylon world
+         */
         public update() {
             // Get current device position in babylon world
             Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
@@ -378,6 +548,11 @@ module BABYLON {
 
             super.update();
         }
+
+        /**
+         * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
+         * @returns an identity matrix
+         */
         public _getViewMatrix(): Matrix {
             return Matrix.Identity();
         }
@@ -447,6 +622,9 @@ module BABYLON {
         private _onGamepadConnectedObserver: Nullable<Observer<Gamepad>>;
         private _onGamepadDisconnectedObserver: Nullable<Observer<Gamepad>>;
 
+        /**
+         * Initializes the controllers and their meshes
+         */
         public initControllers() {
             this.controllers = [];