Преглед на файлове

Merge pull request #3566 from sebavan/master

merge preview back to master
sebavan преди 7 години
родител
ревизия
9c8c3ad79a

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

@@ -19694,83 +19694,6 @@
         }
       }
     },
-    "GeometryBufferRenderer": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new GeometryBufferRenderer": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "ratio": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "enablePosition": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "isSupported": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "renderList": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "samples": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "dispose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "getGBuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "isReady": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "subMesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "useInstances": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "GroundGeometry": {
       "Class": {
         "Comments": {

+ 19 - 0
src/Actions/babylon.actionManager.ts

@@ -319,6 +319,25 @@
         }
 
         /**
+         * Unregisters an action to this action manager
+         * @param action The action to be unregistered
+         * @return whether the action has been unregistered
+         */
+        public unregisterAction(action: Action): Boolean {
+            var index = this.actions.indexOf(action);
+            if (index !== -1) {
+                this.actions.splice(index, 1);
+                ActionManager.Triggers[action.trigger] -= 1;
+                if (ActionManager.Triggers[action.trigger] === 0) {
+                    delete ActionManager.Triggers[action.trigger]
+                }
+                delete action._actionManager;
+                return true;
+            }
+            return false;
+        }
+
+        /**
          * Process a specific trigger
          * @param {number} trigger - the trigger to process
          * @param evt {BABYLON.ActionEvent} the event details to be processed

+ 18 - 0
src/Math/babylon.math.ts

@@ -1460,6 +1460,24 @@
         }
 
         /**
+         * Get angle between two vectors.
+         * @param vector0 angle between vector0 and vector1
+         * @param vector1 angle between vector0 and vector1
+         * @param normal direction of the normal.
+         * @return the angle between vector0 and vector1.
+         */
+        public static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3):number {
+            var v0:Vector3 = vector0.clone().normalize();
+            var v1:Vector3 = vector1.clone().normalize();
+            var dot:number = Vector3.Dot(v0, v1);
+            var n = Vector3.Cross(v0, v1);
+            if (Vector3.Dot(n, normal) > 0) {
+                return Math.acos(dot);
+            }
+            return -Math.acos(dot);
+        }
+
+        /**
          * Returns a new Vector3 set from the index "offset" of the passed array.
          */
         public static FromArray(array: ArrayLike<number>, offset?: number): Vector3 {

+ 56 - 4
src/Rendering/babylon.geometryBufferRenderer.ts

@@ -1,32 +1,66 @@
 module BABYLON {
+    /**
+     * This renderer is helpfull to fill one of the render target with a geometry buffer.
+     */
     export class GeometryBufferRenderer {
         private _scene: Scene;
         private _multiRenderTarget: MultiRenderTarget;
         private _effect: Effect;
         private _ratio: number;
-
         private _cachedDefines: string;
-
         private _enablePosition: boolean = false;
 
+        /**
+         * Set the render list (meshes to be rendered) used in the G buffer.
+         */
         public set renderList(meshes: Mesh[]) {
             this._multiRenderTarget.renderList = meshes;
         }
 
+        /**
+         * Gets wether or not G buffer are supported by the running hardware.
+         * This requires draw buffer supports
+         */
         public get isSupported(): boolean {
             return this._multiRenderTarget.isSupported;
         }
 
+        /**
+         * Gets wether or not position are enabled for the G buffer.
+         */
         public get enablePosition(): boolean {
             return this._enablePosition;
         }
 
+        /**
+         * Sets wether or not position are enabled for the G buffer.
+         */
         public set enablePosition(enable: boolean) {
             this._enablePosition = enable;
             this.dispose();
             this._createRenderTargets();
         }
 
+        /**
+         * Gets the scene associated with the buffer.
+         */
+        public get scene(): Scene {
+            return this._scene;
+        }
+
+        /**
+         * Gets the ratio used by the buffer during its creation.
+         * How big is the buffer related to the main canvas.
+         */
+        public get ratio(): number {
+            return this._ratio
+        }
+
+        /**
+         * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
+         * @param scene The scene the buffer belongs to
+         * @param ratio How big is the buffer related to the main canvas.
+         */
         constructor(scene: Scene, ratio: number = 1) {
             this._scene = scene;
             this._ratio = ratio;
@@ -35,6 +69,12 @@ module BABYLON {
             this._createRenderTargets();
         }
 
+        /**
+         * Checks wether everything is ready to render a submesh to the G buffer.
+         * @param subMesh the submesh to check readiness for
+         * @param useInstances is the mesh drawn using instance or not
+         * @returns true if ready otherwise false
+         */
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
             var material: any = subMesh.getMaterial();
 
@@ -104,24 +144,36 @@ module BABYLON {
             return this._effect.isReady();
         }
 
+        /**
+         * Gets the current underlying G Buffer.
+         * @returns the buffer
+         */
         public getGBuffer(): MultiRenderTarget {
             return this._multiRenderTarget;
         }
 
+        /**
+         * Gets the number of samples used to render the buffer (anti aliasing).
+         */
         public get samples(): number {
             return this._multiRenderTarget.samples;
         }
 
+        /**
+         * Sets the number of samples used to render the buffer (anti aliasing).
+         */
         public set samples(value: number) {
             this._multiRenderTarget.samples = value;
         }
 
-        // Methods
+        /**
+         * Disposes the renderer and frees up associated resources.
+         */
         public dispose(): void {
             this.getGBuffer().dispose();
         }
 
-        private _createRenderTargets(): void {
+        protected _createRenderTargets(): void {
             var engine = this._scene.getEngine();
             var count = this._enablePosition ? 3 : 2;
 

+ 14 - 0
src/babylon.scene.ts

@@ -930,6 +930,20 @@
 
         private _depthRenderer: Nullable<DepthRenderer>;
         private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
+        /**
+         * Gets the current geometry buffer associated to the scene.
+         */
+        public get geometryBufferRenderer(): Nullable<GeometryBufferRenderer> {
+            return this._geometryBufferRenderer;
+        }
+        /**
+         * Sets the current geometry buffer for the scene.
+         */
+        public set geometryBufferRenderer(geometryBufferRenderer: Nullable<GeometryBufferRenderer>) {
+            if (geometryBufferRenderer && geometryBufferRenderer.isSupported) {
+                this._geometryBufferRenderer = geometryBufferRenderer;
+            }
+        }
 
         private _pickedDownMesh: Nullable<AbstractMesh>;
         private _pickedUpMesh: Nullable<AbstractMesh>;