Start a new topic

Geo AR for indoor

Suppose that I can get a decently accurate localization using beacons. Can the Wikitude SDK give me the possibility to navigate around a 3d model placed with geospatial coordinates (in a similar way as I navigate around a 3d model placed with the Instant Tracking Demo of Wikitude I found on Github)


I tried to place an object at a given position near myself, but when I try to navigate around it, it looks like the object moves with me. (The 3d model always show me the same face). 


I want to know if I'm using the Geo AR feature improperly or it is possible to achieve what I need.


This is the code I use to place the 3d model (I place it on my current position and then I try to navigate around it)


/* Implementation of AR-Experience (aka "World"). */
var World = {
/* True once data was fetched. */
initiallyLoadedData: false,

/* pOI-Marker asset. */
markerDrawableIdle: null,

/* Called to inject new POI data. */
loadPoisFromJsonData: function loadPoisFromJsonDataFn(poiData) {

/*
The example Image Recognition already explained how images are loaded and displayed in the augmented
reality view. This sample loads an AR.ImageResource when the World variable was defined. It will be
reused for each marker that we will create afterwards.
*/

/*
For creating the marker a new object AR.GeoObject will be created at the specified geolocation. An
AR.GeoObject connects one or more AR.GeoLocations with multiple AR.Drawables. The AR.Drawables can be
defined for multiple targets. A target can be the camera, the radar or a direction indicator. Both the
radar and direction indicators will be covered in more detail in later examples.
*/
var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude);
var saturnModel = new AR.Model("assets/saturn.wt3", {
scale: {
x: 0.5,
y: 0.5,
z: 0.5
},
onClick: function logga(geoObject){
var loc = geoObject.locations[0];
document.getElementById('status-message').innerHTML =
loc.distanceToUser() + ' ' + loc.latitude + ' ' +loc.longitude;

}
});

/* Create GeoObject. */
var markerObject = new AR.GeoObject(markerLocation, {
drawables: {
cam: [saturnModel]
}
});

/* Updates status message as a user feedback that everything was loaded properly. */
World.updateStatusMessage('1 place loaded');
},

/* Updates status message shown in small "i"-button aligned bottom center. */
updateStatusMessage: function updateStatusMessageFn(message, isWarning) {

var themeToUse = isWarning ? "e" : "c";
var iconToUse = isWarning ? "alert" : "info";

$("#status-message").html(message);
$("#popupInfoButton").buttonMarkup({
theme: themeToUse,
icon: iconToUse
});
},

/* Location updates, fired every time you call architectView.setLocation() in native environment. */
locationChanged: function locationChangedFn(lat, lon, alt, acc) {

/*
The custom function World.onLocationChanged checks with the flag World.initiallyLoadedData if the
function was already called. With the first call of World.onLocationChanged an object that contains geo
information will be created which will be later used to create a marker using the
World.loadPoisFromJsonData function.
*/

if (!World.initiallyLoadedData) {
/* Creates a poi object with a random location near the user's location. */

var poiData = {
"id": 1,
"longitude": (lon),
"latitude": (lat),
"altitude": alt
};

World.loadPoisFromJsonData(poiData);
World.initiallyLoadedData = true;
}
},

onError: function onErrorFn(error) {
alert(error)
}
};

/*
Set a custom function where location changes are forwarded to. There is also a possibility to set
AR.context.onLocationChanged to null. In this case the function will not be called anymore and no further
location updates will be received.
*/
AR.context.onLocationChanged = World.locationChanged;
1 Comment

Hi Francesco!


Please have a look at this forum post.

I think "rotate.global.x/y/z" have to be set to achieve your desired behaviour.


Best regards,
Andreas

Login or Signup to post a comment