javascript - How can i shake object when object in squre on AR view and How to alert when object is in square in mobile Application? -


i getting midpoint of ios devices , object polar angle, how match both midpoint , polar angle?

for example, have 3 objects in ar screen, when shake on particular 1 object not getting alert or anything.

i using "cordova-plugin-device-orientation" plugin current heading using "$cordovadeviceorientation.getcurrentheading().then(function(result) {});" , getting 4 parameter 1. magneticheading, 2. trueheading, 3. headingaccuracy , 4. timestamp parameter of device orientation.

and used "cordova plugin add cordova-plugin-shake" plugin shake object on ar following screenshots:

enter image description here enter image description here

my code below shaking based on device-orientation.

function onshake() {   console.log("shake");  $cordovadeviceorientation.getcurrentheading().then(function(result) {    // alert("result: "+json.stringify(result));    $scope.magneticheading = result.magneticheading;    // $scope.trueheading = result.trueheading;    // $scope.headingaccuracy = result.headingaccuracy;    // var magneticheading = result.magneticheading;    console.log("heading: "+$scope.magneticheading);     angular.foreach($scope.poilocations, function(getpois, index) {      console.log("getpois: "+json.stringify(getpois));       var width = (window.innerwidth > 0) ? window.innerwidth : screen.width;      var height = (window.innerheight > 0) ? window.innerheight : screen.height;      console.log("height" +height);      console.log("width" +width);      var midpoint = (height/2, width/2)      console.log("midpoint" +midpoint);      $rootscope.midpnt = midpoint;      $rootscope.mymidpoint = true;      // var minrange = getpois.polar.angle - 10; // set range using btrfly's angle      // var maxrange = getpois.polar.angle + 10; // set range using btrfly's angle      var minrange = $scope.magneticheading - 8; // set range using device's angle      var maxrange = $scope.magneticheading + 8; // set range using device's angle       console.log("getpois.polar.angle: "+getpois.polar.angle);      console.log("minrange: "+minrange);      console.log("maxrange: "+maxrange);      // if(magneticheading >= minrange && magneticheading<=maxrange){ // set range using btrfly's angle     if (getpois.polar.angle >= minrange && getpois.polar.angle <= maxrange) { // set range using device's angle                                        console.log("btrfly: " + getpois.polar.angle + " " + getpois.polar.email);        // $ionicloading.show({        //    template: 'loading...'        // });         $scope.clicklistner(getpois.polar.email);       }      });    }, function(err) {      // error occurred   });  }  shake.startwatch(onshake, 12 /*, onerror */ ); 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -