Browse Source

Revert auto play to first animation group when loading a glTF file

noalak 5 years ago
parent
commit
669a6a3dcb
2 changed files with 4 additions and 5 deletions
  1. 0 1
      dist/preview release/what's new.md
  2. 4 4
      sandbox/index.js

+ 0 - 1
dist/preview release/what's new.md

@@ -93,7 +93,6 @@
 - Added diff navigator in the playground ([sailro](http://www.github.com/sailro))
 - Added custom filter to remove internals from the completion in the playground ([sailro](http://www.github.com/sailro))
 - Added support for tagging deprecated members (both in editor and for completion) in the playground ([sailro](http://www.github.com/sailro))
-- Updated the sandbox to autoplay the last animation group loaded instead of the first one ([noalak](https://github.com/noalak/))
 
 ### Meshes
 

+ 4 - 4
sandbox/index.js

@@ -86,7 +86,7 @@ if (BABYLON.Engine.isSupported()) {
         engine.resize();
     });
 
-    var anyLoaded = function(babylonScene) {
+    var anyLoaded = function(babylonScene, playFirstAnimationGroup) {
         // Clear dropdown that contains animation names
         dropdownContent.innerHTML = "";
         animationBar.style.display = "none";
@@ -98,7 +98,7 @@ if (BABYLON.Engine.isSupported()) {
                 var group = babylonScene.animationGroups[index];
                 createDropdownLink(group, index);
             }
-            currentGroupIndex = babylonScene.animationGroups.length - 1;
+            currentGroupIndex = playFirstAnimationGroup ? 0 : babylonScene.animationGroups.length - 1;
             currentGroup = babylonScene.animationGroups[currentGroupIndex];
             currentGroup.play(true);
         }
@@ -127,7 +127,7 @@ if (BABYLON.Engine.isSupported()) {
     var sceneLoaded = function (sceneFile, babylonScene) {
         engine.clearInternalTexturesCache();
 
-        anyLoaded(babylonScene);
+        anyLoaded(babylonScene, true);
 
         // Fix for IE, otherwise it will change the default filter for files selection after first use
         htmlInput.value = "";
@@ -135,7 +135,7 @@ if (BABYLON.Engine.isSupported()) {
         currentScene = babylonScene;
 
         babylonScene.onAnimationFileImportedObservable.add((scene) => {
-            anyLoaded(scene);
+            anyLoaded(scene, false);
         });
 
         document.title = "Babylon.js - " + sceneFile.name;