var World = { //true once data is fetched initiallyLoadedData: false, //POI-Marker Assets markerDrawable_idle: null, //URL/Path to the augmented reality experience you would like to load arExperienceUrl: "../explore.html", //The features your augmented reality experience requires, only define the ones you really need requiredFeatures: ["2d_tracking", "geo"], //Represents the device capabilities of launching AR experiences with specific features isDeviceSupport: false, //Additional startup settings, for now the only setting available is camera_position startupConfiguration: { "camera_position": "back" }, // Application Constructor initialize: function() { this.bindEvents(); alert("init"); }, bindEvents: function(){ document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // Bind any cordova events here. Common events are: // 'pause', 'resume', etc. onDeviceReady: function() { World.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin"); World.wikitudePlugin.isDeviceSupported(World.onDeviceSupported, World.onDeviceNotSupported, World.requiredFeatures); }, onDeviceSupported: function(){ alert("Device Supported"); World.wikitudePlugin.loadARchitectWorld( World.onARExperienceLoadedSuccessful, World.onARExperienceLoadError, World.arExperienceUrl, World.requiredFeatures, World.startupConfiguration ); }, onDeviceNotSupported: function(errorMessage){ alert("No support for device: " + errorMessage); }, loadPoisFromJsonData: function(poiData){ alert(poiData.latitude + " : " + poiData.longitude); // start loading marker assets World.markerDrawable_idle = new AR.ImageResource("../assets/marker_idle.png"); var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude); var markerImageDrawable_idle = new AR.ImageDrawable(markerDrawable_idle, 2.5, { zOrder: 0, opacity: 1.0 }); //create GeoObject var markerObject = new AR.GeoObject(markerLocation, { drawable:{ cam: [markerImageDrawable_idle] } }); console.log('1 place loaded'); }, onARExperienceLoadedSuccessful: function(loadedURL){ alert("AR experience loaded"); // request data if not already present if(!World.initiallyLoadedData){ var poiData = { "id": 1, "longitude": 2.992115, "latitude": 55.959722, "altitude": 100.0 }; World.loadPoisFromJsonData(poiData); World.initiallyLoadedData = true; } }, onARExperienceLoadError: function(errorMessage){ alert("Error in Loading AR experience: " + errorMessage); } }; World.initialize();