使用的核心代码:
let video = document.createElement('video');
video.src = "js/sintel.mp4"; // 设置视频地址
video.autoplay = "autoplay"; //要设置播放
video.loop = true;//循环播放
// video对象作为VideoTexture参数创建纹理对象
var texture = new THREE.VideoTexture(video)
var material = new THREE.MeshPhongMaterial({
map: texture, // 设置纹理贴图
}); //材质对象Material
之后将material替换到想指定的材质即可
示例:
for (var i = allChildren.length - 1; i >= 0; i--) {
if (scene.children[i].name == "动画1") {
//console.log(screen1); scene.children[i].children[23].children[1].children[2].children[1].children[0].material[2] = material;
}
}
|