Heads up! We're sunsetting this forum to streamline our community space.

join us on Discord for support, updates, and all things Snap AR! See you there!
Sign up for our live Camera Kit office hour on July 17 @ 9:30am (PT) / 4:30pm (GMT)

Populating Assets & Layering Lenses

-We’d like to build a suite of 3D assets and store them in Remote Assets. Then, upload 1 lens (template) to our app and pull from there based on that user's specific information. Is this possible? Looking to avoid manually building each individual avatar as a lens and rather automate the lens with the traits stored on Remote Assets or elsewhere

-Can we layer lenses on top of each other in our app/can we pull multiple lens ID's and put them on top of each other at the same time? So, if we had a full body tracking avatar for 1 lens and then 1 lens with a coat with bull body tracking for instance, could we put them on top of each other? Assuming fps and ram are thought of ahead of time during the build

Answers

  • stevenxu
    stevenxu Posts: 612 👻

    @Blnk | Michael Thanks for posting your question on the forum here! Confirming a ticket has been raised for our eng team. Hang tight!

  • stevenxu
    stevenxu Posts: 612 👻

    @Blnk | Michael Bumped up our internal ticket on this. Thanks for your patience! Also great hearing from you at office hours :)

  • ForumChris
    ForumChris Posts: 23 👻

    Hello @Blnk | Michael

    To follow up on my comment from Office Hours, this is possible and there are a couple of ways to approach it.

    From the Lens standpoint:

    1. Start from the Dynamic Lens Template:

    This template shows how to read in Launch Parameters

    2. Upload to Remote Assets:

    Once you have your assets uploaded to Remote Assets by Right Clicking them in the Resources window and selecting upload to Remote Assets, you will have the Remote Assets in the project.

    3. Import Preview Remote Asset from Asset Library:

    This is a helper prefab that gives an example of instantiating a prefab from remote assets, you could also use the Remote Asset Cycler example as a starting point as well since this pulls in an asset at random which you could then specify but either is doable.

    4. Modify WorldOfTheDayManager.js

    Change the js file from the Dynamic Template to have an array of all of the possible remote assets

    Then you will want to read in your values from Launch Parameters and do a check as is shown how its reading the data on lines 28-32. from there you could do something like:

    //@input  Asset.RemoteReferenceAsset[] remoteAssets;
    
    if (launchParams) && launchParams.has("identifier") {
    var id = launchParams.getFloat("identifier");
    // could use a string as ID if preferred or plug the id directly into the index
     if (id == 0) {
        var asset = script.remoteAssets[0];
        asset.downloadAsset(onDownloadSuccess, onFailed);
        /* onDownloadSuccess would need to instantiate as the previewRemoteAsset script does on line 48; */
    }
    

    For the App side of things:

    To send in Launch Parameters, I highly recommend this example from @aidan who has adapted the vendor data example in the sample app to show this use case.

    Option 2: Remote APIs

    Another option is to use the Remote APIs to send data back and forth from the Lens and App. Through this you could follow a similar approach to what I outlined for the Lens above but could be more flexible if you want the ability to change which remote asset was being pulled in at runtime.

  • Thank you! @ForumChris & @aidan

Categories