Prechádzať zdrojové kódy

Remove import animations file button from sandbox
Remove extras assignment from glTF lights (extension)
Clean up code to reflect overwrite mode only
Update animatable target equality check

noalak 5 rokov pred
rodič
commit
7c892e0aae

+ 0 - 13
loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts

@@ -81,17 +81,6 @@ export class KHR_lights implements IGLTFLoaderExtension {
         }
     }
 
-    private _assignExtras(
-        babylonObject: ObjectWithMetadata,
-        gltfProp: IProperty
-    ): void {
-        if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) {
-            const metadata = (babylonObject.metadata = babylonObject.metadata || {});
-            const gltf = (metadata.gltf = metadata.gltf || {});
-            gltf.extras = gltfProp.extras;
-        }
-    }
-
     /** @hidden */
     public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {
         return GLTFLoader.LoadExtensionAsync<ILightReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {
@@ -130,8 +119,6 @@ export class KHR_lights implements IGLTFLoaderExtension {
 
                 GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
 
-                this._assignExtras(babylonLight, node);
-
                 assign(babylonMesh);
             });
         });

BIN
sandbox/Assets/Icon_OpenAnimFile.png


+ 0 - 6
sandbox/index-local.html

@@ -56,12 +56,6 @@
                 </a>
                 <a href="javascript:void(null);" id="btnInspector" class="hidden"><img src="./Assets/Icon_EditModel.svg"
                         alt="Display inspector" title="Display inspector" /></a>
-                <a href="javascript:void(null);" id="animationFilesButton" class="hidden">
-                    <div class="custom-upload custom-upload-animation"
-                        title="Open your animation scene from your hard drive (.babylon, .gltf, .glb, .obj)">
-                        <input type="file" id="animationFiles" multiple />
-                    </div>
-                </a>
                 <div id="dropdownContent-env" class="hidden">
                 </div>
             </div>

+ 1 - 6
sandbox/index.html

@@ -67,13 +67,8 @@
                 <a href="javascript:void(null);" id="btnInspector" class="hidden"><img src="./Assets/Icon_EditModel.svg"
                         alt="Display inspector" title="Display inspector" /></a>
                 <a href="javascript:void(null);" id="animationFilesButton" class="hidden">
-                    <div class="custom-upload custom-upload-animation"
-                        title="Open your animation scene from your hard drive (.babylon, .gltf, .glb, .obj)">
-                        <input type="file" id="animationFiles" multiple />
+                    <div id="dropdownContent-env" class="hidden">
                     </div>
-                </a>
-                <div id="dropdownContent-env" class="hidden">
-                </div>
             </div>
         </div>
         <div id="logoContainer">

+ 0 - 31
sandbox/index.js

@@ -45,7 +45,6 @@ if (kiosk) {
 if (BABYLON.Engine.isSupported()) {
     var engine = new BABYLON.Engine(canvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
     var htmlInput = document.getElementById("files");
-    var htmlInputAnimation = document.getElementById("animationFiles");
     var btnInspector = document.getElementById("btnInspector");
     var errorZone = document.getElementById("errorZone");
     var btnAnimationFiles = document.getElementById("animationFilesButton");
@@ -126,9 +125,6 @@ if (BABYLON.Engine.isSupported()) {
 
     var assetContainerLoaded = function (sceneFile, babylonScene) {
         anyLoaded(babylonScene);
-
-        // Fix for IE, otherwise it will change the default filter for files selection after first use
-        htmlInputAnimation.value = "";
     }
 
     var sceneLoaded = function (sceneFile, babylonScene) {
@@ -307,33 +303,6 @@ if (BABYLON.Engine.isSupported()) {
             }
             filesInput.loadFiles(event);
         }, false);
-
-
-        var reload = function (sceneFile) {
-            // If a scene file has been provided
-            if (sceneFile) {
-                var onSuccess = function (scene) {
-                    assetContainerLoaded(sceneFile, scene);
-                };
-                BABYLON.SceneLoader.ImportAnimations("file:", sceneFile, currentScene, null, onSuccess);
-            }
-            else {
-                Logger.Error("Please provide a valid .babylon file.");
-            }
-        };
-        filesInputAnimation = new BABYLON.FilesInput(engine, null, null, null, null, null, startProcessingFiles, reload, sceneError);
-
-        htmlInputAnimation.addEventListener('change', function (event) {
-            // Handling data transfer via drag'n'drop
-            if (event && event.dataTransfer && event.dataTransfer.files) {
-                filesToLoad = event.dataTransfer.files;
-            }
-            // Handling files from input files
-            if (event && event.target && event.target.files) {
-                filesToLoad = event.target.files;
-            }
-            filesInputAnimation.loadFiles(event);
-        }, false);
     }
 
     window.addEventListener("keydown", function (event) {

+ 2 - 9
src/Loading/sceneLoader.ts

@@ -1013,7 +1013,7 @@ export class SceneLoader {
         }
         scene.stopAllAnimations();
         scene.animationGroups.slice().forEach(animationGroup => {
-            // animationGroup.dispose();
+            animationGroup.dispose();
         });
         let animatableObjects = this._getAllAnimatableObjects(scene);
         animatableObjects.forEach(animatableObject => {
@@ -1064,13 +1064,6 @@ export class SceneLoader {
 
         // Copy animation groups
         animationAssetContainer.animationGroups.slice().forEach(animationGroupInAC => {
-            // Dispose animation groups with same name as one being loaded
-            scene.animationGroups.forEach(animationGroup => {
-                if (animationGroup.name == animationGroupInAC.name) {
-                    animationGroup.dispose();
-                }
-            })
-
             // Clone the animation group and all its animatables
             animationGroupInAC.clone(animationGroupInAC.name, _targetConverter);
 
@@ -1085,7 +1078,7 @@ export class SceneLoader {
             let target = _targetConverter(animatable.target);
 
             // If the animatable has just been loaded
-            if (target && target != animatable.target) {
+            if (target && target !== animatable.target) {
                 // Clone the animatable and retarget it
                 scene.beginAnimation(target, animatable.fromFrame, animatable.toFrame, animatable.loopAnimation, animatable.speedRatio, animatable.onAnimationEnd ? animatable.onAnimationEnd : undefined, undefined, true, undefined, animatable.onAnimationLoop ? animatable.onAnimationLoop : undefined);