cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Include Java Script Dokuments

mn1
14-Alexandrite
14-Alexandrite

Include Java Script Dokuments

Hi there,

is there a possibility to include .js files ? 

I need to use the function round of math.js.

 

Thanks for help.

 

ACCEPTED SOLUTION

Accepted Solutions

I think the math module should be already available as part of node.js installation. When I check my Vuforia Studio installation I could find it  in folder:

C:\Users\<my_user_name>\Documents\VuforiaStudio\Projects\node_modules\three\src\math\Math.js

I think to access it you need to call some think like Math.round()

In generally it should be possible to use an external module. I think  C:\Users\<your_user_name>\Documents\VuforiaStudio\Projects\<your_projectName>\extensions  or extensions\js ... could be a good location where you can try to save the additional javaScript library file / I could remember that some time added libraries but could not find such example now. I think you must add also the path to runtimeExtensions.json file

But there is another simple way in JavaScript. So for example you can upload the javaScript file to you resource/Uploaded project directory and  load it by JavaScript e.g. :

 

//---------------START Loading the API----------------------- 
$scope.loadMyScript = function() {
  $scope.asyncLoadScript("app/resources/Uploaded/myJavaScriptFile.js")
    .then(function() { 
   console.log("myJavaScriptFile.js was loaded successfully" }, 
          function() { 
    console.log("there something went wrong""); 
 
  });
}
//---------------END Loading the API----------------------- 
        

 

View solution in original post

3 REPLIES 3

I think the math module should be already available as part of node.js installation. When I check my Vuforia Studio installation I could find it  in folder:

C:\Users\<my_user_name>\Documents\VuforiaStudio\Projects\node_modules\three\src\math\Math.js

I think to access it you need to call some think like Math.round()

In generally it should be possible to use an external module. I think  C:\Users\<your_user_name>\Documents\VuforiaStudio\Projects\<your_projectName>\extensions  or extensions\js ... could be a good location where you can try to save the additional javaScript library file / I could remember that some time added libraries but could not find such example now. I think you must add also the path to runtimeExtensions.json file

But there is another simple way in JavaScript. So for example you can upload the javaScript file to you resource/Uploaded project directory and  load it by JavaScript e.g. :

 

//---------------START Loading the API----------------------- 
$scope.loadMyScript = function() {
  $scope.asyncLoadScript("app/resources/Uploaded/myJavaScriptFile.js")
    .then(function() { 
   console.log("myJavaScriptFile.js was loaded successfully" }, 
          function() { 
    console.log("there something went wrong""); 
 
  });
}
//---------------END Loading the API----------------------- 
        

 

mn1
14-Alexandrite
14-Alexandrite
(To:RolandRaytchev)

Hi @RolandRaytchev 

If I copy your codelines i get the error:

ionic.bundle.min.js:150 TypeError: $scope.asyncLoadScript is not a function

 

In my folder I coudn´n find math.js.

 

Thanks for help.

I am sorry , I forgot , of course, to provide the function definition:

scope.asyncLoadScript = function (fname) {
  return new Promise((resolve, reject) => {
    if(fname) {
      var head = document.head || document.getElementsByTagName('head')[0],
          script = document.createElement('script');
      script.async = true;
      script.onload = resolve;
      script.onerror = reject;
      script.type = 'text/javascript';
      script.src=fname;
      head.appendChild(script);
    }
  });
}

 

Announcements

Top Tags