|
|
@@ -11,6 +11,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const _imageDimensions = new Vector2();
|
|
|
const _videoTextures = new WeakMap();
|
|
|
+ const _htmlTextures = new Set();
|
|
|
let _canvas;
|
|
|
|
|
|
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
|
@@ -312,6 +313,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( texture.isHTMLTexture ) {
|
|
|
+
|
|
|
+ _htmlTextures.delete( texture );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function onRenderTargetDispose( event ) {
|
|
|
@@ -1230,10 +1237,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
canvas.appendChild( image );
|
|
|
|
|
|
- // Wait for the browser to paint the element before uploading.
|
|
|
- canvas.onpaint = () => {
|
|
|
+ // Register and set up a shared paint callback for all HTMLTextures.
|
|
|
+ _htmlTextures.add( texture );
|
|
|
+
|
|
|
+ canvas.onpaint = ( event ) => {
|
|
|
+
|
|
|
+ const changed = event.changedElements;
|
|
|
|
|
|
- texture.needsUpdate = true;
|
|
|
+ for ( const t of _htmlTextures ) {
|
|
|
+
|
|
|
+ if ( changed.includes( t.image ) ) {
|
|
|
+
|
|
|
+ t.needsUpdate = true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
};
|
|
|
|