1

In Spark AR I am trying to place an object at the point on a plane tracker that is equal to the center of the bottom of the screen. In pseudo code:

tracker.hitTest(screenBottomCenter)

Problem is as it states in the docs that the hitTest function takes a Point2d object which is not the same as a Point2dSignal. If I try to create the screenCenter value using

Reactive.point2d(x,y)

I get this error:

expected to get a subclass of point2d ; got Point2dSignal

The thing is you're just 'supposed to' feed a tap location into the hit test and it seems Spark did not account for other types of values. So any solutions or workarounds? Really just want to place my object so if I need a custom hit test so be it. But it would be nice to use the built in function.

Vibber
  • 127
  • 1
  • 7

2 Answers2

1

I found the solution. I post the full code here:'

// Subscribe to tap gestures. Set placedObject at the bottom 
//of the screen onto tracked plane
 TouchGestures.onTap().subscribeWithSnapshot( {
    previewX: CameraInfo.previewSize.x,
    previewY: CameraInfo.previewSize.y,
 }, function (gesture, snapshot) {

        var screen = gesture.location;
        // Because we can't manually create a Point2D object we use the 
        // gesture location object and change the values ourselves
        screen.x = snapshot.previewX / 2;
        screen.y = snapshot.previewY;

        tracker.performHitTest(screen).then((result) => {
            Diagnostics.log(result.x);
            placedObject.transform.position = R.pack3(result.x, result.y, result.z);
        });

 });
Vibber
  • 127
  • 1
  • 7
0

The method performHitTest has multiple signatures. You can simply use:

tracker.performHitTest(snapshot.previewX / 2, snapshot.previewY).then(...)
andypotato
  • 703
  • 5
  • 10