Sfoglia il codice sorgente

download manager step 1

David `Deltakosh` Catuhe 5 anni fa
parent
commit
be15ee0d39

+ 11 - 0
Playground/src/components/rendererComponent.tsx

@@ -4,6 +4,7 @@ import {Engine} from "babylonjs/Engines/engine"
 import { Nullable } from 'babylonjs/types';
 import { Scene } from 'babylonjs/scene';
 import { Utilities } from '../tools/utilities';
+import { DownloadManager } from '../tools/downloadManager';
 
 require("../scss/rendering.scss");
 
@@ -15,6 +16,7 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
     private _engine: Nullable<Engine>;
     private _scene: Nullable<Scene>;
     private _canvasRef: React.RefObject<HTMLCanvasElement>;
+    private _downloadManager: DownloadManager;
 
     public constructor(props: IRenderingComponentProps) {
         super(props);
@@ -29,6 +31,15 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
         this.props.globalState.onRunRequiredObservable.add(() => {
            this.compileAndRun();
         });
+
+        
+        this._downloadManager = new DownloadManager();
+        this.props.globalState.onDownloadRequiredObservable.add(() => {
+            if (!this._engine) {
+                return;
+            }
+            this._downloadManager.download(this._engine);
+        });
     }
 
     compileAndRun() {

+ 50 - 0
Playground/src/tools/downloadManager.ts

@@ -0,0 +1,50 @@
+import { Engine } from 'babylonjs/Engines/engine';
+
+export class DownloadManager {
+
+    public download(engine: Engine) {
+        // var zip = new JSZip();
+
+        // var scene = engine.scenes[0];
+        // var textures = scene.textures;
+        // var importedFiles = scene.importedMeshesFiles;
+
+        // document.getElementById("statusBar").innerHTML = "Creating archive... Please wait.";
+
+        // var regex = /CreateGroundFromHeightMap\(".+", "(.+)"/g;
+
+        // do {
+        //     let match = regex.exec(this.zipCode);            
+
+        //     if (!match) {
+        //         break;
+        //     }
+
+        //     textures.push({ name: match[1] });
+        // } while(true);
+
+
+        // this.addContentToZip(zip,
+        //     "index.html",
+        //     "/zipContent/index.html",
+        //     this.zipCode,
+        //     false,
+        //     function () {
+        //         this.addTexturesToZip(zip,
+        //             0,
+        //             textures,
+        //             null,
+        //             function () {
+        //                 this.addImportedFilesToZip(zip,
+        //                     0,
+        //                     importedFiles,
+        //                     null,
+        //                     function () {
+        //                         var blob = zip.generate({ type: "blob" });
+        //                         saveAs(blob, "sample.zip");
+        //                         document.getElementById("statusBar").innerHTML = "";
+        //                     }.bind(this));
+        //             }.bind(this));
+        //     }.bind(this));
+    }
+}