提交 86700091 编写于 作者: M Mr.doob

MaterialLoader/MaterialExporter: Added blending and refactoring.

上级 9b3b209d
......@@ -27,6 +27,7 @@ THREE.MaterialExporter.prototype = {
output.type = 'MeshBasicMaterial';
output.color = material.color.getHex();
if ( material.vertexColors !== THREE.NoColors ) output.vertexColors = material.vertexColors;
if ( material.blending !== THREE.NormalBlending ) output.blending = material.blending;
output.opacity = material.opacity;
output.transparent = material.transparent;
output.wireframe = material.wireframe;
......@@ -38,6 +39,7 @@ THREE.MaterialExporter.prototype = {
output.ambient = material.ambient.getHex();
output.emissive = material.emissive.getHex();
if ( material.vertexColors !== THREE.NoColors ) output.vertexColors = material.vertexColors;
if ( material.blending !== THREE.NormalBlending ) output.blending = material.blending;
output.opacity = material.opacity;
output.transparent = material.transparent;
output.wireframe = material.wireframe;
......@@ -51,6 +53,7 @@ THREE.MaterialExporter.prototype = {
output.specular = material.specular.getHex();
output.shininess = material.shininess;
if ( material.vertexColors !== THREE.NoColors ) output.vertexColors = material.vertexColors;
if ( material.blending !== THREE.NormalBlending ) output.blending = material.blending;
output.opacity = material.opacity;
output.transparent = material.transparent;
output.wireframe = material.wireframe;
......@@ -58,6 +61,7 @@ THREE.MaterialExporter.prototype = {
} else if ( material instanceof THREE.MeshNormalMaterial ) {
output.type = 'MeshNormalMaterial';
if ( material.blending !== THREE.NormalBlending ) output.blending = material.blending;
output.opacity = material.opacity;
output.transparent = material.transparent;
output.wireframe = material.wireframe;
......@@ -65,6 +69,7 @@ THREE.MaterialExporter.prototype = {
} else if ( material instanceof THREE.MeshDepthMaterial ) {
output.type = 'MeshDepthMaterial';
if ( material.blending !== THREE.NormalBlending ) output.blending = material.blending;
output.opacity = material.opacity;
output.transparent = material.transparent;
output.wireframe = material.wireframe;
......
......@@ -34,82 +34,18 @@ THREE.MaterialLoader.prototype = {
parse: function ( json ) {
var material;
switch ( json.type ) {
case 'MeshBasicMaterial':
material = new THREE.MeshBasicMaterial( {
color: json.color,
opacity: json.opacity,
transparent: json.transparent,
wireframe: json.wireframe
} );
break;
case 'MeshLambertMaterial':
material = new THREE.MeshLambertMaterial( {
color: json.color,
ambient: json.ambient,
emissive: json.emissive,
opacity: json.opacity,
transparent: json.transparent,
wireframe: json.wireframe
} );
break;
case 'MeshPhongMaterial':
material = new THREE.MeshPhongMaterial( {
color: json.color,
ambient: json.ambient,
emissive: json.emissive,
specular: json.specular,
shininess: json.shininess,
opacity: json.opacity,
transparent: json.transparent,
wireframe: json.wireframe
} );
break;
case 'MeshNormalMaterial':
material = new THREE.MeshNormalMaterial( {
opacity: json.opacity,
transparent: json.transparent,
wireframe: json.wireframe
} );
break;
case 'MeshDepthMaterial':
material = new THREE.MeshDepthMaterial( {
opacity: json.opacity,
transparent: json.transparent,
wireframe: json.wireframe
} );
break;
}
var material = new THREE[ json.type ];
if ( json.color !== undefined ) material.color.setHex( json.color );
if ( json.ambient !== undefined ) material.ambient.setHex( json.ambient );
if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive );
if ( json.specular !== undefined ) material.specular.setHex( json.specular );
if ( json.shininess !== undefined ) material.shininess = json.shininess;
if ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors;
if ( json.blending !== undefined ) material.blending = json.blending;
if ( json.opacity !== undefined ) material.opacity = json.opacity;
if ( json.transparent !== undefined ) material.transparent = json.transparent;
if ( json.wireframe !== undefined ) material.wireframe = json.wireframe;
return material;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册