Konstantin Ladutenko 4 years ago
parent
commit
b6117bf192
3 changed files with 41 additions and 46 deletions
  1. 1 1
      Makefile
  2. 1 2
      vue-cli3-webapp/package.json
  3. 39 43
      vue-cli3-webapp/src/App.vue

+ 1 - 1
Makefile

@@ -58,7 +58,7 @@ wasm: $(SRCDIR)/nmie-js-wrapper.cc $(CXX_NMIE_HEADERS)
 #	emcc --bind -lm -Wall -O2 -std=c++11 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
 
 # 	emcc --bind -lm -Wall -O2 -std=c++11 -s MODULARIZE=1 -s WASM=1 -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc
-	emcc --bind -lm -Wall -O2 -std=c++11 -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+	emcc --bind -lm -Wall -Oz -std=c++11 -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
 #	emcc --bind -lm -Wall -O3 -std=c++11 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="nmiejs"' -o ./nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
 
 # 	emcc -g --bind -lm -Wall -std=c++11 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc

+ 1 - 2
vue-cli3-webapp/package.json

@@ -16,8 +16,7 @@
     "cubic-spline": "^3.0.3",
     "js-yaml": "^3.14.1",
     "plotly.js": "^1.58.4",
-    "vue": "^2.6.12",
-    "wasi": "^0.0.6"
+    "vue": "^2.6.12"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^4.5.12",

+ 39 - 43
vue-cli3-webapp/src/App.vue

@@ -126,45 +126,31 @@
   // );
 
   import nmiejs from './nmiejs.js';
-  const module = nmiejs({
-    locateFile(path) {
-      let deploy_path = process.env.BASE_URL;
-      // '/themes/custom/physics/mie/';
-      // console.log();
-      // // let deploy_path = '';
-      console.log(deploy_path+path);
-      return deploy_path+path;
-    }
-  }).then(function (module){
-    const nmie = new module.nmie();
-      nmie.ClearTarget();
-      let R = 100.0;
-      let reN = 4.0;
-      let imN = 0.01;
-      nmie.AddTargetLayerReIm(R, reN, imN)
-      nmie.SetModeNmaxAndType(-1, -1);
-      let WL = 800;
-      nmie.SetWavelength(WL);
-      nmie.RunMieCalculation();
-      console.log(nmie.GetQsca());
-  });
-
-
   // // Test nmiejs if working
-  // module.onRuntimeInitialized = () => {
-  //   const nmie = new module.nmie();
-  //   nmie.ClearTarget();
-  //   let R = 100.0;
-  //   let reN = 4.0;
-  //   let imN = 0.01;
-  //   nmie.AddTargetLayerReIm(R, reN, imN)
-  //   nmie.SetModeNmaxAndType(-1, -1);
-  //   let WL = 800;
-  //   nmie.SetWavelength(WL);
-  //   nmie.RunMieCalculation();
-  //   console.log(nmie.GetQsca());
-  // };
-
+  // (async () => {
+  //   const module = await nmiejs({
+  //     locateFile(path) {
+  //       let deploy_path = process.env.BASE_URL;
+  //       // '/themes/custom/physics/mie/';
+  //       // console.log();
+  //       // // let deploy_path = '';
+  //       console.log(deploy_path + path);
+  //       return deploy_path + path;
+  //     }
+  //   })
+  //     const nmie = new module.nmie();
+  //       nmie.ClearTarget();
+  //       let R = 100.0;
+  //       let reN = 4.0;
+  //       let imN = 0.01;
+  //       nmie.AddTargetLayerReIm(R, reN, imN)
+  //       nmie.SetModeNmaxAndType(-1, -1);
+  //       let WL = 800;
+  //       nmie.SetWavelength(WL);
+  //       nmie.RunMieCalculation();
+  //       console.log(nmie.GetQsca());
+  //
+  // })();
 
   const range = (start, stop, step = 1) => Array(Math.ceil((stop - start) / step)).fill(start).map((x, y) => x + y * step);
 
@@ -207,7 +193,7 @@
           isSourceOtherUnits: false,
           simulationSetup: {
             hostIndex: 1,
-            stepWL: 0.5,
+            stepWL: 2,
             fromWL: 300.0,
             toWL: 1000.0,
             layers: [
@@ -225,7 +211,7 @@
           simulationRuntime: {
             r_units: 'nm',
             r_source_units: 'nm',
-            stepWL: 0.5,
+            stepWL: 2,
             fromWL: 300.0,
             toWL: 1000.0,
             layers: [
@@ -324,14 +310,24 @@
       },
     mounted() {
       this.setXaxisTitle();
-      module.onRuntimeInitialized = () => {
+      (async () => {
+        const module = await nmiejs({
+          locateFile(path) {
+            let deploy_path = process.env.BASE_URL;
+            // '/themes/custom/physics/mie/';
+            // console.log();
+            // // let deploy_path = '';
+            console.log(deploy_path + path);
+            return deploy_path + path;
+          }
+        })
         this.nmie = new module.nmie();
+        this.isLoading = false;
         this.runMie();
         this.setIsPlotMode();
         this.setModeNNames();
         this.plotResults();
-        this.isLoading = false;
-      }
+      })();
 
 
     },