三个js将视频添加到平面几何体

时间:2018-01-10 09:17:56

标签: video three.js geometry plane

我试图将视频显示为具有三个js的平面几何体,但我得到的只是一个黑色矩形。

var video = document.getElementById('video');
var texture = new THREE.VideoTexture(video);
texture.needsUpdate;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.format = THREE.RGBFormat;
texture.crossOrigin = 'anonymous';

var imageObject = new THREE.Mesh(
    new THREE.PlaneGeometry(width, height),
    new THREE.MeshBasicMaterial({ map: texture }),);

scene.add( imageObject );

添加了:

video.src = "src to video";
video.load();
video.play();

并且有效!

1 个答案:

答案 0 :(得分:0)

解决方案,添加以下代码:

video.src = "src to video";
video.load();
video.play();