materials_cars.html 18 KB

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