提交 76b8032e 编写于 作者: A alteredq

Updated text example with normals hack to be able to use smooth shading also...

Updated text example with normals hack to be able to use smooth shading also for unbeveled geometry.
上级 692b3927
......@@ -386,6 +386,7 @@
}
function createText() {
textGeo = new THREE.TextGeometry( text, {
size: size,
......@@ -403,13 +404,38 @@
bend: bend,
material: textMaterialFront,
extrudeMaterial: bevelEnabled ? textMaterialSide : textMaterialFront
extrudeMaterial: textMaterialSide
});
textGeo.computeBoundingBox();
textGeo.computeVertexNormals();
// "fix" side normals by removing z-component of normals for side faces
// (this doesn't work well for beveled geometry as then we lose nice curvature around z-axis)
if ( ! bevelEnabled ) {
for ( var i = 0; i < textGeo.faces.length; i ++ ) {
var face = textGeo.faces[ i ];
if ( face.materials[ 0 ].id == textMaterialSide.id ) {
for ( var j = 0; j < face.vertexNormals.length; j ++ ) {
face.vertexNormals[ j ].z = 0;
face.vertexNormals[ j ].normalize();
}
}
}
}
var centerOffset = -0.5 * ( textGeo.boundingBox.x[ 1 ] - textGeo.boundingBox.x[ 0 ] );
textMesh1 = new THREE.Mesh( textGeo, faceMaterial );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册