-
Notifications
You must be signed in to change notification settings - Fork 1
/
greyscale.js
33 lines (29 loc) · 958 Bytes
/
greyscale.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
javascript:
if (typeof material_storage === 'undefined') {
var material_storage = {};
};
if (!('type' in material_storage) ||material_storage['type'] == 'GREYSCALE') {
material_storage['type'] = 'GREYSCALE';
AFRAME.scenes[0].object3D.traverse(o => {
if (o.isMesh) {
if (!(o.uuid in material_storage)) {
material_storage[o.uuid] = {
'color': o.material.color,
'map': o.material.map,
'vertexColors': o.material.vertexColors,
};
}
}
});
var color = new THREE.Color( 0x666666 );
AFRAME.scenes[0].object3D.traverse(o => {
if (o.isMesh) {
if (o.uuid in material_storage) {
o.material.color = color;
o.material.map = null;
o.material.vertexColors = false;
o.material.needsUpdate = true;
}
}
});
}