-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaterial.js
More file actions
52 lines (41 loc) · 1.69 KB
/
material.js
File metadata and controls
52 lines (41 loc) · 1.69 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
define(function(){
//color - RGB array [r, g, b], specularity 0 - 1, specularMultiplier 0 - 15, specularExponent 0 - infinity, diffusion 0 - 1, ambience 0 - 1, shine unsigned int, reflectivity
//set by passing in an object eg. {"color":"#808080", "diffusion":0.5 ... etc.}
function Material(m) {
this.color = [128, 128, 128];
this.specularity = 1;
this.diffusion = 1;
this.ambience = 1;
this.shine = 100;
this.specularMultiplier = 5;
this.specularExponent = 3;
this.reflectivity = 0;
if (typeof m !== 'undefined'){
if (typeof m.color !== 'undefined'){
this.color = m.color;
}
if (typeof m.specularity !== 'undefined'){
this.specularity = m.specularity;
}
if (typeof m.diffusion !== 'undefined'){
this.diffusion = m.diffusion;
}
if (typeof m.ambience !== 'undefined'){
this.ambience = m.ambience;
}
if (typeof m.shine !== 'undefined'){
this.shine = m.shine;
}
if (typeof m.specularMultiplier !== 'undefined'){
this.specularMultiplier = m.specularMultiplier;
}
if (typeof m.specularExponent !== 'undefined'){
this.specularExponent = m.specularExponent;
}
if (typeof m.reflectivity !== "undefined"){
this.reflectivity = m.reflectivity;
}
}
}
return Material;
});