Я хотел бы загрузить объект ".obj" с Three.js.
Мой код:
/********** Imports **********/
import React, { PureComponent } from 'react';
import * as THREE from 'three';
import OBJLoader from 'three-obj-loader';
OBJLoader('THREE');
export class Satellites extends PureComponent {
componentDidMount() {
// Satellite Sphere
this.geometry = new THREE.SphereGeometry( 10, 32, 32 );
// Texture
this.texture = new THREE.OBJLoader().load
('textures/Satellite.obj',
texture => {
this.sat = new THREE.MeshBasicMaterial( { map: this.texture } );
this.sphere = new THREE.Mesh( this.geometry, this.sat );
this.props.scene.add( this.sphere );
}
)
}
render() {
return null;
}
}
Ошибка:
Attempted import error: 'OBJLoader' is not exported from 'three' (imported as 'THREE').
Так что я использую этот пакет
Я добавляю эту строку импорт OBJLoader из 'three-obj-loader';
Но ничего ... У меня все еще та же ошибка с этим импортом!
Подробнее: https://github.com/SolenneD/earth-react
Scene.js и Satellite.js (это первая версия, поэтому не этот код, но есть текстура .obj)
Спасибо за помощь.