Skip to content

Commit

Permalink
Merge pull request #5615 from mozilla/FixDarkenedVideoTextureTarget2
Browse files Browse the repository at this point in the history
Fix darkened video-texture-target
  • Loading branch information
takahirox authored Aug 17, 2022
2 parents 221d2f1 + baacf7c commit 960aaf3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/tools/pen-laser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ AFRAME.registerComponent("pen-laser", {
material = convertStandardMaterial(material, quality);

const tipMaterial = material.clone();
tipMaterial.onBeforeRender = material.onBeforeRender;

const lineCurve = new THREE.LineCurve3(new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, 2));
const geometry = new THREE.TubeBufferGeometry(lineCurve, 2, 0.003, 8, true);
Expand Down
5 changes: 2 additions & 3 deletions src/components/video-texture-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ AFRAME.registerComponent("video-texture-target", {
const texture = videoTextureSource.renderTarget.texture;
this.applyTexture(texture);

// Bit of a hack here to only update the renderTarget when the screens are in view
material.map.isVideoTexture = true;
material.map.update = () => {
// Only update the renderTarget when the screens are in view
material.onBeforeRender = () => {
videoTextureSource.textureNeedsUpdate = true;
};
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/material-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class HubsMeshBasicMaterial extends THREE.MeshBasicMaterial {
const material = new HubsMeshBasicMaterial();

THREE.Material.prototype.copy.call(material, source);
material.onBeforeRender = source.onBeforeRender;

material.color.copy(source.color);

Expand Down Expand Up @@ -130,6 +131,7 @@ class HubsMeshPhongMaterial extends THREE.MeshPhongMaterial {
const material = new HubsMeshPhongMaterial();

THREE.Material.prototype.copy.call(material, source);
material.onBeforeRender = source.onBeforeRender;

material.color.copy(source.color);

Expand Down
1 change: 1 addition & 0 deletions src/utils/media-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export function injectCustomShaderChunks(obj) {
return material;

const newMaterial = material.clone();
newMaterial.onBeforeRender = material.onBeforeRender;
newMaterial.onBeforeCompile = (shader, renderer) => {
if (shader.vertexShader.indexOf("#include <skinning_vertex>") == -1) return;

Expand Down

0 comments on commit 960aaf3

Please sign in to comment.