Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. var group = new THREE.Object3D();
  2.  
  3. var materials = [];
  4. var side = new THREE.ImageUtils.loadTexture("textures/box_sides.png");
  5. // side.wrapS = side.wrapT = THREE.RepeatWrapping;
  6. var sideMat = new THREE.MeshPhongMaterial({
  7. emissive: 0x000000,
  8. color: 0x555555,
  9. specular: 0x000000,
  10. map: side
  11. });
  12. materials.push(sideMat);
  13. materials.push(sideMat);
  14. materials.push(sideMat);
  15. materials.push(sideMat);
  16.  
  17. var top = new THREE.ImageUtils.loadTexture("textures/box_top.png");
  18. top.wrapS = top.wrapT = THREE.RepeatWrapping;
  19. top.repeat.set(1,1);
  20. materials.push(new THREE.MeshPhongMaterial({
  21. emissive: 0x000000,
  22. color: 0x555555,
  23. specular: 0x333333,
  24. map: top
  25. }));
  26. var bottom = new THREE.ImageUtils.loadTexture("textures/box_bottom.png");
  27. materials.push(new THREE.MeshPhongMaterial({
  28. emissive: 0x000000,
  29. color: 0x555555,
  30. specular: 0x000000,
  31. map: bottom
  32. }));
  33.  
  34. var cubeGeo = new THREE.CubeGeometry(width,height,depth,1,1,1, materials);
  35.  
  36. // rotate texture on sides
  37. cubeGeo.faceVertexUvs[0][0] = [];
  38. cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(0,1));
  39. cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(1,1));
  40. cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(0,0));
  41. cubeGeo.faceVertexUvs[0][1] = [];
  42. cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(1,1));
  43. cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(1,0));
  44. cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(0,0));
  45.  
  46. cubeGeo.faceVertexUvs[0][2] = [];
  47. cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(1,0));
  48. cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(0,0));
  49. cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(1,1));
  50. cubeGeo.faceVertexUvs[0][3] = [];
  51. cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(0,0));
  52. cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(0,1));
  53. cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(1,1));
  54.  
  55. cubeGeo.faceVertexUvs[0][4] = [];
  56. cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(1,0));
  57. cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(1,1));
  58. cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(0,0));
  59. cubeGeo.faceVertexUvs[0][5] = [];
  60. cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(0,1));
  61. cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(1,1));
  62. cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(1,0));
  63.  
  64. var mesh = new THREE.Mesh(cubeGeo, new THREE.MeshFaceMaterial(materials));
  65.  
  66. mesh.position.set( x, y-(depth/2), z );
  67. mesh.rotation.x = - Math.PI/2;
  68. mesh.scale.set( scale, scale, scale );
  69. mesh.receiveShadow = true;
  70. group.add(mesh);
  71.  
  72. // Base of the plateau
  73. var texture = THREE.ImageUtils.loadTexture( "textures/stone.jpg" );
  74. texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
  75. texture.repeat.set( 2, 2 );
  76. var base_material = new THREE.MeshPhongMaterial( {color: 0xFFFFFF, map: texture, transparent: false} );
  77. // var base = new THREE.CubeGeometry(500,1000,500,10,10,10);
  78. // var baseobject = new THREE.Mesh(base, base_material);
  79. var baseobject = new THREE.Mesh( new THREE.CylinderGeometry( 200, 100 , 1000, 20, 5, true ), base_material);
  80. baseobject.position.set( x, y-depth-500, z );
  81. baseobject.scale.set(scale,scale,scale);
  82. group.add(baseobject);
  83. this.mesh = group;
  84. scene.add(group);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement