Texturing a Body with image from webcam

I'm looking for a way to texture body objects made with Matter.js with snapshots taken from a webcam. For example, every time I call mousePressed() two things happen: 1) a new body is created and 2) a frame from the webcam is pushed into an array. I want to use a new image from that array to texture each new rectangular body. Do I need to somehow use the render/sprite option within Matter.js or can I somehow just use p5 to do this? Thanks for any suggestions!

Here are the two pertinent files:

Screen Shot 2017-11-09 at 12.10.20 PM Screen Shot 2017-11-09 at 12.10.26 PM

Answers

  • okay Somehow I figured it out, although I'm sure it's not sound. Here is the working code for using a section of the webcam image to be shown. This is NOT dynamic as it is not a sprite texture, it all happens in the this.show() of the body. I know there is a better way to do this as per Matter.js but for now it's a crackpot solution.Screen Shot 2017-11-15 at 10.37.26 AM Screen Shot 2017-11-15 at 10.37.44 AM

Sign In or Register to comment.