I got the following error
Uncaught TypeError: Cannot read property 'normal' of undefined
after running the following code on my webpage:
var text_geo = new THREE.TextGeometry("H", {size:20});
var text_mat = new THREE.MeshBasicMaterial({color:"white", overdraw:true});
var txt = new THREE.Mesh(text_geo, text_mat);
When I use the Chrome debugger, it traces the problem to the three.js source code file. Is there a way to get around this?
Thanks
I got the following error
Uncaught TypeError: Cannot read property 'normal' of undefined
after running the following code on my webpage:
var text_geo = new THREE.TextGeometry("H", {size:20});
var text_mat = new THREE.MeshBasicMaterial({color:"white", overdraw:true});
var txt = new THREE.Mesh(text_geo, text_mat);
When I use the Chrome debugger, it traces the problem to the three.js source code file. Is there a way to get around this?
Thanks
- where is 'normal' in your code? – Lucas Commented Jan 10, 2014 at 1:25
- I don't have 'normal' anywhere in my code. I think it is the default value for one of the properties of TextGeometry. – user3179985 Commented Jan 10, 2014 at 1:26
- Normal is a property of each face of the geometry. Each face has three vertices with an associated normal or one normal defined per face. The error suggests the faces are not being generated for the geometry. – user1329695 Commented Jan 10, 2014 at 14:22
1 Answer
Reset to default 7I've faced the same problem, you should download a font to let THREE.js use it. As default font is helvetiker
, it is located here, add it to the page just as regular JavaScript
<script src="http://mrdoob.github./three.js/examples/fonts/helvetiker_regular.typeface.js"></script>
Be sure, that you load the font after THREE.js.
If you want to use font of another type, you can download the respective font and set a weight
property:
<script src="http://mrdoob.github./three.js/examples/fonts/helvetiker_bold.typeface.js"></script>
var text_geo = new THREE.TextGeometry("H", {size:20, weight: "bold"});
r.54