Start a new topic

Dynamically create world and pass to loadARchitectWorld()

I'm developing an AR app using wikitude phonegap plugin.

It has been working well so far, but I got struck in this step where I want to create the overlays & world dynamically and pass it to loadARchitectWorld(), rather than calling a html.

This is what I have at the moment. Here I load the www/world.html file as the world. In that file I have no html tags. It's just the Javascript functions to create the overlays.

  startAR: function() {
    app.wikitudePlugin.loadARchitectWorld(
      app.onARExperienceLoadedSuccessful,
      app.onARExperienceLoadError,
      "www/world.html",
      [ "2d_tracking"],
      {"camera_position": "back"}
    );
  }

 

Content of world.html:

<script src="architect://architect.js"></script>
<script type="text/javascript" src="js/world.js"></script>

 

However, I noticed that when I call this loadARchitectWorld() function, it starts a new webview and I'm not able to access any of my Js variables inside the world.js file.

What I actually want to do is to connect to the database, then read what overlays has been created and load them into the world, so that they can be tracked. I already have the db object created and I want to be able to access them inside the world.js file. But it's not practical because the world is opened in a new webview.

Is there anyway to create the overlays dynamically and pass it to loadARchitectWorld() function? Something like, instead of giving a url of the world.html file,can I create a js object with overlays and pass it to loadARchitectWorld(),


I hope this is clear? I'm using the version 5.3 of the SDK. I'm sorry if I'm not clear enough. Please ask me if you want any further clarifications. Thanks in advance!


Hi Amaury,

Thx for your feedback regarding the Cordova Plugin architecture. As developer feedback is very valuable for us, we're making sure that this feedback gets to our developers. As for the Ionic Plugin - we have this alread on our feature list, but not on our current roadmap.

Greetings

Nicola

 

To wikitude team : also I cannot find these two functions in the new forum :

- a "quote" function 

- a "edit my message" function (!!)

Nimeshka Srimal has said :

What I actually want to do is to connect to the database, then read what overlays has been created and load them into the world, so that they can be tracked. I already have the db object created and I want to be able to access them inside the world.js file. But it's not practical because the world is opened in a new webview.

 Hey Nimeshka,


I think that the best for you would be to load all the info from your database directly in world.js (in the new webview). The loadARchitectWorld is just here to instantiate the AR webview, and from this new webview you can do some XHR request to your server/db, and create new overlays dynamically based on the result.


To wikitude team : this double webview architecture is a bit limitating :
- it is confusing for beginners.
- the ways of passing data between the cordova and AR webview are limited, only small strings can be used as parameter (in particular with the architectsdk:// urls). 

- moreover it makes thing difficult when we want to integrate js framework like ionic.


Are you planning something new to overcome these limitations ?! Or even better a proper ionic 2 plugin ? That would be great :-)


Hi Nimeshka,

Unfortunately this is not possible as you need to pass the url as a parameter in the function you are calling.

Thanks
Eva

 

Hi Eva,

Thanks for the reply. I tried the WikitudePlugin.callJavascript() function. But that only allows passing string parameters.

What I really want to do is pass an object from phonegap side to the AR view (ARchitect?)

I'm not able to define the overlays in the world.html file because I can't access my phonegap instance there. The problem is that "the world" opens in a new web view.

Is there any other function like callJavascript which I can use to pass variables instead of strings ?

Thank you!!
Hello Nimeshka,

 

Could you please refer to the forum post here and let me know if this solves your issue?


Thanks

Eva

Login or Signup to post a comment