Pārlūkot izejas kodu

Add a scene callback to animation file import

noalak 5 gadi atpakaļ
vecāks
revīzija
3130b945ec
3 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. 4 0
      sandbox/index.js
  2. 2 0
      src/Loading/sceneLoader.ts
  3. 5 0
      src/scene.ts

+ 4 - 0
sandbox/index.js

@@ -135,6 +135,10 @@ if (BABYLON.Engine.isSupported()) {
 
         currentScene = babylonScene;
 
+        babylonScene.onAnimationFileImportedObservable.add((scene) => {
+            anyLoaded(scene);
+        });
+
         document.title = "Babylon.js - " + sceneFile.name;
 
         btnInspector.classList.remove("hidden");

+ 2 - 0
src/Loading/sceneLoader.ts

@@ -1029,6 +1029,8 @@ export class SceneLoader {
 
             container.dispose();
 
+            scene.onAnimationFileImportedObservable.notifyObservers(scene);
+
             if (onSuccess) {
                 onSuccess(scene);
             }

+ 5 - 0
src/scene.ts

@@ -627,6 +627,11 @@ export class Scene extends AbstractScene implements IAnimatable {
     public onMeshImportedObservable = new Observable<AbstractMesh>();
 
     /**
+     * This Observable will when an animation file has been imported into the scene.
+     */
+    public onAnimationFileImportedObservable = new Observable<Scene>();
+
+    /**
      * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
      * By default this function is undefined and Babylon.js will select LOD based on distance to camera
      */