Arwa Alsaati / Katelynn Browne / Anastasia Green / Vesper Guo / Halley Yue Huang / Vasu Kuram / Rachael Lu / Marketa Mala / Shehara Ranasinghe / Tanvi Sharma / Christopher Strawley / Ni Ni Than / Kristian Zadlo /
Calculating Distance with Behavior Scripts in Lens Studio
Open a New Project in Lens Studio
We will be using this Lens to calculate the distance between the user and a 3D object placed in the world. That distance can then be used to change the output of objects in your scene.
Click the Project Info button at the top-left of the screen and Uncheck the Front Facing Camera option. We will be using this Lens as a window into a 3D augmented world with our phones as the viewport.
In the Objects panel, click the + create a new Text3Dcomponent.
Click + in the Objects Panel and search for World Object Controller under
Helper Scripts.
Click the disclosure button to the left of the newly created World Object Controller and delete the example FBX Object.
Replace the deleted resource with the 3D text component and drag it to the top of the World Object Controller’s hierarchy.
We are going to add a component that will allow device tracking. Select the Camera in the Objects panel. Look for the Inspector and click the +Add Component button to search and add Device Tracking. It will now be added as a component of the Camera.
Back in the Objects panel, click the + to search and add a Behavior Script. It is located under Helper Scripts -> Behavior Script. Drag the Behavior Scriptover the World Object Controller object to make it a child of the World Object Controller.
In the Scene panel, use “W”, “E”, and “R” to activate the transform gizmos.
“W” – Position
“E” – Rotation
“R” – Scale.
Then move and scale the Text3D so that it sits on top of the green Ground Grid in the scene.
Be sure that your cursor is in the scene panel when you use these shortcuts to avoid renaming your Objects.
Select the newly created Behavior script and in the Inspector, switch the trigger to Distance Check.
Underneath Trigger, setObject A to the World Object Controller. Next, set Object B to the main Camera object that has the Device Camera Tracker component.
Set the Compare Type to Is Less Than and provide a unit of distance to compare. This example uses 50.0. You may have to play with these numbers depending on your space.
Under the Response Type drop down box, select “Send Custom Trigger” and set the Trigger Name to “close”.
Then right click on the Behavior script component and duplicate it.
Paste the copied Behavior script below and set the Compare Type equal toIs Greater Than and rename the Trigger Name to “far”.
Now create a new Script in the Resources Panel and attach it to the Behavior Script object. Drag it below where our two Distance Check Behavior Scripts are located.
Double click the newly created Script in the Resources window to open the Script Editor. Start by adding a new component input with the following code. This will allow you to drag in the 3D Text Scene Object to be changed within our script.
//—–JS CODE—–
//@input Component.text3D words
The //@input adds access to any type of Lens Studio component. So to access a Text3D component, you would have to declare the type (Component.text3D) and then name the variable you’ll be referring to in your project (words). Save the script and there will be an input on your script.
The Behavior Scripts that we are using to check distance have a method to receive the custom triggers they are outputting when the Distance Check conditions are met. You can double click the Behavior Script in the Resources panel and parse through the various methods included in the Behavior Script For our case, we are interested in addCustomTriggerResponse() method.
Go to the Resources pane and open the Scripts Folder under the World Object Controller to double click and expose the code of the Behavior Script.
Let’s extract this line and copy it into the script with the 3D Text component so we can make changes when either of the distance check conditions are triggered.
This method looks for the custom trigger with the same name as the “triggerName” and runs the function callback when that trigger is active. As you are bringing in the distance check behavior scripts, make sure to match the triggerName to the trigger name from the Behavior scripts. This value is passed in as a “string”.
Then set up your callback functions in the same script. For simplicity, you can name your callback functions the same as your custom trigger names. Because we have the 3D Text component input, we can set the text for the 3D object with either of these functions that are called when the custom trigger is sent.
Finally, preview the effects in the Preview Pane by selecting the environment in the upper part of the window.
You can also pair your Snapchat account and send the Lens to your device.
The Text3DComponent is just one of many possibilities able to be controlled with Behavior Scripts. Look through all of the Triggers on the Behavior script to see what else you can control!
MARS Mobile Augmented Reality Show AR 2021 is LIVE @ the Damon BakAR Gallery! Show dates – 12/17/21 – till infinity.
How to see it-
Get SnapChat. Scan the code. See the 2021 AR show!! You need 2 phones to really experience it. See documentation-
Artists
Arwa Alsaati / Katelynn Browne / Anastasia Green / Vesper Guo / Halley Yue Huang / Vasu Kuram / Rachael Lu / Marketa Mala / Shehara Ranasinghe / Tanvi Sharma / Christopher Strawley / Ni Ni Than / Kristian Zadlo /
The DAMON (Loren) BakAR(er) Gallery Grand Opening Ribbon Cutting 2021! It happened! We cut the ribbon and the gallery is finally open!!!!
This Gallery is dedicated to Damon Loren Baker, Pioneer of the field of Augmented Reality Art (among many other things).
Damon is responsible for some of the first works of augmented and virtual art. He often did this with sound. The Damon BakAR Gallery is an augmented reality gallery that can be seen by people w a smartphone and a proper net connection. Damon pioneered this very form of art. This gallery will only show Augmented Reality Art that pushes what the medium can do. Damon’s pioneering work in AR will now live on through shows and live events (sound anyone???) of future generations of AR creators. We plan to have regular shows so please check back regularly.
The DAMON (Loren) BakAR(er) Gallery is run by NYU’s Mobile AR Lab. Damon was instrumental in setting up The Mobile AR Lab and he was a Resident with the lab where we created the world’s first “Augmented Ensemble”.
This is the beta build of the gallery and we plan to build this out a bit but it works and is live now!!! Our show is live when all the other NYU shows were shut down due to COVID Omicron. The future is uncertain and the timing of this gallery could not be better!
The DAMON (Loren) BakAR(er) Gallery actively accepts AR ART curatorial proposals. We love AR (sound) + all AR art so feel free to reach out.
The Mobile AR Lab is back and we are kicking it off w the launch of our very own AR gallery; “The Damon BakAR Gallery” which, to be clear, is an AR gallery and can be seen around the world by smartphone uses. We do have shows in IRL gallery spaces but… that’s not really the point. Our first show is MARS [mobile augmented reality show 2021] and will showcase the some of the very best AR at NYU! This groups show includes artists
Arwa Alsaati / Katelynn Browne / Anastasia Green / Vesper Guo / Halley Yue Huang / Vasu Kuram / Rachael Lu / Marketa Mala / Shehara Ranasinghe / Tanvi Sharma / Christopher Strawley / Ni Ni Than / Kristian Zadlo /
Keiichi Matsuda, considered to be the most influential artist/developer working with augmented reality, will lecture for NYU’s Mobile AR Lab Fall 2016!!!!!!