Start a new topic

GEOLOCATION GPS

GEOLOCATION GPS


Hello, 

i do'nt find the working way to put a 3D model on a fixed position gps...

IS it really possible with wikitude tu put on gps point a 3dmodel, and is it possible to trun around this model in a fixed position ( and real )... because when i move 3d model move... i dont understand how to do !!! please help me lol...

 

thanks

Hello Ced,

If you wish to work with Geo Location and not relative location then you can refer to the sample code below and simply replace our 3D model with your 3D model. Please keep in mind that 3D models are renderred in a special way in Geo splace which means that the 3D model will always look for example in the user's direction.

var World = {
loaded: false,
rotating: false,
created: false,

init: function initFn() {

// wait for first location signal before creating the experience to ensure you know user's location during setup process
AR.context.onLocationChanged = function(latitude, longitude, altitude, accuracy){

// store user's location so you have access to it at any time
World.myLocation = {"latitude": latitude, "longitude" : longitude, "altitude" : altitude };

document.getElementById('fetchingLocation').innerHTML = (World.myLocation.latitude + ", " + World.myLocation.longitude);
if (!World.created) {
World.created = true;
World.createModelAtLocation();
}
};


},

createModelAtLocation: function createModelAtLocationFn() {

// place object around the user, in this case just a few meters next to the user. Note that the object will stay where it is, so user can move around it.
var geoLocation = new AR.GeoLocation(World.myLocation.latitude + 0.00001, World.myLocation.longitude + 0.00001, AR.CONST.UNKNOWN_ALTITUDE);

/*
you may also use relativeLocation using null as first param to display an object relative to the user. This sample uses GeoLocation to show that it also works without Relative locations
*/
// var location = new AR.RelativeLocation(null, 1, 1, 0);



/*
Next the model object is loaded.
*/
var modelEarth = new AR.Model("assets/earth.wt3", {
onLoaded: this.worldLoaded,
scale: {
x: 0.5,
y: 0.5,
z: 0.5
}
});

var indicatorImage = new AR.ImageResource("assets/indi.png");

var indicatorDrawable = new AR.ImageDrawable(indicatorImage, 0.1, {
verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP
});

/*
Putting it all together the location and 3D model is added to an AR.GeoObject.
*/
var obj = new AR.GeoObject(geoLocation, {
drawables: {
cam: ,
indicator:
}
});
},

worldLoaded: function worldLoadedFn() {
World.loaded = true;
var e = document.getElementById('loadingMessage');
e.parentElement.removeChild(e);
}
};

World.init();

 

 

Hello Eva,

i must be so bad in dev... because i have tried your example... and model move with me ... when i move it 's stay a relative location about me...

i d'ont undertand why...

Hi,

Sorry for the confusion - the sample code is showing how you can display a 3D model based on a RelativeLocation. Please check this thread:

https://support.wikitude.com/support/search/topics?term=ios+ipad2+geolocation

This explains what you need to change to use real lat/lon values.

Greetings

Nicola
Login or Signup to post a comment