Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:43:19+00:00 2026-06-11T22:43:19+00:00

I’m trying to implement a delayed webcam viewer in javascript, using Three.js for WebGL

  • 0

I’m trying to implement a delayed webcam viewer in javascript, using Three.js for WebGL capabilities.

I need to store frames grabbed from webcam, so they can be shown after some time (some milliseconds to some seconds). I’m able to do this without Three.js, using canvas and getImageData(). You can find an example on jsfidle.

I’m trying to find a way to do this without canvas, but using Three.js Texture or DataTexture object. Here an example of what I’m trying. The problem is that I cannot find how to copy the image from a Texture (image is of type HTMLVideoElement) to another.

In rotateFrames() function the older frame should be lost and newer should replace, like in a FIFO. But the line

frames[i].image = frames[i + 1].image;

is just copying the reference, not the texture data. I guess DataTexture should do this, but I’m not able to get a DataTexture out of a Texture or HTMLVideoElement.

Any idea?

Warning: you must have a camera and allow the browser to use it to get examples working. And obviously, you must have an updated browser.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:43:20+00:00Added an answer on June 11, 2026 at 10:43 pm

    Is this what your looking for??

    http://fiddle.jshell.net/m4Bh7/10/

    Edit:

    function onFrame(dt) {
        if (video.readyState === video.HAVE_ENOUGH_DATA) { /* new frame available from webcam */
            context.drawImage(video, 0, 0,videoWidth,videoHeight);
            frames[framesNum - 1].image.data = new Uint8Array(context.getImageData(0,0,videoWidth, videoHeight).data.buffer);
            frames[framesNum - 1].needsUpdate = true;
        }
    }
    

    This is the most important part: It makes a copy of the frame and saves it as a data in a dataTexture.

    function rotateFrames() {
        for (var i = 0; i != framesNum - 1; ++i) {
    /*
             * FIXME: this does not work!
             */
            frames[i].image.data = frames[i + 1].image.data;
            frames[i].needsUpdate = true;
        }
    }
    

    This copies then the data from texture to texture in the frames.

    new version:http://fiddle.jshell.net/hWL2E/4/

    function onFrame(dt) {
        if (video.readyState === video.HAVE_ENOUGH_DATA) { /* new frame available from webcam */
            context.drawImage(video, 0, 0,videoWidth,videoHeight);
             var frame = new THREE.DataTexture(new Uint8Array(context.getImageData(0,0,videoWidth, videoHeight).data.buffer) ,videoWidth,videoHeight);
            frames[framesNum - 1] = frame;
            frames[framesNum - 1].needsUpdate = true;
            sprites[framesNum - 1].map = frames[framesNum - 1];
        }
    }
    

    It generates a new texture every frame for the video images.

    function rotateFrames() {
        for (var i = 0; i != framesNum - 1; ++i) {
    /*
             * FIXME: this does not work!
             */
            frames[i] = frames[i + 1];
            sprites[i].map = frames[i];
    
        }
    }
    

    this is what makes it better. Becuase it reuses the textures that were used, means that it doesn’t need to be resent to the GPU.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.