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
requested changes to comments
  • Loading branch information
kylebakerio committed Sep 13, 2022
commit 536b354540dd2cb43ffca59c403f8780c628c6a7
11 changes: 4 additions & 7 deletions src/components/oculus-touch-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ module.exports.Component = registerComponent('oculus-touch-controls', {

for (var button in this.buttonMeshes) {
if (this.buttonMeshes[button]) {
cloneMaterialToTHREE(this.buttonMeshes[button]);
cloneMeshMaterials(this.buttonMeshes[button]);
}
}

Expand Down Expand Up @@ -470,13 +470,10 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
});

/**
* A-Frame's material component makes a single unified shared material for all child meshes.
* In order to be able to color individual buttons, we need to give each sub-mesh its own
* THREE material. Without this, changing the color on any individual button mesh changes
* the color on every button mesh.
* Some of the controller models share the same material for different parts (buttons, triggers...).
* In order to change their color independently we have to create separate materials.
*/

function cloneMaterialToTHREE (object3d) {
function cloneMeshMaterials (object3d) {
object3d.traverse(function (node) {
if (node.type !== 'Mesh') return;
let newMaterial = node.material.clone();
Expand Down