最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Three.js - Uncaught TypeError: Cannot read property 'normal' of undefined - Stack Overflow

programmeradmin2浏览0评论

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

Share Improve this question edited Jan 10, 2014 at 1:46 WestLangley 105k11 gold badges287 silver badges283 bronze badges asked Jan 10, 2014 at 1:23 user3179985user3179985 932 silver badges6 bronze badges 3
  • 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
Add a ment  | 

1 Answer 1

Reset to default 7

I'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

发布评论

评论列表(0)

  1. 暂无评论