Currently, my goal is to create a delayed webcam viewer using javascript, utilizing Three.js for its WebGL capabilities.
At the moment, I am able to capture frames from the webcam and display them after a specified time interval using canvas
and getImageData()
. An example of this implementation can be found here.
However, my aim is to achieve this without relying on canvas, but rather utilizing the Texture
or DataTexture
object from Three.js. You can see my attempt at this here. The challenge I am facing is figuring out how to transfer the image from one Texture
(where the image is of type HTMLVideoElement
) to another.
Within the rotateFrames()
function, I need the older frame to be replaced by the newer one in a FIFO manner. However, the line
frames[i].image = frames[i + 1].image;
simply copies the reference, not the actual texture data. I suspect that utilizing DataTexture
might be the solution, but I am struggling to extract a DataTexture
from a Texture
or HTMLVideoElement
.
Any thoughts or suggestions on how to approach this?
Important Note: To run the examples successfully, ensure you have access to a camera and have granted permission for the browser to use it. Additionally, make sure you are using an updated browser.