1 | /**
|
---|
2 | * @author mrdoob / http://mrdoob.com/
|
---|
3 | * @author alteredq / http://alteredqualia.com/
|
---|
4 | *
|
---|
5 | * parameters = {
|
---|
6 | * color: <hex>,
|
---|
7 | * ambient: <hex>,
|
---|
8 | * emissive: <hex>,
|
---|
9 | * specular: <hex>,
|
---|
10 | * shininess: <float>,
|
---|
11 | * opacity: <float>,
|
---|
12 | *
|
---|
13 | * map: new THREE.Texture( <Image> ),
|
---|
14 | *
|
---|
15 | * lightMap: new THREE.Texture( <Image> ),
|
---|
16 | *
|
---|
17 | * bumpMap: new THREE.Texture( <Image> ),
|
---|
18 | * bumpScale: <float>,
|
---|
19 | *
|
---|
20 | * normalMap: new THREE.Texture( <Image> ),
|
---|
21 | * normalScale: <Vector2>,
|
---|
22 | *
|
---|
23 | * specularMap: new THREE.Texture( <Image> ),
|
---|
24 | *
|
---|
25 | * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
|
---|
26 | * combine: THREE.Multiply,
|
---|
27 | * reflectivity: <float>,
|
---|
28 | * refractionRatio: <float>,
|
---|
29 | *
|
---|
30 | * shading: THREE.SmoothShading,
|
---|
31 | * blending: THREE.NormalBlending,
|
---|
32 | * depthTest: <bool>,
|
---|
33 | * depthWrite: <bool>,
|
---|
34 | *
|
---|
35 | * wireframe: <boolean>,
|
---|
36 | * wireframeLinewidth: <float>,
|
---|
37 | *
|
---|
38 | * vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
|
---|
39 | *
|
---|
40 | * skinning: <bool>,
|
---|
41 | * morphTargets: <bool>,
|
---|
42 | * morphNormals: <bool>,
|
---|
43 | *
|
---|
44 | * fog: <bool>
|
---|
45 | * }
|
---|
46 | */
|
---|
47 |
|
---|
48 | THREE.MeshPhongMaterial = function ( parameters ) {
|
---|
49 |
|
---|
50 | THREE.Material.call( this );
|
---|
51 |
|
---|
52 | this.color = new THREE.Color( 0xffffff ); // diffuse
|
---|
53 | this.ambient = new THREE.Color( 0xffffff );
|
---|
54 | this.emissive = new THREE.Color( 0x000000 );
|
---|
55 | this.specular = new THREE.Color( 0x111111 );
|
---|
56 | this.shininess = 30;
|
---|
57 |
|
---|
58 | this.metal = false;
|
---|
59 | this.perPixel = true;
|
---|
60 |
|
---|
61 | this.wrapAround = false;
|
---|
62 | this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
|
---|
63 |
|
---|
64 | this.map = null;
|
---|
65 |
|
---|
66 | this.lightMap = null;
|
---|
67 |
|
---|
68 | this.bumpMap = null;
|
---|
69 | this.bumpScale = 1;
|
---|
70 |
|
---|
71 | this.normalMap = null;
|
---|
72 | this.normalScale = new THREE.Vector2( 1, 1 );
|
---|
73 |
|
---|
74 | this.specularMap = null;
|
---|
75 |
|
---|
76 | this.envMap = null;
|
---|
77 | this.combine = THREE.MultiplyOperation;
|
---|
78 | this.reflectivity = 1;
|
---|
79 | this.refractionRatio = 0.98;
|
---|
80 |
|
---|
81 | this.fog = true;
|
---|
82 |
|
---|
83 | this.shading = THREE.SmoothShading;
|
---|
84 |
|
---|
85 | this.wireframe = false;
|
---|
86 | this.wireframeLinewidth = 1;
|
---|
87 | this.wireframeLinecap = 'round';
|
---|
88 | this.wireframeLinejoin = 'round';
|
---|
89 |
|
---|
90 | this.vertexColors = THREE.NoColors;
|
---|
91 |
|
---|
92 | this.skinning = false;
|
---|
93 | this.morphTargets = false;
|
---|
94 | this.morphNormals = false;
|
---|
95 |
|
---|
96 | this.setValues( parameters );
|
---|
97 |
|
---|
98 | };
|
---|
99 |
|
---|
100 | THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
|
---|
101 |
|
---|
102 | THREE.MeshPhongMaterial.prototype.clone = function () {
|
---|
103 |
|
---|
104 | var material = new THREE.MeshPhongMaterial();
|
---|
105 |
|
---|
106 | THREE.Material.prototype.clone.call( this, material );
|
---|
107 |
|
---|
108 | material.color.copy( this.color );
|
---|
109 | material.ambient.copy( this.ambient );
|
---|
110 | material.emissive.copy( this.emissive );
|
---|
111 | material.specular.copy( this.specular );
|
---|
112 | material.shininess = this.shininess;
|
---|
113 |
|
---|
114 | material.metal = this.metal;
|
---|
115 | material.perPixel = this.perPixel;
|
---|
116 |
|
---|
117 | material.wrapAround = this.wrapAround;
|
---|
118 | material.wrapRGB.copy( this.wrapRGB );
|
---|
119 |
|
---|
120 | material.map = this.map;
|
---|
121 |
|
---|
122 | material.lightMap = this.lightMap;
|
---|
123 |
|
---|
124 | material.bumpMap = this.bumpMap;
|
---|
125 | material.bumpScale = this.bumpScale;
|
---|
126 |
|
---|
127 | material.normalMap = this.normalMap;
|
---|
128 | material.normalScale.copy( this.normalScale );
|
---|
129 |
|
---|
130 | material.specularMap = this.specularMap;
|
---|
131 |
|
---|
132 | material.envMap = this.envMap;
|
---|
133 | material.combine = this.combine;
|
---|
134 | material.reflectivity = this.reflectivity;
|
---|
135 | material.refractionRatio = this.refractionRatio;
|
---|
136 |
|
---|
137 | material.fog = this.fog;
|
---|
138 |
|
---|
139 | material.shading = this.shading;
|
---|
140 |
|
---|
141 | material.wireframe = this.wireframe;
|
---|
142 | material.wireframeLinewidth = this.wireframeLinewidth;
|
---|
143 | material.wireframeLinecap = this.wireframeLinecap;
|
---|
144 | material.wireframeLinejoin = this.wireframeLinejoin;
|
---|
145 |
|
---|
146 | material.vertexColors = this.vertexColors;
|
---|
147 |
|
---|
148 | material.skinning = this.skinning;
|
---|
149 | material.morphTargets = this.morphTargets;
|
---|
150 | material.morphNormals = this.morphNormals;
|
---|
151 |
|
---|
152 | return material;
|
---|
153 |
|
---|
154 | };
|
---|