Start a new topic

handle scale of 3D object

handle scale of 3D object


Hi Everyone...

 

I know I can put a 3d object in a geolocation point based on a relative position, but my question is how can i handle the scale of object based on the distance to it (from user)? ...for that the scale of the object is real in sight and distance of user

 

Please help me.

 

Regards.

 

Christian.

Hi Christian,
Please refer to the GeoLocation documentation. AR.GeoLocations have a 'distanceTo' and 'distanceToUser' function that you can use to get the distance between either two AR.GeoLocations or a GeoLocation and your current position. You can use 'AR.context.onLocationChanged' to get notified when the user location changes.

With these information, you can use AR.Model.scale.x, AR.Model.scale.y & AR.Model.scale.z to change the model scale. 

Best regards

Andreas
Please show me a example code...thanks

Hi Christian,

 

here is your snippet.

var firstLocation = new AR.GeoLocation(47.801427, 13.044800);

var secondLocation = new AR.GeoLocation(47.800526, 13.044403);

 

var distanceInMeter = firstLocation.distanceTo(secondLocation);

 

 

var thirdLocation = new AR.GeoLocation(47.801096, 13.041893);

var distanceToUser = thirdLocation.distanceToUser();

 

Please read through our JavaScript API reference as it already contains code snippets for various functions, including the AR.GeoLocation and AR.RelativeLocation API!

 


Best regards

Andreas
Login or Signup to post a comment