Skip to main content

BitmojiModule

Class

Provides access to functionalities related to Bitmoji avatar.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v173

Index

Example

// @input Asset.BitmojiModule bitmojiModule
// @input Asset.RemoteMediaModule remoteMediaModule
// @input Asset.Material pbrMaterialHolder

script.bitmojiModule.requestBitmoji3DResource(
function (bitmoji3DResource) {
script.remoteMediaModule.loadResourceAsGltfAsset(
bitmoji3DResource,
onDownloaded,
onFail
)
}
)

function onDownloaded (gltfAsset){
var root = scene.createSceneObject("BitmojiAvatar");
var gltfSettings = GltfSettings.create();
gltfSettings.convertMetersToCentimeters = true;
var avatar = gltfAsset.tryInstantiateWithSetting(root, script.pbrMaterialHolder, gltfSettings);
}

function onFail (e){
print(e);
}

Extends

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

createMockUser()

createMockUser(seed): SafeUser

Creates a mock user with a deterministic Bitmoji avatar. The returned user can be set on Bitmoji3DOptions.user or Bitmoji2DOptions.user to load a Bitmoji without requiring a real Snapchat user. The same seed value always produces the same avatar within a given lens, while different seeds produce different avatars.

Parameters

ParameterTypeDescription
seedstringA non-empty string used to deterministically select the avatar.

Returns

SafeUser

Since

Lens Scripting Version 353


getTypeName()

static getTypeName(): TypeName<BitmojiModule>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<BitmojiModule>

Since

Lens Scripting Version 173

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame


requestBaseBitmoji3DResourceWithOptions()

requestBaseBitmoji3DResourceWithOptions(options, baseBodyParams, callback): void

Request a base Bitmoji3D resource with explicit body customization options. Uses the default base avatar and applies body parameters from baseBodyParams if provided. If baseBodyParams is not provided or missing values, falls back to cached avatar data.

Parameters

ParameterType
optionsBitmoji3DOptions
baseBodyParamsBaseBodyParams
callback(resource) => void

Returns

void

Since

Lens Scripting Version 345


requestBitmoji2DResource()

requestBitmoji2DResource(options, callback): void

Returns a DynamicResource via the provided callback, which can be resolved into a texture using RemoteMediaModule.

Parameters

ParameterType
optionsBitmoji2DOptions
callback(resource) => void

Returns

void

Since

Lens Scripting Version 256


requestBitmoji3DResource()

requestBitmoji3DResource(callback): void

Request the current user's 3D Bitmoji avatar.

Parameters

ParameterType
callback(resource) => void

Returns

void

Since

Lens Scripting Version 173


requestBitmoji3DResourceWithOptions()

requestBitmoji3DResourceWithOptions(options, callback): void

Request the Bitmoji3D resource.

Parameters

ParameterType
optionsBitmoji3DOptions
callback(resource) => void

Returns

void

Since

Lens Scripting Version 256

See also

Bitmoji Overview guide.