فهرست منبع

FilesInput should call _startingProcessingFilesCallback only if files have been dropped

Julien MOREAU-MATHIS 7 سال پیش
والد
کامیت
239595a52e
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 4 0
      src/Mesh/babylon.mesh.ts
  2. 9 3
      src/Tools/babylon.filesInput.ts

+ 4 - 0
src/Mesh/babylon.mesh.ts

@@ -2354,6 +2354,10 @@
             serializationObject.instances = [];
             serializationObject.instances = [];
             for (var index = 0; index < this.instances.length; index++) {
             for (var index = 0; index < this.instances.length; index++) {
                 var instance = this.instances[index];
                 var instance = this.instances[index];
+                if (instance.doNotSerialize) {
+                    continue;
+                }
+                
                 var serializationInstance: any = {
                 var serializationInstance: any = {
                     name: instance.name,
                     name: instance.name,
                     id: instance.id,
                     id: instance.id,

+ 9 - 3
src/Tools/babylon.filesInput.ts

@@ -10,7 +10,7 @@
         private _progressCallback: (progress: SceneLoaderProgressEvent) => void;
         private _progressCallback: (progress: SceneLoaderProgressEvent) => void;
         private _additionalRenderLoopLogicCallback: () => void;
         private _additionalRenderLoopLogicCallback: () => void;
         private _textureLoadingCallback: (remaining: number) => void;
         private _textureLoadingCallback: (remaining: number) => void;
-        private _startingProcessingFilesCallback: () => void;
+        private _startingProcessingFilesCallback: (files?: File[]) => void;
         private _onReloadCallback: (sceneFile: File) => void;
         private _onReloadCallback: (sceneFile: File) => void;
         private _errorCallback: (sceneFile: File, scene: Scene, message: string) => void;
         private _errorCallback: (sceneFile: File, scene: Scene, message: string) => void;
         private _elementToMonitor: HTMLElement;
         private _elementToMonitor: HTMLElement;
@@ -136,8 +136,6 @@
         }
         }
 
 
         public loadFiles(event: any): void {
         public loadFiles(event: any): void {
-            if (this._startingProcessingFilesCallback) this._startingProcessingFilesCallback();
-
             // Handling data transfer via drag'n'drop
             // Handling data transfer via drag'n'drop
             if (event && event.dataTransfer && event.dataTransfer.files) {
             if (event && event.dataTransfer && event.dataTransfer.files) {
                 this._filesToLoad = event.dataTransfer.files;
                 this._filesToLoad = event.dataTransfer.files;
@@ -148,6 +146,14 @@
                 this._filesToLoad = event.target.files;
                 this._filesToLoad = event.target.files;
             }
             }
 
 
+            if (!this._filesToLoad || this._filesToLoad.length === 0) {
+                return;
+            }
+
+            if (this._startingProcessingFilesCallback) {
+                this._startingProcessingFilesCallback(this._filesToLoad);
+            }
+
             if (this._filesToLoad && this._filesToLoad.length > 0) {
             if (this._filesToLoad && this._filesToLoad.length > 0) {
                 let files = new Array<File>();
                 let files = new Array<File>();
                 let folders = [];
                 let folders = [];