瀏覽代碼

actionManager can be created automatically

David Catuhe 9 年之前
父節點
當前提交
8854ff2b00

File diff suppressed because it is too large
+ 23 - 23
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 2998 - 2727
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 38 - 38
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 654 - 22
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 38 - 38
dist/preview release/babylon.noworker.js


+ 9 - 7
src/Cameras/VR/babylon.webVRCamera.js

@@ -13,8 +13,6 @@ var BABYLON;
             this._hmdDevice = null;
             this._sensorDevice = null;
             this._cacheState = null;
-            this._cacheQuaternion = new BABYLON.Quaternion();
-            this._cacheRotation = BABYLON.Vector3.Zero();
             this._vrEnabled = false;
             var metrics = BABYLON.VRCameraMetrics.GetDefault();
             metrics.compensateDistortion = compensateDistortion;
@@ -46,11 +44,10 @@ var BABYLON;
         WebVRFreeCamera.prototype._checkInputs = function () {
             if (this._vrEnabled) {
                 this._cacheState = this._sensorDevice.getState();
-                this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x, this._cacheState.orientation.y, this._cacheState.orientation.z, this._cacheState.orientation.w);
-                this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation);
-                this.rotation.x = -this._cacheRotation.x;
-                this.rotation.y = -this._cacheRotation.y;
-                this.rotation.z = this._cacheRotation.z;
+                this.rotationQuaternion.copyFrom(this._cacheState.orientation);
+                //Flip in XY plane
+                this.rotationQuaternion.z *= -1;
+                this.rotationQuaternion.w *= -1;
             }
             _super.prototype._checkInputs.call(this);
         };
@@ -68,6 +65,11 @@ var BABYLON;
             _super.prototype.detachControl.call(this, element);
             this._vrEnabled = false;
         };
+        WebVRFreeCamera.prototype.requestVRFullscreen = function (requestPointerlock) {
+            if (!this._hmdDevice)
+                return;
+            this.getEngine().switchFullscreen(requestPointerlock, { vrDisplay: this._hmdDevice });
+        };
         WebVRFreeCamera.prototype.getTypeName = function () {
             return "WebVRFreeCamera";
         };

+ 18 - 2
src/Materials/babylon.colorCurves.js

@@ -53,6 +53,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._globalHue = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -73,6 +74,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._globalDensity = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -91,6 +93,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._globalSaturation = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -109,6 +112,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._highlightsHue = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -129,6 +133,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._highlightsDensity = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -147,6 +152,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._highlightsSaturation = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -165,6 +171,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._highlightsExposure = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -183,6 +190,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._midtonesHue = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -203,6 +211,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._midtonesDensity = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -221,6 +230,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._midtonesSaturation = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -239,6 +249,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._midtonesExposure = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -257,6 +268,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._shadowsHue = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -277,6 +289,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._shadowsDensity = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -295,6 +308,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._shadowsSaturation = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -313,6 +327,7 @@ var BABYLON;
              */
             set: function (value) {
                 this._shadowsExposure = value;
+                this._dirty = true;
             },
             enumerable: true,
             configurable: true
@@ -324,6 +339,7 @@ var BABYLON;
          */
         ColorCurves.Bind = function (colorCurves, effect) {
             if (colorCurves._dirty) {
+                colorCurves._dirty = false;
                 // Fill in global info.
                 colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
                 // Compute highlights info.
@@ -360,7 +376,7 @@ var BABYLON;
          */
         ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
             if (hue == null) {
-                return null;
+                return;
             }
             hue = ColorCurves.clamp(hue, 0, 360);
             density = ColorCurves.clamp(density, -100, 100);
@@ -524,6 +540,6 @@ var BABYLON;
             BABYLON.serialize()
         ], ColorCurves.prototype, "_midtonesExposure", void 0);
         return ColorCurves;
-    }());
+    })();
     BABYLON.ColorCurves = ColorCurves;
 })(BABYLON || (BABYLON = {}));

+ 9 - 9
src/Materials/babylon.colorCurves.ts

@@ -10,15 +10,15 @@
         
         private _dirty = true;
         
