"export ‘Geometry’ (imported as ‘THREE’) was not found in ‘three’
因为three.js 在 r125版本中干掉了Geometry,全部采用BufferGeometry。
~~three.js 在 r125版本中终于干掉了Geometry。~~
如果你的项目升级后出现了上述的错误,就需要仔细修改了。
比如之前采用了geometry.vertices.push那么就会接着报错的,找到错误按照API修改即可。
TypeError: Cannot read property 'push' of undefined
//125之前的代码
const geometry = new THREE.Geometry()
points.forEach(d => {
const [x, y, z] = d;
geometry.vertices.push(new THREE.Vector3(x, y, z));
});
//125时候的代码
const geometry = new THREE.BufferGeometry();
const arr = [];
points.forEach(d => {
const [x, y, z] = d;
arr.push(x,y,z)
});
const vertices = new Float32Array(arr);//得写arr赋值后面?之前写前面咋没事!
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
最后~three的API修改往往如此任性!