StickerManager.load收藏我的收藏
收藏
我的收藏基础库 2.32.0 开始支持本方法,低版本需做兼容处理,这是一个同步方法。
加载对应传入 ID 的贴纸。
语法
StickerManager.load()
参数说明
无
返回值
无
代码示例
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
- Tip: 需在调用 load 前设置回调,否则无法触发回调。
文 档评论
登录后可参与评论