在 Three.js 中使用视频作为纹理 [英] Using Video as texture with Three.js
问题描述
我正在尝试使用 .mp4 视频作为纹理创建一个简单的矩形.根据three.js文档(http://threejs.org/docs/#Reference/Textures/纹理)这应该是直截了当的.
I am trying to create a simple rectangle with a .mp4 video as texture. As per three.js documentation(http://threejs.org/docs/#Reference/Textures/Texture) this should be straight forward.
当我放置视频链接时,我得到的只是一个没有纹理的黑色框.我已经通过用 jpg 图像替换视频来测试代码,它工作正常.有人可以解释一下我做错了什么.
When I am putting link of video, all I am getting is a black colored box with no texture on it. I have tested code by replacing video with a jpg image and it works fine. Can someone please explain me what I am doing wrong.
我已经看过播放视频的示例,首先将视频链接到视频元素,然后将帧复制到画布上.我想尝试一下three.js文档中提到的直接方式.
I have already seen the examples in which video is played by first linking it to a video element and then copy the frames on a canvas. I want to try the direct way as mentioned in the three.js documentation.
推荐答案
将视频视为一系列图像.因此,要在您的 3D 对象上播放"此视频 - 您必须将该序列的每一帧都传递给您的材料,然后更新该材料.
Think of video as a sequence of images. So to "play" this video on your 3D object - you'll have to pass every single frame of that sequence to your material and then update that material.
好的起点在这里:https://github.com/mrdoob/three.js/wiki/更新
这里:http://stemkoski.github.io/Three.js/Video.html
这篇关于在 Three.js 中使用视频作为纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!