瀏覽代碼

Merge pull request #5184 from sebavan/master

More doc
sebavan 7 年之前
父節點
當前提交
e448b9e0e1
共有 3 個文件被更改,包括 144 次插入2 次删除
  1. 13 1
      src/Layer/babylon.layer.ts
  2. 54 1
      src/LensFlare/babylon.lensFlare.ts
  3. 77 0
      src/LensFlare/babylon.lensFlareSystem.ts

+ 13 - 1
src/Layer/babylon.layer.ts

@@ -94,6 +94,10 @@
         public onAfterRenderObservable = new Observable<Layer>();
 
         private _onAfterRenderObserver: Nullable<Observer<Layer>>;
+        /**
+         * Back compatibility with callback before the onAfterRenderObservable existed.
+         * The set callback will be triggered just after rendering the layer.
+         */
         public set onAfterRender(callback: () => void) {
             if (this._onAfterRenderObserver) {
                 this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
@@ -112,7 +116,15 @@
          * @param isBackground Defines whether the layer is displayed in front or behind the scene
          * @param color Defines a color for the layer
          */
-        constructor(public name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4) {
+        constructor(
+            /**
+             * Define the name of the layer.
+             */
+            public name: string, 
+            imgUrl: Nullable<string>, 
+            scene: Nullable<Scene>, 
+            isBackground?: boolean, color?: Color4) {
+            
             this.texture = imgUrl ? new Texture(imgUrl, scene, true) : null;
             this.isBackground = isBackground === undefined ? true : isBackground;
             this.color = color === undefined ? new Color4(1, 1, 1, 1) : color;

+ 54 - 1
src/LensFlare/babylon.lensFlare.ts

@@ -1,16 +1,66 @@
 module BABYLON {
+    /**
+     * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
+     * It controls one of the indiviual texture used in the effect.
+     * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
+     */
     export class LensFlare {
+        /**
+         * Define the lens color.
+         */
         public color: Color3;
+
+        /**
+         * Define the lens texture.
+         */
         public texture: Nullable<Texture>;
+
+        /**
+         * Define the alpha mode to render this particular lens.
+         */
         public alphaMode: number = Engine.ALPHA_ONEONE;
 
         private _system: LensFlareSystem;
 
+        /**
+         * Creates a new Lens Flare.
+         * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
+         * It controls one of the indiviual texture used in the effect.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
+         * @param size Define the size of the lens flare (a floating value between 0 and 1)
+         * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
+         * @param color Define the lens color
+         * @param imgUrl Define the lens texture url
+         * @param system Define the `lensFlareSystem` this flare is part of
+         */
         public static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare {
             return new LensFlare(size, position, color, imgUrl, system);
         }
 
-        constructor(public size: number, public position: number, color: Color3, imgUrl: string, system: LensFlareSystem) {
+        /**
+         * Instantiates a new Lens Flare.
+         * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
+         * It controls one of the indiviual texture used in the effect.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
+         * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
+         * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
+         * @param color Define the lens color
+         * @param imgUrl Define the lens texture url
+         * @param system Define the `lensFlareSystem` this flare is part of
+         */
+        constructor(
+            /**
+             * Define the size of the lens flare in the system (a floating value between 0 and 1)
+             */
+            public size: number, 
+            /**
+             * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
+             */
+            public position: number, 
+            color: Color3, 
+            imgUrl: string, 
+            system: LensFlareSystem) {
+
             this.color = color || new Color3(1, 1, 1);
             this.texture = imgUrl ? new Texture(imgUrl, system.getScene(), true) : null;
             this._system = system;
@@ -18,6 +68,9 @@
             system.lensFlares.push(this);
         }
 
+        /**
+         * Dispose and release the lens flare with its associated resources.
+         */
         public dispose(): void {
             if (this.texture) {
                 this.texture.dispose();

+ 77 - 0
src/LensFlare/babylon.lensFlareSystem.ts

@@ -1,10 +1,39 @@
 module BABYLON {
+    /**
+     * This represents a Lens Flare System or the shiny effect created by the light reflection on the  camera lenses.
+     * It is usually composed of several `BABYLON.lensFlare`.
+     * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
+     */
     export class LensFlareSystem {
+        /**
+         * List of lens flares used in this system.
+         */
         public lensFlares = new Array<LensFlare>();
+
+        /**
+         * Define a limit from the border the lens flare can be visible.
+         */
         public borderLimit = 300;
+
+        /**
+         * Define a viewport border we do not want to see the lens flare in.
+         */
         public viewportBorder = 0;
+
+        /**
+         * Define a predicate which could limit the list of meshes able to occlude the effect.
+         */
         public meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
+
+        /**
+         * Restricts the rendering of the effect to only the camera rendering this layer mask.
+         */
         public layerMask: number = 0x0FFFFFFF;
+
+        /**
+         * Define the id of the lens flare system in the scene.
+         * (equal to name by default)
+         */
         public id: string;
 
         private _scene: Scene;
@@ -16,6 +45,15 @@
         private _positionY: number;
         private _isEnabled = true;
 
+        /**
+         * Instantiates a lens flare system.
+         * This represents a Lens Flare System or the shiny effect created by the light reflection on the  camera lenses.
+         * It is usually composed of several `BABYLON.lensFlare`.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
+         * @param name Define the name of the lens flare system in the scene
+         * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
+         * @param scene Define the scene the lens flare system belongs to
+         */
         constructor(public name: string, emitter: any, scene: Scene) {
 
             this._scene = scene || Engine.LastCreatedScene;
@@ -61,6 +99,9 @@
                 ["textureSampler"], "");
         }
 
+        /**
+         * Define if the lens flare system is enabled.
+         */
         public get isEnabled(): boolean {
             return this._isEnabled;
         }
@@ -69,22 +110,41 @@
             this._isEnabled = value;
         }
 
+        /**
+         * Get the scene the effects belongs to.
+         * @returns the scene holding the lens flare system
+         */
         public getScene(): Scene {
             return this._scene;
         }
 
+        /**
+         * Get the emitter of the lens flare system.
+         * It defines the source of the lens flares (it can be a camera, a light or a mesh).
+         */
         public getEmitter(): any {
             return this._emitter;
         }
 
+        /**
+         * Set the emitter of the lens flare system.
+         * It defines the source of the lens flares (it can be a camera, a light or a mesh).
+         */
         public setEmitter(newEmitter: any): void {
             this._emitter = newEmitter;
         }
 
+        /**
+         * Get the lens flare system emitter position.
+         * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
+         */
         public getEmitterPosition(): Vector3 {
             return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
         }
 
+        /**
+         * @hidden
+         */
         public computeEffectivePosition(globalViewport: Viewport): boolean {
             var position = this.getEmitterPosition();
 
@@ -134,6 +194,9 @@
             return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
         }
 
+        /**
+         * @hidden
+         */
         public render(): boolean {
             if (!this._effect.isReady() || !this._scene.activeCamera)
                 return false;
@@ -249,6 +312,9 @@
             return true;
         }
 
+        /**
+         * Dispose and release the lens flare with its associated resources.
+         */
         public dispose(): void {
             var vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];
             if (vertexBuffer) {
@@ -270,6 +336,13 @@
             this._scene.lensFlareSystems.splice(index, 1);
         }
 
+        /**
+         * Parse a lens flare system from a JSON repressentation
+         * @param parsedLensFlareSystem Define the JSON to parse
+         * @param scene Define the scene the parsed system should be instantiated in
+         * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
+         * @returns the parsed system
+         */
         public static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem {
             var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
 
@@ -288,6 +361,10 @@
             return lensFlareSystem;
         }
 
+        /**
+         * Serialize the current Lens Flare System into a JSON representation.
+         * @returns the serialized JSON
+         */
         public serialize(): any {
             var serializationObject: any = {};