小编rga*_*rah的帖子

未捕获的 SyntaxError Three.js FontLoader

我尝试在 Three.js 中使用 FontLoader 创建 3D 文本,但出现错误。

我使用 Three.js 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);
  });
Run Code Online (Sandbox Code Playgroud)

Chrome 开发者工具的输出如下。

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)
Run Code Online (Sandbox Code Playgroud)

而 VM …

javascript three.js

3
推荐指数
1
解决办法
767
查看次数

标签 统计

javascript ×1

three.js ×1