World tracking + User position


Hi, the World tracking option is a fantastic addition! I was wondering, if it is possible to get the user position, relatively to the world or 3D object, once it is placed? For example, to trigger events when the user is close from specific points? Anyways, great job! Cheers.


Absolutely! The “user” in Zappar is just so you can stick a TriggerRegion relative to the world anchor, and a simple visible false, enabled true plane object relative to with a tag set to the triggerTag of the trigger region.

You can then get callbacks with the local position of the trigger in the world every frame.

Using trigger regions or raycasters between tracked nodes (such as world anchors) and other nodes like the camera used to introduce a frame delay when the local positions are reported to javascript (they are calculated using the previously rendered positions, but the tracking data is already updated for the current frame).

The latest Zappar app includes a way of removing this frame delay, just set the updatePhase property of the trigger region to Z.FramePhase.after_early_updates, which will calculate the trigger positions after early updates for the new frame (including things like gyro and tracking updates).

This is a bit hidden right now (it’s not exposed in Studio’s property list yet and not documented). You can just set it in a script node, only needs to be done once:


Thanks Simon! It’s working fine :grin:
But regarding the frame delay, the ‘zappar’ keyword is not found and fires a script error.


Oops, sorry. You can just use Z. now it’s in the typescript definitions in Studio. I copied and pasted from an earlier test scene I was working on. I’ve edited the post above now for anyone new to the thread.


Perfect! Thanks again!:grin:


I’m sorry to ask, but would it be possible to elaborate a little on this procedure? I have been trying to do this for a while without success. I placed a plane in the area where I want action to trigger (in my case, display a plane with text materiel on root) when user enters plane. I used ACTION in properties “ON TRIGGER REGION ENTER” and sert a state that will make a plane on root visible, but this does not seem to work. I’m not clear on how to set-up a trigger region. Where could I find this info?

Thank you for your help :slight_smile:


OK! I figured it out! Didn’t understand that I had to first define a trigger region from NEW menu! Duh. Sorry for misunderstanding :slight_smile:


And I have just see this thread: Sipsmith Portal - Inspiration Project
With everything inside… :smile:

But I still have a question: how can we get the coordinates of the relatively to the world? Z.Camera.position() returns always (0,0,0)… Triggers are great, but I would like also be able to control element with their distance from specific points.



In Zappar we don’t have a single coordinate system shared by everything in the scene. There are instead different “spaces” - so we refer to as “camera space”, and target finders and world anchors define their own spaces. is always [0,0,0] as it is the origin of the camera space.

The Javascript side of scenes doesn’t have full access to all the information - for example tracked targets have their transforms set on the native side and are not directly passed on to the Javascript, so there is no API to query them.

This is where TriggerRegion comes in. You can use them in the same space if you want, so you can have a TriggerRegion relativeTo and an object node defined as a trigger also relative to However their real utility is when the TriggerRegion and trigger objects are in different “spaces”, as this allows you to map coordinates of the object from the space where it is defined to the space where you want it.

In the case of user position, you want your trigger object relativeTo and your TriggerRegion relativeTo a group in the world tracking space. If you have the shape of the TriggerRegion set to none then the trigger will always be inside the active volume of the TriggerRegion. That means every frame you can retrieve the position of the user in world space with an event handler.

I’ve put together a quick demo scene to show how this works:
WorldTrackingTriggerRegionDemo.zpp (4.6 KB)

Hold down on the screen to make a trail of planes in world space. It’s pretty fun :smiley:

From screen to 3D

So the example above shows how to get the exact position of trigger objects in the TriggerRegion’s coordinates. However if all you want to do is have something happen when the user enters a certain part of the world, that can be done without any code at all, just using actions “on trigger enter” and “on trigger leave”.

Here’s a minimal example using the standard ground placement subsymbol:
WorldTrackingTriggerRegionActions.zpp (1.1 MB)

You need an object relativeTo, with a tag set (something like ‘cameraTrigger’ is sensible). Then add a TriggerRegion anywhere you want to take an action when the user enters or leaves, and set the triggerTag property to the same tag you added to the object that you want to use as the trigger.


Thank you so much Simon, for these precisions! Your demo is very useful and opens a lot of opportunities for cool apps! - Too bad Little Thumb didn’t get Zappar! :grin::+1:


This is SO COOL!!


:eyes: I can tell you’ve been getting involved with this, @jvouillon …!


Hi James! :smile:
So, here it is a very basic prototype, based on Simon’s code. [Updated: sliders for the color and the size…]



This is great! Love the undo functionality!

This same content will also run in the new version of the ZapBox app (submitted to Apple now, so hopefully live early next week). With the ZapBox app you could update it to use a ZapBox controller to draw the lines, and perhaps link the analog trigger value to radius…


So we can finally get the drawing in the air picture from the kickstarter campaign that was promised!?