Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 years ago
parent
commit
6178cc8d25

+ 7 - 0
Viewer/dist/external/msft/config.json

@@ -21,5 +21,12 @@
             "g": 0.9607843137254902,
             "g": 0.9607843137254902,
             "b": 0.9607843137254902
             "b": 0.9607843137254902
         }
         }
+    },
+    "templates": {
+        "navBar": {
+            "params": {
+                "hideHdButton": false
+            }
+        }
     }
     }
 }
 }

+ 7 - 0
Viewer/src/viewer/defaultViewer.ts

@@ -106,6 +106,12 @@ export class DefaultViewer extends AbstractViewer {
                 }
                 }
                 this._resumePlay = false;
                 this._resumePlay = false;
             }, "pointerup", ".progress-wrapper");
             }, "pointerup", ".progress-wrapper");
+
+            if (window.devicePixelRatio === 1 && navbar.configuration.params && !navbar.configuration.params.hideHdButton) {
+                navbar.updateParams({
+                    hideHdButton: true
+                });
+            }
         }
         }
     }
     }
 
 
@@ -535,6 +541,7 @@ export class DefaultViewer extends AbstractViewer {
     }
     }
 
 
     protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
     protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
+
         super._onConfigurationLoaded(configuration);
         super._onConfigurationLoaded(configuration);
 
 
         // initialize the templates
         // initialize the templates

+ 2 - 7
Viewer/src/viewer/viewer.ts

@@ -255,14 +255,9 @@ export abstract class AbstractViewer {
     public toggleHD() {
     public toggleHD() {
         this._hdToggled = !this._hdToggled;
         this._hdToggled = !this._hdToggled;
 
 
-        let currentLevel = this.engine.getHardwareScalingLevel();
-        const scalingFactor = 2;
+        var scale = this._hdToggled ? Math.max(0.5, 1 / (window.devicePixelRatio || 2)) : 1;
 
 
-        if (this._hdToggled) {
-            this.engine.setHardwareScalingLevel(currentLevel / scalingFactor);
-        } else {
-            this.engine.setHardwareScalingLevel(currentLevel * scalingFactor);
-        }
+        this.engine.setHardwareScalingLevel(scale);
     }
     }
 
 
     /**
     /**

+ 2 - 3
src/Animations/babylon.animationGroup.ts

@@ -270,9 +270,8 @@ module BABYLON {
                 return this;
                 return this;
             }
             }
 
 
-            for (var index = 0; index < this._animatables.length; index++) {
-                let animatable = this._animatables[index];
-                animatable.stop();
+            while (this._animatables.length > 0) {
+                this._animatables[0].stop();
             }
             }
 
 
             this._isStarted = false;
             this._isStarted = false;

+ 73 - 0
tests/unit/babylon/src/Animations/babylon.animationGroup.tests.ts

@@ -0,0 +1,73 @@
+/**
+ * Describes the test suite.
+ */
+describe('Babylon Animation Group', function () {
+    let subject: BABYLON.Engine;
+
+    /**
+     * Loads the dependencies.
+     */
+    before(function (done) {
+        this.timeout(180000);
+        (BABYLONDEVTOOLS).Loader
+            .useDist()
+            .load(function () {
+                // Force apply promise polyfill for consistent behavior between PhantomJS, IE11, and other browsers.
+                BABYLON.PromisePolyfill.Apply(true);
+                done();
+            });
+    });
+
+    /**
+     * Create a new engine subject before each test.
+     */
+    beforeEach(function () {
+        subject = new BABYLON.NullEngine({
+            renderHeight: 256,
+            renderWidth: 256,
+            textureSize: 256,
+            deterministicLockstep: false,
+            lockstepMaxSteps: 1
+        });
+
+        // Avoid creating normals in PBR materials.
+        subject.getCaps().standardDerivatives = true;
+    });
+
+    /**
+     * Animation group tests.
+     */
+    describe('#AnimationGroup', () => {
+        it('start and stop', () => {
+            const scene = new BABYLON.Scene(subject);
+            const node = new BABYLON.TransformNode("node0", scene);
+
+            const animationGroup = new BABYLON.AnimationGroup("animationGroup0", scene);
+
+            const length = 10;
+            for (let i = 0; i < length; i++) {
+                const animation = new BABYLON.Animation(`animation${i}`, "", 1, BABYLON.Animation.ANIMATIONTYPE_VECTOR3);
+                animation.setKeys([
+                    {
+                        frame: 0,
+                        value: BABYLON.Vector3.Zero()
+                    },
+                    {
+                        frame: 1,
+                        value: BABYLON.Vector3.Zero()
+                    }
+                ]);
+
+                animationGroup.addTargetedAnimation(animation, node);
+            }
+
+            animationGroup.start();
+            expect(animationGroup.animatables.length, "animationGroup.animatables.length").to.equal(length);
+            expect(scene.animatables.length, "scene.animatables.length").to.equal(length);
+
+            animationGroup.stop();
+            expect(animationGroup.animatables.length, "animationGroup.animatables.length").to.equal(0);
+            expect(scene.animatables.length, "scene.animatables.length").to.equal(0);
+        });
+    });
+});

+ 1 - 0
tests/unit/karma.conf.js

@@ -16,6 +16,7 @@ module.exports = function (config) {
             './tests/unit/babylon/babylon.example.tests.js',
             './tests/unit/babylon/babylon.example.tests.js',
             './tests/unit/babylon/serializers/babylon.glTFSerializer.tests.js',
             './tests/unit/babylon/serializers/babylon.glTFSerializer.tests.js',
             './tests/unit/babylon/src/babylon.node.tests.js',
             './tests/unit/babylon/src/babylon.node.tests.js',
+            './tests/unit/babylon/src/Animations/babylon.animationGroup.tests.js',
             './tests/unit/babylon/src/Helpers/babylon.particleHelper.tests.js',
             './tests/unit/babylon/src/Helpers/babylon.particleHelper.tests.js',
             './tests/unit/babylon/src/Loading/babylon.sceneLoader.tests.js',
             './tests/unit/babylon/src/Loading/babylon.sceneLoader.tests.js',
             './tests/unit/babylon/src/PostProcess/babylon.postProcess.tests.js',
             './tests/unit/babylon/src/PostProcess/babylon.postProcess.tests.js',