Search code examples
three.jsscreenvideo-capturecapturescreen-capture

How to capture a screen through Three.js?


So I have an idea for a project I want to do and I don't really wanna touch programming languages I don't already know. However,11 after some searching around, I'm not entirely sure if I can do what I want in Three.js. So here goes; How do I screenshot or record a monitor on my computer, and have it refresh the screenshot or the capture at 60 frames per second so I can check for diffrences in frames?

I've attempted to do this in java before, and the result of checking colour alterations would be a keypress. But, I had issues with getting it to keypress the way I wanted as I was completely unable to use the software unless I was tabbed into the capture. And in this specific usecase, I don't want that. The only alternate way I could find was to hook it to the software I want to use this on but at that point, I was sorta just lost.

So my second question would be; Can I check for pixel alterations and be tabbed out of the screen recording for it to press a key or button as a result to the slight alteration of a set of pixels?

I know it's a kinda weird request but I just want to be pointed in a general direction on where to start. I've searched around and I couldn't really find anything of capturing a screen at all, nevermind doing anything with it.


Solution

  • You can only get the contents of the canvas element that THREE is rendering into.. via

    var dataURL = canvas.toDataURL();

    There are limitations having to do with browser security though. Read about canvas tainting...