Start a new topic

Position 3D object on the middle of the Screen?

Position 3D object on the middle of the Screen?


Hello! 

I am trying to position a 3D Model in the middle of the screen and it does not always work. I do not use Trackable2DObject and thus cannot make use of snap to screen feature. The way it works for me now is with RelativeLocation with null for its location: 

var location1 =   new AR.RelativeLocation(null, 0, 0, 0); 

        var geoObject1 = new AR.GeoObject(location1, {

               drawables: {

                    cam:

                } 

       });

 

The code works very well and positions my 3D model exactly in the middle of the screen only when Location permission is OFF for my app. However if Location updates are enabled the 3D Model appears at a different place on the screen every time I load the view. 


Is there a way of positioning a 3D model in the middle of the camera view or may be simulate the Location updates are off with JavaScript when "onLoaded" is called?  I do need WTFeature_Geo set because there are other features that Use GeoLocation. 

 

Thank you very much for your advise!

 

 

Hi,

I assume you are using the Android SDK: the location provider is an external component, implemented by your application, and does not belong to the SDK itself.
You can implement the location update in your code, and handle the location events in Javascript using the "AR.context.onLocationChanged" callback function.

Such a mechanism is implemented in our sample application, please refer to the source code of LocationProvider.java and sample 4.1 "Poi At Location".

Gabriele, thank you very much for your reply. 

I use both, iOS and Android. I get best results with positioning 3D object in the middle of the screen when Location permissions are truned off.

... I thought if I update 3D object every time AR.context.onLocationChanged is called then it will be moving from one possion to another on the screen. And I do not really need the 3D object to update as soon as location details change. All I need is to fix it in the middle of the screen and I wondered if it is possible. The code above helps me to achive that, but when location permissions are on, 3D object is never exactly in the middle of the screen. Everytime the view loads it is at a different position... 

Hi Sergey,
You can try and turn off the sensor service right after your World finished loading. Simply set AR.hardware.sensors.enabled = false (Please verify this API in the AR.hardware documentation). After that is done, all GeoObjects should stay where they are at that point in time.

Best regards

Andreas

hey..Does the 3D model appear in front of the camera if you keep the northing and easting 0??

Hi saher,
Simply give it a try ;) Don't forget that you can also change the translation.x/y/z for 3d models to move them relatively of there geo location/relative location.

Best regards,

Andreas
Login or Signup to post a comment