I read the documentation but it is not clear to me what to do next.
Do I have to load the wtc with AR.ClientTracker or the index.html with wikitudePlugin.loadARchitectWorld?
I´m using the Ionic Framework with Angular.js by the way.
Thanks!
A
Andreas Schacherbauer
said
over 8 years ago
Hi Nico, You don't need to add the file 'WikitudePlugin.js' to your cordova index.html. This is done by an internal cordova mechanism when you add the WikitudePlugin to your project.
You also don't need to create a AR.ClientTracker yourself, this is done in the .js scripts that are included in the js folder of your Wikitude Studio export.
What you need to do is to package the folder structure that you got from Wikitude Studio into your cordova application. You can have a look at our Wikitude PhoneGap example application how this can be done. Once you have the folder structure in your project, use the wikitudePlugin.loadArchitectWorldFromUrl and pass the local file url which points to the Wikitude Studio index.html to load the content that you created in Wikitude Studio.
I hope this was helpfull for you
Best regards
Andreas
N
Nico
said
over 8 years ago
Hi Andreas,
thanks for the clarification but I still have questions :)
Ok, so I removed the WikitudePlugin.js and my folder structure looks like the attached screenshot.
Are you sure it´s wikitudePlugin.loadArchitectWorldFromUrl ?
And do I need to load var wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin"); ?
The code would then look like:
var wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
wikitudePlugin.loadARchitectWorld("path/to/world.html"); or wikitudePlugin.loadArchitectWorldFromUrl("path/to/world.html");
Thanks!
A
Andreas Schacherbauer
said
over 8 years ago
Sure you need var wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin"); to instantiate a Wikitude PhoneGap Plugin object.
Yes, it is loadArchitectWorld. The other method name is used in the iOS SDK - my mistake, sorry.
//initialize plugin var wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
//check if device supports AR wikitudePlugin.isDeviceSupported(function(){
console.log("Device is Supported");
//config object var world = { "path": "ar/world.html", "requiredFeatures": , "startupConfiguration": { "camera_position": "back" } };
//load the AR view wikitudePlugin.loadARchitectWorld(function successFn() {
console.log("world loaded"); }, function errorFn(error) { alert('Loading AR web view failed: ' + error); }, world.path, world.requiredFeatures, world.startupConfiguration); }, function(errorMessage) { console.log("Device is not supported !!! err " + errorMessage); }); }, false);
I dont have any JS files from the SDK included. Only the phonegap plugin is added.
When I start and debug the app on a real device (iPad) I can see the deviceready output and thats it. So even console.log("Device is Supported"); does not get called.
Do I need to load anything else? Currently I have no idea what I could test or try next...
I really need this to work! Any help would be appreciated!
THANKS!
EDIT:
When I console.log(JSON.stringify(wikitudePlugin) I get:
.... i did not include the WikitudePlugin.js, so where is this ENTER-YOUR-KEY-HERE coming from?
N
Nico
said
over 8 years ago
Ok, I got a bit further...
This is my code now:
var app = {
onDeviceReady: function() {
console.log("device ready");
// create a Wikitude Plugin instance app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
var world = { "path": "ar/world.html", "requiredFeatures": , "startupConfiguration": { "camera_position": "back" } };
// check if the current device is able to launch augmented reality experiences app.wikitudePlugin.isDeviceSupported(app.onDeviceSupported(world), app.onDeviceNotSupported, world.requiredFeatures);
app.wikitudePlugin.loadARchitectWorld(function() { /* Respond to successful world loading if you need to */ console.log("world loaded!"); }, function(error) { console.log("world NOT loaded!"); alert('Loading AR web view failed: ' + error); }, "ar/world.html" );
}, onDeviceNotSupported: function() { // ... code that is executed if the device is not supported ... console.log("device not supported!"); alert("device not supported!");
But thats it. Nothing happens :( Is there something wrong with the app.wikitudePlugin.loadARchitectWorld function?
Thanks!
A
Andreas Schacherbauer
said
over 8 years ago
In the last snippet you posted, you don't specify any requiredFeatures or startup configuration. Please pass World.path, World.requiredFeatures and World.startupConfiguration as third, fourth and fifth parameter to loadARchitectWorld.
Best regards
Andreas
N
Nico
said
over 8 years ago
Hi!
Thanks for pointing that out but I already tried it like this:
var world = { "path": "ar/world.html", "requiredFeatures": , "startupConfiguration": { "camera_position": "back" } };
app.wikitudePlugin.loadARchitectWorld(function successFn() { /* Respond to successful world loading if you need to */ console.log("world loaded!"); }, function errorFn(error) { console.log("world NOT loaded!"); }, world.path, world.requiredFeatures, world.startupConfiguration );
A
Andreas Schacherbauer
said
over 8 years ago
On which device do you test? Android, iOS? Version?
Have you checked the log output from your IDE?
Best regards
Andreas
A
Andreas Schacherbauer
said
over 8 years ago
can you verify that the relative path is correct? Please compare your relative path with the ones we use in the Wikitude PhoneGap exmaple application.
Best regards
Andreas
N
Nico
said
over 8 years ago
I wasn't sure about the path but I tried a lot of combinations... is it realtive to the www directory or to the js file in which it is included?
Nico