Start a new topic

Dynamically loading wtc

Dynamically loading wtc


Hello, I'm using cordova plugin wikitude and I have a problem: I want to download a .wtc file and save in memory of device and after pass the path of this one for initialize AR.ClientTracker. For download the file .wtc I'm using another plugin (cordova plugin file transfer) and it works very well. Now this plugin return the path of the file that is difference beetwen Android and iOs. My goal is pass this path to plugin wikitude in inizialization. This is my js in cordova part:

var app = {

 

     isDeviceSupported: false,

 

     initialize: function() {

         app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");

         app.loadARchitectWorld();

     },

 

     loadARchitectWorld: function() {

 

     var example = {

          "path": "www/world/1_ClientRecognition_4_Interactivity/index.html",

          "requiredFeatures": ,

          "startupConfiguration": {

               "camera_position": "back"

          }

     };

 

 

     app.wikitudePlugin.isDeviceSupported(function() {

 

          app.wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {

 

               app.wikitudePlugin.callJavaScript("setTracker('"+localStorageService.get("path_wtc")+"');");

 

          }, function errorFn(error) {

               alert('Loading AR web view failed: ' + error);

          },

          example.path, example.requiredFeatures, example.startupConfiguration

     );

     }, function(errorMessage) {

          alert(errorMessage);

     },

     example.requiredFeatures

     );

     }

};

 

app.initialize();

 

This is the code in my World:

 


var World = {

     loaded: false,

 

     init: function initFn() {

          this.createOverlays();

     },

 

     createOverlays: function createOverlaysFn() {

          this.tracker = new AR.ClientTracker(window.pathFile);

 

     var imgOne = new AR.ImageResource("assets/imageOne.png");

     var overlayOne = new AR.ImageDrawable(imgOne, 1, {

          offsetX: -0.15,

          offsetY: 0

     });

 

     var pageOne = new AR.Trackable2DObject(this.tracker, "*", {

          drawables: {

               cam: overlayOne

          }

     });

}

};

 

function setTracker(pathFile) {

     console.log("Path del file: "+pathFile);

     window.path = pathFile;

     World.init();

}

 

Sfortunatly this code works on Android but doesn't work on iOs...where is the problem??? Do you have ideas??? Thanks!!!

Hi LoZio,
cdvfile:// urls are not supported. Have you tried to use the .toURL() function to convert the .wtc path into a proper platform path?

Best regards

Andreas
Login or Signup to post a comment