no, because I need a fixed location of the model near my smartphone.
The idea is to start the experience, see the 3d model in front of me and can walk around the model.
With relativeLocation the model will always move away and I can't walk around.
Greetings
Raimund
A
Andreas Fötschl
said
almost 8 years ago
So you want to use an absolute position which is set nearby the user ;-)
I recommend yo create an AR experience which waits for the first onLocationChanged-event in JS and then use slighly adjusted lat/lon values for the AR.Location of the 3D Model in Geo.
Note that this scenario heaviliy relies on the accuracy of your location strategy. On iOS you get best possible location already out of the box, but on Android you need to make use of e.g. GooglePlayServices (find out more).
Best regards
R
Raimund Koestler
said
almost 8 years ago
Hi Andreas,
I got the location of my smartphone now,
locationChanged: function locationChangedFn(lat, lon, alt, acc) { // the current location's latitude, longitude, altitude and accuracy // are passed in by the ARchitect if (World.userlocation==null) { World.userlocation = {"lat": lat, "lon":lon, "alt":alt, "acc":acc}; this.createModelAtLocation(); } // alert('onLocationChanged lat: '+lat+' lon: '+lon); },
Is it possible to move a GeoObject? I found no methode.
Greetings
Raimund
R
Raimund Koestler
said
almost 8 years ago
Hi Andreas,
I have finalized my script, but it won't do what I want.
Any idea?
Raimund
var World = { loaded: false, rotating: false,
userlocation: null,
init: function initFn() { AR.context.onLocationChanged = World.locationChanged; },
locationChanged: function locationChangedFn(lat, lon, alt, acc) { // the current location's latitude, longitude, altitude and accuracy // are passed in by the ARchitect if (World.userlocation==null) { // World.userlocation = {"lat": lat, "lon":lon, "alt":alt, "acc":acc}; World.userlocation = new AR.GeoLocation(lat, lon, alt); World.createModelAtLocation(); } // alert('onLocationChanged lat: '+lat+' lon: '+lon); },
createModelAtLocation: function createModelAtLocationFn() {
/* First a location where the model should be displayed will be defined. This location will be relativ to the user. */ var location = new AR.RelativeLocation(World.userlocation, 0, 0, -1); /* Next the model object is loaded. */ var modelHotel = new AR.Model("assets/HotelMitFarbe002.wt3", { onLoaded: this.worldLoaded, scale: { x: 1, y: 1, z: 1 } });
/* Putting it all together the location and 3D model is added to an AR.GeoObject. */ var obj = new AR.GeoObject(location, { drawables: { cam: , } }); },
worldLoaded: function worldLoadedFn() { World.loaded = true; var e = document.getElementById('loadingMessage'); e.parentElement.removeChild(e); } };
World.init();
A
Andreas Fötschl
said
almost 8 years ago
Please use AR.Location instead to create an absolute location. Also ensure to use constructor as documented.
Best regards, Andreas
A
Anuraj SL
said
almost 7 years ago
Hi,
Do you find any way to display the Object always in front of the User? Please let me know if there any way to do that?
Thanks!
A
Andreas Fötschl
said
almost 7 years ago
Please have a look at AR.RelativeLocation, you may use it to place objects relative to the user, they will always stay e.g. 2m North to the user.
Best regards, Andreas
A
Anuraj SL
said
almost 7 years ago
Hi ,
Thanks.I have already done AR.RelativeLocation,but Object shows north to me. How to use AR.RelativeLocation to show the Object always in front of me.
Raimund Koestler