MeshLambertMaterial.js 2.5 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
 *  map: new THREE.Texture( <Image> ),
8
 
9
 *  env_map: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
10
 *  combine: THREE.Multiply,
11
 *  reflectivity: <float>,
12 13
 *  refraction_ratio: <float>,
 
M
Mr.doob 已提交
14
 *  opacity: <float>,
15
 *  shading: THREE.SmoothShading,
M
Mr.doob 已提交
16 17 18
 *  blending: THREE.NormalBlending,
 *  wireframe: <boolean>,
 *  wireframe_linewidth: <float>
19
 * }
N
Nicolas Garcia Belmonte 已提交
20 21
 */

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

24
	this.id = THREE.MeshLambertMaterialCounter.value ++;
N
Nicolas Garcia Belmonte 已提交
25

M
Mr.doob 已提交
26
	this.color = new THREE.Color( 0xeeeeee );
M
Mr.doob 已提交
27
	this.map = null;
28
	
29
	this.env_map = null;
30
	this.combine = THREE.Multiply;
31
	this.reflectivity = 1;
32 33
	this.refraction_ratio = 0.98;
	
M
Mr.doob 已提交
34
	this.opacity = 1;
35
	this.shading = THREE.SmoothShading;
M
Mr.doob 已提交
36 37 38
	this.blending = THREE.NormalBlending;
	this.wireframe = false;
	this.wireframe_linewidth = 1;
N
Nicolas Garcia Belmonte 已提交
39

M
Mr.doob 已提交
40
	if ( parameters ) {
N
Nicolas Garcia Belmonte 已提交
41

M
Mr.doob 已提交
42 43
		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
		if ( parameters.map !== undefined ) this.map = parameters.map;
44
		
45
		if ( parameters.env_map !== undefined ) this.env_map = parameters.env_map;
46
		if ( parameters.combine !== undefined ) this.combine = parameters.combine;
47
		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
48 49
		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
		
M
Mr.doob 已提交
50 51 52 53 54
		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
55

56
	}
M
Mr.doob 已提交
57 58 59 60 61 62 63

	this.toString = function () {

		return 'THREE.MeshLambertMaterial (<br/>' +
			'id: ' + this.id + '<br/>' +
			'color: ' + this.color + '<br/>' +
			'map: ' + this.map + '<br/>' +
64
		
65
			'env_map: ' + this.env_map + '<br/>' +
66
			'combine: ' + this.combine + '<br/>' +
67
			'reflectivity: ' + this.reflectivity + '<br/>' +
68 69
			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
		
M
Mr.doob 已提交
70 71 72 73 74 75 76 77 78
			'opacity: ' + this.opacity + '<br/>' +
			'shading: ' + this.shading + '<br/>' +
			'blending: ' + this.blending + '<br/>' +
			'wireframe: ' + this.wireframe + '<br/>' +
			'wireframe_size: ' + this.wireframe_linewidth + '<br/>' +
			' )';

	};

79 80
};

81
THREE.MeshLambertMaterialCounter = { value: 0 };