webgl_marching_cubes.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - marching cubes</title>
  5. <meta charset="utf-8">
  6. <style>
  7. body {
  8. color: #fff;
  9. font-family: Monospace;
  10. font-size: 13px;
  11. text-align: center;
  12. background-color: #000;
  13. margin: 0px;
  14. overflow: hidden;
  15. }
  16. #info {
  17. color: #ffffff;
  18. position: absolute;
  19. top: 0px;
  20. width: 100%;
  21. padding: 5px;
  22. }
  23. a {
  24. color: gold;
  25. }
  26. #oldie {
  27. font-family: monospace;
  28. font-size: 13px;
  29. text-align: center;
  30. background: rgb(0, 0, 50);
  31. color: #fff;
  32. padding: 1em;
  33. width: 475px;
  34. margin: 5em auto 0;
  35. display: none;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="container"></div>
  41. <div id="info">
  42. <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> -
  43. marching cubes -
  44. [based on greggman's <a href="http://webglsamples.googlecode.com/hg/blob/blob.html">blob</a>, original code by Henrik Rydgård]
  45. </div>
  46. <script src="../build/Three.js"></script>
  47. <script src="js/MarchingCubes.js"></script>
  48. <script src="js/ShaderExtras.js"></script>
  49. <script src="js/ShaderToon.js"></script>
  50. <script src="js/ShaderExtras.js"></script>
  51. <script src="js/postprocessing/EffectComposer.js"></script>
  52. <script src="js/postprocessing/RenderPass.js"></script>
  53. <script src="js/postprocessing/BloomPass.js"></script>
  54. <script src="js/postprocessing/ShaderPass.js"></script>
  55. <script src="js/postprocessing/MaskPass.js"></script>
  56. <script src="js/postprocessing/SavePass.js"></script>
  57. <script src="js/Detector.js"></script>
  58. <script src="js/Stats.js"></script>
  59. <script src="js/DAT.GUI.min.js"></script>
  60. <script>
  61. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  62. var MARGIN = 0;
  63. var SCREEN_WIDTH = window.innerWidth;
  64. var SCREEN_HEIGHT = window.innerHeight - 2 * MARGIN;
  65. var container, stats;
  66. var camera, scene, renderer;
  67. var mesh, texture, geometry, materials, material, current_material;
  68. var light, pointLight, ambientLight;
  69. var effect, resolution, numBlobs;
  70. var composer, effectFXAA, hblur, vblur;
  71. var effectController;
  72. var time = 0;
  73. var clock = new THREE.Clock();
  74. init();
  75. animate();
  76. function init() {
  77. container = document.getElementById( 'container' );
  78. // SCENE
  79. scene = new THREE.Scene();
  80. // CAMERA
  81. camera = new THREE.PerspectiveCamera( 45, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
  82. camera.position.set( -500, 500, 1500 );
  83. scene.add( camera );
  84. // CONTROLS
  85. controls = new THREE.TrackballControls( camera );
  86. // LIGHTS
  87. light = new THREE.DirectionalLight( 0xffffff );
  88. light.position.set( 0.5, 0.5, 1 );
  89. scene.add( light );
  90. pointLight = new THREE.PointLight( 0xff3300 );
  91. pointLight.position.set( 0, 0, 100 );
  92. scene.add( pointLight );
  93. ambientLight = new THREE.AmbientLight( 0x080808 );
  94. scene.add( ambientLight );
  95. // MATERIALS
  96. materials = generateMaterials();
  97. current_material = "shiny";
  98. // MARCHING CUBES
  99. resolution = 28;
  100. numBlobs = 10;
  101. effect = new THREE.MarchingCubes( resolution, materials[ current_material ].m, true, true );
  102. effect.position.set( 0, 0, 0 );
  103. effect.scale.set( 700, 700, 700 );
  104. effect.enableUvs = false;
  105. effect.enableColors = false;
  106. scene.add( effect );
  107. // RENDERER
  108. renderer = new THREE.WebGLRenderer( { clearColor: 0x050505, clearAlpha: 1, alpha: false } );
  109. renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
  110. renderer.domElement.style.position = "absolute";
  111. renderer.domElement.style.top = MARGIN + "px";
  112. renderer.domElement.style.left = "0px";
  113. container.appendChild( renderer.domElement );
  114. //
  115. renderer.gammaInput = true;
  116. renderer.gammaOutput = true;
  117. renderer.physicallyBasedShading = true;
  118. // STATS
  119. stats = new Stats();
  120. stats.domElement.style.position = 'absolute';
  121. stats.domElement.style.top = '0px';
  122. container.appendChild( stats.domElement );
  123. stats.domElement.children[ 0 ].children[ 0 ].style.color = "#888";
  124. stats.domElement.children[ 0 ].style.background = "transparent";
  125. stats.domElement.children[ 0 ].children[ 1 ].style.display = "none";
  126. // COMPOSER
  127. renderer.autoClear = false;
  128. renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
  129. renderTarget = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters );
  130. effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
  131. hblur = new THREE.ShaderPass( THREE.ShaderExtras[ "horizontalTiltShift" ] );
  132. vblur = new THREE.ShaderPass( THREE.ShaderExtras[ "verticalTiltShift" ] );
  133. var bluriness = 8;
  134. hblur.uniforms[ 'h' ].value = bluriness / SCREEN_WIDTH;
  135. vblur.uniforms[ 'v' ].value = bluriness / SCREEN_HEIGHT;
  136. hblur.uniforms[ 'r' ].value = vblur.uniforms[ 'r' ].value = 0.5;
  137. effectFXAA.uniforms[ 'resolution' ].value.set( 1 / SCREEN_WIDTH, 1 / SCREEN_HEIGHT );
  138. composer = new THREE.EffectComposer( renderer, renderTarget );
  139. var renderModel = new THREE.RenderPass( scene, camera );
  140. vblur.renderToScreen = true;
  141. //effectFXAA.renderToScreen = true;
  142. composer = new THREE.EffectComposer( renderer, renderTarget );
  143. composer.addPass( renderModel );
  144. composer.addPass( effectFXAA );
  145. composer.addPass( hblur );
  146. composer.addPass( vblur );
  147. // GUI
  148. setupGui();
  149. // EVENTS
  150. window.addEventListener( 'resize', onWindowResize, false );
  151. }
  152. //
  153. function onWindowResize( event ) {
  154. SCREEN_WIDTH = window.innerWidth;
  155. SCREEN_HEIGHT = window.innerHeight - 2 * MARGIN;
  156. renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
  157. camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
  158. camera.updateProjectionMatrix();
  159. renderTarget = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters );
  160. composer.reset( renderTarget );
  161. hblur.uniforms[ 'h' ].value = 4 / SCREEN_WIDTH;
  162. vblur.uniforms[ 'v' ].value = 4 / SCREEN_HEIGHT;
  163. effectFXAA.uniforms[ 'resolution' ].value.set( 1 / SCREEN_WIDTH, 1 / SCREEN_HEIGHT );
  164. }
  165. function generateMaterials() {
  166. // environment map
  167. var path = "textures/cube/SwedishRoyalCastle/";
  168. var format = '.jpg';
  169. var urls = [
  170. path + 'px' + format, path + 'nx' + format,
  171. path + 'py' + format, path + 'ny' + format,
  172. path + 'pz' + format, path + 'nz' + format
  173. ];
  174. var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
  175. reflectionCube.format = THREE.RGBFormat;
  176. var refractionCube = new THREE.Texture( reflectionCube.image, new THREE.CubeRefractionMapping() );
  177. reflectionCube.format = THREE.RGBFormat;
  178. // toons
  179. var toonMaterial1 = createShaderMaterial( "toon1", light, ambientLight ),
  180. toonMaterial2 = createShaderMaterial( "toon2", light, ambientLight ),
  181. hatchingMaterial = createShaderMaterial( "hatching", light, ambientLight ),
  182. hatchingMaterial2 = createShaderMaterial( "hatching", light, ambientLight ),
  183. dottedMaterial = createShaderMaterial( "dotted", light, ambientLight ),
  184. dottedMaterial2 = createShaderMaterial( "dotted", light, ambientLight );
  185. hatchingMaterial2.uniforms.uBaseColor.value.setRGB( 0, 0, 0 );
  186. hatchingMaterial2.uniforms.uLineColor1.value.setHSV( 0, 0.9, 0.9 );
  187. hatchingMaterial2.uniforms.uLineColor2.value.setHSV( 0, 0.9, 0.9 );
  188. hatchingMaterial2.uniforms.uLineColor3.value.setHSV( 0, 0.9, 0.9 );
  189. hatchingMaterial2.uniforms.uLineColor4.value.setHSV( 0.1, 0.9, 0.9 );
  190. dottedMaterial2.uniforms.uBaseColor.value.setRGB( 0, 0, 0 );
  191. dottedMaterial2.uniforms.uLineColor1.value.setHSV( 0.05, 1.0, 1.0 );
  192. var texture = THREE.ImageUtils.loadTexture( "textures/ash_uvgrid01.jpg" );
  193. texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
  194. var materials = {
  195. "chrome" :
  196. {
  197. m: new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: reflectionCube } ),
  198. h: 0, s: 0, v: 1
  199. },
  200. "liquid" :
  201. {
  202. m: new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: refractionCube, refractionRatio: 0.85 } ),
  203. h: 0, s: 0, v: 1
  204. },
  205. "shiny" :
  206. {
  207. m: new THREE.MeshPhongMaterial( { color: 0x550000, specular: 0x440000, envMap: reflectionCube, combine: THREE.MixOperation, reflectivity: 0.3, perPixel: true, metal: true } ),
  208. h: 0, s: 0.9, v: 0.3
  209. },
  210. "matte" :
  211. {
  212. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x111111, shininess: 1, perPixel: true } ),
  213. h: 0, s: 0, v: 1
  214. },
  215. "flat" :
  216. {
  217. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x111111, shininess: 1, shading: THREE.FlatShading, perPixel: true } ),
  218. h: 0, s: 0, v: 1
  219. },
  220. "textured" :
  221. {
  222. m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 1, map: texture, perPixel: true } ),
  223. h: 0, s: 0, v: 1
  224. },
  225. "colors" :
  226. {
  227. m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 2, vertexColors: THREE.VertexColors, perPixel: true } ),
  228. h: 0, s: 0, v: 1
  229. },
  230. "plastic" :
  231. {
  232. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x888888, ambient: 0x000000, shininess: 250, perPixel: true } ),
  233. h: 0.6, s: 0.9, v: 0.2
  234. },
  235. "toon1" :
  236. {
  237. m: toonMaterial1,
  238. h: 0.2, s: 0.5, v: 1
  239. },
  240. "toon2" :
  241. {
  242. m: toonMaterial2,
  243. h: 0.4, s: 0.5, v: 1
  244. },
  245. "hatching" :
  246. {
  247. m: hatchingMaterial,
  248. h: 0.2, s: 0.2, v: 1
  249. },
  250. "hatching2" :
  251. {
  252. m: hatchingMaterial2,
  253. h: 0.0, s: 0.9, v: 0.9
  254. },
  255. "dotted" :
  256. {
  257. m: dottedMaterial,
  258. h: 0.2, s: 0.2, v: 1
  259. },
  260. "dotted2" :
  261. {
  262. m: dottedMaterial2,
  263. h: 0.1, s: 1.0, v: 1
  264. }
  265. };
  266. return materials;
  267. }
  268. function createShaderMaterial( id, light, ambientLight ) {
  269. var shader = THREE.ShaderToon[ id ];
  270. var u = THREE.UniformsUtils.clone( shader.uniforms );
  271. var vs = shader.vertexShader;
  272. var fs = shader.fragmentShader;
  273. var material = new THREE.ShaderMaterial( { uniforms: u, vertexShader: vs, fragmentShader: fs } );
  274. material.uniforms.uDirLightPos.value = light.position;
  275. material.uniforms.uDirLightColor.value = light.color;
  276. material.uniforms.uAmbientLightColor.value = ambientLight.color;
  277. return material;
  278. }
  279. //
  280. function setupGui() {
  281. var createHandler = function( id ) {
  282. return function() {
  283. var mat_old = materials[ current_material ];
  284. mat_old.h = m_h.getValue();
  285. mat_old.s = m_s.getValue();
  286. mat_old.v = m_v.getValue();
  287. current_material = id;
  288. var mat = materials[ id ];
  289. effect.material = mat.m;
  290. m_h.setValue( mat.h );
  291. m_s.setValue( mat.s );
  292. m_v.setValue( mat.v );
  293. mm.setValue( current_material );
  294. if ( current_material === "textured" ) {
  295. effect.enableUvs = true;
  296. } else {
  297. effect.enableUvs = false;
  298. }
  299. if ( current_material === "colors" ) {
  300. effect.enableColors = true;
  301. } else {
  302. effect.enableColors = false;
  303. }
  304. };
  305. };
  306. function toggle( e ) {
  307. if ( e.style.display === "block" ) {
  308. e.style.display = "none";
  309. } else {
  310. e.style.display = "block";
  311. }
  312. }
  313. effectController = {
  314. material: "shiny",
  315. speed : 1.0,
  316. numBlobs: 10,
  317. resolution: 28,
  318. isolation: 80,
  319. floor: true,
  320. wallx: false,
  321. wallz: false,
  322. hue: 0.0,
  323. saturation: 0.9,
  324. value: 0.3,
  325. lhue: 0.04,
  326. lsaturation: 1.0,
  327. lvalue: 1.0,
  328. lx: 0.5,
  329. ly: 0.5,
  330. lz: 1.0,
  331. postprocessing: false,
  332. h_m: function() {
  333. for (var i = 0; i < g_m.length; i++) toggle(g_m[ i ].domElement);
  334. },
  335. h_c: function() {
  336. for (var i = 0; i < g_c.length; i++) toggle(g_c[ i ].domElement);
  337. },
  338. h_pc: function() {
  339. for (var i = 0; i < g_pc.length; i++) toggle(g_pc[ i ].domElement);
  340. },
  341. h_do: function() {
  342. for (var i = 0; i < g_do.length; i++) toggle(g_do[ i ].domElement);
  343. },
  344. h_s: function() {
  345. for (var i = 0; i < g_s.length; i++) toggle(g_s[ i ].domElement);
  346. },
  347. h_r: function() {
  348. for (var i = 0; i < g_r.length; i++) toggle(g_r[ i ].domElement);
  349. },
  350. dummy: function() {
  351. }
  352. };
  353. var e1, e2, e3, e4, e5, e6, h, m_h, m_s, m_v,
  354. g_m = [], g_c, g_pc, g_do, g_s, g_r, mm,
  355. gui = new DAT.GUI();
  356. // material (type)
  357. mm = gui.add( effectController, "material" );
  358. mm.domElement.style.display = "none";
  359. h = gui.add( effectController, "h_m" ).name( "Materials" );
  360. setGuiHeaderStyle(h, 0, 65, 50);
  361. for ( var m in materials ) {
  362. effectController[ m ] = createHandler( m );
  363. e1 = gui.add( effectController, m ).name( m );
  364. setGuiElementStyle( [ e1 ], 0, 65, 50, "block" );
  365. g_m.push( e1 );
  366. }
  367. // material (color)
  368. h = gui.add( effectController, "h_c" ).name( "Material color" );
  369. m_h = gui.add( effectController, "hue", 0.0, 1.0, 0.025 );
  370. m_s = gui.add( effectController, "saturation", 0.0, 1.0, 0.025 );
  371. m_v = gui.add( effectController, "value", 0.0, 1.0, 0.025 );
  372. g_c = [ m_h, m_s, m_v ];
  373. setGuiHeaderStyle( h, 20, 65, 50 );
  374. setGuiElementStyle( g_c, 20, 65, 50, "block" );
  375. // light (point)
  376. h = gui.add(effectController, "h_pc").name("Point light color");
  377. e1 = gui.add(effectController, "lhue", 0.0, 1.0, 0.025).name("hue");
  378. e2 = gui.add(effectController, "lsaturation", 0.0, 1.0, 0.025).name("saturation");
  379. e3 = gui.add(effectController, "lvalue", 0.0, 1.0, 0.025).name("value");
  380. g_pc = [ e1, e2, e3 ];
  381. setGuiHeaderStyle(h, 50, 65, 50);
  382. setGuiElementStyle(g_pc, 50, 65, 50);
  383. // light (directional)
  384. h = gui.add(effectController, "h_do").name("Directional light orientation");
  385. e1 = gui.add(effectController, "lx", -1.0, 1.0, 0.025).name("x");
  386. e2 = gui.add(effectController, "ly", -1.0, 1.0, 0.025).name("y");
  387. e3 = gui.add(effectController, "lz", -1.0, 1.0, 0.025).name("z");
  388. g_do = [ e1, e2, e3 ];
  389. setGuiHeaderStyle(h, 80, 65, 50);
  390. setGuiElementStyle(g_do, 80, 65, 50);
  391. // simulation
  392. h = gui.add(effectController, "h_s").name("Simulation");
  393. e1 = gui.add(effectController, "speed", 0.1, 8.0, 0.05);
  394. e2 = gui.add(effectController, "numBlobs", 1, 50, 1);
  395. e3 = gui.add(effectController, "resolution", 14, 40, 1);
  396. e4 = gui.add(effectController, "isolation", 10, 300, 1);
  397. e5 = gui.add(effectController, "floor");
  398. e6 = gui.add(effectController, "wallx");
  399. e7 = gui.add(effectController, "wallz");
  400. e5.updateDisplay();
  401. e6.updateDisplay();
  402. e7.updateDisplay();
  403. g_s = [ e1, e2, e3, e4, e5, e6, e7 ];
  404. setGuiHeaderStyle(h, 200, 65, 50);
  405. setGuiElementStyle(g_s, 200, 65, 50, "block");
  406. // rendering
  407. h = gui.add(effectController, "h_r").name("Rendering");
  408. e1 = gui.add(effectController, "postprocessing");
  409. g_r = [ e1 ];
  410. setGuiHeaderStyle(h, 225, 65, 50);
  411. setGuiElementStyle(g_r, 225, 65, 50, "block");
  412. // save
  413. //e1 = gui.add(GUI, "saveURL").name("Save to URL");
  414. //setGuiHeaderStyle(e1, 250, 65, 50, "block");
  415. gui.domElement.style.backgroundColor = "#222";
  416. // restore material from URL
  417. id = mm.getValue()
  418. current_material = id;
  419. var mat = materials[ id ];
  420. effect.material = mat.m;
  421. }
  422. function setGuiHeaderStyle( g, h, s, v ) {
  423. var color = "hsl(" + h + "," + s + "%, " + v + "%)";
  424. g.domElement.style.borderLeft = "solid 5px " + color;
  425. g.domElement.style.background = color;
  426. g.domElement.style.fontWeight = "bold";
  427. }
  428. function setGuiElementStyle( a, h, s, v, display ) {
  429. var s, color = "hsl(" + h + "," + s + "%, " + v + "%)";
  430. for ( i = 0; i < a.length; i ++ ) {
  431. s = a[ i ].domElement.style;
  432. s.borderLeft = "solid 5px " + color;
  433. s.display = display ? display : "none";
  434. }
  435. }
  436. // this controls content of marching cubes voxel field
  437. function updateCubes( object, time, numblobs, floor, wallx, wallz ) {
  438. object.reset();
  439. // fill the field with some metaballs
  440. var i, ballx, bally, ballz, subtract, strength;
  441. subtract = 12;
  442. strength = 1.2 / ( ( Math.sqrt( numblobs ) - 1 ) / 4 + 1 );
  443. for ( i = 0; i < numblobs; i ++ ) {
  444. ballx = Math.sin( i + 1.26 * time * ( 1.03 + 0.5 * Math.cos( 0.21 * i ) ) ) * 0.27 + 0.5;
  445. bally = Math.abs( Math.cos( i + 1.12 * time * Math.cos( 1.22 + 0.1424 * i ) ) ) * 0.77; // dip into the floor
  446. ballz = Math.cos( i + 1.32 * time * 0.1 * Math.sin( ( 0.92 + 0.53 * i ) ) ) * 0.27 + 0.5;
  447. object.addBall(ballx, bally, ballz, strength, subtract);
  448. }
  449. if ( floor ) object.addPlaneY( 2, 12 );
  450. if ( wallz ) object.addPlaneZ( 2, 12 );
  451. if ( wallx ) object.addPlaneX( 2, 12 );
  452. }
  453. //
  454. function animate() {
  455. requestAnimationFrame( animate );
  456. render();
  457. stats.update();
  458. }
  459. function render() {
  460. var delta = clock.getDelta();
  461. time += delta * effectController.speed * 0.5;
  462. controls.update( delta );
  463. // marching cubes
  464. if ( effectController.resolution !== resolution ) {
  465. resolution = effectController.resolution;
  466. effect.init( resolution );
  467. }
  468. if ( effectController.isolation !== effect.isolation ) {
  469. effect.isolation = effectController.isolation;
  470. }
  471. updateCubes( effect, time, effectController.numBlobs, effectController.floor, effectController.wallx, effectController.wallz );
  472. // materials
  473. if ( effect.material instanceof THREE.ShaderMaterial ) {
  474. if ( current_material === "dotted2" ) {
  475. effect.material.uniforms.uLineColor1.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  476. } else if ( current_material === "hatching2" ) {
  477. u = effect.material.uniforms;
  478. u.uLineColor1.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  479. u.uLineColor2.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  480. u.uLineColor3.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  481. u.uLineColor4.value.setHSV( ( effectController.hue + 0.2 % 1.0 ), effectController.saturation, effectController.value );
  482. } else {
  483. effect.material.uniforms.uBaseColor.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  484. }
  485. } else {
  486. effect.material.color.setHSV( effectController.hue, effectController.saturation, effectController.value );
  487. }
  488. // lights
  489. light.position.set( effectController.lx, effectController.ly, effectController.lz );
  490. light.position.normalize();
  491. pointLight.color.setHSV( effectController.lhue, effectController.lsaturation, effectController.lvalue );
  492. // render
  493. if ( effectController.postprocessing ) {
  494. composer.render( delta );
  495. } else {
  496. renderer.clear();
  497. renderer.render( scene, camera );
  498. }
  499. }
  500. </script>
  501. </body>
  502. </html>