I would like to load an object ".obj" with three.js.
My code :
/********** 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;
}
}
Error :
Attempted import error: 'OBJLoader' is not exported from 'three' (imported as 'THREE').
So I use this package I add this line import OBJLoader from 'three-obj-loader';
But nothing... I still have the same error with this import !
More details : https://github.com/SolenneD/earth-react
Scene.js and Satellite.js (this is the first version so not this code but there is a texture .obj)
Thanks for help.