wikitude-sdk-samples
wikitude-sdk-samples copied to clipboard
architect.js not working
Hi,
I am following the guides from the wikitude cordova documentation. When I am running my application, I am getting an error when trying to load a AR object. The actual error code I get is:
[console.log] Error in Success callbackId: WikitudePlugin1329171891 : ReferenceError: AR is not defined
explore.html `
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/explore.js"></script>
<title>Explore</title>
</head>
<body>
</body>
`
explore.js `var app = {
//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();
},
bindEvents: function(){
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
app.wikitudePlugin.isDeviceSupported(app.onDeviceSupported, app.onDeviceNotSupported, app.requiredFeatures);
},
onDeviceSupported: function(){
alert("Device Supported");
app.wikitudePlugin.loadARchitectWorld(
app.onARExperienceLoadedSuccessful,
app.onARExperienceLoadError,
app.arExperienceUrl,
app.requiredFeatures,
app.startupConfiguration
);
},
onDeviceNotSupported: function(errorMessage){
alert("No support for device: " + errorMessage);
},
loadPoisFromJsonData: function(poiData){
alert(poiData.latitude + " : " + poiData.longitude);
// start loading marker assets
app.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(!app.initiallyLoadedData){
var poiData = {
"id": 1,
"longitude": 2.992115,
"latitude": 55.959722,
"altitude": 100.0
};
app.loadPoisFromJsonData(poiData);
app.initiallyLoadedData = true;
}
},
onARExperienceLoadError: function(errorMessage){
alert("Error in Loading AR experience: " + errorMessage);
}
};
app.initialize();`