Просмотр исходного кода

Improved exception list detection

David Catuhe 7 лет назад
Родитель
Сommit
4192a28ae4

Разница между файлами не показана из-за своего большого размера
+ 6344 - 6334
Playground/babylon.d.txt


Разница между файлами не показана из-за своего большого размера
+ 9064 - 9054
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 40 - 40
dist/preview release/babylon.js


+ 32 - 9
dist/preview release/babylon.max.js

@@ -8203,15 +8203,34 @@ var BABYLON;
                 this._lockstepMaxSteps = options.lockstepMaxSteps;
                 this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
                 // Exceptions
-                if (!options.disableWebGL2Support) {
-                    if (navigator && navigator.userAgent) {
-                        var ua = navigator.userAgent;
-                        for (var _i = 0, _a = Engine.WebGL2UniformBuffersExceptionList; _i < _a.length; _i++) {
-                            var exception = _a[_i];
-                            if (ua.indexOf(exception) > -1) {
-                                this.disableUniformBuffers = true;
-                                break;
+                if (navigator && navigator.userAgent) {
+                    var ua = navigator.userAgent;
+                    for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
+                        var exception = _a[_i];
+                        var key = exception.key;
+                        var targets = exception.targets;
+                        if (ua.indexOf(key) > -1) {
+                            if (exception.capture && exception.captureConstraint) {
+                                var capture = exception.capture;
+                                var constraint = exception.captureConstraint;
+                                var regex = new RegExp(capture);
+                                var matches = regex.exec(ua);
+                                if (matches && matches.length > 0) {
+                                    var capturedValue = parseInt(matches[matches.length - 1]);
+                                    if (capturedValue >= constraint) {
+                                        continue;
+                                    }
+                                }
                             }
+                            for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
+                                var target = targets_1[_b];
+                                switch (target) {
+                                    case "uniformBuffer":
+                                        this.disableUniformBuffers = true;
+                                        break;
+                                }
+                            }
+                            break;
                         }
                     }
                 }
@@ -12678,7 +12697,10 @@ var BABYLON;
             }
         };
         /** Use this array to turn off some WebGL2 features on known buggy browsers version */
-        Engine.WebGL2UniformBuffersExceptionList = ["Firefox/58"];
+        Engine.ExceptionList = [
+            { key: "Chrome/63", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
+            { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }
+        ];
         Engine.Instances = new Array();
         // Const statics
         Engine._ALPHA_DISABLE = 0;
@@ -39027,6 +39049,7 @@ var BABYLON;
             return _this;
         }
         TargetCamera.prototype.getFrontPosition = function (distance) {
+            this.getWorldMatrix();
             var direction = this.getTarget().subtract(this.position);
             direction.normalize();
             direction.scaleInPlace(distance);

Разница между файлами не показана из-за своего большого размера
+ 40 - 40
dist/preview release/babylon.worker.js


Разница между файлами не показана из-за своего большого размера
+ 5376 - 5366
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 43 - 43
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 32 - 9
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -8203,15 +8203,34 @@ var BABYLON;
                 this._lockstepMaxSteps = options.lockstepMaxSteps;
                 this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
                 // Exceptions
-                if (!options.disableWebGL2Support) {
-                    if (navigator && navigator.userAgent) {
-                        var ua = navigator.userAgent;
-                        for (var _i = 0, _a = Engine.WebGL2UniformBuffersExceptionList; _i < _a.length; _i++) {
-                            var exception = _a[_i];
-                            if (ua.indexOf(exception) > -1) {
-                                this.disableUniformBuffers = true;
-                                break;
+                if (navigator && navigator.userAgent) {
+                    var ua = navigator.userAgent;
+                    for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
+                        var exception = _a[_i];
+                        var key = exception.key;
+                        var targets = exception.targets;
+                        if (ua.indexOf(key) > -1) {
+                            if (exception.capture && exception.captureConstraint) {
+                                var capture = exception.capture;
+                                var constraint = exception.captureConstraint;
+                                var regex = new RegExp(capture);
+                                var matches = regex.exec(ua);
+                                if (matches && matches.length > 0) {
+                                    var capturedValue = parseInt(matches[matches.length - 1]);
+                                    if (capturedValue >= constraint) {
+                                        continue;
+                                    }
+                                }
                             }
+                            for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
+                                var target = targets_1[_b];
+                                switch (target) {
+                                    case "uniformBuffer":
+                                        this.disableUniformBuffers = true;
+                                        break;
+                                }
+                            }
+                            break;
                         }
                     }
                 }
@@ -12678,7 +12697,10 @@ var BABYLON;
             }
         };
         /** Use this array to turn off some WebGL2 features on known buggy browsers version */
-        Engine.WebGL2UniformBuffersExceptionList = ["Firefox/58"];
+        Engine.ExceptionList = [
+            { key: "Chrome/63", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
+            { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }
+        ];
         Engine.Instances = new Array();
         // Const statics
         Engine._ALPHA_DISABLE = 0;
@@ -39027,6 +39049,7 @@ var BABYLON;
             return _this;
         }
         TargetCamera.prototype.getFrontPosition = function (distance) {
+            this.getWorldMatrix();
             var direction = this.getTarget().subtract(this.position);
             direction.normalize();
             direction.scaleInPlace(distance);

Разница между файлами не показана из-за своего большого размера
+ 24 - 24
dist/preview release/viewer/babylon.viewer.js


+ 1 - 0
src/Cameras/babylon.targetCamera.ts

@@ -37,6 +37,7 @@
         }
 
         public getFrontPosition(distance: number): Vector3 {
+            this.getWorldMatrix();
             var direction = this.getTarget().subtract(this.position);
             direction.normalize();
             direction.scaleInPlace(distance);

+ 33 - 8
src/Engine/babylon.engine.ts

@@ -279,7 +279,10 @@
      */
     export class Engine {
         /** Use this array to turn off some WebGL2 features on known buggy browsers version */
-        public static WebGL2UniformBuffersExceptionList = ["Chrome/63", "Firefox/58"];
+        public static ExceptionList = [
+            { key: "Chrome/63", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
+            { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }
+        ];
 
         public static Instances = new Array<Engine>();
 
@@ -854,15 +857,37 @@
                 this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
 
                 // Exceptions
-                if (!options.disableWebGL2Support) {
-                    if (navigator && navigator.userAgent) {
-                        let ua = navigator.userAgent;
+                if (navigator && navigator.userAgent) {
+                    let ua = navigator.userAgent;
+
+                    for (var exception of Engine.ExceptionList) {
+                        let key = exception.key;
+                        let targets = exception.targets;
+
+                        if (ua.indexOf(key) > -1) {
+                            if (exception.capture && exception.captureConstraint) {
+                                let capture = exception.capture;
+                                let constraint = exception.captureConstraint;
+
+                                let regex = new RegExp(capture);
+                                let matches = regex.exec(ua);
+
+                                if (matches && matches.length > 0) {
+                                    let capturedValue = parseInt(matches[matches.length - 1]);
+                                    if (capturedValue >= constraint) {
+                                        continue;
+                                    }
+                                }
+                            }
 
-                        for (var exception of Engine.WebGL2UniformBuffersExceptionList) {
-                            if (ua.indexOf(exception) > -1) {
-                                this.disableUniformBuffers = true;
-                                break;
+                            for (var target of targets) {
+                                switch (target) {
+                                    case "uniformBuffer":
+                                        this.disableUniformBuffers = true;
+                                        break;
+                                }
                             }
+                            break;
                         }
                     }
                 }