MCPcopy
hub / github.com/aframevr/aframe / cloneMeshMaterial

Function cloneMeshMaterial

src/components/meta-touch-controls.js:477–486  ·  view source on GitHub ↗

* 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.

(object3d)

Source from the content-addressed store, hash-verified

475 * In order to change their color independently we have to create separate materials.
476 */
477function cloneMeshMaterial (object3d) {
478 object3d.traverse(function (node) {
479 var newMaterial;
480 if (node.type !== 'Mesh') return;
481 newMaterial = node.material.clone();
482 object3d.originalColor = node.material.color;
483 node.material.dispose();
484 node.material = newMaterial;
485 });
486}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected