Browse Source

Merge pull request #386 from raananw/Documentation

Documentation
David Catuhe 10 years ago
parent
commit
db1568c7d0

+ 4 - 1
Babylon/Mesh/babylon.InstancedMesh.js

@@ -6,6 +6,9 @@
 };
 var BABYLON;
 (function (BABYLON) {
+    /**
+    * Creates an instance based on a source mesh.
+    */
     var InstancedMesh = (function (_super) {
         __extends(InstancedMesh, _super);
         function InstancedMesh(name, source) {
@@ -183,4 +186,4 @@ var BABYLON;
     })(BABYLON.AbstractMesh);
     BABYLON.InstancedMesh = InstancedMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.instancedMesh.js.map
+//# sourceMappingURL=babylon.InstancedMesh.js.map

+ 4 - 0
Babylon/Mesh/babylon.InstancedMesh.ts

@@ -1,4 +1,8 @@
 module BABYLON {
+
+    /**
+     * Creates an instance based on a source mesh.
+     */
     export class InstancedMesh extends AbstractMesh {
         private _sourceMesh: Mesh;
         private _currentLOD: Mesh;

+ 12 - 0
Babylon/Mesh/babylon.mesh.js

@@ -19,6 +19,7 @@ var BABYLON;
     var Mesh = (function (_super) {
         __extends(Mesh, _super);
         /**
+        * @constructor
         * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
         * @param {Scene} scene - The scene to add this mesh to.
         * @param {Node} parent - The parent of this mesh, if it has one
@@ -104,6 +105,12 @@ var BABYLON;
             });
         };
 
+        /**
+        * Add a mesh as LOD level triggered at the given distance.
+        * @param {number} distance - the distance from the center of the object to show this level
+        * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
+        * @return {BABYLON.Mesh} this mesh (for chaining)
+        */
         Mesh.prototype.addLODLevel = function (distance, mesh) {
             if (mesh && mesh._masterMesh) {
                 BABYLON.Tools.Warn("You cannot use a mesh as LOD level twice");
@@ -122,6 +129,11 @@ var BABYLON;
             return this;
         };
 
+        /**
+        * Remove a mesh from the LOD array
+        * @param {BABYLON.Mesh} mesh - the mesh to be removed.
+        * @return {BABYLON.Mesh} this mesh (for chaining)
+        */
         Mesh.prototype.removeLODLevel = function (mesh) {
             for (var index = 0; index < this._LODLevels.length; index++) {
                 if (this._LODLevels[index].mesh === mesh) {

+ 14 - 2
Babylon/Mesh/babylon.mesh.ts

@@ -29,6 +29,7 @@
         private _preActivateId: number;
 
         /**
+         * @constructor
          * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
          * @param {Scene} scene - The scene to add this mesh to.
          * @param {Node} parent - The parent of this mesh, if it has one
@@ -103,6 +104,12 @@
             });
         }
 
+        /**
+         * Add a mesh as LOD level triggered at the given distance.
+         * @param {number} distance - the distance from the center of the object to show this level
+         * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
+         * @return {BABYLON.Mesh} this mesh (for chaining)
+         */
         public addLODLevel(distance: number, mesh: Mesh): Mesh {
             if (mesh && mesh._masterMesh) {
                 Tools.Warn("You cannot use a mesh as LOD level twice");
@@ -121,6 +128,11 @@
             return this;
         }
 
+        /**
+         * Remove a mesh from the LOD array
+         * @param {BABYLON.Mesh} mesh - the mesh to be removed.
+         * @return {BABYLON.Mesh} this mesh (for chaining)
+         */
         public removeLODLevel(mesh: Mesh): Mesh {
 
             for (var index = 0; index < this._LODLevels.length; index++) {
@@ -810,8 +822,8 @@
             return true;
         }
 
-        // Clone
-        public clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Mesh {
+        // Clone 
+        public clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): Mesh {
             return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren);
         }
 

+ 43 - 0
Babylon/babylon.engine.js

@@ -366,7 +366,16 @@
     })();
     BABYLON.EngineCapabilities = EngineCapabilities;
 
+    /**
+    * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
+    */
     var Engine = (function () {
+        /**
+        * @constructor
+        * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
+        * @param {boolean} [antialias] - enable antialias
+        * @param options - further options to be sent to the getContext function
+        */
         function Engine(canvas, antialias, options) {
             var _this = this;
             // Public members
@@ -715,6 +724,10 @@
             this._depthCullingState.depthFunc = this._gl.LEQUAL;
         };
 
+        /**
+        * stop executing a render loop function and remove it from the execution array
+        * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
+        */
         Engine.prototype.stopRenderLoop = function (renderFunction) {
             if (!renderFunction) {
                 this._activeRenderLoops = [];
@@ -759,6 +772,14 @@
             }
         };
 
+        /**
+        * Register and execute a render loop. The engine can have more than one render function.
+        * @param {Function} renderFunction - the function to continuesly execute starting the next render loop.
+        * @example
+        * engine.runRenderLoop(function () {
+        *      scene.render()
+        * })
+        */
         Engine.prototype.runRenderLoop = function (renderFunction) {
             var _this = this;
             if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
@@ -775,6 +796,10 @@
             }
         };
 
+        /**
+        * Toggle full screen mode.
+        * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
+        */
         Engine.prototype.switchFullscreen = function (requestPointerLock) {
             if (this.isFullscreen) {
                 BABYLON.Tools.ExitFullscreen();
@@ -802,6 +827,12 @@
             this._gl.clear(mode);
         };
 
+        /**
+        * Set the WebGL's viewport
+        * @param {BABYLON.Viewport} viewport - the viewport element to be used.
+        * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
+        * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
+        */
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
             var width = requiredWidth || this._renderingCanvas.width;
             var height = requiredHeight || this._renderingCanvas.height;
@@ -827,10 +858,22 @@
             this.flushFramebuffer();
         };
 
+        /**
+        * resize the view according to the canvas' size.
+        * @example
+        *   window.addEventListener("resize", function () {
+        *      engine.resize();
+        *   });
+        */
         Engine.prototype.resize = function () {
             this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
         };
 
+        /**
+        * force a specific size of the canvas
+        * @param {number} width - the new canvas' width
+        * @param {number} height - the new canvas' height
+        */
         Engine.prototype.setSize = function (width, height) {
             this._renderingCanvas.width = width;
             this._renderingCanvas.height = height;

+ 43 - 0
Babylon/babylon.engine.ts

@@ -351,6 +351,9 @@
         public uintIndices: boolean;
     }
 
+    /**
+     * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
+     */
     export class Engine {
         // Const statics
         private static _ALPHA_DISABLE = 0;
@@ -502,6 +505,12 @@
         private _workingCanvas: HTMLCanvasElement;
         private _workingContext: CanvasRenderingContext2D;
 
+        /**
+         * @constructor
+         * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
+         * @param {boolean} [antialias] - enable antialias
+         * @param options - further options to be sent to the getContext function
+         */
         constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?) {
             this._renderingCanvas = canvas;
             this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();
@@ -710,6 +719,10 @@
             this._depthCullingState.depthFunc = this._gl.LEQUAL;
         }
 
+        /**
+         * stop executing a render loop function and remove it from the execution array
+         * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
+         */
         public stopRenderLoop(renderFunction?: () => void): void {
             if (!renderFunction) {
                 this._activeRenderLoops = [];
@@ -753,6 +766,14 @@
             }
         }
 
+        /**
+         * Register and execute a render loop. The engine can have more than one render function.
+         * @param {Function} renderFunction - the function to continuesly execute starting the next render loop.
+         * @example
+         * engine.runRenderLoop(function () {
+         *      scene.render()
+         * })
+         */
         public runRenderLoop(renderFunction: () => void): void {
             if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
                 return;
@@ -768,6 +789,10 @@
             }
         }
 
+        /**
+         * Toggle full screen mode.
+         * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
+         */
         public switchFullscreen(requestPointerLock: boolean): void {
             if (this.isFullscreen) {
                 Tools.ExitFullscreen();
@@ -795,6 +820,12 @@
             this._gl.clear(mode);
         }
 
+        /**
+         * Set the WebGL's viewport
+         * @param {BABYLON.Viewport} viewport - the viewport element to be used.
+         * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
+         * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
+         */
         public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void {
             var width = requiredWidth || this._renderingCanvas.width;
             var height = requiredHeight || this._renderingCanvas.height;
@@ -820,10 +851,22 @@
             this.flushFramebuffer();
         }
 
+        /**
+         * resize the view according to the canvas' size.
+         * @example
+         *   window.addEventListener("resize", function () {
+         *      engine.resize();
+         *   });
+         */
         public resize(): void {
             this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
         }
 
+        /**
+         * force a specific size of the canvas
+         * @param {number} width - the new canvas' width
+         * @param {number} height - the new canvas' height
+         */
         public setSize(width: number, height: number): void {
             this._renderingCanvas.width = width;
             this._renderingCanvas.height = height;