ti3*_*uxx 6 javascript three.js reactjs react-three-fiber
我是 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;
Run Code Online (Sandbox Code Playgroud)
我的错误: //THREE.FontLoader 已移至 /examples/jsm/loaders/FontLoader.js
//未捕获类型错误:(中间值).parse 不是函数
当然,该组件将位于主页的 Canvas 元素内。我的控制台错误 :我的控制台错误
Mug*_*n87 17
该错误意味着它FontLoader
不再是核心库的一部分,因为r133
. 您需要额外导入才能在应用程序中使用此加载程序。尝试一下:
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
Run Code Online (Sandbox Code Playgroud)
请注意,您使用的FontLoader
now 没有THREE
命名空间。
归档时间: |
|
查看次数: |
5389 次 |
最近记录: |