File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,13 @@ class MediaElement extends Element {
713713 duration ( ) {
714714 return this . elt . duration ;
715715 }
716+ _checkIfTextureNeedsUpdate ( ) {
717+ const needsUpdate = this . _frameOnTexture !== this . _pInst . frameCount ;
718+ if ( needsUpdate ) {
719+ this . setModified ( true ) ;
720+ this . _frameOnTexture = this . _pInst . frameCount ;
721+ }
722+ }
716723 _ensureCanvas ( ) {
717724 if ( ! this . canvas ) {
718725 this . canvas = document . createElement ( 'canvas' ) ;
@@ -1647,13 +1654,13 @@ function media(p5, fn){
16471654 if ( domElement . width ) {
16481655 videoEl . width = domElement . width ;
16491656 videoEl . height = domElement . height ;
1650- if ( flipped ) {
1651- videoEl . elt . style . transform = 'scaleX(-1)' ;
1652- }
16531657 } else {
16541658 videoEl . width = videoEl . elt . width = domElement . videoWidth ;
16551659 videoEl . height = videoEl . elt . height = domElement . videoHeight ;
16561660 }
1661+ if ( flipped ) {
1662+ videoEl . elt . style . transform = 'scaleX(-1)' ;
1663+ }
16571664 videoEl . loadedmetadata = true ;
16581665
16591666 if ( callback ) callback ( domElement . srcObject ) ;
Original file line number Diff line number Diff line change @@ -102,11 +102,18 @@ class Texture {
102102 this . isSrcMediaElement ||
103103 this . isSrcHTMLElement
104104 ) {
105- // if param is a video HTML element
106- if ( this . src . _ensureCanvas ) {
105+ // createCapture elements that are flipped need
106+ // to go through a canvas
107+ if ( this . isSrcMediaElement && this . src . flipped ) {
107108 this . src . _ensureCanvas ( ) ;
109+ textureData = this . src . canvas ;
110+ } else {
111+ // if param is a video HTML element
112+ if ( this . src . _checkIfTextureNeedsUpdate ) {
113+ this . src . _checkIfTextureNeedsUpdate ( ) ;
114+ }
115+ textureData = this . src . elt ;
108116 }
109- textureData = this . src . elt ;
110117 } else if ( this . isSrcP5Graphics || this . isSrcP5Renderer ) {
111118 textureData = this . src . canvas ;
112119 } else if ( this . isImageData ) {
You can’t perform that action at this time.
0 commit comments