Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
linter
  • Loading branch information
kylebakerio committed Aug 30, 2022
commit 5beffda4aef1bc6dc718eeebf3d4111195eda6fb
18 changes: 4 additions & 14 deletions src/components/oculus-touch-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,10 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
if (!this.buttonMeshes[button]) return;
this.buttonMeshes[button].traverse((node) => {
if (node.type !== 'Mesh') return;
var originalMaterial = node.material;
this.buttonMeshes[button].naturalColor = originalMaterial.color;
node.material = new THREE.MeshStandardMaterial();

// preserve details; not iterable, so we have to use Object.keys()
Object.keys(originalMaterial).forEach(key => {
if (originalMaterial[key] !== node.material[key]) {
// because A-Frame uses the same single material object for all material nodes, it also uses the
// same color. This means they use the same color object--we have to break that link. Other links
// likely also exist, but they don't matter to us, because color is the only one we change.
node.material[key] = key !== 'color' ? originalMaterial[key] : originalMaterial[key].clone();
}
});
originalMaterial.dispose();
let newMaterial = node.material.clone();
this.buttonMeshes[button].naturalColor = node.material.color;
node.material.dispose();
node.material = newMaterial;
});
},

Expand Down