jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.29k stars 454 forks source link

[Question] Is it possible to use some Video formats as Texture of a Shape? #667

Closed joex92 closed 1 year ago

joex92 commented 1 year ago

Describe your question just as you create a texture from an image to .fill a shape, as well use a video file (like mp4, flv, mov, etc) to .fill a shape, so the shape show the video displayed.

Your code (either pasted here, or a link to a hosted example) this is an example on Three.js instead of being a 3D mesh, this time it would be a 2D shape:

tex = new Two.Texture('path/to/video.mp4');
rec = two.makeRectangle(0,0,128,72);
rec.fill = tex;

Environment (please select one):

jonobr1 commented 1 year ago

Yep, you cannot use it as a file path, aka URI. But, you can directly add a <video /> element to the texture to get it to work. Here's an example: https://codepen.io/jonobr1/pen/PoazvEv