Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. //main file
  2. init();
  3. animate();
  4.  
  5. function init()
  6. {
  7. if ( !Detector.webgl ) Detector.addGetWebGLMessage();
  8.  
  9. renderer = new THREE.WebGLRenderer({antialias: true});
  10. renderer.setSize(window.innerWidth, window.innerHeight);
  11. document.body.appendChild(renderer.domElement);
  12. renderer.setClearColor(0xFFFFFF, 1);
  13.  
  14. camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 2843.14990, 12217.65039);
  15. camera.position.x = 0.00000;
  16. camera.position.y = 0.00000;
  17. camera.position.z = 5897.56250;
  18. camera.up = new THREE.Vector3(0, 1, 0);
  19. var target = new THREE.Vector3(0.00000, 0.00000, 0.00000);
  20. camera.lookAt(target);
  21.  
  22. controls = new THREE.TrackballControls(camera);
  23. controls.addEventListener('change', render);
  24.  
  25. scene = new THREE.Scene();
  26.  
  27.  
  28. var light_ambient = new THREE.AmbientLight(0x000000);
  29. scene.add(light_ambient);
  30.  
  31. light = new THREE.PointLight(0x999999);
  32. light.position.set(2843.14941, -3790.86621, 5686.29980);
  33. scene.add(light);
  34. light = new THREE.PointLight(0x4C4C4C);
  35. light.position.set(-3790.86621, -3790.86621, 2843.14990);
  36. scene.add(light);
  37. light = new THREE.PointLight(0x4C4C4C);
  38. light.position.set(0.00000, 3790.86646, 3790.86621);
  39. scene.add(light);
  40.  
  41. create_component(scene);
  42.  
  43. window.addEventListener('resize', onWindowResize, false);
  44. }
  45.  
  46. function onWindowResize()
  47. {
  48. camera.aspect = window.innerWidth / window.innerHeight;
  49. camera.updateProjectionMatrix();
  50.  
  51. renderer.setSize(window.innerWidth, window.innerHeight);
  52.  
  53. controls.handleResize();
  54. render();
  55. }
  56.  
  57. function animate()
  58. {
  59. requestAnimationFrame(animate);
  60. renderer.render(scene, camera);
  61. controls.update();
  62. }
  63.  
  64. function render()
  65. {
  66. renderer.render(scene, camera);
  67. }
  68.  
  69.  
  70. //second file
  71. function create_component(scene)
  72. {
  73. var mesh;
  74. var material;
  75. var geometry;
  76. //var parent;
  77.  
  78. //parent = new THREE.Object3D();
  79. //parent.name = 'test';
  80. //scene.add(parent);
  81.  
  82. geometry = new THREE.BufferGeometry();
  83. geometry.attributes = {
  84. position: {
  85. itemSize: 3,
  86. array: new Float32Array([
  87. 439.22070, 1088.16528, 57.26282,
  88. 14.22070, 1088.16528, 57.26282,
  89. 439.22070, -351.82593, 57.26282,
  90. 439.22070, -351.82593, 57.26282,
  91. 14.22070, 1088.16528, 57.26282,
  92. 14.22070, -351.82593, 57.26282,
  93. 589.22070, -1126.83447, 57.26282,
  94. 1014.22070, -1126.83447, 57.26282,
  95. 589.22070, 1033.15649, 57.26282,
  96. 589.22070, 1033.15649, 57.26282,
  97. 1014.22070, -1126.83447, 57.26282,
  98. 1014.22070, 1033.15649, 57.26282,
  99. 515.72070, -1016.83447, 57.26282,
  100. 515.72070, -391.83472, 57.26282,
  101. -1103.27100, -1016.83496, 57.26282,
  102. -1103.27100, -1016.83496, 57.26282,
  103. 515.72070, -391.83472, 57.26282,
  104. -1103.27100, -391.83472, 57.26282,
  105. -1103.27979, -1166.83496, 57.26282,
  106. -1103.27979, -1791.83496, 57.26282,
  107. 1056.71191, -1166.83447, 57.26282,
  108. 1056.71191, -1166.83447, 57.26282,
  109. -1103.27979, -1791.83496, 57.26282,
  110. 1056.71191, -1791.83447, 57.26282,
  111. 466.76074, -1166.83447, 57.26282,
  112. 466.76074, -1791.83447, 57.26282,
  113. 1465.75195, -1166.83447, 57.26282,
  114. 1465.75195, -1166.83447, 57.26282,
  115. 466.76074, -1791.83447, 57.26282,
  116. 1465.75195, -1791.83447, 57.26282
  117. ])
  118. },
  119. normal: {
  120. itemSize: 3,
  121. array: new Float32Array([
  122. 0.00000, 0.00000, 1.00000,
  123. 0.00000, 0.00000, 1.00000,
  124. 0.00000, 0.00000, 1.00000,
  125. 0.00000, 0.00000, 1.00000,
  126. 0.00000, 0.00000, 1.00000,
  127. 0.00000, 0.00000, 1.00000,
  128. 0.00000, 0.00000, 1.00000,
  129. 0.00000, 0.00000, 1.00000,
  130. 0.00000, 0.00000, 1.00000,
  131. 0.00000, 0.00000, 1.00000,
  132. 0.00000, 0.00000, 1.00000,
  133. 0.00000, 0.00000, 1.00000,
  134. 0.00000, 0.00000, 1.00000,
  135. 0.00000, 0.00000, 1.00000,
  136. 0.00000, 0.00000, 1.00000,
  137. 0.00000, 0.00000, 1.00000,
  138. 0.00000, 0.00000, 1.00000,
  139. 0.00000, 0.00000, 1.00000,
  140. 0.00000, 0.00000, 1.00000,
  141. 0.00000, 0.00000, 1.00000,
  142. 0.00000, 0.00000, 1.00000,
  143. 0.00000, 0.00000, 1.00000,
  144. 0.00000, 0.00000, 1.00000,
  145. 0.00000, 0.00000, 1.00000,
  146. 0.00000, 0.00000, 1.00000,
  147. 0.00000, 0.00000, 1.00000,
  148. 0.00000, 0.00000, 1.00000,
  149. 0.00000, 0.00000, 1.00000,
  150. 0.00000, 0.00000, 1.00000,
  151. 0.00000, 0.00000, 1.00000
  152. ])
  153. }
  154. };
  155.  
  156. material = new THREE.MeshPhongMaterial({
  157. color: 0x505050,
  158. shininess: 2.00000,
  159. ambient: 0x505050,
  160. side: THREE.DoubleSide,
  161. specular: 0x000000
  162. });
  163.  
  164. mesh = new THREE.Mesh(geometry, material);
  165. //parent.add(mesh);
  166. scene.add(mesh);
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement