I attempted to generate 3D text with FontLoader in Three.js, but encountered an error.
My Three.js version is r99.
const loader = new THREE.FontLoader();
//https://github.com/mrdoob/three.js/tree/dev/examples/fonts
loader.load("./fonts/helvetiker_regular.typeface.json", function(font) {
const textGeometry = new THREE.TextGeometry("Hello!", {
font: font,
size: 20,
height: 5,
curveSegments: 12
});
const material = new THREE.MeshNormalMaterial();
const textMesh = new THREE.Mesh(textGeometry, material);
scene.add(textMesh);
});
The Chrome developer tool output is:
THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.
VM5770:1 Uncaught SyntaxError: Unexpected token T in JSON at position 0
at JSON.parse (<anonymous>)
at Object.onLoad (three.module.js:39064)
at XMLHttpRequest.<anonymous> (three.module.js:33974)
VM 5770(?) appears to be pointing to the index.html contents. The "T" might refer to the T in
<meta charset = "UTF-8" />.
This issue has me stumped. Any suggestions?