Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix darkened video-texture-target #5615

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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