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