158 lines
3.5 KiB
JavaScript
158 lines
3.5 KiB
JavaScript
/**
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author alteredq / http://alteredqualia.com/
|
|
*
|
|
* parameters = {
|
|
* color: <hex>,
|
|
* emissive: <hex>,
|
|
* specular: <hex>,
|
|
* shininess: <float>,
|
|
* opacity: <float>,
|
|
*
|
|
* map: new THREE.Texture( <Image> ),
|
|
*
|
|
* lightMap: new THREE.Texture( <Image> ),
|
|
*
|
|
* bumpMap: new THREE.Texture( <Image> ),
|
|
* bumpScale: <float>,
|
|
*
|
|
* normalMap: new THREE.Texture( <Image> ),
|
|
* normalScale: <Vector2>,
|
|
*
|
|
* specularMap: new THREE.Texture( <Image> ),
|
|
*
|
|
* alphaMap: new THREE.Texture( <Image> ),
|
|
*
|
|
* envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
|
|
* combine: THREE.Multiply,
|
|
* reflectivity: <float>,
|
|
* refractionRatio: <float>,
|
|
*
|
|
* shading: THREE.SmoothShading,
|
|
* blending: THREE.NormalBlending,
|
|
* depthTest: <bool>,
|
|
* depthWrite: <bool>,
|
|
*
|
|
* wireframe: <boolean>,
|
|
* wireframeLinewidth: <float>,
|
|
*
|
|
* vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
|
|
*
|
|
* skinning: <bool>,
|
|
* morphTargets: <bool>,
|
|
* morphNormals: <bool>,
|
|
*
|
|
* fog: <bool>
|
|
* }
|
|
*/
|
|
|
|
THREE.MeshPhongMaterial = function ( parameters ) {
|
|
|
|
THREE.Material.call( this );
|
|
|
|
this.type = 'MeshPhongMaterial';
|
|
|
|
this.color = new THREE.Color( 0xffffff ); // diffuse
|
|
this.emissive = new THREE.Color( 0x000000 );
|
|
this.specular = new THREE.Color( 0x111111 );
|
|
this.shininess = 30;
|
|
|
|
this.metal = false;
|
|
|
|
this.wrapAround = false;
|
|
this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
|
|
|
|
this.map = null;
|
|
|
|
this.lightMap = null;
|
|
|
|
this.bumpMap = null;
|
|
this.bumpScale = 1;
|
|
|
|
this.normalMap = null;
|
|
this.normalScale = new THREE.Vector2( 1, 1 );
|
|
|
|
this.specularMap = null;
|
|
|
|
this.alphaMap = null;
|
|
|
|
this.envMap = null;
|
|
this.combine = THREE.MultiplyOperation;
|
|
this.reflectivity = 1;
|
|
this.refractionRatio = 0.98;
|
|
|
|
this.fog = true;
|
|
|
|
this.shading = THREE.SmoothShading;
|
|
|
|
this.wireframe = false;
|
|
this.wireframeLinewidth = 1;
|
|
this.wireframeLinecap = 'round';
|
|
this.wireframeLinejoin = 'round';
|
|
|
|
this.vertexColors = THREE.NoColors;
|
|
|
|
this.skinning = false;
|
|
this.morphTargets = false;
|
|
this.morphNormals = false;
|
|
|
|
this.setValues( parameters );
|
|
|
|
};
|
|
|
|
THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
|
|
THREE.MeshPhongMaterial.prototype.constructor = THREE.MeshPhongMaterial;
|
|
|
|
THREE.MeshPhongMaterial.prototype.clone = function () {
|
|
|
|
var material = new THREE.MeshPhongMaterial();
|
|
|
|
THREE.Material.prototype.clone.call( this, material );
|
|
|
|
material.color.copy( this.color );
|
|
material.emissive.copy( this.emissive );
|
|
material.specular.copy( this.specular );
|
|
material.shininess = this.shininess;
|
|
|
|
material.metal = this.metal;
|
|
|
|
material.wrapAround = this.wrapAround;
|
|
material.wrapRGB.copy( this.wrapRGB );
|
|
|
|
material.map = this.map;
|
|
|
|
material.lightMap = this.lightMap;
|
|
|
|
material.bumpMap = this.bumpMap;
|
|
material.bumpScale = this.bumpScale;
|
|
|
|
material.normalMap = this.normalMap;
|
|
material.normalScale.copy( this.normalScale );
|
|
|
|
material.specularMap = this.specularMap;
|
|
|
|
material.alphaMap = this.alphaMap;
|
|
|
|
material.envMap = this.envMap;
|
|
material.combine = this.combine;
|
|
material.reflectivity = this.reflectivity;
|
|
material.refractionRatio = this.refractionRatio;
|
|
|
|
material.fog = this.fog;
|
|
|
|
material.shading = this.shading;
|
|
|
|
material.wireframe = this.wireframe;
|
|
material.wireframeLinewidth = this.wireframeLinewidth;
|
|
material.wireframeLinecap = this.wireframeLinecap;
|
|
material.wireframeLinejoin = this.wireframeLinejoin;
|
|
|
|
material.vertexColors = this.vertexColors;
|
|
|
|
material.skinning = this.skinning;
|
|
material.morphTargets = this.morphTargets;
|
|
material.morphNormals = this.morphNormals;
|
|
|
|
return material;
|
|
|
|
};
|