我在Create React App项目中以以下方式安装了three.js:
"three": "^0.115.0",
当我尝试通过以下方式将其导入组件时:
import * as THREE from "three";
然后我得到(删节):
TypeError: attribute.onUploadCallback is not a function
createBuffer
node_modules/three/build/three.module.js:14471
14468 | gl.bindBuffer( bufferType, buffer );
14469 | gl.bufferData( bufferType, array, usage );
14470 |
> 14471 | attribute.onUploadCallback();
| ^ 14472 |
14473 | var type = 5126;
如果我创建一个文件,例如:
import * as THREE from "three";
window.THREE = THREE;
export default window.THREE;
然后我就可以从那里成功导入。
我不知道为什么需要将其添加到window
才能起作用。
错误实际上与使用名为AMI.js的three.js的相关库有关。