renderFace3 method
void
renderFace3(
- dynamic v1,
- dynamic v2,
- dynamic v3,
- dynamic element,
- Material material,
)
Implementation
void renderFace3(RenderableVertex v1,RenderableVertex v2,RenderableVertex v3, RenderableFace element, Material material) {
info.vertices += 3;
info.faces ++;
String path = 'M' + convert(v1.positionScreen.x) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y ) + 'L' + convert( v3.positionScreen.x ) + ',' + convert( v3.positionScreen.y ) + 'z';
String style = '';
if ( material is MeshBasicMaterial) {
_color.copy(material.color);
if ( material.vertexColors ) {
_color.multiply(element.color);
}
}
else if ( material is MeshLambertMaterial || material is MeshPhongMaterial || material is MeshStandardMaterial ) {
_diffuseColor.copy( material.color );
if ( material.vertexColors ) {
_diffuseColor.multiply( element.color );
}
_color.copy( _ambientLight );
_centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 );
calculateLight(lights!, _centroid, element.normalModel, _color);
_color.multiply( _diffuseColor ).add(material.emissive!);
}
else if ( material is MeshNormalMaterial ) {
_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix ).normalize();
_color.setRGB( _normal.x, _normal.y, _normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
}
String colorStyle = _color.getStyle();
if ( material.wireframe ) {
style = 'fill:none;stroke:$colorStyle;stroke-opacity:${material.opacity};stroke-width:${material.wireframeLinewidth};stroke-linecap:${material.wireframeLinecap};stroke-linejoin:${material.wireframeLinejoin}';
}
else {
style = 'fill:$colorStyle;fill-opacity:${material.opacity}';
}
addPath(style, path);
}