Skip to content

Commit fb93bcc

Browse files
committed
Reintroduce a needsRedraw flag that can be set to true to update the quad layer if you use a canvas as src
1 parent 849636d commit fb93bcc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/layer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export var Component = registerComponent('layer', {
1616
init: function () {
1717
this.quaternion = new THREE.Quaternion();
1818
this.position = new THREE.Vector3();
19+
// From another component, set this.el.components.layer.needsRedraw = true
20+
// if you use a canvas as src and want to redraw the layer.
21+
this.needsRedraw = false;
1922

2023
this.bindMethods();
2124

@@ -209,7 +212,7 @@ export var Component = registerComponent('layer', {
209212
if (!this.layer && (this.el.sceneEl.is('vr-mode') || this.el.sceneEl.is('ar-mode'))) { this.initLayer(); }
210213
this.updateTransform();
211214
if (this.data.src.complete && (this.pendingCubeMapUpdate || this.loadingScreen || this.visibilityChanged)) { this.loadCubeMapImages(); }
212-
if (!this.layer.needsRedraw) { return; }
215+
if (!this.needsRedraw && !this.layer.needsRedraw) { return; }
213216
if (this.textureIsVideo) { return; }
214217
if (this.data.type === 'quad') { this.draw(); }
215218
},
@@ -345,6 +348,7 @@ export var Component = registerComponent('layer', {
345348
gl.bindTexture(gl.TEXTURE_2D, glayer.colorTexture);
346349
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureEl.width, textureEl.height, gl.RGBA, gl.UNSIGNED_BYTE, textureEl);
347350
gl.bindTexture(gl.TEXTURE_2D, null);
351+
this.needsRedraw = false;
348352
},
349353

350354
updateTransform: function () {

0 commit comments

Comments
 (0)