whs.js: Cannot read property 'ConvexMesh' of undefined with WHS.Text

I’m able to get the examples working and when I paste the following in the playground it works fine, but on my local machine I get Cannot read property ‘ConvexMesh’ of undefined

`const text = new WHS.Text({ geometry: { text: ‘hello world’, parameters: { font: ‘assets/fonts/gentilis_bold.typeface.js’, size: 20, height: 5, curveSegments: 6 } },

mass: 10,

material: { color: 0x00ff00, kind: “lambert” },

pos: { x: -40, y: 20, z: 0 } });

text.addTo(world);`

Version:
  • r9 (dev)
  • r8
  • r7
Issue type:
  • Bug
  • Proposal/Enhancement
  • Question

Tested on:

— Desktop
  • Chrome
  • Chrome Canary
  • Chrome dev-channel
  • Firefox
  • Opera
  • Microsoft IE
  • Microsoft Edge
— Android
  • Chrome
  • Firefox
  • Opera
— IOS
  • Chrome
  • Firefox
  • Opera

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 50 (26 by maintainers)

Most upvoted comments

@Tzikas It’s possible, but this way you may have split your letters into separate meshes. Also trick with using different shapes for graphic and physics should help. I’ll explain:

With this trick you use different geometries for physics shape and three.js mesh. Simplified one you apply to physics to achieve best performance.

image

How can you do it with text? Here is what i suggest:

  • Make a WHS.Text with simplified letter geometry. // This will make such for physics too.
  • Make a high-resolution (as you want) three.js geometry of letter.
  • Apply this geometry to myLetter.getNative().geometry
  • Profit! Now you have a simple geometry for collisions and complex for graphics!

@Tzikas One more advice: reduce the amount of curveSegments. Right now you have 6 of them, you may set to 1.

@Tzikas Those errors in console are not so bad. They are just errors of compiling your font to .js font (for three.js) I had them too, it’s okay.

You may also enable this option. Sometimes it reduces the amount of errors. 4bf797e7-36a0-4915-8ad5-3943a8c720f9