gpt4 book ai didi

javascript - THREE.FontLoader() 在三个 JS 中不起作用

转载 作者:行者123 更新时间:2023-12-05 00:31:04 25 4
gpt4 key购买 nike

我是三个 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 元素内。
我的控制台错误: My console Errors

最佳答案

该错误意味着 FontLoader不再是核心库的一部分,因为 r133 .您需要额外的导入才能在应用程序中使用此加载器。试试看:

import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
请注意,您使用 FontLoader现在没有 THREE命名空间。

关于javascript - THREE.FontLoader() 在三个 JS 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71272396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com