-        private _tempColor = new BABYLON.Color4(0, 0, 0, 0);
+        private _tempColor = new Color4(0, 0, 0, 0);
         
-        private _globalCurve = new BABYLON.Color4(0, 0, 0, 0);
-        private _highlightsCurve = new BABYLON.Color4(0, 0, 0, 0);
-        private _midtonesCurve = new BABYLON.Color4(0, 0, 0, 0);
-        private _shadowsCurve = new BABYLON.Color4(0, 0, 0, 0);
+        private _globalCurve = new Color4(0, 0, 0, 0);
+        private _highlightsCurve = new Color4(0, 0, 0, 0);
+        private _midtonesCurve = new Color4(0, 0, 0, 0);
+        private _shadowsCurve = new Color4(0, 0, 0, 0);
         
-        private _positiveCurve = new BABYLON.Color4(0, 0, 0, 0);
-        private _negativeCurve = new BABYLON.Color4(0, 0, 0, 0);
+        private _positiveCurve = new Color4(0, 0, 0, 0);
+        private _negativeCurve = new Color4(0, 0, 0, 0);
         
         @serialize()
         private _globalHue = 30;
@@ -386,7 +386,7 @@
          */
         private getColorGradingDataToRef(hue: number, density: number, saturation: number, exposure: number, result: Color4) : void {
             if (hue == null) {
-                return null;
+                return;
             }
 
             hue = ColorCurves.clamp(hue, 0, 360);
@@ -439,7 +439,7 @@
          * @param brightness The brightness (B) input.
          * @result An RGBA color represented as Vector4.
          */
-        private static fromHSBToRef(hue: number, saturation: number, brightness: number, result: BABYLON.Color4): void {
+        private static fromHSBToRef(hue: number, saturation: number, brightness: number, result: Color4): void {
             var h: number = ColorCurves.clamp(hue, 0, 360);
             var s: number = ColorCurves.clamp(saturation / 100, 0, 1);
             var v: number = ColorCurves.clamp(brightness / 100, 0, 1);

+ 18 - 0
src/Materials/babylon.pbrMaterial.js

@@ -62,6 +62,7 @@ var BABYLON;
             this.CAMERATONEMAP = false;
             this.CAMERACONTRAST = false;
             this.CAMERACOLORGRADING = false;
+            this.CAMERACOLORCURVES = false;
             this.OVERLOADEDVALUES = false;
             this.OVERLOADEDSHADOWVALUES = false;
             this.USESPHERICALFROMREFLECTIONMAP = false;
@@ -153,6 +154,13 @@ var BABYLON;
             this.cameraColorGradingTexture = null;
             this._cameraColorGradingScaleOffset = new BABYLON.Vector4(1.0, 1.0, 0.0, 0.0);
             this._cameraColorGradingInfos = new BABYLON.Vector4(1.0, 1.0, 0.0, 0.0);
+            /**
+             * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
+             * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
+             * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
+             * corresponding to low luminance, medium luminance, and high luminance areas respectively.
+             */
+            this.cameraColorCurves = null;
             this._cameraInfos = new BABYLON.Vector4(1.0, 1.0, 0.0, 0.0);
             this._microsurfaceTextureLods = new BABYLON.Vector2(0.0, 0.0);
             /**
@@ -618,6 +626,9 @@ var BABYLON;
             if (this.cameraExposure != 1) {
                 this._defines.CAMERATONEMAP = true;
             }
+            if (this.cameraColorCurves) {
+                this._defines.CAMERACOLORCURVES = true;
+            }
             if (this.overloadedShadeIntensity != 1 ||
                 this.overloadedShadowIntensity != 1) {
                 this._defines.OVERLOADEDSHADOWVALUES = true;
@@ -783,6 +794,7 @@ var BABYLON;
                 ];
                 var samplers = ["albedoSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "reflectivitySampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler",
                     "cameraColorGrading2DSampler"];
+                BABYLON.ColorCurves.PrepareUniforms(uniforms);
                 BABYLON.MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, this._defines, this.maxSimultaneousLights);
                 this._effect = scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights });
             }
@@ -967,6 +979,9 @@ var BABYLON;
                 this._cameraInfos.x = this.cameraExposure;
                 this._cameraInfos.y = this.cameraContrast;
                 this._effect.setVector4("vCameraInfos", this._cameraInfos);
+                if (this.cameraColorCurves) {
+                    BABYLON.ColorCurves.Bind(this.cameraColorCurves, this._effect);
+                }
                 this._overloadedIntensity.x = this.overloadedAmbientIntensity;
                 this._overloadedIntensity.y = this.overloadedAlbedoIntensity;
                 this._overloadedIntensity.z = this.overloadedReflectivityIntensity;
@@ -1109,6 +1124,9 @@ var BABYLON;
             BABYLON.serializeAsTexture()
         ], PBRMaterial.prototype, "cameraColorGradingTexture", void 0);
         __decorate([
+            BABYLON.serializeAsColorCurves()
+        ], PBRMaterial.prototype, "cameraColorCurves", void 0);
+        __decorate([
             BABYLON.serializeAsColor3()
         ], PBRMaterial.prototype, "overloadedAmbient", void 0);
         __decorate([

+ 21 - 0
src/Math/babylon.math.js

@@ -251,6 +251,27 @@ var BABYLON;
             result.a = this.a * scale;
             return this;
         };
+        /**
+          * Multipy an RGBA Color4 value by another and return a new Color4 object
+          * @param color The Color4 (RGBA) value to multiply by
+          * @returns A new Color4.
+          */
+        Color4.prototype.multiply = function (color) {
+            return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
+        };
+        /**
+         * Multipy an RGBA Color4 value by another and push the result in a reference value
+         * @param color The Color4 (RGBA) value to multiply by
+         * @param result The Color4 (RGBA) to fill the result in
+         * @returns the result Color4.
+         */
+        Color4.prototype.multiplyToRef = function (color, result) {
+            result.r = this.r * color.r;
+            result.g = this.g * color.g;
+            result.b = this.b * color.b;
+            result.a = this.a * color.a;
+            return result;
+        };
         Color4.prototype.toString = function () {
             return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
         };

+ 21 - 0
src/Mesh/babylon.abstractMesh.js

@@ -171,6 +171,27 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "actionManager", {
+            /**
+             * This scene's action manager
+             * @type {BABYLON.ActionManager}
+            */
+            get: function () {
+                if (!this._actionManager) {
+                    this.actionManager = new BABYLON.ActionManager(this.getScene());
+                }
+                return this._actionManager;
+            },
+            /**
+             * This scene's action manager
+             * @type {BABYLON.ActionManager}
+            */
+            set: function (value) {
+                this._actionManager = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "skeleton", {
             get: function () {
                 return this._skeleton;

+ 21 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -95,7 +95,6 @@
         public renderingGroupId = 0;
         public material: Material;
         public receiveShadows = false;
-        public actionManager: ActionManager;
         public renderOutline = false;
         public outlineColor = Color3.Red();
         public outlineWidth = 0.02;
@@ -117,6 +116,27 @@
 
         public alwaysSelectAsActiveMesh = false;
 
+        // Actions
+        private _actionManager: ActionManager;
+        /**
+         * This scene's action manager
+         * @type {BABYLON.ActionManager}
+        */
+        public get actionManager(): ActionManager {
+            if (!this._actionManager) {
+                this.actionManager = new ActionManager(this.getScene());
+            }
+
+            return this._actionManager;
+        }
+        /**
+         * This scene's action manager
+         * @type {BABYLON.ActionManager}
+        */
+        public set actionManager(value: ActionManager) {
+            this._actionManager = value;
+        }
+
         // Physics
         public physicsImpostor: BABYLON.PhysicsImpostor;
         //Deprecated, Legacy support

+ 12 - 1
src/Tools/babylon.decorators.js

@@ -36,6 +36,10 @@ var BABYLON;
         return generateSerializableMember(6, sourceName); // mesh reference member
     }
     BABYLON.serializeAsMeshReference = serializeAsMeshReference;
+    function serializeAsColorCurves(sourceName) {
+        return generateSerializableMember(7, sourceName); // color curves
+    }
+    BABYLON.serializeAsColorCurves = serializeAsColorCurves;
     var SerializationHelper = (function () {
         function SerializationHelper() {
         }
@@ -74,6 +78,9 @@ var BABYLON;
                         case 6:
                             serializationObject[targetPropertyName] = sourceProperty.id;
                             break;
+                        case 7:
+                            serializationObject[targetPropertyName] = sourceProperty.serialize();
+                            break;
                     }
                 }
             }
@@ -111,6 +118,9 @@ var BABYLON;
                         case 6:
                             destination[property] = scene.getLastMeshByID(sourceProperty);
                             break;
+                        case 7:
+                            destination[property] = BABYLON.ColorCurves.Parse(sourceProperty);
+                            break;
                     }
                 }
             }
@@ -135,7 +145,8 @@ var BABYLON;
                         case 2: // Color3
                         case 3: // FresnelParameters
                         case 4: // Vector2
-                        case 5:
+                        case 5: // Vector3
+                        case 7:
                             destination[property] = sourceProperty.clone();
                             break;
                     }

+ 5 - 9
src/Tools/babylon.tools.js

@@ -212,15 +212,11 @@ var BABYLON;
                 window.setTimeout(func, 16);
             }
         };
