Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

architect.js not working #19

Open
DoubleD1994 opened this issue Mar 12, 2018 · 0 comments
Open

architect.js not working #19

DoubleD1994 opened this issue Mar 12, 2018 · 0 comments

Comments

@DoubleD1994
Copy link

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 src="https://www.wikitude.com/libs/architect.js"></script>
    <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();`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant