尝试导入和使用Drei中的HTML,但一直出现错误。

3
  import { Html } from '@react-three/drei';
   
 ./node_modules/three-stdlib/lights/RectAreaLightUniformsLib.js
    Attempted import error: 'DataUtils' is not exported from 'three'.

我尝试查看了关于 drei 在 HTML 上的文档,但得到的结果仍然无法正常工作。

The native route of the library does not export Html or Loader. The default export of the library is web which does export Html and Loader.
import { Icosahedron, Html, OrthographicCamera } from '../../src'



import { HtmlProps, CalculatePosition } from 'web/Html'

我使用

import { Html, useProgress, useGLTFLoader } from "drei";

它有效。

但当我使用时

  import { Html } from '@react-three/drei';

它破裂了


2
drei与threejs有天然的联系,请确保版本至少匹配或一切都是最新的。three不使用semver,这使得它相当困难,但是drei将始终与最新的three一起工作。 "drei"已被弃用,请始终使用@react-three/... - hpalu
1个回答

4

我遇到了类似的问题,并通过 npm install three-stdlib 解决了它。我在 drei git repo 的 README 顶部找到了提示:https://github.com/pmndrs/drei

一个逐渐增长的有用帮助程序和抽象层,是为 react-three-fiber 设计的。

npm install @react-three/drei

该软件包使用独立的three-stdlib而不是three/examples/jsm


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接