Guest User

Untitled

a guest
Feb 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. var loadingManager = new THREE.LoadingManager();
  2. var loader = new THREE.OBJLoader(loadingManager);
  3. var threeDTexture = new THREE.TextureLoader(loadingManager);
  4. threeDTexture = new THREE.ImageUtils.loadTexture( 'models/Sofa/Textures/669170.jpg' );
  5. threeDTexture2 = new THREE.ImageUtils.loadTexture( 'models/Sofa/Textures/paradis_beige.jpg' );
  6. threeDTexture.wrapS = threeDTexture.wrapT = THREE.RepeatWrapping;
  7. var material = new THREE.MeshBasicMaterial({map: threeDTexture, side: THREE.DoubleSide});
  8. loader.load('models/Sofa/Sofa.OBJ', function (object) {
  9. object.traverse(function (child) {
  10. if (child instanceof THREE.Mesh) {
  11. child.material = material;
  12.  
  13. }
  14. });
  15. object.position.x = posX;
  16. object.position.y = 0;
  17. object.position.z = posZ;
  18.  
  19. var size = new THREE.Box3().setFromObject(object).getSize();
  20. object.scale.set(width/size.x, height/size.y, depth/size.z);
  21. scene1.add(object);
  22.  
  23. console.log(object);
  24. console.log(size);
  25. console.log(width/size.x, height/size.y, depth/size.z);
  26.  
  27. },
  28. function ( xhr ) {
  29. returnValue = ( xhr.loaded / xhr.total * 100 ) + '% loaded';
  30. console.log(returnValue);
  31. },
  32. function ( error ) {
  33. console.log( 'An error happened' );
  34. }
  35. );
Add Comment
Please, Sign In to add comment