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

javascript - THREE.FontLoader() doesn't work in Three JS - Stack Overflow

programmeradmin1浏览0评论

I'm new in Three JS and I would like to create a 3D text. I followed most of the tuto to create it, but I have an error even if I follow all the steps or copy/past the tuto's code. This is my component :

import * as THREE from "three";
import bumped from "../Bumped.json";

const Text = () => {
  const font = new THREE.FontLoader().parse(bumped);

  const textOptions = {
    font,
    size: 5,
    height: 1,
  };

  return (
    <mesh>
      <textGeometry attach="geometry" args={["three.js", textOptions]} />
      <meshStandardMaterial attach="material" />
    </mesh>
  );
};

export default Text;

My errors : //THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js

//Uncaught TypeError: (intermediate value).parse is not a function

Of course, this component will be inside a Canvas element in the main page. My console Errors : My console Errors

I'm new in Three JS and I would like to create a 3D text. I followed most of the tuto to create it, but I have an error even if I follow all the steps or copy/past the tuto's code. This is my component :

import * as THREE from "three";
import bumped from "../Bumped.json";

const Text = () => {
  const font = new THREE.FontLoader().parse(bumped);

  const textOptions = {
    font,
    size: 5,
    height: 1,
  };

  return (
    <mesh>
      <textGeometry attach="geometry" args={["three.js", textOptions]} />
      <meshStandardMaterial attach="material" />
    </mesh>
  );
};

export default Text;

My errors : //THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js

//Uncaught TypeError: (intermediate value).parse is not a function

Of course, this component will be inside a Canvas element in the main page. My console Errors : My console Errors

Share Improve this question asked Feb 25, 2022 at 22:34 ti3uxxti3uxx 631 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 19

The error means that FontLoader is not part of the core library anymore since r133. You need an additional import to use this loader in your application. Try it with:

import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';

Notice that you use FontLoader now without the THREE namespace.

发布评论

评论列表(0)

  1. 暂无评论