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

Dumber (but safer) approach for material.clone().

上级 8439417f
......@@ -43,43 +43,45 @@ THREE.Material.prototype.setValues = function ( values ) {
for ( var key in values ) {
if ( key === 'id' || key === 'setValues' || key === 'clone' ) continue;
var value = values[ key ];
if ( this[ key ] !== undefined ) {
if ( this[ key ] instanceof THREE.Color ) {
if ( value instanceof THREE.Color ) {
this[ key ] = value;
this[ key ].copy( value );
}
} else {
}
};
this[ key ].setHex( value );
THREE.Material.prototype.clone = function () {
}
} else if ( this[ key ] instanceof THREE.Vector3 ) {
material.name = this.name;
this[ key ].copy( value );
material.side = this.side;
} else {
material.opacity = this.opacity;
material.transparent = this.transparent;
this[ key ] = value;
material.blending = this.blending;
}
material.blendSrc = this.blendSrc;
material.blendDst = this.blendDst;
material.blendEquation = this.blendEquation;
}
material.depthTest = this.depthTest;
material.depthWrite = this.depthWrite;
}
material.polygonOffset = this.polygonOffset;
material.polygonOffsetFactor = this.polygonOffsetFactor;
material.polygonOffsetUnits = this.polygonOffsetUnits;
};
material.alphaTest = this.alphaTest;
THREE.Material.prototype.clone = function () {
material.overdraw = this.overdraw;
return new THREE.Material( this );
material.visible = this.visible;
};
......
......@@ -67,6 +67,33 @@ THREE.MeshBasicMaterial.prototype = Object.create( THREE.Material.prototype );
THREE.MeshBasicMaterial.prototype.clone = function () {
return new THREE.MeshBasicMaterial( this );
var material = new THREE.MeshBasicMaterial();
material.color.copy( this.color );
material.map = this.map;
material.lightMap = this.lightMap;
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;
return material;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册