MeshLambertMaterial.js 3.1 KB
Newer Older
N
Nicolas Garcia Belmonte 已提交
1 2
/**
 * @author mr.doob / http://mrdoob.com/
3
 * @author alteredq / http://alteredqualia.com/
M
Mr.doob 已提交
4 5 6
 *
 * parameters = {
 *  color: <hex>,
7
 *  ambient: <hex>,
8
 *  emissive: <hex>,
9
 *  opacity: <float>,
10
 *
11
 *  map: new THREE.Texture( <Image> ),
12
 *
13
 *  lightMap: new THREE.Texture( <Image> ),
14
 *
15
 *  envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
16
 *  combine: THREE.Multiply,
17
 *  reflectivity: <float>,
18
 *  refractionRatio: <float>,
19
 *
20
 *  shading: THREE.SmoothShading,
M
Mr.doob 已提交
21
 *  blending: THREE.NormalBlending,
22
 *  depthTest: <bool>,
23
 *
M
Mr.doob 已提交
24
 *  wireframe: <boolean>,
25
 *  wireframeLinewidth: <float>,
26
 *
27 28
 *  vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
 *
29
 *  skinning: <bool>,
30 31
 *  morphTargets: <bool>,
 *  morphNormals: <bool>,
32 33
 *
 *	fog: <bool>
34
 * }
N
Nicolas Garcia Belmonte 已提交
35 36
 */

M
Mr.doob 已提交
37
THREE.MeshLambertMaterial = function ( parameters ) {
N
Nicolas Garcia Belmonte 已提交
38

39
	THREE.Material.call( this, parameters );
40

41
	parameters = parameters || {};
42

43
	// color property represents diffuse for MeshLambertMaterial
44

45
	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
46
	this.ambient = parameters.ambient !== undefined ? new THREE.Color( parameters.ambient ) : new THREE.Color( 0xffffff );
47
	this.emissive = parameters.emissive !== undefined ? new THREE.Color( parameters.emissive ) : new THREE.Color( 0x000000 );
48

49 50 51
	this.wrapAround = parameters.wrapAround !== undefined ? parameters.wrapAround: false;
	this.wrapRGB = new THREE.Vector3( 1, 1, 1 );

52
	this.map = parameters.map !== undefined ? parameters.map : null;
53

54
	this.lightMap = parameters.lightMap !== undefined ? parameters.lightMap : null;
55

56 57 58 59
	this.envMap = parameters.envMap !== undefined ? parameters.envMap : null;
	this.combine = parameters.combine !== undefined ? parameters.combine : THREE.MultiplyOperation;
	this.reflectivity = parameters.reflectivity !== undefined ? parameters.reflectivity : 1;
	this.refractionRatio = parameters.refractionRatio !== undefined ? parameters.refractionRatio : 0.98;
N
Nicolas Garcia Belmonte 已提交
60

61
	this.fog = parameters.fog !== undefined ? parameters.fog : true;
62

63
	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading;
N
Nicolas Garcia Belmonte 已提交
64

65 66 67 68
	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
	this.wireframeLinecap = parameters.wireframeLinecap !== undefined ? parameters.wireframeLinecap : 'round';
	this.wireframeLinejoin = parameters.wireframeLinejoin !== undefined ? parameters.wireframeLinejoin : 'round';
69

70
	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : THREE.NoColors;
71

72 73
	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false;
	this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false;
A
alteredq 已提交
74
	this.morphNormals = parameters.morphNormals !== undefined ? parameters.morphNormals : false;
M
Mr.doob 已提交
75

76
};
77

78
THREE.MeshLambertMaterial.prototype = Object.create( THREE.Material.prototype );
L
libra guest 已提交
79 80 81 82 83 84

THREE.MeshLambertMaterial.prototype.clone = function(){ 
	var returnValue = new THREE.MeshLambertMaterial(this);
	returnValue.wrapRGB = this.wrapRGB.clone();
	return returnValue;
};