Optional
dataReadonly
idOptional
jwtOptional
profileOptional
profileOptional
userAdd a new avatar
const animationMeta = {
"emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
}
const spriteSheetJSON = {
"animations": {
"emote": [
"emote/1.png"
]
},
"frames": {
"emote/1.png": {
"frame": {
"x": 1911,
"y": 778,
"w": 58,
"h": 91
},
"rotated": true,
"trimmed": true,
"spriteSourceSize": {
"x": 50,
"y": 33,
"w": 58,
"h": 91
},
"sourceSize": {
"w": 159,
"h": 159
}
}
},
"spriteSheetTypeMeta": {
"nameplate": {
"x": 0,
"y": -70
}
},
"meta": {
"image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
"format": "RGBA8888",
"size": {
"w": 2006,
"h": 1099
},
"scale": "1"
}
}
const formData = new FormData();
formData.append('animationMeta', animationMeta);
formData.append('name', "ExampleAvatarName");
formData.append('spriteSheetJSON', spriteSheetJSON);
formData.append('expression_dance', expression_dance);
formData.append('expression_emote', expression_emote);
formData.append('expression_sit', expression_sit);
formData.append('expression_stand', expression_stand);
formData.append('expression_transport', expression_transport);
formData.append('preview', preview);
formData.append('spriteSheet', spriteSheet);
formData.append('unityPackage', unityPackage);
await user.uploadAvatarFiles("exampleAvatarId", formData);
Verify user has valid interactive credentials
await user.checkInteractiveCredentials();
Close an iframe for a visitor currently in a world.
await visitor.closeIframe("droppedAssetId");
Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
await user.deleteAvatar("exampleAvatarId");
Optional
error?: unknownOptional
message?: stringOptional
params?: objectOptional
sdkRetrieves all worlds a user with matching API Key is an admin in, creates a new World object for each, and creates new map of Worlds accessible via user.adminWorlds.
await user.fetchAdminWorldsByKey();
const adminWorlds = user.adminWorlds;
Returns all assets owned by User when an email address is provided.
await user.fetchAssets();
const userAssets = user.assets;
Returns all avatars owned by User
const avatars = await user.fetchAvatars();
Retrieves the data object for a visitor.
const dataObject = await visitor.fetchDataObject();
Retrieves ids of all dropped assets in all worlds with a matching interactivePublicKey.
await user.fetchInteractiveWorldsByKey("interactivePublicKeyExample");
const interactiveWorlds = user.interactiveWorlds;
Returns all platform assets.
const assets = await user.fetchPlatformAssets();
Returns all scenes owned by User.
await user.fetchScenes();
const userScenes = user.scenes;
Get a single visitor from a world
await visitor.fetchVisitor();
Returns details for a visitor in a world by id and urlSlug
Retrieves all worlds owned by user with matching API Key, creates a new World object for each, and creates new map of Worlds accessible via user.worlds.
await user.fetchWorldsByKey();
const userWorlds = user.worlds;
{ urlSlug: new World({ apiKey, worldArgs, urlSlug }) }
Display a message via a toast to a visitor currently in a world.
await visitor.fireToast({
groupId: "custom-message",
title: "Hello World",
text: "Thank you for participating!",
});
Get all particles available
await visitor.getAllParticles();
Grant expression to a visitor by id or name.
await visitor.grantExpression({ name: "Eyes" });
Optional
id?: stringOptional
name?: stringIncrements a specific value in the data object for a visitor by the amount specified. Must have valid interactive credentials from a visitor in the world.
Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
await visitor.incrementDataObjectValue("key", 1);
Optional
analytics?: AnalyticType[]Optional
lock?: { Optional
releaseTeleport or walk a visitor currently in a world to a single set of coordinates.
await visitor.moveVisitor({
shouldTeleportVisitor: true,
x: 100,
y: 100,
});
Updates each Visitor instance and world.visitors map.
Open an iframe in a drawer or modal for a visitor currently in a world.
await visitor.openIframe({
droppedAssetId: "droppedAssetId",
link: "https://topia.io",
shouldOpenInDrawer: true,
title: "Hello World",
});
Reload an iframe for a visitor currently in a world.
await visitor.reloadIframe("droppedAssetId");
Send an email
const html = `<p><b>Hello World!</b></p><p>This email is being sent from via SDK.</p>`
await user.sendEmail({ html, subject: "Example", to: "example@email.io" });
Setup signal to visitor
await visitor.sendSignalToVisitor(iceServers);
Sets the data object for a visitor.
Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
await visitor.setDataObject({
"exampleKey": "exampleValue",
});
Optional
analytics?: AnalyticType[]Optional
lock?: { Optional
releaseTrigger a particle effect on a visitor
await visitor.triggerParticle({ name: "Flame" });
Optional
duration?: numberOptional
id?: stringOptional
name?: stringMute and turn video off for a visitor currently in a world.
await visitor.turnAVOff();
Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
const animationMeta = {
"emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
}
const spriteSheetJSON = {
"animations": {
"emote": [
"emote/1.png"
]
},
"frames": {
"emote/1.png": {
"frame": {
"x": 1911,
"y": 778,
"w": 58,
"h": 91
},
"rotated": true,
"trimmed": true,
"spriteSourceSize": {
"x": 50,
"y": 33,
"w": 58,
"h": 91
},
"sourceSize": {
"w": 159,
"h": 159
}
}
},
"spriteSheetTypeMeta": {
"nameplate": {
"x": 0,
"y": -70
}
},
"meta": {
"image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
"format": "RGBA8888",
"size": {
"w": 2006,
"h": 1099
},
"scale": "1"
}
}
const formData = new FormData();
formData.append('animationMeta', animationMeta);
formData.append('name', "ExampleAvatarName");
formData.append('spriteSheetJSON', spriteSheetJSON);
formData.append('expression_dance', expression_dance);
formData.append('expression_emote', expression_emote);
formData.append('expression_sit', expression_sit);
formData.append('expression_stand', expression_stand);
formData.append('expression_transport', expression_transport);
formData.append('preview', preview);
formData.append('spriteSheet', spriteSheet);
formData.append('unityPackage', unityPackage);
await user.uploadAvatarFiles("exampleAvatarId", formData);
Updates the data object for a visitor.
Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
await visitor.updateDataObject({
"exampleKey": "exampleValue",
});
Optional
analytics?: AnalyticType[]Optional
lock?: { Optional
releaseUpdate analytics for a given public key. Must have valid interactive credentials from a visitor in the world.
await visitor.updatePublicKeyAnalytics([{ analyticName: "joins", profileId, uniqueKey: profileId, urlSlug }]);
Optional
analytics: AnalyticType[]
Summary
Create an instance of Visitor class with a given id and optional attributes and session credentials.
Usage