Hello there… i have a canvas where i can add object and it can be drag and drop but now i cant to drag a material that is loaded with mtl file and obj file. But i cant do it.
The code i used for creating object is below
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 );
for ( var i = 0; i < 1; i ++ ) {
var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: Math.random() * 0xffffff } ) );
object.position.set(100,100,100);
object.scale.x = 0.2;
object.scale.y = 0.2;
object.scale.z = 0.2;
scene.add( object );
objects.push( object );
}
and the code for adding material is
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
}
};
var onError = function () { };
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
new THREE.MTLLoader()
.setPath( 'Crate/' )
.load( 'Crate1.mtl', function ( materials ) {
materials.preload();
new THREE.OBJLoader()
.setMaterials( materials )
.setPath( 'Crate/' )
.load( 'Crate1.obj', function ( object ) {
object.position.z = 0;
object.position.y = -1.9;
object.scale.set(0.5,0.5,0.5);
scene.add( object );
objects.push( object );
}, onProgress, onError );
} );
i want to drag and drop the material like the box… can anyone help me…