ZapparThreeJS sdk docs?

Hey there,

I’m looking for sdk docs, methods, properties, etc. available. I see them for the studio, but not for the JS sdks. For instance, I’m trying to figure out if there are properties telling me “how far” I am from an object I set down in UniversalAR, so that I can trigger JS based on “distance.”

Thanks! Love the platform.

Hi @mark3,

I’m happy to hear you’re enjoying the platform!
We have Universal AR ThreeJS docs over at https://docs.zap.works/universal-ar/threejs/

What you’re trying to acomplish is to check the world position distance between the camera and a group, which is more of a three question rather than Universal AR. You can find THREE docs over at https://threejs.org/docs

Most three objects have a position Vector3 which is one way of working this out.
Vector3 comes with a handy utility function distanceTo which is prefect for this.

Getting tracker group’s location:
const trackerPosition = trackerGroup.getWorldPosition()
Getting camera’s location:
const cameraPosition = camera.getWorldPosition()

Using the two positions:
const distance = trackerPosition.distanceTo(cameraPosition)

I’ve created a sandbox demo which illustrates this :slight_smile:

Thank you so much for the response. This helps enormously.

Edit: got it.

1 Like