Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi there,
is there a possibility to include .js files ?
I need to use the function round of math.js.
Thanks for help.
Solved! Go to Solution.
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-----------------------
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-----------------------
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); } }); }