Creates an effect from Url
const octopus = new Effect("/path/to/Octopus.zip")
Creates an effect from Request
const octopus = new Effect(new Request(
"/path/to/Octopus.zip",
{ headers: { etag: "\"8b13dff520339ba88a610ceb58d4fa6b\"" } },
))
Creates an effect from Blob
const file = $("#file-upload").files[0] // File is subclass of Blob
const octopus = new Effect(file)
Evaluates JavaScript method in context of the effect.
The method won't evaluate if the effect is not applied to a player
Use evalJs instead.
const makeup = new Effect("/path/to/Makeup.zip")
await player.applyEffect(makeup)
// ...
const electricBlueColor = "0.09 0.25 0.38"
makeup.callJsMethod("Eyes.color", JSON.stringify(electricBlueColor))
Evaluates JavaScript in context of the effect.
The script won't evaluate if the effect is not applied to a player
const makeup = new Effect("/path/to/Makeup.zip")
await player.applyEffect(makeup)
// ...
const electricBlueColor = "0.09 0.25 0.38"
await makeup.evalJs(`Eyes.color("${electricBlueColor}")`)
const makeup = new Effect("/path/to/Makeup.zip")
const filename = "nude_makeup.png"
const buffer = await fetch("/path/to/${filename}").then(r => r.arrayBuffer())
// ...
await makeup.writeFile(filename, buffer)
await makeup.evalJs(`Makeup.set("${filename}")`)
const makeup = new Effect("/path/to/Makeup.zip")
const filename = "nude_makeup.png"
const file = $("#file-upload").files[0]
// ...
await makeup.writeFile(filename, file)
await makeup.evalJs(`Makeup.set("${filename}")`)
Static
preloadCreates an effect by preloading it from Url
Optional
options: LoadOptionsconst octopus = await Effect.preload("/path/to/Octopus.zip")
// with a progress listener
const onProgress = ({ total, transferred }) => {
console.log(`Effect is loaded on ${100 * transferred / total}%`)
}
const octopus = await Effect.preload("/path/to/Octopus.zip", { onProgress })
Creates an array of effects by preloading them from a list of Urls
Optional
options: LoadOptionsconst [octopus, policeman] = await Effect.preload(["effects/Octopus.zip", "effects/Policeman.zip"])
// with a progress listener
const onProgress = (effectIndex, { total, transferred }) => {
console.log(`Effect #${effectIndex} is loaded on ${100 * transferred / total}%`)
}
const [octopus, policeman] = await Effect.preload(
["effects/Octopus.zip", "effects/Policeman.zip"],
{ onProgress },
)
An AR effect, filter or mask