Three.js: Error "Cannot read property 'y' of undefined" in the file ShapePath.js

Created on 8 Sep 2020  路  6Comments  路  Source: mrdoob/three.js

If in the file Font.js in the function createPath value glyph.o ends with text "m {number} {number} z " (e.g. "m 167 878 z ") then in the file ShapePath.js in the function isPointInsidePolygon occurs this error:
image
image

This happens, for example, when I use character "脰" of font Calibri.

In the file ShapePath.js in the function toShapes this code:

} else {

    newShapeHoles[ mainIdx ].push( { h: tmpPath, p: tmpPoints[ 0 ] } );

should be changed to this code:

} else if ( tmpPoints.length ) {

    newShapeHoles[ mainIdx ].push( { h: tmpPath, p: tmpPoints[ 0 ] } );

All 6 comments

Can you create a jsfiddle?

I've checked out your fiddle but I don't think the suggested change is appropriate. We should clarify instead why THREE.Font creates an empty sub path.

Does a definition of "m {number} {number} z " actually makes sense? Could this be a problem in the font generator?

The JSON file used in jsfiddle was generated using generator http://gero3.github.io/facetype.js/ and using TTF file downloaded from https://www.fontmirror.com/calibri.

I have replaced all texts "m {number} {number} z " with text "z" and now there is no error and the character "脰" seems to be fine: https://jsfiddle.net/blizzard_mindfloat/6smn8heb/2

@gero3 Do you mind having a look at this? It would be good to know why "m {number} {number} z" exists in the JSON (and what's its purpose).

Closing for now. The issue can be reopened if it's proven that facetype.js works as intended.

Was this page helpful?
0 / 5 - 0 ratings