Start a new topic

3D model at geolocation

3D model at geolocation


Could anyone post a sample project about 3D model at geolocation.Not relative location.Sory i am new to this so if i get a sample project it would be good for me.I look at the other posts and i cant figure it out.So if anyone can  send me a project it would be nice. Thanks..
Hello Mehmet,

You can follow this forum post here regarding how to position 3D Models at Geo Location
https://support.wikitude.com/support/search/topics?term=3d+geo+location

You can also refer to the sample code here on how to achieve that functionality:


 

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.0003,
y: 0.0003,
z: 0.0003
}
});

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();

 


Thank you for your answer. I was copy your code and use it and it was saying loading in the app and nothing happen.As i was said i'm very new to this stuff.So if you have complete project like other examples it would be better i think.

1 person likes this

Hi Mehmet,

You need to make sure that you have positioned all the files and images under the correct path as posted in the code or change the path in the code to reflect the absolute position of your files and images. Unfortunately I cannot provide you with a whole project but only with this sample code.

Thank you

Hello again :D. I used sample project namely 4_PointOfInterest_2_PoiWithLabel. It uses the geolocation. When i run the app it is trying to find out where i am.But i was waiting too long and notting happened.GPS was on.I tried another program like navigation and it can find where i am.So any idea why it doesn't work.I gave the permission in the masifest file.Because it cant find my location there is no label on the screen.Thank you in advence.By the way i am using trial lisence.Is this problem occour because of that.
Login or Signup to post a comment