MeshBasicMaterial.js 3.0 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.MeshBasicMaterial = function ( parameters ) {
N
Nicolas Garcia Belmonte 已提交
23

M
Mr.doob 已提交
24 25
	this.id = THREE.MeshBasicMaterialCounter.value ++;

26
	this.color = new THREE.Color( 0xffffff );
M
Mr.doob 已提交
27
	this.map = null;
28

29
	this.env_map = null;
30
	this.combine = THREE.MultiplyOperation;
31
	this.reflectivity = 1;
32
	this.refraction_ratio = 0.98;
33

34 35
	this.fog = true;

M
Mr.doob 已提交
36
	this.opacity = 1;
37
	this.shading = THREE.SmoothShading;
M
Mr.doob 已提交
38
	this.blending = THREE.NormalBlending;
39

M
Mr.doob 已提交
40 41
	this.wireframe = false;
	this.wireframe_linewidth = 1;
42 43
	this.wireframe_linecap = 'round';
	this.wireframe_linejoin = 'round';
M
Mr.doob 已提交
44 45 46 47 48

	if ( parameters ) {

		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
		if ( parameters.map !== undefined ) this.map = parameters.map;
49

50
		if ( parameters.env_map !== undefined ) this.env_map = parameters.env_map;
51
		if ( parameters.combine !== undefined ) this.combine = parameters.combine;
52
		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
53
		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
54

55 56
		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;

M
Mr.doob 已提交
57
		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
58
		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
M
Mr.doob 已提交
59
		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
60

M
Mr.doob 已提交
61 62
		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
63 64
		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
M
Mr.doob 已提交
65 66

	}
N
Nicolas Garcia Belmonte 已提交
67

M
Mr.doob 已提交
68 69 70 71 72
};

THREE.MeshBasicMaterial.prototype = {

	toString: function () {
N
Nicolas Garcia Belmonte 已提交
73

M
Mr.doob 已提交
74 75 76 77
		return 'THREE.MeshBasicMaterial (<br/>' +
			'id: ' + this.id + '<br/>' +
			'color: ' + this.color + '<br/>' +
			'map: ' + this.map + '<br/>' +
78

79
			'env_map: ' + this.env_map + '<br/>' +
80
			'combine: ' + this.combine + '<br/>' +
81
			'reflectivity: ' + this.reflectivity + '<br/>' +
82
			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
83

M
Mr.doob 已提交
84 85
			'opacity: ' + this.opacity + '<br/>' +
			'blending: ' + this.blending + '<br/>' +
86

M
Mr.doob 已提交
87 88
			'wireframe: ' + this.wireframe + '<br/>' +
			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
89 90
			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
M
Mr.doob 已提交
91
			')';
N
Nicolas Garcia Belmonte 已提交
92

M
Mr.doob 已提交
93
	}
N
Nicolas Garcia Belmonte 已提交
94

M
Mr.doob 已提交
95
};
M
Mr.doob 已提交
96 97

THREE.MeshBasicMaterialCounter = { value: 0 };