-        Tools.RequestFullscreen = function (element) {
-            if (element.requestFullscreen)
-                element.requestFullscreen();
-            else if (element.msRequestFullscreen)
-                element.msRequestFullscreen();
-            else if (element.webkitRequestFullscreen)
-                element.webkitRequestFullscreen();
-            else if (element.mozRequestFullScreen)
-                element.mozRequestFullScreen();
+        Tools.RequestFullscreen = function (element, options) {
+            var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
+            if (!requestFunction)
+                return;
+            requestFunction.call(element, options);
         };
         Tools.ExitFullscreen = function () {
             if (document.exitFullscreen) {

+ 3 - 2
src/babylon.engine.js

@@ -563,14 +563,15 @@ var BABYLON;
         /**
          * Toggle full screen mode.
          * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
+         * @param {any} options - an options object to be sent to the requestFullscreen function
          */
-        Engine.prototype.switchFullscreen = function (requestPointerLock) {
+        Engine.prototype.switchFullscreen = function (requestPointerLock, options) {
             if (this.isFullscreen) {
                 BABYLON.Tools.ExitFullscreen();
             }
             else {
                 this._pointerLockRequested = requestPointerLock;
-                BABYLON.Tools.RequestFullscreen(this._renderingCanvas);
+                BABYLON.Tools.RequestFullscreen(this._renderingCanvas, options);
             }
         };
         Engine.prototype.clear = function (color, backBuffer, depthStencil) {

+ 21 - 0
src/babylon.scene.js

@@ -395,6 +395,27 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Scene.prototype, "actionManager", {
+            /**
+             * This scene's action manager
+             * @type {BABYLON.ActionManager}
+            */
+            get: function () {
+                if (!this._sceneActionManager) {
+                    this.actionManager = new BABYLON.ActionManager(this);
+                }
+                return this._sceneActionManager;
+            },
+            /**
+             * This scene's action manager
+             * @type {BABYLON.ActionManager}
+            */
+            set: function (value) {
+                this._sceneActionManager = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Scene.prototype, "debugLayer", {
             // Properties
             get: function () {

+ 18 - 2
src/babylon.scene.ts

@@ -388,11 +388,27 @@
         public database; //ANY
 
         // Actions
+
+        private _sceneActionManager: ActionManager;
         /**
          * This scene's action manager
          * @type {BABYLON.ActionManager}
-         */
-        public actionManager: ActionManager;
+        */
+        public get actionManager(): ActionManager {
+            if (!this._sceneActionManager) {
+                this.actionManager = new ActionManager(this);
+            }
+
+            return this._sceneActionManager;
+        }
+        /**
+         * This scene's action manager
+         * @type {BABYLON.ActionManager}
+        */
+        public set actionManager(value: ActionManager) {
+            this._sceneActionManager = value;
+        }
+
         public _actionManagers = new Array<ActionManager>();
         private _meshesForIntersections = new SmartArray<AbstractMesh>(256);