THREE.FontLoader() 在 Three JS 中不起作用
我是 Three JS 的新手,我想创建一个 3D 文本。我按照大部分教程来创建它,但即使我按照所有步骤或复制/粘贴教程的代码,我也会出错。 这是我的组件:
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;
我的错误: //THREE.FontLoader 已移至 /examples/jsm/loaders/FontLoader.js
//Uncaught TypeError: (intermediate value).parse is not a function
当然,此组件将位于主页中的 Canvas 元素内。 我的控制台错误:我的控制台错误
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误意味着自
r133
以来,FontLoader
不再是核心库的一部分。您需要额外导入才能在应用程序中使用此加载程序。尝试一下:请注意,您现在使用的
FontLoader
没有THREE
命名空间。The error means that
FontLoader
is not part of the core library anymore sincer133
. You need an additional import to use this loader in your application. Try it with:Notice that you use
FontLoader
now without theTHREE
namespace.