Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help on THREE.js TextGeometry

Tags:

three.js

Not sure why following code (basically a cut & paste from example) is returning error.

var textWhy = new THREE.TextGeometry( "Why", { size: 10, height: 5, curveSegments: 6, font: "helvetiker", weight: "normal", style: "bold" });

Cannot read property 'normal' of undefined

I am new to webgl, hope someone can point me to a solution.

Thanks.

Tried with this simplest snippet. Result is the same.

<html>
<head>
<title>Three.js Why Text</title>
<script src="typeface-0.15.js"></script>
<script src="helvetiker_regular.typeface.js"></script>
<script src="helvetiker_bold.typeface.js"></script>
<script type="text/javascript" src="Three.min.js"></script>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        textWhy = new THREE.TextGeometry( "Why", { size: 10, height: 5, curveSegments: 6, font: "helvetiker", weight: "normal", style: "normal" });
    });
</script>
</head>
<body>
</body>
</html>
like image 813
sglai Avatar asked Dec 28 '11 13:12

sglai


1 Answers

Found that I should not use "typeface-0.15.js" but only the font helvetiker_*.typeface.js. The 'load' function is provided in Three.js. So it should be:

<html>
<head>
<title>Three.js Why Text</title>
<script type="text/javascript" src="Three.min.js"></script>
<script src="helvetiker_regular.typeface.js"></script>
<script src="helvetiker_bold.typeface.js"></script>
...
like image 105
sglai Avatar answered Sep 18 '22 08:09

sglai