webgl_materials_cars.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - materials - cube reflection [cars]</title>
  5. <meta charset="utf-8">
  6. <style type="text/css">
  7. body {
  8. background:#000;
  9. color:#fff;
  10. padding:0;
  11. margin:0;
  12. overflow:hidden;
  13. font-family:georgia;
  14. text-align:center;
  15. }
  16. h1 { }
  17. a { color:skyblue; text-decoration:none }
  18. canvas { pointer-events:none; z-index:10; position:relative; }
  19. #log { position:absolute; top:50px; text-align:left; display:block; z-index:100 }
  20. #d { position:absolute; width: 100%; text-align:center; margin:1em 0 -4.5em 0; z-index:1000; }
  21. .bwrap { margin:0.5em 0 0 0 }
  22. button { font-family:georgia; border:0; background:#000; color:#fff; padding:0.2em 0.5em; cursor:pointer; border-radius:3px; }
  23. button:hover { background:#333 }
  24. #buttons_cars button { color:#fa0 }
  25. #car_info { text-align:center; }
  26. #car_name { font-size:1em }
  27. #car_author { font-size:1em }
  28. #oldie { background:rgb(50,0,0) !important; color:#fff !important; margin-top:7em!important }
  29. </style>
  30. </head>
  31. <body>
  32. <div id="d">
  33. <div id="info">
  34. <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl demo :
  35. texture by <a href="http://www.humus.name/index.php?page=Textures" target="_blank">Humus</a> :
  36. <span id="car_info">
  37. <span id="car_name">Bugatti Veyron model</span>
  38. by <span id="car_author"><a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank">Troyano</a></span>
  39. </span>
  40. </div>
  41. <div id="buttons_cars" class="bwrap">
  42. <button id="veyron">Bugatti Veyron</button>
  43. <button id="gallardo">Lamborghini Gallardo</button>
  44. <button id="f50">Ferrari F50</button>
  45. <button id="camaro">Chevrolet Camaro</button>
  46. </div>
  47. <div id="buttons_materials" class="bwrap"></div>
  48. </div>
  49. <div id="log"></div>
  50. <script type="text/javascript" src="../build/Three.js"></script>
  51. <script type="text/javascript" src="js/Detector.js"></script>
  52. <script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
  53. <script type="text/javascript" src="js/Stats.js"></script>
  54. <script type="text/javascript">
  55. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  56. var STATS_ENABLED = false;
  57. var CARS = {
  58. "veyron": {
  59. name: "Bugatti Veyron",
  60. url: "obj/veyron/VeyronNoUv_bin.js",
  61. author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank">Troyano</a>',
  62. init_rotation: [ 0, 0, 0 /*0.3, 1.57, 0.0*/ ],
  63. scale: 5.5,
  64. init_material: 4,
  65. body_materials: [ 2 ],
  66. object: null,
  67. buttons: null,
  68. materials: null
  69. },
  70. "gallardo": {
  71. name: "Lamborghini Gallardo",
  72. url: "obj/gallardo/GallardoNoUv_bin.js",
  73. author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1711" target="_blank">machman_3d</a>',
  74. init_rotation: [ 0, 0, 0 /*0.2, 1.77, 0.0*/ ],
  75. scale: 3.7,
  76. init_material: 9,
  77. body_materials: [ 3 ],
  78. object: null,
  79. buttons: null,
  80. materials: null
  81. },
  82. "f50": {
  83. name: "Ferrari F50",
  84. url: "obj/f50/F50NoUv_bin.js",
  85. author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1687" target="_blank">daniel sathya</a>',
  86. init_rotation: [ 0, 0, 0 /*0.2, 1.37, 0.0*/ ],
  87. scale: 0.175,
  88. init_material: 2,
  89. body_materials: [ 3, 6, 7, 8, 9, 10, 23, 24 ],
  90. object: null,
  91. buttons: null,
  92. materials: null
  93. },
  94. "camaro": {
  95. name: "Chevrolet Camaro",
  96. url: "obj/camaro/CamaroNoUv_bin.js",
  97. author: '<a href="http://www.turbosquid.com/3d-models/blender-camaro/411348" target="_blank">dskfnwn</a>',
  98. init_rotation: [ 0.0, 0.0, 0.0 /*0, 1, 0*/ ],
  99. scale: 75,
  100. init_material: 0,
  101. body_materials: [ 0 ],
  102. object: null,
  103. buttons: null,
  104. materials: null
  105. }
  106. };
  107. var container, stats;
  108. var camera, scene, webglRenderer;
  109. var cameraCube, sceneCube;
  110. var m, mi;
  111. var directionalLight, pointLight;
  112. var mouseX = 0, mouseY = 0;
  113. var windowHalfX = window.innerWidth / 2;
  114. var windowHalfY = window.innerHeight / 2;
  115. var loader = new THREE.Loader( true );
  116. document.body.appendChild( loader.statusDomElement );
  117. init();
  118. animate();
  119. function init() {
  120. container = document.createElement('div');
  121. document.body.appendChild(container);
  122. camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 100000 );
  123. // camera.position.z = 1000;
  124. camera.updateMatrix();
  125. cameraCube = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 100000 );
  126. scene = new THREE.Scene();
  127. sceneCube = new THREE.Scene();
  128. // LIGHTS
  129. var ambient = new THREE.AmbientLight( 0x555555 );
  130. scene.addLight( ambient );
  131. directionalLight = new THREE.DirectionalLight( 0xffffff, 2 );
  132. directionalLight.position.x = 2;
  133. directionalLight.position.y = 1.2;
  134. directionalLight.position.z = 10;
  135. directionalLight.position.normalize();
  136. scene.addLight( directionalLight );
  137. directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
  138. directionalLight.position.x = - 2;
  139. directionalLight.position.y = 1.2;
  140. directionalLight.position.z = - 10;
  141. directionalLight.position.normalize();
  142. scene.addLight( directionalLight );
  143. pointLight = new THREE.PointLight( 0xffaa00, 2 );
  144. pointLight.position.x = 2000;
  145. pointLight.position.y = 1200;
  146. pointLight.position.z = 10000;
  147. scene.addLight( pointLight );
  148. SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
  149. webglRenderer = new THREE.WebGLRenderer();
  150. webglRenderer.setSize( window.innerWidth, window.innerHeight );
  151. webglRenderer.setFaceCulling( 0 );
  152. webglRenderer.autoClear = false;
  153. container.appendChild( webglRenderer.domElement );
  154. if ( STATS_ENABLED ) {
  155. stats = new Stats();
  156. stats.domElement.style.position = 'absolute';
  157. stats.domElement.style.top = '0px';
  158. stats.domElement.style.zIndex = 100;
  159. container.appendChild( stats.domElement );
  160. }
  161. document.addEventListener('mousemove', onDocumentMouseMove, false);
  162. var r = "textures/cube/Bridge2/";
  163. var urls = [ r + "posx.jpg", r + "negx.jpg",
  164. r + "posy.jpg", r + "negy.jpg",
  165. r + "posz.jpg", r + "negz.jpg" ];
  166. var images = ImageUtils.loadArray( urls );
  167. var textureCube = new THREE.Texture( images );
  168. // common materials
  169. var mlib = {
  170. "Orange": new THREE.MeshLambertMaterial( { color: 0xff6600, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
  171. "Blue": new THREE.MeshLambertMaterial( { color: 0x001133, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
  172. "Red": new THREE.MeshLambertMaterial( { color: 0x660000, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
  173. "Black": new THREE.MeshLambertMaterial( { color: 0x000000, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.15 } ),
  174. "White": new THREE.MeshLambertMaterial( { color: 0xffffff, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
  175. "Carmine": new THREE.MeshPhongMaterial( { color: 0x770000, specular:0xffaaaa, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  176. "Gold": new THREE.MeshPhongMaterial( { color: 0xaa9944, specular:0xbbaa99, shininess:50, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  177. "Bronze": new THREE.MeshPhongMaterial( { color: 0x150505, specular:0xee6600, shininess:10, env_map: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
  178. "Chrome": new THREE.MeshPhongMaterial( { color: 0xffffff, specular:0xffffff, env_map: textureCube, combine: THREE.Multiply } ),
  179. "Orange metal": new THREE.MeshLambertMaterial( { color: 0xff6600, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  180. "Blue metal": new THREE.MeshLambertMaterial( { color: 0x001133, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  181. "Red metal": new THREE.MeshLambertMaterial( { color: 0x770000, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  182. "Green metal": new THREE.MeshLambertMaterial( { color: 0x007711, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  183. "Black metal": new THREE.MeshLambertMaterial( { color: 0x222222, env_map: textureCube, combine: THREE.MultiplyOperation } ),
  184. "Pure chrome": new THREE.MeshLambertMaterial( { color: 0xffffff, env_map: textureCube } ),
  185. "Dark chrome": new THREE.MeshLambertMaterial( { color: 0x444444, env_map: textureCube } ),
  186. "Darker chrome":new THREE.MeshLambertMaterial( { color: 0x222222, env_map: textureCube } ),
  187. "Black glass": new THREE.MeshLambertMaterial( { color: 0x101016, env_map: textureCube, opacity: 0.975 } ),
  188. "Dark glass": new THREE.MeshLambertMaterial( { color: 0x101046, env_map: textureCube, opacity: 0.25 } ),
  189. "Blue glass": new THREE.MeshLambertMaterial( { color: 0x668899, env_map: textureCube, opacity: 0.75 } ),
  190. "Light glass": new THREE.MeshBasicMaterial( { color: 0x223344, env_map: textureCube, opacity: 0.25, combine: THREE.MixOperation, reflectivity: 0.25 } ),
  191. "Red glass": new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.75 } ),
  192. "Yellow glass": new THREE.MeshLambertMaterial( { color: 0xffffaa, opacity: 0.75 } ),
  193. "Orange glass": new THREE.MeshLambertMaterial( { color: 0x995500, opacity: 0.75 } ),
  194. "Orange glass 50": new THREE.MeshLambertMaterial( { color: 0xffbb00, opacity: 0.5 } ),
  195. "Red glass 50": new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.5 } ),
  196. "Fullblack rough": new THREE.MeshLambertMaterial( { color: 0x000000 } ),
  197. "Black rough": new THREE.MeshLambertMaterial( { color: 0x050505 } ),
  198. "Darkgray rough": new THREE.MeshLambertMaterial( { color: 0x090909 } ),
  199. "Red rough": new THREE.MeshLambertMaterial( { color: 0x330500 } ),
  200. "Darkgray shiny": new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x050505 } ),
  201. "Gray shiny": new THREE.MeshPhongMaterial( { color: 0x050505, shininess: 20 } )
  202. }
  203. // Gallardo materials
  204. CARS[ "gallardo" ].materials = {
  205. body: [
  206. [ "Orange", mlib[ "Orange" ] ],
  207. [ "Blue", mlib[ "Blue" ] ],
  208. [ "Red", mlib[ "Red" ] ],
  209. [ "Black", mlib[ "Black" ] ],
  210. [ "White", mlib[ "White" ] ],
  211. [ "Orange metal", mlib[ "Orange metal" ] ],
  212. [ "Blue metal", mlib[ "Blue metal" ] ],
  213. [ "Green metal", mlib[ "Green metal" ] ],
  214. [ "Black metal", mlib[ "Black metal" ] ],
  215. [ "Carmine", mlib[ "Carmine" ] ],
  216. [ "Gold", mlib[ "Gold" ] ],
  217. [ "Bronze", mlib[ "Bronze" ] ],
  218. [ "Chrome", mlib[ "Chrome" ] ]
  219. ]
  220. }
  221. m = CARS[ "gallardo" ].materials;
  222. mi = CARS[ "gallardo" ].init_material;
  223. CARS[ "gallardo" ].mmap = {
  224. 0: mlib[ "Pure chrome" ], // wheels chrome
  225. 1: mlib[ "Black rough" ], // tire
  226. 2: mlib[ "Black glass" ], // windshield
  227. 3: m.body[ mi ][ 1 ], // body
  228. 4: mlib[ "Red glass" ], // back lights
  229. 5: mlib[ "Yellow glass" ], // front lights
  230. 6: mlib[ "Dark chrome" ] // windshield rim
  231. }
  232. // Veyron materials
  233. CARS[ "veyron" ].materials = {
  234. body: [
  235. [ "Orange metal", mlib[ "Orange metal" ] ],
  236. [ "Blue metal", mlib[ "Blue metal" ] ],
  237. [ "Red metal", mlib[ "Red metal" ] ],
  238. [ "Green metal", mlib[ "Green metal" ] ],
  239. [ "Black metal", mlib[ "Black metal" ] ],
  240. [ "Gold", mlib[ "Gold" ] ],
  241. [ "Bronze", mlib[ "Bronze" ] ],
  242. [ "Chrome", mlib[ "Chrome" ] ]
  243. ],
  244. }
  245. m = CARS[ "veyron" ].materials;
  246. mi = CARS[ "veyron" ].init_material;
  247. CARS[ "veyron" ].mmap = {
  248. 0: mlib[ "Black rough" ], // tires + inside
  249. 1: mlib[ "Pure chrome" ], // wheels + extras chrome
  250. 2: m.body[ mi ][ 1 ], // back / top / front torso
  251. 3: mlib[ "Dark glass" ], // glass
  252. 4: mlib[ "Pure chrome" ], // sides torso
  253. 5: mlib[ "Pure chrome" ], // engine
  254. 6: mlib[ "Red glass 50" ], // backlights
  255. 7: mlib[ "Orange glass 50" ] // backsignals
  256. }
  257. // F50 materials
  258. CARS[ "f50" ].materials = {
  259. body: [
  260. [ "Orange", mlib[ "Orange" ] ],
  261. [ "Blue", mlib[ "Blue" ] ],
  262. [ "Red", mlib[ "Red" ] ],
  263. [ "Black", mlib[ "Black" ] ],
  264. [ "White", mlib[ "White" ] ],
  265. [ "Orange metal", mlib[ "Orange metal" ] ],
  266. [ "Blue metal", mlib[ "Blue metal" ] ],
  267. [ "Black metal", mlib[ "Black metal" ] ],
  268. [ "Carmine", mlib[ "Carmine" ] ],
  269. [ "Gold", mlib[ "Gold" ] ],
  270. [ "Bronze", mlib[ "Bronze" ] ],
  271. [ "Chrome", mlib[ "Chrome" ] ]
  272. ],
  273. }
  274. m = CARS[ "f50" ].materials;
  275. mi = CARS[ "f50" ].init_material;
  276. CARS[ "f50" ].mmap = {
  277. 0: mlib[ "Dark chrome" ], // interior + rim
  278. 1: mlib[ "Pure chrome" ], // wheels + gears chrome
  279. 2: mlib[ "Blue glass" ], // glass
  280. 3: m.body[ mi ][ 1 ], // torso mid + front spoiler
  281. 4: mlib[ "Darkgray shiny" ], // interior + behind seats
  282. 5: mlib[ "Darkgray shiny" ], // tiny dots in interior
  283. 6: m.body[ mi ][ 1 ], // back torso
  284. 7: m.body[ mi ][ 1 ], // right mirror decal
  285. 8: m.body[ mi ][ 1 ], // front decal
  286. 9: m.body[ mi ][ 1 ], // front torso
  287. 10: m.body[ mi ][ 1 ], // left mirror decal
  288. 11: mlib[ "Pure chrome" ], // engine
  289. 12: mlib[ "Darkgray rough" ], // tires side
  290. 13: mlib[ "Darkgray rough" ], // tires bottom
  291. 14: mlib[ "Darkgray shiny" ], // bottom
  292. 15: mlib[ "Black rough" ], // ???
  293. 16: mlib[ "Orange glass" ], // front signals
  294. 17: mlib[ "Dark chrome" ], // wheels center
  295. 18: mlib[ "Red glass" ], // back lights
  296. 19: mlib[ "Black rough" ], // ???
  297. 20: mlib[ "Red rough" ], // seats
  298. 21: mlib[ "Black rough" ], // back plate
  299. 22: mlib[ "Black rough" ], // front light dots
  300. 23: m.body[ mi ][ 1 ], // back torso
  301. 24: m.body[ mi ][ 1 ] // back torso center
  302. }
  303. // Camero materials
  304. CARS[ "camaro" ].materials = {
  305. body: [
  306. [ "Orange", mlib[ "Orange" ] ],
  307. [ "Blue", mlib[ "Blue" ] ],
  308. [ "Red", mlib[ "Red" ] ],
  309. [ "Black", mlib[ "Black" ] ],
  310. [ "White", mlib[ "White" ] ],
  311. [ "Orange metal", mlib[ "Orange metal" ] ],
  312. [ "Blue metal", mlib[ "Blue metal" ] ],
  313. [ "Red metal", mlib[ "Red metal" ] ],
  314. [ "Green metal", mlib[ "Green metal" ] ],
  315. [ "Black metal", mlib[ "Black metal" ] ],
  316. [ "Gold", mlib[ "Gold" ] ],
  317. [ "Bronze", mlib[ "Bronze" ] ],
  318. [ "Chrome", mlib[ "Chrome" ] ]
  319. ],
  320. }
  321. m = CARS[ "camaro" ].materials;
  322. mi = CARS[ "camaro" ].init_material;
  323. CARS[ "camaro" ].mmap = {
  324. 0: m.body[ mi ][ 1 ], // car body
  325. 1: mlib[ "Pure chrome" ], // wheels chrome
  326. 2: mlib[ "Pure chrome" ], // grille chrome
  327. 3: mlib[ "Dark chrome" ], // door lines
  328. 4: mlib[ "Light glass" ], // windshield
  329. 5: mlib[ "Gray shiny" ], // interior
  330. 6: mlib[ "Black rough" ], // tire
  331. 7: mlib[ "Fullblack rough" ], // tireling
  332. 8: mlib[ "Fullblack rough" ] // behind grille
  333. }
  334. loader.loadBinary( { model: CARS[ "veyron" ].url, callback: function( geometry ) { createScene( geometry, "veyron" ) } } );
  335. for( var c in CARS ) initCarButton( c );
  336. }
  337. function initCarButton( car ) {
  338. $( car ).addEventListener( 'click', function() {
  339. if ( ! CARS[ car ].object ) {
  340. loader.statusDomElement.style.display = "block";
  341. loader.loadBinary( { model: CARS[ car ].url, callback: function( geometry ) { createScene( geometry, car ) } } );
  342. } else {
  343. switchCar( car );
  344. }
  345. }, false);
  346. }
  347. function $( id ) { return document.getElementById( id ) }
  348. function button_name( car, index ) { return "m_" + car + "_" + index }
  349. function switchCar( car ) {
  350. for ( var c in CARS ) {
  351. if ( c != car && CARS[ c ].object ) {
  352. CARS[ c ].object.visible = false;
  353. CARS[ c ].buttons.style.display = "none";
  354. }
  355. }
  356. CARS[ car ].object.visible = true;
  357. CARS[ car ].buttons.style.display = "block";
  358. $( "car_name" ).innerHTML = CARS[ car ].name + " model";
  359. $( "car_author" ).innerHTML = CARS[ car ].author;
  360. }
  361. function createButtons( materials, car ) {
  362. var buttons, i, src = "";
  363. for( i = 0; i < materials.length; i++ ) {
  364. src += '<button id="' + button_name( car, i ) + '">' + materials[ i ][ 0 ] + '</button> ';
  365. }
  366. buttons = document.createElement("div");
  367. buttons.innerHTML = src;
  368. $( "buttons_materials" ).appendChild( buttons );
  369. return buttons;
  370. }
  371. function attachButtonMaterials( materials, geometry, material_indices, car ) {
  372. for( var i = 0; i < materials.length; i++ ) {
  373. $( button_name( car, i ) ).counter = i;
  374. $( button_name( car, i ) ).addEventListener( 'click', function() {
  375. for ( var j = 0; j < material_indices.length; j++ ) {
  376. geometry.materials[ material_indices [ j ] ][ 0 ] = materials[ this.counter ][ 1 ];
  377. }
  378. }, false );
  379. }
  380. }
  381. function createScene( geometry, car ) {
  382. loader.statusDomElement.innerHTML = "Creating model ...";
  383. var m = new THREE.MeshFaceMaterial(),
  384. s = CARS[ car ].scale * 1,
  385. r = CARS[ car ].init_rotation,
  386. materials = CARS[ car ].materials,
  387. mi = CARS[ car ].init_material,
  388. bm = CARS[ car ].body_materials;
  389. for( var i in CARS[ car ].mmap ) {
  390. geometry.materials[ i ][ 0 ] = CARS[ car ].mmap[ i ];
  391. }
  392. CARS[ car ].object = SceneUtils.addMesh( scene, geometry, s, 0, 0, 0, r[0], r[1], r[2], m );
  393. CARS[ car ].buttons = createButtons( materials.body, car );
  394. attachButtonMaterials( materials.body, geometry, bm, car );
  395. switchCar( car );
  396. loader.statusDomElement.style.display = "none";
  397. loader.statusDomElement.innerHTML = "Loading model ...";
  398. }
  399. function onDocumentMouseMove(event) {
  400. mouseY = ( event.clientY - window.innerHeight );
  401. }
  402. //
  403. function animate() {
  404. requestAnimationFrame( animate );
  405. render();
  406. }
  407. function render() {
  408. var timer = - new Date().getTime() * 0.0002;
  409. camera.position.y += ( - mouseY - camera.position.y ) * .05;
  410. camera.position.x = 1000 * Math.cos( timer );
  411. camera.position.z = 1000 * Math.sin( timer );
  412. cameraCube.target.position.x = - camera.position.x;
  413. cameraCube.target.position.y = - camera.position.y;
  414. cameraCube.target.position.z = - camera.position.z;
  415. webglRenderer.clear();
  416. webglRenderer.render( sceneCube, cameraCube );
  417. webglRenderer.render( scene, camera );
  418. if ( STATS_ENABLED ) stats.update();
  419. }
  420. function log( text ) {
  421. var e = document.getElementById("log");
  422. e.innerHTML = text + "<br/>" + e.innerHTML;
  423. }
  424. </script>
  425. </body>
  426. </html>