tt.createStickerManager收藏我的收藏
收藏
我的收藏获取传入贴纸 ID 对应的算法管理器。目前该接口仅对白名单小程序开放,如需使用,开发者需要至控制台-小程序页面下,进入“能力-能力实验室-小程序能力”,申请AI特效贴纸能力。以上仅申请接口权限,无法满足使用条件;能力使用方式及付费问题,详情请联系火山引擎商务咨询。
语法
tt.createStickerManager(stickerId);
参数说明
stickerId
类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
string | | 是 | 需要使用的贴纸的 ID | 2.32.0 |
返回值
代码示例
Page({ onLoad: function () { console.log("Welcome to Mini Code"); }, onReady: function () { tt.createSelectorQuery() .select("#myCanvas") .node() .exec((res) => { this.canvas = res[0].node; this.gl = this.canvas.getContext("webgl"); this.render = require("./render"); this.render.initRenderContext(this.gl); }); }, requestEffectCamera: function () { this.effectCameraStream = tt.createEffectCameraStream(this); this.effectCameraStream.onRequest(() => { this.effectCameraStream.play(); }); this.effectCameraStream.onPlay((video) => { this.video = video; this.videoTexture = this.render.createTexture( this.gl, video.width, video.height ); this.processedTexture = this.render.createTexture( this.gl, video.width, video.height ); console.log("video size: ", video.width, video.height); this.render.renderVideoToTexture(this.gl, this.video, this.videoTexture); const paint = () => { console.log("paint"); this.render.renderVideoToTexture( this.gl, this.video, this.videoTexture ); this.processor.paintToTexture(this.videoTexture, this.processedTexture); this.render.renderToScreen(this.gl, this.processedTexture); this.canvas.requestAnimationFrame(paint); }; paint(); }); this.effectCameraStream.request(); }, requestSticker: function () { console.log("request sticker"); this.stickerManager = tt.createStickerManager("1404075"); this.stickerManager.onLoad((processor) => { console.log("sticker loaded"); this.processor = processor; }); this.stickerManager.onError((err) => { console.log("sticker load failed, ", err); }); this.stickerManager.load(); console.log("start request sticker"); }, });
Bug & Tip
无